Unverified 提交 ba15559f authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #1021 from katzyn/metadata

Update JdbcDatabaseMetaData to JDBC 4.1 (Java 7)
...@@ -146,20 +146,19 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -146,20 +146,19 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of tables in the database. The result set is sorted by * Gets the list of tables in the database. The result set is sorted by
* TABLE_TYPE, TABLE_SCHEM, and TABLE_NAME. * TABLE_TYPE, TABLE_SCHEM, and TABLE_NAME.
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog </li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema </li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name </li> * <li>TABLE_NAME (String) table name</li>
* <li>4 TABLE_TYPE (String) table type </li> * <li>TABLE_TYPE (String) table type</li>
* <li>5 REMARKS (String) comment </li> * <li>REMARKS (String) comment</li>
* <li>6 TYPE_CAT (String) always null </li> * <li>TYPE_CAT (String) always null</li>
* <li>7 TYPE_SCHEM (String) always null </li> * <li>TYPE_SCHEM (String) always null</li>
* <li>8 TYPE_NAME (String) always null </li> * <li>TYPE_NAME (String) always null</li>
* <li>9 SELF_REFERENCING_COL_NAME (String) always null </li> * <li>SELF_REFERENCING_COL_NAME (String) always null</li>
* <li>10 REF_GENERATION (String) always null </li> * <li>REF_GENERATION (String) always null</li>
* <li>11 SQL (String) the create table statement or NULL for systems tables * <li>SQL (String) the create table statement or NULL for systems tables.</li>
* </li> * </ol>
* </ul>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -265,34 +264,33 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -265,34 +264,33 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of columns. The result set is sorted by TABLE_SCHEM, * Gets the list of columns. The result set is sorted by TABLE_SCHEM,
* TABLE_NAME, and ORDINAL_POSITION. * TABLE_NAME, and ORDINAL_POSITION.
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog </li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema </li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name </li> * <li>TABLE_NAME (String) table name</li>
* <li>4 COLUMN_NAME (String) column name </li> * <li>COLUMN_NAME (String) column name</li>
* <li>5 DATA_TYPE (short) data type (see java.sql.Types) </li> * <li>DATA_TYPE (short) data type (see java.sql.Types)</li>
* <li>6 TYPE_NAME (String) data type name ("INTEGER", "VARCHAR",...) </li> * <li>TYPE_NAME (String) data type name ("INTEGER", "VARCHAR",...)</li>
* <li>7 COLUMN_SIZE (int) precision * <li>COLUMN_SIZE (int) precision
* (values larger than 2 GB are returned as 2 GB)</li> * (values larger than 2 GB are returned as 2 GB)</li>
* <li>8 BUFFER_LENGTH (int) unused </li> * <li>BUFFER_LENGTH (int) unused</li>
* <li>9 DECIMAL_DIGITS (int) scale (0 for INTEGER and VARCHAR) </li> * <li>DECIMAL_DIGITS (int) scale (0 for INTEGER and VARCHAR)</li>
* <li>10 NUM_PREC_RADIX (int) radix (always 10) </li> * <li>NUM_PREC_RADIX (int) radix (always 10)</li>
* <li>11 NULLABLE (int) columnNoNulls or columnNullable</li> * <li>NULLABLE (int) columnNoNulls or columnNullable</li>
* <li>12 REMARKS (String) comment (always empty) </li> * <li>REMARKS (String) comment (always empty)</li>
* <li>13 COLUMN_DEF (String) default value </li> * <li>COLUMN_DEF (String) default value</li>
* <li>14 SQL_DATA_TYPE (int) unused </li> * <li>SQL_DATA_TYPE (int) unused</li>
* <li>15 SQL_DATETIME_SUB (int) unused </li> * <li>SQL_DATETIME_SUB (int) unused</li>
* <li>16 CHAR_OCTET_LENGTH (int) unused </li> * <li>CHAR_OCTET_LENGTH (int) unused</li>
* <li>17 ORDINAL_POSITION (int) the column index (1,2,...) </li> * <li>ORDINAL_POSITION (int) the column index (1,2,...)</li>
* <li>18 IS_NULLABLE (String) "NO" or "YES" </li> * <li>IS_NULLABLE (String) "NO" or "YES"</li>
* <li>19 SCOPE_CATALOG (String) always null </li> * <li>SCOPE_CATALOG (String) always null</li>
* <li>20 SCOPE_SCHEMA (String) always null </li> * <li>SCOPE_SCHEMA (String) always null</li>
* <li>21 SCOPE_TABLE (String) always null </li> * <li>SCOPE_TABLE (String) always null</li>
* <li>22 SOURCE_DATA_TYPE (short) null </li> * <li>SOURCE_DATA_TYPE (short) null</li>
* <li>23 IS_AUTOINCREMENT (String) "NO" or "YES" </li> * <li>IS_AUTOINCREMENT (String) "NO" or "YES"</li>
* <li>24 SCOPE_CATLOG (String) always null (the typo is on purpose, * <li>IS_GENERATEDCOLUMN (String) "NO" or "YES"</li>
* for compatibility with the JDBC specification prior to 4.1)</li> * </ol>
* </ul>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -344,7 +342,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -344,7 +342,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "SCOPE_TABLE, " + "SCOPE_TABLE, "
+ "SOURCE_DATA_TYPE, " + "SOURCE_DATA_TYPE, "
+ "IS_AUTOINCREMENT, " + "IS_AUTOINCREMENT, "
+ "SCOPE_CATLOG " + "IS_GENERATEDCOLUMN "
+ "FROM (" + "FROM ("
+ "SELECT " + "SELECT "
+ "s.SYNONYM_CATALOG TABLE_CAT, " + "s.SYNONYM_CATALOG TABLE_CAT, "
...@@ -371,7 +369,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -371,7 +369,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "c.SOURCE_DATA_TYPE, " + "c.SOURCE_DATA_TYPE, "
+ "CASE WHEN c.SEQUENCE_NAME IS NULL THEN " + "CASE WHEN c.SEQUENCE_NAME IS NULL THEN "
+ "CAST(?1 AS VARCHAR) ELSE CAST(?2 AS VARCHAR) END IS_AUTOINCREMENT, " + "CAST(?1 AS VARCHAR) ELSE CAST(?2 AS VARCHAR) END IS_AUTOINCREMENT, "
+ "CAST(c.SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG " + "CASE WHEN c.IS_COMPUTED THEN "
+ "CAST(?2 AS VARCHAR) ELSE CAST(?1 AS VARCHAR) END IS_GENERATEDCOLUMN "
+ "FROM INFORMATION_SCHEMA.COLUMNS c JOIN INFORMATION_SCHEMA.SYNONYMS s ON " + "FROM INFORMATION_SCHEMA.COLUMNS c JOIN INFORMATION_SCHEMA.SYNONYMS s ON "
+ "s.SYNONYM_FOR = c.TABLE_NAME " + "s.SYNONYM_FOR = c.TABLE_NAME "
+ "AND s.SYNONYM_FOR_SCHEMA = c.TABLE_SCHEMA " + "AND s.SYNONYM_FOR_SCHEMA = c.TABLE_SCHEMA "
...@@ -406,7 +405,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -406,7 +405,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "SOURCE_DATA_TYPE, " + "SOURCE_DATA_TYPE, "
+ "CASE WHEN SEQUENCE_NAME IS NULL THEN " + "CASE WHEN SEQUENCE_NAME IS NULL THEN "
+ "CAST(?1 AS VARCHAR) ELSE CAST(?2 AS VARCHAR) END IS_AUTOINCREMENT, " + "CAST(?1 AS VARCHAR) ELSE CAST(?2 AS VARCHAR) END IS_AUTOINCREMENT, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG " + "CASE WHEN IS_COMPUTED THEN "
+ "CAST(?2 AS VARCHAR) ELSE CAST(?1 AS VARCHAR) END IS_GENERATEDCOLUMN "
+ "FROM INFORMATION_SCHEMA.COLUMNS " + "FROM INFORMATION_SCHEMA.COLUMNS "
+ "WHERE TABLE_CATALOG LIKE ?3 ESCAPE ?7 " + "WHERE TABLE_CATALOG LIKE ?3 ESCAPE ?7 "
+ "AND TABLE_SCHEMA LIKE ?4 ESCAPE ?7 " + "AND TABLE_SCHEMA LIKE ?4 ESCAPE ?7 "
...@@ -436,23 +436,23 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -436,23 +436,23 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* is sorted by NON_UNIQUE ('false' first), TYPE, TABLE_SCHEM, INDEX_NAME, * is sorted by NON_UNIQUE ('false' first), TYPE, TABLE_SCHEM, INDEX_NAME,
* and ORDINAL_POSITION. * and ORDINAL_POSITION.
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog </li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema </li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name </li> * <li>TABLE_NAME (String) table name</li>
* <li>4 NON_UNIQUE (boolean) 'true' if non-unique</li> * <li>NON_UNIQUE (boolean) 'true' if non-unique</li>
* <li>5 INDEX_QUALIFIER (String) index catalog </li> * <li>INDEX_QUALIFIER (String) index catalog</li>
* <li>6 INDEX_NAME (String) index name </li> * <li>INDEX_NAME (String) index name</li>
* <li>7 TYPE (short) the index type (always tableIndexOther) </li> * <li>TYPE (short) the index type (always tableIndexOther)</li>
* <li>8 ORDINAL_POSITION (short) column index (1, 2, ...) </li> * <li>ORDINAL_POSITION (short) column index (1, 2, ...)</li>
* <li>9 COLUMN_NAME (String) column name </li> * <li>COLUMN_NAME (String) column name</li>
* <li>10 ASC_OR_DESC (String) ascending or descending (always 'A') </li> * <li>ASC_OR_DESC (String) ascending or descending (always 'A')</li>
* <li>11 CARDINALITY (int) numbers of unique values </li> * <li>CARDINALITY (int) numbers of unique values</li>
* <li>12 PAGES (int) number of pages use (always 0) </li> * <li>PAGES (int) number of pages use (always 0)</li>
* <li>13 FILTER_CONDITION (String) filter condition (always empty) </li> * <li>FILTER_CONDITION (String) filter condition (always empty)</li>
* <li>14 SORT_TYPE (int) the sort type bit map: 1=DESCENDING, * <li>SORT_TYPE (int) the sort type bit map: 1=DESCENDING,
* 2=NULLS_FIRST, 4=NULLS_LAST </li> * 2=NULLS_FIRST, 4=NULLS_LAST</li>
* </ul> * </ol>
* *
* @param catalogPattern null or the catalog name * @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -517,14 +517,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -517,14 +517,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the primary key columns for a table. The result set is sorted by * Gets the primary key columns for a table. The result set is sorted by
* TABLE_SCHEM, and COLUMN_NAME (and not by KEY_SEQ). * TABLE_SCHEM, and COLUMN_NAME (and not by KEY_SEQ).
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog</li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema</li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name</li> * <li>TABLE_NAME (String) table name</li>
* <li>4 COLUMN_NAME (String) column name</li> * <li>COLUMN_NAME (String) column name</li>
* <li>5 KEY_SEQ (short) the column index of this column (1,2,...)</li> * <li>KEY_SEQ (short) the column index of this column (1,2,...)</li>
* <li>6 PK_NAME (String) the name of the primary key index</li> * <li>PK_NAME (String) the name of the primary key index</li>
* </ul> * </ol>
* *
* @param catalogPattern null or the catalog name * @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -700,18 +700,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -700,18 +700,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* procedures with the same name, each with a different number of input * procedures with the same name, each with a different number of input
* parameters. * parameters.
* *
* <ul> * <ol>
* <li>1 PROCEDURE_CAT (String) catalog </li> * <li>PROCEDURE_CAT (String) catalog</li>
* <li>2 PROCEDURE_SCHEM (String) schema </li> * <li>PROCEDURE_SCHEM (String) schema</li>
* <li>3 PROCEDURE_NAME (String) name </li> * <li>PROCEDURE_NAME (String) name</li>
* <li>4 NUM_INPUT_PARAMS (int) the number of arguments </li> * <li>NUM_INPUT_PARAMS (int) the number of arguments</li>
* <li>5 NUM_OUTPUT_PARAMS (int) for future use, always 0 </li> * <li>NUM_OUTPUT_PARAMS (int) for future use, always 0</li>
* <li>6 NUM_RESULT_SETS (int) for future use, always 0 </li> * <li>NUM_RESULT_SETS (int) for future use, always 0</li>
* <li>7 REMARKS (String) description </li> * <li>REMARKS (String) description</li>
* <li>8 PROCEDURE_TYPE (short) if this procedure returns a result * <li>PROCEDURE_TYPE (short) if this procedure returns a result
* (procedureNoResult or procedureReturnsResult) </li> * (procedureNoResult or procedureReturnsResult)</li>
* <li>9 SPECIFIC_NAME (String) name </li> * <li>SPECIFIC_NAME (String) name</li>
* </ul> * </ol>
* *
* @param catalogPattern null or the catalog name * @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -764,32 +764,32 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -764,32 +764,32 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* There are potentially multiple procedures with the same name, each with a * There are potentially multiple procedures with the same name, each with a
* different number of input parameters. * different number of input parameters.
* *
* <ul> * <ol>
* <li>1 PROCEDURE_CAT (String) catalog </li> * <li>PROCEDURE_CAT (String) catalog</li>
* <li>2 PROCEDURE_SCHEM (String) schema </li> * <li>PROCEDURE_SCHEM (String) schema</li>
* <li>3 PROCEDURE_NAME (String) name </li> * <li>PROCEDURE_NAME (String) name</li>
* <li>4 COLUMN_NAME (String) column name </li> * <li>COLUMN_NAME (String) column name</li>
* <li>5 COLUMN_TYPE (short) column type * <li>COLUMN_TYPE (short) column type
* (always DatabaseMetaData.procedureColumnIn)</li> * (always DatabaseMetaData.procedureColumnIn)</li>
* <li>6 DATA_TYPE (short) sql type </li> * <li>DATA_TYPE (short) sql type</li>
* <li>7 TYPE_NAME (String) type name </li> * <li>TYPE_NAME (String) type name</li>
* <li>8 PRECISION (int) precision </li> * <li>PRECISION (int) precision</li>
* <li>9 LENGTH (int) length </li> * <li>LENGTH (int) length</li>
* <li>10 SCALE (short) scale </li> * <li>SCALE (short) scale</li>
* <li>11 RADIX (int) always 10 </li> * <li>RADIX (int) always 10</li>
* <li>12 NULLABLE (short) nullable * <li>NULLABLE (short) nullable
* (DatabaseMetaData.columnNoNulls for primitive data types, * (DatabaseMetaData.columnNoNulls for primitive data types,
* DatabaseMetaData.columnNullable otherwise)</li> * DatabaseMetaData.columnNullable otherwise)</li>
* <li>13 REMARKS (String) description </li> * <li>REMARKS (String) description</li>
* <li>14 COLUMN_DEF (String) always null </li> * <li>COLUMN_DEF (String) always null</li>
* <li>15 SQL_DATA_TYPE (int) for future use, always 0 </li> * <li>SQL_DATA_TYPE (int) for future use, always 0</li>
* <li>16 SQL_DATETIME_SUB (int) for future use, always 0 </li> * <li>SQL_DATETIME_SUB (int) for future use, always 0</li>
* <li>17 CHAR_OCTET_LENGTH (int) always null </li> * <li>CHAR_OCTET_LENGTH (int) always null</li>
* <li>18 ORDINAL_POSITION (int) the parameter index * <li>ORDINAL_POSITION (int) the parameter index
* starting from 1 (0 is the return value) </li> * starting from 1 (0 is the return value)</li>
* <li>19 IS_NULLABLE (String) always "YES" </li> * <li>IS_NULLABLE (String) always "YES"</li>
* <li>20 SPECIFIC_NAME (String) name </li> * <li>SPECIFIC_NAME (String) name</li>
* </ul> * </ol>
* *
* @param catalogPattern null or the catalog name * @param catalogPattern null or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -858,11 +858,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -858,11 +858,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of schemas. * Gets the list of schemas.
* The result set is sorted by TABLE_SCHEM. * The result set is sorted by TABLE_SCHEM.
* *
* <ul> * <ol>
* <li>1 TABLE_SCHEM (String) schema name * <li>TABLE_SCHEM (String) schema name</li>
* </li><li>2 TABLE_CATALOG (String) catalog name * <li>TABLE_CATALOG (String) catalog name</li>
* </li><li>3 IS_DEFAULT (boolean) if this is the default schema * <li>IS_DEFAULT (boolean) if this is the default schema</li>
* </li></ul> * </ol>
* *
* @return the schema list * @return the schema list
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
...@@ -889,9 +889,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -889,9 +889,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of catalogs. * Gets the list of catalogs.
* The result set is sorted by TABLE_CAT. * The result set is sorted by TABLE_CAT.
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) catalog name * <li>TABLE_CAT (String) catalog name</li>
* </li></ul> * </ol>
* *
* @return the catalog list * @return the catalog list
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
...@@ -913,9 +913,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -913,9 +913,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements
/** /**
* Gets the list of table types. This call returns a result set with five * Gets the list of table types. This call returns a result set with five
* records: "SYSTEM TABLE", "TABLE", "VIEW", "TABLE LINK" and "EXTERNAL". * records: "SYSTEM TABLE", "TABLE", "VIEW", "TABLE LINK" and "EXTERNAL".
* <ul> * <ol>
* <li>1 TABLE_TYPE (String) table type * <li>TABLE_TYPE (String) table type</li>
* </li></ul> * </ol>
* *
* @return the table types * @return the table types
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
...@@ -939,18 +939,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -939,18 +939,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of column privileges. The result set is sorted by * Gets the list of column privileges. The result set is sorted by
* COLUMN_NAME and PRIVILEGE * COLUMN_NAME and PRIVILEGE
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog</li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema</li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name</li> * <li>TABLE_NAME (String) table name</li>
* <li>4 COLUMN_NAME (String) column name</li> * <li>COLUMN_NAME (String) column name</li>
* <li>5 GRANTOR (String) grantor of access</li> * <li>GRANTOR (String) grantor of access</li>
* <li>6 GRANTEE (String) grantee of access</li> * <li>GRANTEE (String) grantee of access</li>
* <li>7 PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES * <li>PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES
* (only one per row)</li> * (only one per row)</li>
* <li>8 IS_GRANTABLE (String) YES means the grantee can grant access to * <li>IS_GRANTABLE (String) YES means the grantee can grant access to
* others</li> * others</li>
* </ul> * </ol>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -1006,17 +1006,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1006,17 +1006,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of table privileges. The result set is sorted by * Gets the list of table privileges. The result set is sorted by
* TABLE_SCHEM, TABLE_NAME, and PRIVILEGE. * TABLE_SCHEM, TABLE_NAME, and PRIVILEGE.
* *
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog </li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema </li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name </li> * <li>TABLE_NAME (String) table name</li>
* <li>4 GRANTOR (String) grantor of access </li> * <li>GRANTOR (String) grantor of access</li>
* <li>5 GRANTEE (String) grantee of access </li> * <li>GRANTEE (String) grantee of access</li>
* <li>6 PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES * <li>PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES
* (only one per row) </li> * (only one per row)</li>
* <li>7 IS_GRANTABLE (String) YES means the grantee can grant access to * <li>IS_GRANTABLE (String) YES means the grantee can grant access to
* others </li> * others</li>
* </ul> * </ol>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -1066,17 +1066,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1066,17 +1066,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of columns that best identifier a row in a table. * Gets the list of columns that best identifier a row in a table.
* The list is ordered by SCOPE. * The list is ordered by SCOPE.
* *
* <ul> * <ol>
* <li>1 SCOPE (short) scope of result (always bestRowSession) * <li>SCOPE (short) scope of result (always bestRowSession)</li>
* </li><li>2 COLUMN_NAME (String) column name * <li>COLUMN_NAME (String) column name</li>
* </li><li>3 DATA_TYPE (short) SQL data type, see also java.sql.Types * <li>DATA_TYPE (short) SQL data type, see also java.sql.Types</li>
* </li><li>4 TYPE_NAME (String) type name * <li>TYPE_NAME (String) type name</li>
* </li><li>5 COLUMN_SIZE (int) precision * <li>COLUMN_SIZE (int) precision
* (values larger than 2 GB are returned as 2 GB) * (values larger than 2 GB are returned as 2 GB)</li>
* </li><li>6 BUFFER_LENGTH (int) unused * <li>BUFFER_LENGTH (int) unused</li>
* </li><li>7 DECIMAL_DIGITS (short) scale * <li>DECIMAL_DIGITS (short) scale</li>
* </li><li>8 PSEUDO_COLUMN (short) (always bestRowNotPseudo) * <li>PSEUDO_COLUMN (short) (always bestRowNotPseudo)</li>
* </li></ul> * </ol>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -1137,17 +1137,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1137,17 +1137,17 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Get the list of columns that are update when any value is updated. * Get the list of columns that are update when any value is updated.
* The result set is always empty. * The result set is always empty.
* *
* <ul> * <ol>
* <li>1 SCOPE (int) not used * <li>1 SCOPE (int) not used</li>
* </li><li>2 COLUMN_NAME (String) column name * <li>2 COLUMN_NAME (String) column name</li>
* </li><li>3 DATA_TYPE (int) SQL data type - see also java.sql.Types * <li>3 DATA_TYPE (int) SQL data type - see also java.sql.Types</li>
* </li><li>4 TYPE_NAME (String) data type name * <li>4 TYPE_NAME (String) data type name</li>
* </li><li>5 COLUMN_SIZE (int) precision * <li>5 COLUMN_SIZE (int) precision
* (values larger than 2 GB are returned as 2 GB) * (values larger than 2 GB are returned as 2 GB)</li>
* </li><li>6 BUFFER_LENGTH (int) length (bytes) * <li>6 BUFFER_LENGTH (int) length (bytes)</li>
* </li><li>7 DECIMAL_DIGITS (int) scale * <li>7 DECIMAL_DIGITS (int) scale</li>
* </li><li>8 PSEUDO_COLUMN (int) is this column a pseudo column * <li>8 PSEUDO_COLUMN (int) is this column a pseudo column</li>
* </li></ul> * </ol>
* *
* @param catalog null (to get all objects) or the catalog name * @param catalog null (to get all objects) or the catalog name
* @param schema null (to get all objects) or a schema name * @param schema null (to get all objects) or a schema name
...@@ -1188,25 +1188,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1188,25 +1188,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* result set is sorted by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, * result set is sorted by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
* FK_NAME, KEY_SEQ. * FK_NAME, KEY_SEQ.
* *
* <ul> * <ol>
* <li>1 PKTABLE_CAT (String) primary catalog </li> * <li>PKTABLE_CAT (String) primary catalog</li>
* <li>2 PKTABLE_SCHEM (String) primary schema </li> * <li>PKTABLE_SCHEM (String) primary schema</li>
* <li>3 PKTABLE_NAME (String) primary table </li> * <li>PKTABLE_NAME (String) primary table</li>
* <li>4 PKCOLUMN_NAME (String) primary column </li> * <li>PKCOLUMN_NAME (String) primary column</li>
* <li>5 FKTABLE_CAT (String) foreign catalog </li> * <li>FKTABLE_CAT (String) foreign catalog</li>
* <li>6 FKTABLE_SCHEM (String) foreign schema </li> * <li>FKTABLE_SCHEM (String) foreign schema</li>
* <li>7 FKTABLE_NAME (String) foreign table </li> * <li>FKTABLE_NAME (String) foreign table</li>
* <li>8 FKCOLUMN_NAME (String) foreign column </li> * <li>FKCOLUMN_NAME (String) foreign column</li>
* <li>9 KEY_SEQ (short) sequence number (1, 2, ...) </li> * <li>KEY_SEQ (short) sequence number (1, 2, ...)</li>
* <li>10 UPDATE_RULE (short) action on update (see * <li>UPDATE_RULE (short) action on update (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>11 DELETE_RULE (short) action on delete (see * <li>DELETE_RULE (short) action on delete (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>12 FK_NAME (String) foreign key name </li> * <li>FK_NAME (String) foreign key name</li>
* <li>13 PK_NAME (String) primary key name </li> * <li>PK_NAME (String) primary key name</li>
* <li>14 DEFERRABILITY (short) deferrable or not (always * <li>DEFERRABILITY (short) deferrable or not (always
* importedKeyNotDeferrable) </li> * importedKeyNotDeferrable)</li>
* </ul> * </ol>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern the schema name of the foreign table * @param schemaPattern the schema name of the foreign table
...@@ -1261,25 +1261,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1261,25 +1261,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, * set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME,
* KEY_SEQ. * KEY_SEQ.
* *
* <ul> * <ol>
* <li>1 PKTABLE_CAT (String) primary catalog </li> * <li>PKTABLE_CAT (String) primary catalog</li>
* <li>2 PKTABLE_SCHEM (String) primary schema </li> * <li>PKTABLE_SCHEM (String) primary schema</li>
* <li>3 PKTABLE_NAME (String) primary table </li> * <li>PKTABLE_NAME (String) primary table</li>
* <li>4 PKCOLUMN_NAME (String) primary column </li> * <li>PKCOLUMN_NAME (String) primary column</li>
* <li>5 FKTABLE_CAT (String) foreign catalog </li> * <li>FKTABLE_CAT (String) foreign catalog</li>
* <li>6 FKTABLE_SCHEM (String) foreign schema </li> * <li>FKTABLE_SCHEM (String) foreign schema</li>
* <li>7 FKTABLE_NAME (String) foreign table </li> * <li>FKTABLE_NAME (String) foreign table</li>
* <li>8 FKCOLUMN_NAME (String) foreign column </li> * <li>FKCOLUMN_NAME (String) foreign column</li>
* <li>9 KEY_SEQ (short) sequence number (1,2,...) </li> * <li>KEY_SEQ (short) sequence number (1,2,...)</li>
* <li>10 UPDATE_RULE (short) action on update (see * <li>UPDATE_RULE (short) action on update (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>11 DELETE_RULE (short) action on delete (see * <li>DELETE_RULE (short) action on delete (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>12 FK_NAME (String) foreign key name </li> * <li>FK_NAME (String) foreign key name</li>
* <li>13 PK_NAME (String) primary key name </li> * <li>PK_NAME (String) primary key name</li>
* <li>14 DEFERRABILITY (short) deferrable or not (always * <li>DEFERRABILITY (short) deferrable or not (always
* importedKeyNotDeferrable) </li> * importedKeyNotDeferrable)</li>
* </ul> * </ol>
* *
* @param catalogPattern null or the catalog name * @param catalogPattern null or the catalog name
* @param schemaPattern the schema name of the primary table * @param schemaPattern the schema name of the primary table
...@@ -1335,25 +1335,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1335,25 +1335,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* result set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, * result set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME,
* FK_NAME, KEY_SEQ. * FK_NAME, KEY_SEQ.
* *
* <ul> * <ol>
* <li>1 PKTABLE_CAT (String) primary catalog </li> * <li>PKTABLE_CAT (String) primary catalog</li>
* <li>2 PKTABLE_SCHEM (String) primary schema </li> * <li>PKTABLE_SCHEM (String) primary schema</li>
* <li>3 PKTABLE_NAME (String) primary table </li> * <li>PKTABLE_NAME (String) primary table</li>
* <li>4 PKCOLUMN_NAME (String) primary column </li> * <li>PKCOLUMN_NAME (String) primary column</li>
* <li>5 FKTABLE_CAT (String) foreign catalog </li> * <li>FKTABLE_CAT (String) foreign catalog</li>
* <li>6 FKTABLE_SCHEM (String) foreign schema </li> * <li>FKTABLE_SCHEM (String) foreign schema</li>
* <li>7 FKTABLE_NAME (String) foreign table </li> * <li>FKTABLE_NAME (String) foreign table</li>
* <li>8 FKCOLUMN_NAME (String) foreign column </li> * <li>FKCOLUMN_NAME (String) foreign column</li>
* <li>9 KEY_SEQ (short) sequence number (1,2,...) </li> * <li>KEY_SEQ (short) sequence number (1,2,...)</li>
* <li>10 UPDATE_RULE (short) action on update (see * <li>UPDATE_RULE (short) action on update (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>11 DELETE_RULE (short) action on delete (see * <li>DELETE_RULE (short) action on delete (see
* DatabaseMetaData.importedKey...) </li> * DatabaseMetaData.importedKey...)</li>
* <li>12 FK_NAME (String) foreign key name </li> * <li>FK_NAME (String) foreign key name</li>
* <li>13 PK_NAME (String) primary key name </li> * <li>PK_NAME (String) primary key name</li>
* <li>14 DEFERRABILITY (short) deferrable or not (always * <li>DEFERRABILITY (short) deferrable or not (always
* importedKeyNotDeferrable) </li> * importedKeyNotDeferrable)</li>
* </ul> * </ol>
* *
* @param primaryCatalogPattern null or the catalog name * @param primaryCatalogPattern null or the catalog name
* @param primarySchemaPattern the schema name of the primary table * @param primarySchemaPattern the schema name of the primary table
...@@ -1424,15 +1424,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1424,15 +1424,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of user-defined data types. * Gets the list of user-defined data types.
* This call returns an empty result set. * This call returns an empty result set.
* *
* <ul> * <ol>
* <li>1 TYPE_CAT (String) catalog * <li>TYPE_CAT (String) catalog</li>
* </li><li>2 TYPE_SCHEM (String) schema * <li>TYPE_SCHEM (String) schema</li>
* </li><li>3 TYPE_NAME (String) type name * <li>TYPE_NAME (String) type name</li>
* </li><li>4 CLASS_NAME (String) Java class * <li>CLASS_NAME (String) Java class</li>
* </li><li>5 DATA_TYPE (short) SQL Type - see also java.sql.Types * <li>DATA_TYPE (short) SQL Type - see also java.sql.Types</li>
* </li><li>6 REMARKS (String) description * <li>REMARKS (String) description</li>
* </li><li>7 BASE_TYPE (short) base type - see also java.sql.Types * <li>BASE_TYPE (short) base type - see also java.sql.Types</li>
* </li></ul> * </ol>
* *
* @param catalog ignored * @param catalog ignored
* @param schemaPattern ignored * @param schemaPattern ignored
...@@ -1473,27 +1473,26 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1473,27 +1473,26 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* afterwards by how closely the data type maps to the corresponding JDBC * afterwards by how closely the data type maps to the corresponding JDBC
* SQL type (best match first). * SQL type (best match first).
* *
* <ul> * <ol>
* <li>1 TYPE_NAME (String) type name </li> * <li>TYPE_NAME (String) type name</li>
* <li>2 DATA_TYPE (short) SQL data type - see also java.sql.Types </li> * <li>DATA_TYPE (short) SQL data type - see also java.sql.Types</li>
* <li>3 PRECISION (int) maximum precision </li> * <li>PRECISION (int) maximum precision</li>
* <li>4 LITERAL_PREFIX (String) prefix used to quote a literal </li> * <li>LITERAL_PREFIX (String) prefix used to quote a literal</li>
* <li>5 LITERAL_SUFFIX (String) suffix used to quote a literal </li> * <li>LITERAL_SUFFIX (String) suffix used to quote a literal</li>
* <li>6 CREATE_PARAMS (String) parameters used (may be null) </li> * <li>CREATE_PARAMS (String) parameters used (may be null)</li>
* <li>7 NULLABLE (short) typeNoNulls (NULL not allowed) or typeNullable * <li>NULLABLE (short) typeNoNulls (NULL not allowed) or typeNullable</li>
* </li> * <li>CASE_SENSITIVE (boolean) case sensitive</li>
* <li>8 CASE_SENSITIVE (boolean) case sensitive </li> * <li>SEARCHABLE (short) typeSearchable</li>
* <li>9 SEARCHABLE (short) typeSearchable </li> * <li>UNSIGNED_ATTRIBUTE (boolean) unsigned</li>
* <li>10 UNSIGNED_ATTRIBUTE (boolean) unsigned </li> * <li>FIXED_PREC_SCALE (boolean) fixed precision</li>
* <li>11 FIXED_PREC_SCALE (boolean) fixed precision </li> * <li>AUTO_INCREMENT (boolean) auto increment</li>
* <li>12 AUTO_INCREMENT (boolean) auto increment </li> * <li>LOCAL_TYPE_NAME (String) localized version of the data type</li>
* <li>13 LOCAL_TYPE_NAME (String) localized version of the data type </li> * <li>MINIMUM_SCALE (short) minimum scale</li>
* <li>14 MINIMUM_SCALE (short) minimum scale </li> * <li>MAXIMUM_SCALE (short) maximum scale</li>
* <li>15 MAXIMUM_SCALE (short) maximum scale </li> * <li>SQL_DATA_TYPE (int) unused</li>
* <li>16 SQL_DATA_TYPE (int) unused </li> * <li>SQL_DATETIME_SUB (int) unused</li>
* <li>17 SQL_DATETIME_SUB (int) unused </li> * <li>NUM_PREC_RADIX (int) 2 for binary, 10 for decimal</li>
* <li>18 NUM_PREC_RADIX (int) 2 for binary, 10 for decimal </li> * </ol>
* </ul>
* *
* @return the list of data types * @return the list of data types
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
...@@ -2946,12 +2945,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -2946,12 +2945,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements
/** /**
* Get the list of super tables of a table. This method currently returns an * Get the list of super tables of a table. This method currently returns an
* empty result set. * empty result set.
* <ul> * <ol>
* <li>1 TABLE_CAT (String) table catalog</li> * <li>TABLE_CAT (String) table catalog</li>
* <li>2 TABLE_SCHEM (String) table schema</li> * <li>TABLE_SCHEM (String) table schema</li>
* <li>3 TABLE_NAME (String) table name</li> * <li>TABLE_NAME (String) table name</li>
* <li>4 SUPERTABLE_NAME (String) the name of the super table</li> * <li>SUPERTABLE_NAME (String) the name of the super table</li>
* </ul> * </ol>
* *
* @param catalog null (to get all objects) or the catalog name * @param catalog null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
...@@ -3054,12 +3053,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -3054,12 +3053,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements
/** /**
* Gets the minor version of the supported JDBC API. * Gets the minor version of the supported JDBC API.
* *
* @return the minor version (0) * @return the minor version (1)
*/ */
@Override @Override
public int getJDBCMinorVersion() { public int getJDBCMinorVersion() {
debugCodeCall("getJDBCMinorVersion"); debugCodeCall("getJDBCMinorVersion");
return 0; return 1;
} }
/** /**
...@@ -3132,11 +3131,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -3132,11 +3131,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* Gets the list of schemas in the database. * Gets the list of schemas in the database.
* The result set is sorted by TABLE_SCHEM. * The result set is sorted by TABLE_SCHEM.
* *
* <ul> * <ol>
* <li>1 TABLE_SCHEM (String) schema name * <li>TABLE_SCHEM (String) schema name</li>
* </li><li>2 TABLE_CATALOG (String) catalog name * <li>TABLE_CATALOG (String) catalog name</li>
* </li><li>3 IS_DEFAULT (boolean) if this is the default schema * <li>IS_DEFAULT (boolean) if this is the default schema</li>
* </li></ul> * </ol>
* *
* @param catalogPattern null (to get all objects) or the catalog name * @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name * @param schemaPattern null (to get all objects) or a schema name
......
...@@ -49,6 +49,7 @@ public class TestMetaData extends TestBase { ...@@ -49,6 +49,7 @@ public class TestMetaData extends TestBase {
testColumnMetaData(); testColumnMetaData();
testColumnPrecision(); testColumnPrecision();
testColumnDefault(); testColumnDefault();
testColumnGenerated();
testCrossReferences(); testCrossReferences();
testProcedureColumns(); testProcedureColumns();
testUDTs(); testUDTs();
...@@ -234,6 +235,24 @@ public class TestMetaData extends TestBase { ...@@ -234,6 +235,24 @@ public class TestMetaData extends TestBase {
conn.close(); conn.close();
} }
private void testColumnGenerated() throws SQLException {
Connection conn = getConnection("metaData");
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs;
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(A INT, B INT AS A + 1)");
rs = meta.getColumns(null, null, "TEST", null);
rs.next();
assertEquals("A", rs.getString("COLUMN_NAME"));
assertEquals("NO", rs.getString("IS_GENERATEDCOLUMN"));
rs.next();
assertEquals("B", rs.getString("COLUMN_NAME"));
assertEquals("YES", rs.getString("IS_GENERATEDCOLUMN"));
assertFalse(rs.next());
stat.execute("DROP TABLE TEST");
conn.close();
}
private void testProcedureColumns() throws SQLException { private void testProcedureColumns() throws SQLException {
Connection conn = getConnection("metaData"); Connection conn = getConnection("metaData");
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
...@@ -404,7 +423,7 @@ public class TestMetaData extends TestBase { ...@@ -404,7 +423,7 @@ public class TestMetaData extends TestBase {
meta.getDriverMinorVersion()); meta.getDriverMinorVersion());
int majorVersion = 4; int majorVersion = 4;
assertEquals(majorVersion, meta.getJDBCMajorVersion()); assertEquals(majorVersion, meta.getJDBCMajorVersion());
assertEquals(0, meta.getJDBCMinorVersion()); assertEquals(1, meta.getJDBCMinorVersion());
assertEquals("H2", meta.getDatabaseProductName()); assertEquals("H2", meta.getDatabaseProductName());
assertEquals(Connection.TRANSACTION_READ_COMMITTED, assertEquals(Connection.TRANSACTION_READ_COMMITTED,
meta.getDefaultTransactionIsolation()); meta.getDefaultTransactionIsolation());
...@@ -711,7 +730,7 @@ public class TestMetaData extends TestBase { ...@@ -711,7 +730,7 @@ public class TestMetaData extends TestBase {
"SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
"ORDINAL_POSITION", "IS_NULLABLE", "SCOPE_CATALOG", "ORDINAL_POSITION", "IS_NULLABLE", "SCOPE_CATALOG",
"SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE", "SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE",
"IS_AUTOINCREMENT", "SCOPE_CATLOG" }, new int[] { "IS_AUTOINCREMENT", "IS_GENERATEDCOLUMN" }, new int[] {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
......
...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al ...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al
opti excessively opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries sourceschema destschema geometries sourceschema destschema generatedcolumn
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论