All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.dbmigration.ddlgeneration.platform.HanaColumnStoreDdl Maven / Gradle / Ivy

There is a newer version: 12.5.2
Show newest version
package io.ebeaninternal.dbmigration.ddlgeneration.platform;

import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer;

import java.io.IOException;

public class HanaColumnStoreDdl extends AbstractHanaDdl {

  public HanaColumnStoreDdl(DatabasePlatform platform) {
    super(platform);
    this.createTable = "create column table";
  }

  @Override
  public String createIndex(WriteCreateIndex create) {
    final String[] columns = create.getColumns();
    if (columns == null || columns.length == 0) {
      return "-- cannot create index: no columns given";
    }
    if (columns.length == 1) {
      return "-- explicit index \"" + create.getIndexName() + "\" for single column \"" + columns[0] + "\" of table \"" + create.getTableName()
          + "\" is not necessary";
    }

    StringBuilder buffer = new StringBuilder();
    buffer.append("create inverted hash index ").append(maxConstraintName(create.getIndexName())).append(" on ").append(create.getTableName());
    appendColumns(columns, buffer);
    return buffer.toString();
  }

  @Override
  public String dropIndex(String indexName, String tableName, boolean concurrent) {
    DdlBuffer buffer = new BaseDdlBuffer(null);
    try {
      buffer.append("delimiter $$").newLine();
      buffer.append("do").newLine();
      buffer.append("begin").newLine();
      buffer.append("declare exit handler for sql_error_code 261 begin end").endOfStatement();
      buffer.append("exec '").append(dropIndexIfExists).append(maxConstraintName(indexName)).append("'")
          .endOfStatement();
      buffer.append("end").endOfStatement();
      buffer.append("$$");
      return buffer.getBuffer();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy