Program: 91686
Project: 91686
Buggy source:
/** 
 * Sets the value of all non-final fields. This method performs two steps: <ol class="verbose"> <li>Finds the schema that seems to contain the EPSG tables. If there is more than one schema containing the tables, gives precedence to the schema named "EPSG" if one is found. If there is no schema named "EPSG", takes an arbitrary schema. It may be the empty string if the tables are not contained in a schema.</li> <li>Fills the   {@link #accessToAnsi} map. That map translates the table and column names used in the SQLstatements into the names used by the database. Two conventions are understood: the names used in the MS-Access database or the names used in the SQL scripts. Both of them are distributed by EPSG.</li> </ol>
 */
final void setup(final DatabaseMetaData md) throws SQLException {
  final boolean toUpperCase=md.storesUpperCaseIdentifiers();
  for (int i=SENTINEL.length; --i >= 0; ) {
    String table=SENTINEL[i];
    if (toUpperCase && i != MIXED_CASE) {
      table=table.toUpperCase(Locale.US);
    }
    try (ResultSet result=md.getTables(catalog,schema,table,null)){
      if (result.next()) {
        isTableFound=true;
        quoteTableNames=(i == MIXED_CASE);
        do {
          catalog=result.getString("String_Node_Str");
          schema=result.getString("String_Node_Str");
        }
 while (!Constants.EPSG.equalsIgnoreCase(schema) && result.next());
        if (schema == null)         schema="String_Node_Str";
        break;
      }
    }
   }
  boolean translateColumns=true;
  accessToAnsi.clear();
  if (quoteTableNames) {
    try (ResultSet result=md.getColumns(catalog,schema,"String_Node_Str","String_Node_Str")){
      translateColumns=!result.next();
    }
   }
 else {
    accessToAnsi.put("String_Node_Str","String_Node_Str");
    accessToAnsi.put("String_Node_Str","String_Node_Str");
  }
  if (translateColumns) {
    accessToAnsi.put("String_Node_Str","String_Node_Str");
  }
  String deprecated="String_Node_Str";
  if (md.storesLowerCaseIdentifiers()) {
    deprecated=deprecated.toLowerCase(Locale.US);
  }
  try (ResultSet result=md.getColumns(catalog,schema,null,deprecated)){
    while (result.next()) {
      if (CharSequences.endsWith(result.getString("String_Node_Str"),"String_Node_Str",true)) {
        final int type=result.getInt("String_Node_Str");
        useBoolean=(type == Types.BOOLEAN) || (type == Types.BIT);
        break;
      }
    }
  }
 }

Fixed version (ground truth):
/** 
 * Sets the value of all non-final fields. This method performs two steps: <ol class="verbose"> <li>Finds the schema that seems to contain the EPSG tables. If there is more than one schema containing the tables, gives precedence to the schema named "EPSG" if one is found. If there is no schema named "EPSG", takes an arbitrary schema. It may be the empty string if the tables are not contained in a schema.</li> <li>Fills the   {@link #accessToAnsi} map. That map translates the table and column names used in the SQLstatements into the names used by the database. Two conventions are understood: the names used in the MS-Access database or the names used in the SQL scripts. Both of them are distributed by EPSG.</li> </ol>
 */
final void setup(final DatabaseMetaData md) throws SQLException {
  final boolean toUpperCase=md.storesUpperCaseIdentifiers();
  for (int i=SENTINEL.length; --i >= 0; ) {
    String table=SENTINEL[i];
    if (toUpperCase && i != MIXED_CASE) {
      table=table.toUpperCase(Locale.US);
    }
    try (ResultSet result=md.getTables(catalog,schema,table,null)){
      if (result.next()) {
        isTableFound=true;
        isPrefixed=table.startsWith(TABLE_PREFIX);
        quoteTableNames=(i == MIXED_CASE);
        do {
          catalog=result.getString("String_Node_Str");
          schema=result.getString("String_Node_Str");
        }
 while (!Constants.EPSG.equalsIgnoreCase(schema) && result.next());
        if (schema == null)         schema="String_Node_Str";
        break;
      }
    }
   }
  boolean translateColumns=true;
  accessToAnsi.clear();
  if (quoteTableNames) {
    try (ResultSet result=md.getColumns(catalog,schema,"String_Node_Str","String_Node_Str")){
      translateColumns=!result.next();
    }
   }
 else {
    accessToAnsi.put("String_Node_Str","String_Node_Str");
    accessToAnsi.put("String_Node_Str","String_Node_Str");
  }
  if (translateColumns) {
    accessToAnsi.put("String_Node_Str","String_Node_Str");
  }
  String deprecated="String_Node_Str";
  if (md.storesLowerCaseIdentifiers()) {
    deprecated=deprecated.toLowerCase(Locale.US);
  }
  try (ResultSet result=md.getColumns(catalog,schema,null,deprecated)){
    while (result.next()) {
      if (CharSequences.endsWith(result.getString("String_Node_Str"),"String_Node_Str",true)) {
        final int type=result.getInt("String_Node_Str");
        useBoolean=(type == Types.BOOLEAN) || (type == Types.BIT);
        break;
      }
    }
  }
 }