/**
   * Tests the pattern-like column retrieval from the database. DbUnit should not interpret any
   * table names as regex patterns.
   *
   * @throws Exception
   */
  public void testGetColumnsForTablesMatchingSamePattern() throws Exception {
    Connection jdbcConnection = HypersonicEnvironment.createJdbcConnection("tempdb");
    HypersonicEnvironment.executeDdlFile(
        new File("src/sql/hypersonic_dataset_pattern_test.sql"), jdbcConnection);
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

    try {
      String tableName = "PATTERN_LIKE_TABLE_X_";
      String[] columnNames = {"VARCHAR_COL_XUNDERSCORE"};

      String sql = "select * from " + tableName;
      ForwardOnlyResultSetTable resultSetTable =
          new ForwardOnlyResultSetTable(tableName, sql, connection);
      ResultSetTableMetaData metaData = (ResultSetTableMetaData) resultSetTable.getTableMetaData();

      Column[] columns = metaData.getColumns();

      assertEquals("column count", columnNames.length, columns.length);

      for (int i = 0; i < columnNames.length; i++) {
        Column column = Columns.getColumn(columnNames[i], columns);
        assertEquals(columnNames[i], columnNames[i], column.getColumnName());
      }
    } finally {
      HypersonicEnvironment.shutdown(jdbcConnection);
      jdbcConnection.close();
      HypersonicEnvironment.deleteFiles("tempdb");
    }
  }
  public Column[] getPrimaryKeys() throws DataSetException {
    logger.debug("getPrimaryKeys() - start");
    DatabaseConfig config = _connection.getConfig();
    IColumnFilter primaryKeysFilter =
        (IColumnFilter) config.getProperty(DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER);

    if (_primaryKeys == null || primaryKeyFilterChanged(primaryKeysFilter)) {
      try {
        lastKeyFilter = primaryKeysFilter;
        if (primaryKeysFilter != null) {
          _primaryKeys = Columns.getColumns(getTableName(), getColumns(), primaryKeysFilter);
        } else {
          String[] pkNames = getPrimaryKeyNames();
          _primaryKeys = Columns.getColumns(pkNames, getColumns());
        }
      } catch (SQLException e) {
        throw new DataSetException(e);
      }
    }
    return _primaryKeys;
  }