/**
  * Create a new full text index for a table and column list. Each table may only have one index at
  * any time.
  *
  * @param conn the connection
  * @param schema the schema name of the table (case sensitive)
  * @param table the table name (case sensitive)
  * @param columnList the column list (null for all columns)
  */
 public static void createIndex(Connection conn, String schema, String table, String columnList)
     throws SQLException {
   init(conn);
   PreparedStatement prep =
       conn.prepareStatement(
           "INSERT INTO " + SCHEMA + ".INDEXES(SCHEMA, TABLE, COLUMNS) VALUES(?, ?, ?)");
   prep.setString(1, schema);
   prep.setString(2, table);
   prep.setString(3, columnList);
   prep.execute();
   createTrigger(conn, schema, table);
   indexExistingRows(conn, schema, table);
 }
 /** INTERNAL */
 public void init(
     Connection conn,
     String schemaName,
     String triggerName,
     String tableName,
     boolean before,
     int type)
     throws SQLException {
   this.schema = schemaName;
   this.table = tableName;
   this.indexPath = getIndexPath(conn);
   this.indexAccess = getIndexAccess(conn);
   ArrayList<String> keyList = New.arrayList();
   DatabaseMetaData meta = conn.getMetaData();
   ResultSet rs =
       meta.getColumns(
           null, escapeMetaDataPattern(schemaName), escapeMetaDataPattern(tableName), null);
   ArrayList<String> columnList = New.arrayList();
   while (rs.next()) {
     columnList.add(rs.getString("COLUMN_NAME"));
   }
   columnTypes = new int[columnList.size()];
   columns = new String[columnList.size()];
   columnList.toArray(columns);
   rs =
       meta.getColumns(
           null, escapeMetaDataPattern(schemaName), escapeMetaDataPattern(tableName), null);
   for (int i = 0; rs.next(); i++) {
     columnTypes[i] = rs.getInt("DATA_TYPE");
   }
   if (keyList.size() == 0) {
     rs = meta.getPrimaryKeys(null, escapeMetaDataPattern(schemaName), tableName);
     while (rs.next()) {
       keyList.add(rs.getString("COLUMN_NAME"));
     }
   }
   if (keyList.size() == 0) {
     throw throwException("No primary key for table " + tableName);
   }
   ArrayList<String> indexList = New.arrayList();
   PreparedStatement prep =
       conn.prepareStatement(
           "SELECT COLUMNS FROM " + SCHEMA + ".INDEXES WHERE SCHEMA=? AND TABLE=?");
   prep.setString(1, schemaName);
   prep.setString(2, tableName);
   rs = prep.executeQuery();
   if (rs.next()) {
     String cols = rs.getString(1);
     if (cols != null) {
       for (String s : StringUtils.arraySplit(cols, ',', true)) {
         indexList.add(s);
       }
     }
   }
   if (indexList.size() == 0) {
     indexList.addAll(columnList);
   }
   keys = new int[keyList.size()];
   setColumns(keys, keyList, columnList);
   indexColumns = new int[indexList.size()];
   setColumns(indexColumns, indexList, columnList);
 }