comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @ 217:7cbd20ff628c

Removed DISTINCT from SELECT DISTINCT where it should not be needed (in getTables() and getFunctionColumns()) Replace "cast(null as varchar(1))" into "cast(null as char(1))" Replace "CAST(" into "cast(" consistently.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 19 Apr 2018 18:44:08 +0200 (2018-04-19)
parents 116b5a149fb4
children 5cc7101c5c8d
comparison
equal deleted inserted replaced
216:116b5a149fb4 217:7cbd20ff628c
1706 String procedureNamePattern 1706 String procedureNamePattern
1707 ) throws SQLException 1707 ) throws SQLException
1708 { 1708 {
1709 boolean useCommentsTable = ((MonetConnection)con).commentsTableExists(); 1709 boolean useCommentsTable = ((MonetConnection)con).commentsTableExists();
1710 StringBuilder query = new StringBuilder(980); 1710 StringBuilder query = new StringBuilder(980);
1711 query.append("SELECT cast(null as varchar(1)) AS \"PROCEDURE_CAT\", " + 1711 query.append("SELECT cast(null as char(1)) AS \"PROCEDURE_CAT\", " +
1712 "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " + 1712 "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " +
1713 "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " + 1713 "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " +
1714 "cast(null as char(1)) AS \"Field4\", " + 1714 "cast(null as char(1)) AS \"Field4\", " +
1715 "cast(null as char(1)) AS \"Field5\", " + 1715 "cast(null as char(1)) AS \"Field5\", " +
1716 "cast(null as char(1)) AS \"Field6\", ") 1716 "cast(null as char(1)) AS \"Field6\", ")
1717 .append(useCommentsTable ? "COALESCE(\"comments\".\"remark\", cast(\"functions\".\"func\" as varchar(9999)))" : "cast(\"functions\".\"func\" as varchar(9999))").append(" AS \"REMARKS\", " + 1717 .append(useCommentsTable ? "COALESCE(\"comments\".\"remark\", cast(\"functions\".\"func\" as varchar(9999)))" : "cast(\"functions\".\"func\" as varchar(9999))").append(" AS \"REMARKS\", " +
1718 // in MonetDB procedures have no return value by design. 1718 // in MonetDB procedures have no return value by design.
1719 "CAST(").append(DatabaseMetaData.procedureNoResult).append(" AS smallint) AS \"PROCEDURE_TYPE\", " + 1719 "cast(").append(DatabaseMetaData.procedureNoResult).append(" AS smallint) AS \"PROCEDURE_TYPE\", " +
1720 // only the id value uniquely identifies a procedure. Include it to be able to differentiate between multiple overloaded procedures with the same name 1720 // only the id value uniquely identifies a procedure. Include it to be able to differentiate between multiple overloaded procedures with the same name
1721 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " + 1721 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " +
1722 "FROM \"sys\".\"functions\" JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") "); 1722 "FROM \"sys\".\"functions\" JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") ");
1723 if (useCommentsTable) { 1723 if (useCommentsTable) {
1724 query.append("LEFT OUTER JOIN \"sys\".\"comments\" ON (\"functions\".\"id\" = \"comments\".\"id\") "); 1724 query.append("LEFT OUTER JOIN \"sys\".\"comments\" ON (\"functions\".\"id\" = \"comments\".\"id\") ");
1816 String schemaPattern, 1816 String schemaPattern,
1817 String procedureNamePattern, 1817 String procedureNamePattern,
1818 String columnNamePattern 1818 String columnNamePattern
1819 ) throws SQLException { 1819 ) throws SQLException {
1820 StringBuilder query = new StringBuilder(2900); 1820 StringBuilder query = new StringBuilder(2900);
1821 query.append("SELECT cast(null as varchar(1)) AS \"PROCEDURE_CAT\", " + 1821 query.append("SELECT cast(null as char(1)) AS \"PROCEDURE_CAT\", " +
1822 "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " + 1822 "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " +
1823 "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " + 1823 "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " +
1824 "\"args\".\"name\" AS \"COLUMN_NAME\", " + 1824 "\"args\".\"name\" AS \"COLUMN_NAME\", " +
1825 "CAST(CASE \"args\".\"inout\"" + 1825 "cast(CASE \"args\".\"inout\"" +
1826 " WHEN 0 THEN (CASE \"args\".\"number\" WHEN 0 THEN ").append(DatabaseMetaData.procedureColumnReturn).append(" ELSE ").append(DatabaseMetaData.procedureColumnOut).append(" END)" + 1826 " WHEN 0 THEN (CASE \"args\".\"number\" WHEN 0 THEN ").append(DatabaseMetaData.procedureColumnReturn).append(" ELSE ").append(DatabaseMetaData.procedureColumnOut).append(" END)" +
1827 " WHEN 1 THEN ").append(DatabaseMetaData.procedureColumnIn) 1827 " WHEN 1 THEN ").append(DatabaseMetaData.procedureColumnIn)
1828 .append(" ELSE ").append(DatabaseMetaData.procedureColumnUnknown).append(" END AS smallint) AS \"COLUMN_TYPE\", " + 1828 .append(" ELSE ").append(DatabaseMetaData.procedureColumnUnknown).append(" END AS smallint) AS \"COLUMN_TYPE\", " +
1829 "CAST(").append(MonetDriver.getSQLTypeMap("\"args\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " + 1829 "cast(").append(MonetDriver.getSQLTypeMap("\"args\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " +
1830 "\"args\".\"type\" AS \"TYPE_NAME\", " + 1830 "\"args\".\"type\" AS \"TYPE_NAME\", " +
1831 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 3 WHEN 'smallint' THEN 5 WHEN 'int' THEN 10 WHEN 'bigint' THEN 19 WHEN 'hugeint' THEN 38 WHEN 'oid' THEN 19 WHEN 'wrd' THEN 19 ELSE \"args\".\"type_digits\" END AS \"PRECISION\", " + 1831 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 3 WHEN 'smallint' THEN 5 WHEN 'int' THEN 10 WHEN 'bigint' THEN 19 WHEN 'hugeint' THEN 38 WHEN 'oid' THEN 19 WHEN 'wrd' THEN 19 ELSE \"args\".\"type_digits\" END AS \"PRECISION\", " +
1832 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 1 WHEN 'smallint' THEN 2 WHEN 'int' THEN 4 WHEN 'bigint' THEN 8 WHEN 'hugeint' THEN 16 WHEN 'oid' THEN 8 WHEN 'wrd' THEN 8 ELSE \"args\".\"type_digits\" END AS \"LENGTH\", " + 1832 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 1 WHEN 'smallint' THEN 2 WHEN 'int' THEN 4 WHEN 'bigint' THEN 8 WHEN 'hugeint' THEN 16 WHEN 'oid' THEN 8 WHEN 'wrd' THEN 8 ELSE \"args\".\"type_digits\" END AS \"LENGTH\", " +
1833 "CAST(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric','time','timetz','timestamp','timestamptz','sec_interval') THEN \"args\".\"type_scale\" ELSE NULL END AS smallint) AS \"SCALE\", " + 1833 "cast(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric','time','timetz','timestamp','timestamptz','sec_interval') THEN \"args\".\"type_scale\" ELSE NULL END AS smallint) AS \"SCALE\", " +
1834 "CAST(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric') THEN 10 WHEN \"args\".\"type\" IN ('real','float','double') THEN 2 ELSE NULL END AS smallint) AS \"RADIX\", " + 1834 "cast(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric') THEN 10 WHEN \"args\".\"type\" IN ('real','float','double') THEN 2 ELSE NULL END AS smallint) AS \"RADIX\", " +
1835 "CAST(").append(DatabaseMetaData.procedureNullableUnknown).append(" AS smallint) AS \"NULLABLE\", " + 1835 "cast(").append(DatabaseMetaData.procedureNullableUnknown).append(" AS smallint) AS \"NULLABLE\", " +
1836 "CAST(null as char(1)) AS \"REMARKS\", " + 1836 "cast(null as char(1)) AS \"REMARKS\", " +
1837 "CAST(null as char(1)) AS \"COLUMN_DEF\", " + 1837 "cast(null as char(1)) AS \"COLUMN_DEF\", " +
1838 "CAST(0 as int) AS \"SQL_DATA_TYPE\", " + 1838 "cast(0 as int) AS \"SQL_DATA_TYPE\", " +
1839 "CAST(0 as int) AS \"SQL_DATETIME_SUB\", " + 1839 "cast(0 as int) AS \"SQL_DATETIME_SUB\", " +
1840 "CAST(CASE WHEN \"args\".\"type\" IN ('char','varchar','clob') THEN \"args\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " + 1840 "cast(CASE WHEN \"args\".\"type\" IN ('char','varchar','clob') THEN \"args\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " +
1841 // in MonetDB procedures have no return value by design. The arguments in sys.args are numbered from 0 so we must add 1 to comply with the API specification. 1841 // in MonetDB procedures have no return value by design. The arguments in sys.args are numbered from 0 so we must add 1 to comply with the API specification.
1842 "CAST(\"args\".\"number\" + 1 as int) AS \"ORDINAL_POSITION\", " + 1842 "cast(\"args\".\"number\" + 1 as int) AS \"ORDINAL_POSITION\", " +
1843 "CAST('' as varchar(3)) AS \"IS_NULLABLE\", " + 1843 "cast('' as varchar(3)) AS \"IS_NULLABLE\", " +
1844 // the specific name contains the function id, in order to be able to match the args to the correct overloaded procedure name 1844 // the specific name contains the function id, in order to be able to match the args to the correct overloaded procedure name
1845 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " + 1845 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " +
1846 "FROM \"sys\".\"args\" " + 1846 "FROM \"sys\".\"args\" " +
1847 "JOIN \"sys\".\"functions\" ON (\"args\".\"func_id\" = \"functions\".\"id\") " + 1847 "JOIN \"sys\".\"functions\" ON (\"args\".\"func_id\" = \"functions\".\"id\") " +
1848 "JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") " + 1848 "JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") " +
1962 StringBuilder query = new StringBuilder(1600); 1962 StringBuilder query = new StringBuilder(1600);
1963 if (preJul2015 && types != null && types.length > 0) { 1963 if (preJul2015 && types != null && types.length > 0) {
1964 // we need to filter on the constructed "TABLE_TYPE" expression, this is only possible when we use a subquery in the FROM 1964 // we need to filter on the constructed "TABLE_TYPE" expression, this is only possible when we use a subquery in the FROM
1965 query.append("SELECT * FROM ("); 1965 query.append("SELECT * FROM (");
1966 } 1966 }
1967 query.append("SELECT DISTINCT cast(null as char(1)) AS \"TABLE_CAT\", " + 1967 query.append("SELECT cast(null as char(1)) AS \"TABLE_CAT\", " +
1968 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " + 1968 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " +
1969 "\"tables\".\"name\" AS \"TABLE_NAME\", "); 1969 "\"tables\".\"name\" AS \"TABLE_NAME\", ");
1970 if (preJul2015) { 1970 if (preJul2015) {
1971 query.append( 1971 query.append(
1972 "CASE WHEN \"tables\".\"system\" = true AND \"tables\".\"type\" IN (0, 10) AND \"tables\".\"temporary\" = 0 THEN 'SYSTEM TABLE' " + 1972 "CASE WHEN \"tables\".\"system\" = true AND \"tables\".\"type\" IN (0, 10) AND \"tables\".\"temporary\" = 0 THEN 'SYSTEM TABLE' " +
2224 "cast(CASE WHEN \"columns\".\"type\" IN ('decimal', 'numeric', 'sec_interval') THEN 10 " + 2224 "cast(CASE WHEN \"columns\".\"type\" IN ('decimal', 'numeric', 'sec_interval') THEN 10 " +
2225 "WHEN \"columns\".\"type\" IN ('int', 'smallint', 'tinyint', 'bigint', 'hugeint', 'float', 'real', 'double', 'oid', 'wrd') THEN 2 " + 2225 "WHEN \"columns\".\"type\" IN ('int', 'smallint', 'tinyint', 'bigint', 'hugeint', 'float', 'real', 'double', 'oid', 'wrd') THEN 2 " +
2226 "ELSE 0 END AS int) AS \"NUM_PREC_RADIX\", " + 2226 "ELSE 0 END AS int) AS \"NUM_PREC_RADIX\", " +
2227 "cast(CASE \"null\" WHEN true THEN ").append(ResultSetMetaData.columnNullable) 2227 "cast(CASE \"null\" WHEN true THEN ").append(ResultSetMetaData.columnNullable)
2228 .append(" WHEN false THEN ").append(ResultSetMetaData.columnNoNulls).append(" END AS int) AS \"NULLABLE\", ") 2228 .append(" WHEN false THEN ").append(ResultSetMetaData.columnNoNulls).append(" END AS int) AS \"NULLABLE\", ")
2229 .append(useCommentsTable ? "\"comments\".\"remark\"" : "cast(null AS varchar(1))").append(" AS \"REMARKS\", " + 2229 .append(useCommentsTable ? "\"comments\".\"remark\"" : "cast(null AS varchar(9999))").append(" AS \"REMARKS\", " +
2230 "\"columns\".\"default\" AS \"COLUMN_DEF\", " + 2230 "\"columns\".\"default\" AS \"COLUMN_DEF\", " +
2231 "cast(0 as int) AS \"SQL_DATA_TYPE\", " + 2231 "cast(0 as int) AS \"SQL_DATA_TYPE\", " +
2232 "cast(0 as int) AS \"SQL_DATETIME_SUB\", " + 2232 "cast(0 as int) AS \"SQL_DATETIME_SUB\", " +
2233 "cast(CASE WHEN \"columns\".\"type\" IN ('char','varchar','clob') THEN \"columns\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " + 2233 "cast(CASE WHEN \"columns\".\"type\" IN ('char','varchar','clob') THEN \"columns\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " +
2234 "cast(\"columns\".\"number\" + 1 as int) AS \"ORDINAL_POSITION\", " + 2234 "cast(\"columns\".\"number\" + 1 as int) AS \"ORDINAL_POSITION\", " +
2235 "cast(CASE \"null\" WHEN true THEN 'YES' WHEN false THEN 'NO' ELSE '' END AS varchar(3)) AS \"IS_NULLABLE\", " + 2235 "cast(CASE \"null\" WHEN true THEN 'YES' WHEN false THEN 'NO' ELSE '' END AS varchar(3)) AS \"IS_NULLABLE\", " +
2236 "cast(null AS varchar(1)) AS \"SCOPE_CATALOG\", " + 2236 "cast(null AS char(1)) AS \"SCOPE_CATALOG\", " +
2237 "cast(null AS varchar(1)) AS \"SCOPE_SCHEMA\", " + 2237 "cast(null AS char(1)) AS \"SCOPE_SCHEMA\", " +
2238 "cast(null AS varchar(1)) AS \"SCOPE_TABLE\", " + 2238 "cast(null AS char(1)) AS \"SCOPE_TABLE\", " +
2239 "cast(null AS smallint) AS \"SOURCE_DATA_TYPE\", " + 2239 "cast(null AS smallint) AS \"SOURCE_DATA_TYPE\", " +
2240 "cast(CASE WHEN \"columns\".\"default\" IS NOT NULL AND \"columns\".\"default\" LIKE 'next value for %' THEN 'YES' ELSE 'NO' END AS varchar(3)) AS \"IS_AUTOINCREMENT\", " + 2240 "cast(CASE WHEN \"columns\".\"default\" IS NOT NULL AND \"columns\".\"default\" LIKE 'next value for %' THEN 'YES' ELSE 'NO' END AS varchar(3)) AS \"IS_AUTOINCREMENT\", " +
2241 "cast('NO' AS varchar(3)) AS \"IS_GENERATEDCOLUMN\" " + 2241 "cast('NO' AS varchar(3)) AS \"IS_GENERATEDCOLUMN\" " +
2242 "FROM \"sys\".\"columns\""); 2242 "FROM \"sys\".\"columns\"");
2243 if (useCommentsTable) { 2243 if (useCommentsTable) {
2311 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " + 2311 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " +
2312 "\"tables\".\"name\" AS \"TABLE_NAME\", " + 2312 "\"tables\".\"name\" AS \"TABLE_NAME\", " +
2313 "\"columns\".\"name\" AS \"COLUMN_NAME\", " + 2313 "\"columns\".\"name\" AS \"COLUMN_NAME\", " +
2314 "\"grantors\".\"name\" AS \"GRANTOR\", " + 2314 "\"grantors\".\"name\" AS \"GRANTOR\", " +
2315 "\"grantees\".\"name\" AS \"GRANTEE\", " + 2315 "\"grantees\".\"name\" AS \"GRANTEE\", " +
2316 "CAST(CASE \"privileges\".\"privileges\" " + 2316 "cast(CASE \"privileges\".\"privileges\" " +
2317 "WHEN 1 THEN 'SELECT' " + 2317 "WHEN 1 THEN 'SELECT' " +
2318 "WHEN 2 THEN 'UPDATE' " + 2318 "WHEN 2 THEN 'UPDATE' " +
2319 "WHEN 4 THEN 'INSERT' " + 2319 "WHEN 4 THEN 'INSERT' " +
2320 "WHEN 8 THEN 'DELETE' " + 2320 "WHEN 8 THEN 'DELETE' " +
2321 "WHEN 16 THEN 'EXECUTE' " + 2321 "WHEN 16 THEN 'EXECUTE' " +
2322 "WHEN 32 THEN 'GRANT' " + 2322 "WHEN 32 THEN 'GRANT' " +
2323 "ELSE NULL " + 2323 "ELSE NULL " +
2324 "END AS varchar(7)) AS \"PRIVILEGE\", " + 2324 "END AS varchar(7)) AS \"PRIVILEGE\", " +
2325 "CAST(CASE \"privileges\".\"grantable\" " + 2325 "cast(CASE \"privileges\".\"grantable\" " +
2326 "WHEN 0 THEN 'NO' " + 2326 "WHEN 0 THEN 'NO' " +
2327 "WHEN 1 THEN 'YES' " + 2327 "WHEN 1 THEN 'YES' " +
2328 "ELSE NULL " + 2328 "ELSE NULL " +
2329 "END AS varchar(3)) AS \"IS_GRANTABLE\" " + 2329 "END AS varchar(3)) AS \"IS_GRANTABLE\" " +
2330 "FROM \"sys\".\"privileges\", " + 2330 "FROM \"sys\".\"privileges\", " +
2399 query.append("SELECT cast(null as char(1)) AS \"TABLE_CAT\", " + 2399 query.append("SELECT cast(null as char(1)) AS \"TABLE_CAT\", " +
2400 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " + 2400 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " +
2401 "\"tables\".\"name\" AS \"TABLE_NAME\", " + 2401 "\"tables\".\"name\" AS \"TABLE_NAME\", " +
2402 "\"grantors\".\"name\" AS \"GRANTOR\", " + 2402 "\"grantors\".\"name\" AS \"GRANTOR\", " +
2403 "\"grantees\".\"name\" AS \"GRANTEE\", " + 2403 "\"grantees\".\"name\" AS \"GRANTEE\", " +
2404 "CAST(CASE \"privileges\".\"privileges\" " + 2404 "cast(CASE \"privileges\".\"privileges\" " +
2405 "WHEN 1 THEN 'SELECT' " + 2405 "WHEN 1 THEN 'SELECT' " +
2406 "WHEN 2 THEN 'UPDATE' " + 2406 "WHEN 2 THEN 'UPDATE' " +
2407 "WHEN 4 THEN 'INSERT' " + 2407 "WHEN 4 THEN 'INSERT' " +
2408 "WHEN 8 THEN 'DELETE' " + 2408 "WHEN 8 THEN 'DELETE' " +
2409 "WHEN 16 THEN 'EXECUTE' " + 2409 "WHEN 16 THEN 'EXECUTE' " +
2410 "WHEN 32 THEN 'GRANT' " + 2410 "WHEN 32 THEN 'GRANT' " +
2411 "ELSE NULL " + 2411 "ELSE NULL " +
2412 "END AS varchar(7)) AS \"PRIVILEGE\", " + 2412 "END AS varchar(7)) AS \"PRIVILEGE\", " +
2413 "CAST(CASE \"privileges\".\"grantable\" " + 2413 "cast(CASE \"privileges\".\"grantable\" " +
2414 "WHEN 0 THEN 'NO' " + 2414 "WHEN 0 THEN 'NO' " +
2415 "WHEN 1 THEN 'YES' " + 2415 "WHEN 1 THEN 'YES' " +
2416 "ELSE NULL " + 2416 "ELSE NULL " +
2417 "END AS varchar(3)) AS \"IS_GRANTABLE\" " + 2417 "END AS varchar(3)) AS \"IS_GRANTABLE\" " +
2418 "FROM \"sys\".\"privileges\", " + 2418 "FROM \"sys\".\"privileges\", " +
2486 int scope, 2486 int scope,
2487 boolean nullable 2487 boolean nullable
2488 ) throws SQLException 2488 ) throws SQLException
2489 { 2489 {
2490 StringBuilder query = new StringBuilder(1500); 2490 StringBuilder query = new StringBuilder(1500);
2491 query.append("SELECT CAST(").append(DatabaseMetaData.bestRowSession).append(" AS smallint) AS \"SCOPE\", " + 2491 query.append("SELECT cast(").append(DatabaseMetaData.bestRowSession).append(" AS smallint) AS \"SCOPE\", " +
2492 "\"columns\".\"name\" AS \"COLUMN_NAME\", " + 2492 "\"columns\".\"name\" AS \"COLUMN_NAME\", " +
2493 "cast(").append(MonetDriver.getSQLTypeMap("\"columns\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " + 2493 "cast(").append(MonetDriver.getSQLTypeMap("\"columns\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " +
2494 "\"columns\".\"type\" AS \"TYPE_NAME\", " + 2494 "\"columns\".\"type\" AS \"TYPE_NAME\", " +
2495 "\"columns\".\"type_digits\" AS \"COLUMN_SIZE\", " + 2495 "\"columns\".\"type_digits\" AS \"COLUMN_SIZE\", " +
2496 "CAST(0 as int) AS \"BUFFER_LENGTH\", " + 2496 "cast(0 as int) AS \"BUFFER_LENGTH\", " +
2497 "CAST(\"columns\".\"type_scale\" AS smallint) AS \"DECIMAL_DIGITS\", " + 2497 "cast(\"columns\".\"type_scale\" AS smallint) AS \"DECIMAL_DIGITS\", " +
2498 "CAST(").append(DatabaseMetaData.bestRowNotPseudo).append(" AS smallint) AS \"PSEUDO_COLUMN\" " + 2498 "cast(").append(DatabaseMetaData.bestRowNotPseudo).append(" AS smallint) AS \"PSEUDO_COLUMN\" " +
2499 "FROM \"sys\".\"keys\", " + 2499 "FROM \"sys\".\"keys\", " +
2500 "\"sys\".\"objects\", " + 2500 "\"sys\".\"objects\", " +
2501 "\"sys\".\"columns\", " + 2501 "\"sys\".\"columns\", " +
2502 "\"sys\".\"tables\", " + 2502 "\"sys\".\"tables\", " +
2503 "\"sys\".\"schemas\" " + 2503 "\"sys\".\"schemas\" " +
2569 String table 2569 String table
2570 ) throws SQLException 2570 ) throws SQLException
2571 { 2571 {
2572 // MonetDB currently does not have columns which update themselves, so return an empty ResultSet 2572 // MonetDB currently does not have columns which update themselves, so return an empty ResultSet
2573 String query = 2573 String query =
2574 "SELECT CAST(0 as smallint) AS \"SCOPE\", " + 2574 "SELECT cast(0 as smallint) AS \"SCOPE\", " +
2575 "CAST(null as varchar(1)) AS \"COLUMN_NAME\", " + 2575 "cast(null as char(1)) AS \"COLUMN_NAME\", " +
2576 "CAST(0 as int) AS \"DATA_TYPE\", " + 2576 "cast(0 as int) AS \"DATA_TYPE\", " +
2577 "CAST(null as varchar(1)) AS \"TYPE_NAME\", " + 2577 "cast(null as char(1)) AS \"TYPE_NAME\", " +
2578 "CAST(0 as int) AS \"COLUMN_SIZE\", " + 2578 "cast(0 as int) AS \"COLUMN_SIZE\", " +
2579 "CAST(0 as int) AS \"BUFFER_LENGTH\", " + 2579 "cast(0 as int) AS \"BUFFER_LENGTH\", " +
2580 "CAST(0 as smallint) AS \"DECIMAL_DIGITS\", " + 2580 "cast(0 as smallint) AS \"DECIMAL_DIGITS\", " +
2581 "CAST(0 as smallint) AS \"PSEUDO_COLUMN\" " + 2581 "cast(0 as smallint) AS \"PSEUDO_COLUMN\" " +
2582 "WHERE 1 = 0"; 2582 "WHERE 1 = 0";
2583 2583
2584 return executeMetaDataQuery(query); 2584 return executeMetaDataQuery(query);
2585 } 2585 }
2586 2586
2611 String schema, 2611 String schema,
2612 String table 2612 String table
2613 ) throws SQLException 2613 ) throws SQLException
2614 { 2614 {
2615 StringBuilder query = new StringBuilder(600); 2615 StringBuilder query = new StringBuilder(600);
2616 query.append("SELECT cast(null AS varchar(1)) AS \"TABLE_CAT\", " + 2616 query.append("SELECT cast(null AS char(1)) AS \"TABLE_CAT\", " +
2617 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " + 2617 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " +
2618 "\"tables\".\"name\" AS \"TABLE_NAME\", " + 2618 "\"tables\".\"name\" AS \"TABLE_NAME\", " +
2619 "\"objects\".\"name\" AS \"COLUMN_NAME\", " + 2619 "\"objects\".\"name\" AS \"COLUMN_NAME\", " +
2620 "CAST(1 + \"objects\".\"nr\" AS smallint) AS \"KEY_SEQ\", " + 2620 "cast(1 + \"objects\".\"nr\" AS smallint) AS \"KEY_SEQ\", " +
2621 " \"keys\".\"name\" AS \"PK_NAME\" " + 2621 " \"keys\".\"name\" AS \"PK_NAME\" " +
2622 "FROM \"sys\".\"keys\", " + 2622 "FROM \"sys\".\"keys\", " +
2623 "\"sys\".\"objects\", " + 2623 "\"sys\".\"objects\", " +
2624 "\"sys\".\"tables\", " + 2624 "\"sys\".\"tables\", " +
2625 "\"sys\".\"schemas\" " + 2625 "\"sys\".\"schemas\" " +
2646 return executeMetaDataQuery(query.toString()); 2646 return executeMetaDataQuery(query.toString());
2647 } 2647 }
2648 2648
2649 2649
2650 private static final String keyQuery = 2650 private static final String keyQuery =
2651 "SELECT cast(null AS varchar(1)) AS \"PKTABLE_CAT\", " + 2651 "SELECT cast(null AS char(1)) AS \"PKTABLE_CAT\", " +
2652 "\"pkschema\".\"name\" AS \"PKTABLE_SCHEM\", " + 2652 "\"pkschema\".\"name\" AS \"PKTABLE_SCHEM\", " +
2653 "\"pktable\".\"name\" AS \"PKTABLE_NAME\", " + 2653 "\"pktable\".\"name\" AS \"PKTABLE_NAME\", " +
2654 "\"pkkeycol\".\"name\" AS \"PKCOLUMN_NAME\", " + 2654 "\"pkkeycol\".\"name\" AS \"PKCOLUMN_NAME\", " +
2655 "cast(null AS varchar(1)) AS \"FKTABLE_CAT\", " + 2655 "cast(null AS char(1)) AS \"FKTABLE_CAT\", " +
2656 "\"fkschema\".\"name\" AS \"FKTABLE_SCHEM\", " + 2656 "\"fkschema\".\"name\" AS \"FKTABLE_SCHEM\", " +
2657 "\"fktable\".\"name\" AS \"FKTABLE_NAME\", " + 2657 "\"fktable\".\"name\" AS \"FKTABLE_NAME\", " +
2658 "\"fkkeycol\".\"name\" AS \"FKCOLUMN_NAME\", " + 2658 "\"fkkeycol\".\"name\" AS \"FKCOLUMN_NAME\", " +
2659 "CAST(1 + \"pkkeycol\".\"nr\" AS smallint) AS \"KEY_SEQ\", " + 2659 "cast(1 + \"pkkeycol\".\"nr\" AS smallint) AS \"KEY_SEQ\", " +
2660 DatabaseMetaData.importedKeyNoAction + " AS \"UPDATE_RULE\", " + 2660 DatabaseMetaData.importedKeyNoAction + " AS \"UPDATE_RULE\", " +
2661 DatabaseMetaData.importedKeyNoAction + " AS \"DELETE_RULE\", " + 2661 DatabaseMetaData.importedKeyNoAction + " AS \"DELETE_RULE\", " +
2662 "\"fkkey\".\"name\" AS \"FK_NAME\", " + 2662 "\"fkkey\".\"name\" AS \"FK_NAME\", " +
2663 "\"pkkey\".\"name\" AS \"PK_NAME\", " + 2663 "\"pkkey\".\"name\" AS \"PK_NAME\", " +
2664 DatabaseMetaData.importedKeyNotDeferrable + " AS \"DEFERRABILITY\" " + 2664 DatabaseMetaData.importedKeyNotDeferrable + " AS \"DEFERRABILITY\" " +
3124 } 3124 }
3125 } 3125 }
3126 3126
3127 StringBuilder query = new StringBuilder(1250); 3127 StringBuilder query = new StringBuilder(1250);
3128 query.append( 3128 query.append(
3129 "SELECT CAST(null AS char(1)) AS \"TABLE_CAT\", " + 3129 "SELECT cast(null AS char(1)) AS \"TABLE_CAT\", " +
3130 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " + 3130 "\"schemas\".\"name\" AS \"TABLE_SCHEM\", " +
3131 "\"tables\".\"name\" AS \"TABLE_NAME\", " + 3131 "\"tables\".\"name\" AS \"TABLE_NAME\", " +
3132 "CASE WHEN \"keys\".\"name\" IS NULL THEN true ELSE false END AS \"NON_UNIQUE\", " + 3132 "CASE WHEN \"keys\".\"name\" IS NULL THEN true ELSE false END AS \"NON_UNIQUE\", " +
3133 "CAST(null AS varchar(1)) AS \"INDEX_QUALIFIER\", " + 3133 "cast(null AS char(1)) AS \"INDEX_QUALIFIER\", " +
3134 "\"idxs\".\"name\" AS \"INDEX_NAME\", " + 3134 "\"idxs\".\"name\" AS \"INDEX_NAME\", " +
3135 "CASE \"idxs\".\"type\" WHEN 0 THEN ").append(DatabaseMetaData.tableIndexHashed).append(" ELSE ").append(DatabaseMetaData.tableIndexOther).append(" END AS \"TYPE\", " + 3135 "CASE \"idxs\".\"type\" WHEN 0 THEN ").append(DatabaseMetaData.tableIndexHashed).append(" ELSE ").append(DatabaseMetaData.tableIndexOther).append(" END AS \"TYPE\", " +
3136 "CAST(\"objects\".\"nr\" +1 AS smallint) AS \"ORDINAL_POSITION\", "+ 3136 "cast(\"objects\".\"nr\" +1 AS smallint) AS \"ORDINAL_POSITION\", "+
3137 "\"columns\".\"name\" AS \"COLUMN_NAME\", " + 3137 "\"columns\".\"name\" AS \"COLUMN_NAME\", " +
3138 "CAST(null AS varchar(1)) AS \"ASC_OR_DESC\", " + // sort sequence currently not supported in keys or indexes in MonetDB 3138 "cast(null AS char(1)) AS \"ASC_OR_DESC\", " + // sort sequence currently not supported in keys or indexes in MonetDB
3139 "CAST(").append(table_row_count).append(" AS int) AS \"CARDINALITY\", " + 3139 "cast(").append(table_row_count).append(" AS int) AS \"CARDINALITY\", " +
3140 "CAST(0 AS int) AS \"PAGES\", " + 3140 "cast(0 AS int) AS \"PAGES\", " +
3141 "CAST(null AS varchar(1)) AS \"FILTER_CONDITION\" " + 3141 "cast(null AS char(1)) AS \"FILTER_CONDITION\" " +
3142 "FROM \"sys\".\"idxs\" LEFT JOIN \"sys\".\"keys\" ON \"idxs\".\"name\" = \"keys\".\"name\", " + 3142 "FROM \"sys\".\"idxs\" LEFT JOIN \"sys\".\"keys\" ON \"idxs\".\"name\" = \"keys\".\"name\", " +
3143 "\"sys\".\"schemas\", " + 3143 "\"sys\".\"schemas\", " +
3144 "\"sys\".\"objects\", " + 3144 "\"sys\".\"objects\", " +
3145 "\"sys\".\"columns\", " + 3145 "\"sys\".\"columns\", " +
3146 "\"sys\".\"tables\" " + 3146 "\"sys\".\"tables\" " +
3309 " WHEN 'inet' THEN 'nl.cwi.monetdb.jdbc.types.INET'" + 3309 " WHEN 'inet' THEN 'nl.cwi.monetdb.jdbc.types.INET'" +
3310 " WHEN 'json' THEN 'java.lang.String'" + 3310 " WHEN 'json' THEN 'java.lang.String'" +
3311 " WHEN 'url' THEN 'nl.cwi.monetdb.jdbc.types.URL'" + 3311 " WHEN 'url' THEN 'nl.cwi.monetdb.jdbc.types.URL'" +
3312 " WHEN 'uuid' THEN 'java.lang.String'" + 3312 " WHEN 'uuid' THEN 'java.lang.String'" +
3313 " ELSE 'java.lang.Object' END AS \"CLASS_NAME\", " + 3313 " ELSE 'java.lang.Object' END AS \"CLASS_NAME\", " +
3314 "CAST(CASE WHEN \"types\".\"sqlname\" IN ('inet', 'json', 'url', 'uuid') THEN ").append(Types.JAVA_OBJECT) 3314 "cast(CASE WHEN \"types\".\"sqlname\" IN ('inet', 'json', 'url', 'uuid') THEN ").append(Types.JAVA_OBJECT)
3315 .append(" ELSE ").append(Types.STRUCT).append(" END AS int) AS \"DATA_TYPE\", " + 3315 .append(" ELSE ").append(Types.STRUCT).append(" END AS int) AS \"DATA_TYPE\", " +
3316 "\"types\".\"systemname\" AS \"REMARKS\", " + 3316 "\"types\".\"systemname\" AS \"REMARKS\", " +
3317 "cast(null as smallint) AS \"BASE_TYPE\" " + 3317 "cast(null as smallint) AS \"BASE_TYPE\" " +
3318 "FROM \"sys\".\"types\" JOIN \"sys\".\"schemas\" ON \"types\".\"schema_id\" = \"schemas\".\"id\" " + 3318 "FROM \"sys\".\"types\" JOIN \"sys\".\"schemas\" ON \"types\".\"schema_id\" = \"schemas\".\"id\" " +
3319 // exclude the built-in types (I assume they always have id <= 99 and eclass < 15) 3319 // exclude the built-in types (I assume they always have id <= 99 and eclass < 15)
3597 String attributeNamePattern 3597 String attributeNamePattern
3598 ) throws SQLException 3598 ) throws SQLException
3599 { 3599 {
3600 String query = 3600 String query =
3601 "SELECT cast(null as char(1)) AS \"TYPE_CAT\", '' AS \"TYPE_SCHEM\", '' AS \"TYPE_NAME\", " + 3601 "SELECT cast(null as char(1)) AS \"TYPE_CAT\", '' AS \"TYPE_SCHEM\", '' AS \"TYPE_NAME\", " +
3602 "'' AS \"ATTR_NAME\", CAST(0 as int) AS \"DATA_TYPE\", '' AS \"ATTR_TYPE_NAME\", CAST(0 as int) AS \"ATTR_SIZE\", " + 3602 "'' AS \"ATTR_NAME\", cast(0 as int) AS \"DATA_TYPE\", '' AS \"ATTR_TYPE_NAME\", cast(0 as int) AS \"ATTR_SIZE\", " +
3603 "CAST(0 as int) AS \"DECIMAL_DIGITS\", CAST(0 as int) AS \"NUM_PREC_RADIX\", CAST(0 as int) AS \"NULLABLE\", " + 3603 "cast(0 as int) AS \"DECIMAL_DIGITS\", cast(0 as int) AS \"NUM_PREC_RADIX\", cast(0 as int) AS \"NULLABLE\", " +
3604 "'' AS \"REMARKS\", '' AS \"ATTR_DEF\", CAST(0 as int) AS \"SQL_DATA_TYPE\", " + 3604 "'' AS \"REMARKS\", '' AS \"ATTR_DEF\", cast(0 as int) AS \"SQL_DATA_TYPE\", " +
3605 "CAST(0 as int) AS \"SQL_DATETIME_SUB\", CAST(0 as int) AS \"CHAR_OCTET_LENGTH\", " + 3605 "cast(0 as int) AS \"SQL_DATETIME_SUB\", cast(0 as int) AS \"CHAR_OCTET_LENGTH\", " +
3606 "CAST(0 as int) AS \"ORDINAL_POSITION\", 'YES' AS \"IS_NULLABLE\", " + 3606 "cast(0 as int) AS \"ORDINAL_POSITION\", 'YES' AS \"IS_NULLABLE\", " +
3607 "'' AS \"SCOPE_CATALOG\", '' AS \"SCOPE_SCHEMA\", '' AS \"SCOPE_TABLE\", " + 3607 "'' AS \"SCOPE_CATALOG\", '' AS \"SCOPE_SCHEMA\", '' AS \"SCOPE_TABLE\", " +
3608 "CAST(0 as smallint) AS \"SOURCE_DATA_TYPE\" " + 3608 "cast(0 as smallint) AS \"SOURCE_DATA_TYPE\" " +
3609 "WHERE 1 = 0"; 3609 "WHERE 1 = 0";
3610 3610
3611 return executeMetaDataQuery(query); 3611 return executeMetaDataQuery(query);
3612 } 3612 }
3613 3613
3830 */ 3830 */
3831 @Override 3831 @Override
3832 public ResultSet getClientInfoProperties() throws SQLException { 3832 public ResultSet getClientInfoProperties() throws SQLException {
3833 // for a list of connection properties see also MonetConnection.java constructor MonetConnection(Properties props) 3833 // for a list of connection properties see also MonetConnection.java constructor MonetConnection(Properties props)
3834 String query = 3834 String query =
3835 "SELECT 'host' AS \"NAME\", CAST(1024 as int) AS \"MAX_LEN\", 'localhost' AS \"DEFAULT_VALUE\", 'DSN or IP-address of machine running MonetDB' AS \"DESCRIPTION\" UNION ALL " + 3835 "SELECT 'host' AS \"NAME\", cast(1024 as int) AS \"MAX_LEN\", 'localhost' AS \"DEFAULT_VALUE\", 'DSN or IP-address of machine running MonetDB' AS \"DESCRIPTION\" UNION ALL " +
3836 "SELECT 'port', 5, '50000', 'communication port number of MonetDB server process' UNION ALL " + 3836 "SELECT 'port', 5, '50000', 'communication port number of MonetDB server process' UNION ALL " +
3837 "SELECT 'user', 1024, '', 'user name to login to MonetDB server' UNION ALL " + 3837 "SELECT 'user', 1024, '', 'user name to login to MonetDB server' UNION ALL " +
3838 "SELECT 'password', 128, '', 'password for user name to login to MonetDB server' UNION ALL " + 3838 "SELECT 'password', 128, '', 'password for user name to login to MonetDB server' UNION ALL " +
3839 "SELECT 'language', 16, 'sql', 'language (sql or mal) used to parse commands in MonetDB server' UNION ALL " + 3839 "SELECT 'language', 16, 'sql', 'language (sql or mal) used to parse commands in MonetDB server' UNION ALL " +
3840 "SELECT 'database', 1024, 'demo', 'name of database. It matches the dbfarm subdirectory name' UNION ALL " + 3840 "SELECT 'database', 1024, 'demo', 'name of database. It matches the dbfarm subdirectory name' UNION ALL " +
3897 String functionNamePattern) 3897 String functionNamePattern)
3898 throws SQLException 3898 throws SQLException
3899 { 3899 {
3900 boolean useCommentsTable = ((MonetConnection)con).commentsTableExists(); 3900 boolean useCommentsTable = ((MonetConnection)con).commentsTableExists();
3901 StringBuilder query = new StringBuilder(800); 3901 StringBuilder query = new StringBuilder(800);
3902 query.append("SELECT cast(null as varchar(1)) AS \"FUNCTION_CAT\", " + 3902 query.append("SELECT cast(null as char(1)) AS \"FUNCTION_CAT\", " +
3903 "\"schemas\".\"name\" AS \"FUNCTION_SCHEM\", " + 3903 "\"schemas\".\"name\" AS \"FUNCTION_SCHEM\", " +
3904 "\"functions\".\"name\" AS \"FUNCTION_NAME\", ") 3904 "\"functions\".\"name\" AS \"FUNCTION_NAME\", ")
3905 .append(useCommentsTable ? "COALESCE(\"comments\".\"remark\", cast(\"functions\".\"func\" as varchar(9999)))" : "cast(\"functions\".\"func\" as varchar(9999))").append(" AS \"REMARKS\", " + 3905 .append(useCommentsTable ? "COALESCE(\"comments\".\"remark\", cast(\"functions\".\"func\" as varchar(9999)))" : "cast(\"functions\".\"func\" as varchar(9999))").append(" AS \"REMARKS\", " +
3906 "CASE \"functions\".\"type\"" + 3906 "CASE \"functions\".\"type\"" +
3907 " WHEN 1 THEN ").append(DatabaseMetaData.functionNoTable) 3907 " WHEN 1 THEN ").append(DatabaseMetaData.functionNoTable)
4001 String functionNamePattern, 4001 String functionNamePattern,
4002 String columnNamePattern) 4002 String columnNamePattern)
4003 throws SQLException 4003 throws SQLException
4004 { 4004 {
4005 StringBuilder query = new StringBuilder(2600); 4005 StringBuilder query = new StringBuilder(2600);
4006 query.append("SELECT DISTINCT CAST(null as char(1)) AS \"FUNCTION_CAT\", " + 4006 query.append("SELECT cast(null as char(1)) AS \"FUNCTION_CAT\", " +
4007 "\"schemas\".\"name\" AS \"FUNCTION_SCHEM\", " + 4007 "\"schemas\".\"name\" AS \"FUNCTION_SCHEM\", " +
4008 "\"functions\".\"name\" AS \"FUNCTION_NAME\", " + 4008 "\"functions\".\"name\" AS \"FUNCTION_NAME\", " +
4009 "\"args\".\"name\" AS \"COLUMN_NAME\", " + 4009 "\"args\".\"name\" AS \"COLUMN_NAME\", " +
4010 "CAST(CASE \"args\".\"inout\"" + 4010 "cast(CASE \"args\".\"inout\"" +
4011 " WHEN 0 THEN (CASE \"args\".\"number\" WHEN 0 THEN ") 4011 " WHEN 0 THEN (CASE \"args\".\"number\" WHEN 0 THEN ")
4012 .append(DatabaseMetaData.functionReturn).append(" ELSE ").append(DatabaseMetaData.functionColumnOut).append(" END)" + 4012 .append(DatabaseMetaData.functionReturn).append(" ELSE ").append(DatabaseMetaData.functionColumnOut).append(" END)" +
4013 " WHEN 1 THEN ").append(DatabaseMetaData.functionColumnIn) 4013 " WHEN 1 THEN ").append(DatabaseMetaData.functionColumnIn)
4014 .append(" ELSE ").append(DatabaseMetaData.functionColumnUnknown).append(" END AS smallint) AS \"COLUMN_TYPE\", " + 4014 .append(" ELSE ").append(DatabaseMetaData.functionColumnUnknown).append(" END AS smallint) AS \"COLUMN_TYPE\", " +
4015 "CAST(").append(MonetDriver.getSQLTypeMap("\"args\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " + 4015 "cast(").append(MonetDriver.getSQLTypeMap("\"args\".\"type\"")).append(" AS int) AS \"DATA_TYPE\", " +
4016 "\"args\".\"type\" AS \"TYPE_NAME\", " + 4016 "\"args\".\"type\" AS \"TYPE_NAME\", " +
4017 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 3 WHEN 'smallint' THEN 5 WHEN 'int' THEN 10 WHEN 'bigint' THEN 19" + 4017 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 3 WHEN 'smallint' THEN 5 WHEN 'int' THEN 10 WHEN 'bigint' THEN 19" +
4018 " WHEN 'hugeint' THEN 38 WHEN 'oid' THEN 19 WHEN 'wrd' THEN 19 ELSE \"args\".\"type_digits\" END AS \"PRECISION\", " + 4018 " WHEN 'hugeint' THEN 38 WHEN 'oid' THEN 19 WHEN 'wrd' THEN 19 ELSE \"args\".\"type_digits\" END AS \"PRECISION\", " +
4019 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 1 WHEN 'smallint' THEN 2 WHEN 'int' THEN 4 WHEN 'bigint' THEN 8" + 4019 "CASE \"args\".\"type\" WHEN 'tinyint' THEN 1 WHEN 'smallint' THEN 2 WHEN 'int' THEN 4 WHEN 'bigint' THEN 8" +
4020 " WHEN 'hugeint' THEN 16 WHEN 'oid' THEN 8 WHEN 'wrd' THEN 8 ELSE \"args\".\"type_digits\" END AS \"LENGTH\", " + 4020 " WHEN 'hugeint' THEN 16 WHEN 'oid' THEN 8 WHEN 'wrd' THEN 8 ELSE \"args\".\"type_digits\" END AS \"LENGTH\", " +
4021 "CAST(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric'," + 4021 "cast(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric'," +
4022 "'time','timetz','timestamp','timestamptz','sec_interval') THEN \"args\".\"type_scale\" ELSE NULL END AS smallint) AS \"SCALE\", " + 4022 "'time','timetz','timestamp','timestamptz','sec_interval') THEN \"args\".\"type_scale\" ELSE NULL END AS smallint) AS \"SCALE\", " +
4023 "CAST(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric') THEN 10" + 4023 "cast(CASE WHEN \"args\".\"type\" IN ('tinyint','smallint','int','bigint','hugeint','oid','wrd','decimal','numeric') THEN 10" +
4024 " WHEN \"args\".\"type\" IN ('real','float','double') THEN 2 ELSE NULL END AS smallint) AS \"RADIX\", " + 4024 " WHEN \"args\".\"type\" IN ('real','float','double') THEN 2 ELSE NULL END AS smallint) AS \"RADIX\", " +
4025 "CAST(").append(DatabaseMetaData.functionNullableUnknown).append(" AS smallint) AS \"NULLABLE\", " + 4025 "cast(").append(DatabaseMetaData.functionNullableUnknown).append(" AS smallint) AS \"NULLABLE\", " +
4026 "CAST(null as char(1)) AS \"REMARKS\", " + 4026 "cast(null as char(1)) AS \"REMARKS\", " +
4027 "CAST(CASE WHEN \"args\".\"type\" IN ('char','varchar','clob') THEN \"args\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " + 4027 "cast(CASE WHEN \"args\".\"type\" IN ('char','varchar','clob') THEN \"args\".\"type_digits\" ELSE NULL END as int) AS \"CHAR_OCTET_LENGTH\", " +
4028 "CAST(\"args\".\"number\" as int) AS \"ORDINAL_POSITION\", " + 4028 "cast(\"args\".\"number\" as int) AS \"ORDINAL_POSITION\", " +
4029 "CAST('' as varchar(3)) AS \"IS_NULLABLE\", " + 4029 "cast('' as varchar(3)) AS \"IS_NULLABLE\", " +
4030 // the specific name contains the function id, in order to be able to match the args to the correct overloaded function name 4030 // the specific name contains the function id, in order to be able to match the args to the correct overloaded function name
4031 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " + 4031 "cast(\"functions\".\"id\" as varchar(10)) AS \"SPECIFIC_NAME\" " +
4032 "FROM \"sys\".\"args\" " + 4032 "FROM \"sys\".\"args\" " +
4033 "JOIN \"sys\".\"functions\" ON (\"args\".\"func_id\" = \"functions\".\"id\") " + 4033 "JOIN \"sys\".\"functions\" ON (\"args\".\"func_id\" = \"functions\".\"id\") " +
4034 "JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") " + 4034 "JOIN \"sys\".\"schemas\" ON (\"functions\".\"schema_id\" = \"schemas\".\"id\") " +
4103 String columnNamePattern) 4103 String columnNamePattern)
4104 throws SQLException 4104 throws SQLException
4105 { 4105 {
4106 // MonetDB currently does not support pseudo or hidden columns, so return an empty ResultSet 4106 // MonetDB currently does not support pseudo or hidden columns, so return an empty ResultSet
4107 String query = 4107 String query =
4108 "SELECT CAST(null as char(1)) AS \"TABLE_CAT\", " + 4108 "SELECT cast(null as char(1)) AS \"TABLE_CAT\", " +
4109 "CAST('' as varchar(1)) AS \"TABLE_SCHEM\", " + 4109 "'' AS \"TABLE_SCHEM\", " +
4110 "CAST('' as varchar(1)) AS \"TABLE_NAME\", " + 4110 "'' AS \"TABLE_NAME\", " +
4111 "CAST('' as varchar(1)) AS \"COLUMN_NAME\", " + 4111 "'' AS \"COLUMN_NAME\", " +
4112 "CAST(0 as int) AS \"DATA_TYPE\", " + 4112 "cast(0 as int) AS \"DATA_TYPE\", " +
4113 "CAST(0 as int) AS \"COLUMN_SIZE\", " + 4113 "cast(0 as int) AS \"COLUMN_SIZE\", " +
4114 "CAST(0 as int) AS \"DECIMAL_DIGITS\", " + 4114 "cast(0 as int) AS \"DECIMAL_DIGITS\", " +
4115 "CAST(0 as int) AS \"NUM_PREC_RADIX\", " + 4115 "cast(0 as int) AS \"NUM_PREC_RADIX\", " +
4116 "CAST('' as varchar(1)) AS \"COLUMN_USAGE\", " + 4116 "'' AS \"COLUMN_USAGE\", " +
4117 "CAST(null as varchar(1)) AS \"REMARKS\", " + 4117 "'' AS \"REMARKS\", " +
4118 "CAST(0 as int) AS \"CHAR_OCTET_LENGTH\", " + 4118 "cast(0 as int) AS \"CHAR_OCTET_LENGTH\", " +
4119 "CAST('' as varchar(3)) AS \"IS_NULLABLE\" " + 4119 "'' AS \"IS_NULLABLE\" " +
4120 "WHERE 1 = 0"; 4120 "WHERE 1 = 0";
4121 4121
4122 return executeMetaDataQuery(query); 4122 return executeMetaDataQuery(query);
4123 } 4123 }
4124 4124