Switch JDBC metadata to indicate all columns nullable (elastic/x-pack-elasticsearch#2835)
We were returning "nullability unknown" but in Elasticsearch all columns are nullable. Original commit: elastic/x-pack-elasticsearch@6ceae418ea
This commit is contained in:
parent
00d30285e1
commit
a211077554
|
@ -25,19 +25,19 @@ CREATE TABLE mock (
|
|||
) AS
|
||||
SELECT '', 'test1', 'name', 12, 'VARCHAR', 2147483647, null, null,
|
||||
10, -- NOCOMMIT 10 seem wrong to hard code for stuff like strings
|
||||
2, -- columnNullableUnknown NOCOMMIT I think it'd be more correct to return columnNullable
|
||||
null, null, null, null, null, 1, '', null, null, null, null, '', ''
|
||||
1, -- columnNullable
|
||||
null, null, null, null, null, 1, 'YES', null, null, null, null, '', ''
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT '', 'test2', 'date', 93, 'TIMESTAMP', 19, null, null,
|
||||
10,
|
||||
2, -- columnNullableUnknown NOCOMMIT I think it'd be more correct to return columnNullable
|
||||
null, null, null, null, null, 1, '', null, null, null, null, '', ''
|
||||
1, -- columnNullable
|
||||
null, null, null, null, null, 1, 'YES', null, null, null, null, '', ''
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT '', 'test2', 'number', -5, 'BIGINT', 19, null, null,
|
||||
10,
|
||||
2, -- columnNullableUnknown NOCOMMIT I think it'd be more correct to return columnNullable
|
||||
null, null, null, null, null, 2, '', null, null, null, null, '', ''
|
||||
1, -- columnNullable
|
||||
null, null, null, null, null, 2, 'YES', null, null, null, null, '', ''
|
||||
FROM DUAL
|
||||
;
|
||||
|
|
|
@ -637,9 +637,9 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
|
||||
return emptySet(con.cfg,
|
||||
"ROUTINES",
|
||||
"PROCEDURE_CAT",
|
||||
"PROCEDURE_SCHEM",
|
||||
"PROCEDURE_NAME",
|
||||
"PROCEDURE_CAT",
|
||||
"PROCEDURE_SCHEM",
|
||||
"PROCEDURE_NAME",
|
||||
"NUM_INPUT_PARAMS", int.class,
|
||||
"NUM_OUTPUT_PARAMS", int.class,
|
||||
"NUM_RESULT_SETS", int.class,
|
||||
|
@ -653,9 +653,9 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
throws SQLException {
|
||||
return emptySet(con.cfg,
|
||||
"PARAMETERS",
|
||||
"PROCEDURE_CAT",
|
||||
"PROCEDURE_SCHEM",
|
||||
"PROCEDURE_NAME",
|
||||
"PROCEDURE_CAT",
|
||||
"PROCEDURE_SCHEM",
|
||||
"PROCEDURE_NAME",
|
||||
"COLUMN_NAME",
|
||||
"COLUMN_TYPE", short.class,
|
||||
"DATA_TYPE", int.class,
|
||||
|
@ -680,7 +680,7 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
private String defaultCatalog() throws SQLException {
|
||||
return con.client.serverInfo().cluster;
|
||||
}
|
||||
|
||||
|
||||
private boolean isDefaultCatalog(String catalog) throws SQLException {
|
||||
// null means catalog info is irrelevant
|
||||
// % means return all catalogs
|
||||
|
@ -699,16 +699,16 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
|
||||
List<ColumnInfo> info = columnInfo("TABLES",
|
||||
"TABLE_CAT", //0
|
||||
"TABLE_SCHEM", //1
|
||||
"TABLE_SCHEM", //1
|
||||
"TABLE_NAME", //2
|
||||
"TABLE_TYPE", //3
|
||||
"REMARKS", //4
|
||||
"TYPE_CAT", //5
|
||||
"TYPE_SCHEM", //6
|
||||
"TYPE_NAME", //7
|
||||
"TABLE_TYPE", //3
|
||||
"REMARKS", //4
|
||||
"TYPE_CAT", //5
|
||||
"TYPE_SCHEM", //6
|
||||
"TYPE_NAME", //7
|
||||
"SELF_REFERENCING_COL_NAME", //8
|
||||
"REF_GENERATION"); //9
|
||||
|
||||
|
||||
// schema and catalogs are not being used, if these are specified return an empty result set
|
||||
if (!isDefaultCatalog(catalog) || !isDefaultSchema(schemaPattern)) {
|
||||
return emptySet(con.cfg, info);
|
||||
|
@ -739,7 +739,7 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
public ResultSet getSchemas() throws SQLException {
|
||||
Object[][] data = { { "", defaultCatalog() } };
|
||||
return memorySet(con.cfg, columnInfo("SCHEMATA",
|
||||
"TABLE_SCHEM",
|
||||
"TABLE_SCHEM",
|
||||
"TABLE_CATALOG"), data);
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,7 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
data[i] = new Object[24];
|
||||
Object[] row = data[i];
|
||||
MetaColumnInfo col = columns.get(i);
|
||||
|
||||
|
||||
row[ 0] = cat;
|
||||
row[ 1] = "";
|
||||
row[ 2] = col.table;
|
||||
|
@ -823,14 +823,14 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
row[ 7] = null;
|
||||
row[ 8] = null;
|
||||
row[ 9] = 10;
|
||||
row[10] = columnNullableUnknown;
|
||||
row[10] = columnNullable;
|
||||
row[11] = null;
|
||||
row[12] = null;
|
||||
row[13] = null;
|
||||
row[14] = null;
|
||||
row[15] = null;
|
||||
row[16] = col.position;
|
||||
row[17] = "";
|
||||
row[17] = "YES";
|
||||
row[18] = null;
|
||||
row[19] = null;
|
||||
row[20] = null;
|
||||
|
@ -1256,4 +1256,4 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
|
|||
return data.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue