comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @ 15:6e48d0fae766

Corrected return values of DatabaseMetaData methods nullsAreSortedHigh(), nullsAreSortedLow(), getMaxCursorNameLength(), getMaxProcedureNameLength(), getMaxStatementLength() and getMaxUserNameLength(). Improved return values of DatabaseMetaData methods getMaxBinaryLiteralLength(), getMaxCharLiteralLength() and getMaxColumnsInTable().
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 06 Oct 2016 19:44:34 +0200 (2016-10-06)
parents b3ca1157be73
children 7acc09f59b21
comparison
equal deleted inserted replaced
14:3fa949cbc783 15:6e48d0fae766
161 public boolean isReadOnly() { 161 public boolean isReadOnly() {
162 return false; 162 return false;
163 } 163 }
164 164
165 /** 165 /**
166 * Are NULL values sorted high? 166 * Retrieves whether NULL values are sorted high. Sorted high means
167 * 167 * that NULL values sort higher than any other value in a domain.
168 * @return true because MonetDB puts NULL values on top upon ORDER BY 168 * In an ascending order, if this method returns true, NULL values will appear at the end.
169 * By contrast, the method nullsAreSortedAtEnd indicates whether NULL values are sorted at the end regardless of sort order.
170 *
171 * @return false because MonetDB shows NULL values at the beginning upon ORDER BY .. ASC
169 */ 172 */
170 @Override 173 @Override
171 public boolean nullsAreSortedHigh() { 174 public boolean nullsAreSortedHigh() {
172 return true; 175 return false;
173 } 176 }
174 177
175 /** 178 /**
176 * Are NULL values sorted low? 179 * Retrieves whether NULL values are sorted low. Sorted low means
180 * that NULL values sort lower than any other value in a domain.
181 * In an ascending order, if this method returns true, NULL values will appear at the beginning.
182 * By contrast, the method nullsAreSortedAtStart indicates whether NULL values are sorted at the beginning regardless of sort order.
183 *
184 * @return true because MonetDB shows NULL values at the beginning upon ORDER BY .. ASC
177 * 185 *
178 * @return negative of nullsAreSortedHigh() 186 * @return negative of nullsAreSortedHigh()
179 * @see #nullsAreSortedHigh() 187 * @see #nullsAreSortedHigh()
180 */ 188 */
181 @Override 189 @Override
182 public boolean nullsAreSortedLow() { 190 public boolean nullsAreSortedLow() {
183 return !nullsAreSortedHigh(); 191 return true;
184 } 192 }
185 193
186 /** 194 /**
187 * Are NULL values sorted at the start regardless of sort order? 195 * Are NULL values sorted at the start regardless of sort order?
188 * 196 *
267 public int getDriverMinorVersion() { 275 public int getDriverMinorVersion() {
268 return MonetDriver.getDriverMinorVersion(); 276 return MonetDriver.getDriverMinorVersion();
269 } 277 }
270 278
271 /** 279 /**
272 * Does the database store tables in a local file? No - it 280 * Does the database store tables in a local file?
273 * stores them in a file on the server. 281 * No, it stores them in files on the server.
274 * 282 *
275 * @return false because that's what MonetDB is for 283 * @return false because that's what MonetDB is for
276 */ 284 */
277 @Override 285 @Override
278 public boolean usesLocalFiles() { 286 public boolean usesLocalFiles() {
279 return false; 287 return false;
280 } 288 }
281 289
282 /** 290 /**
283 * Does the database use a local file for each table? Well, not really, 291 * Does the database use a local file for each table?
284 * since it doesn't use local files.
285 * 292 *
286 * @return false for it doesn't 293 * @return false for it doesn't
287 */ 294 */
288 @Override 295 @Override
289 public boolean usesLocalFilePerTable() { 296 public boolean usesLocalFilePerTable() {
963 public boolean supportsOuterJoins(){ 970 public boolean supportsOuterJoins(){
964 return true; 971 return true;
965 } 972 }
966 973
967 /** 974 /**
968 * Are full nexted outer joins supported? 975 * Are full nested outer joins supported?
969 * 976 *
970 * @return true if so 977 * @return true if so
971 */ 978 */
972 @Override 979 @Override
973 public boolean supportsFullOuterJoins() { 980 public boolean supportsFullOuterJoins() {
1313 return true; 1320 return true;
1314 } 1321 }
1315 1322
1316 /** 1323 /**
1317 * How many hex characters can you have in an inline binary literal 1324 * How many hex characters can you have in an inline binary literal
1318 * I honestly wouldn't know...
1319 * 1325 *
1320 * @return the max literal length 1326 * @return the max literal length
1321 */ 1327 */
1322 @Override 1328 @Override
1323 public int getMaxBinaryLiteralLength() { 1329 public int getMaxBinaryLiteralLength() {
1324 return 0; // no limit 1330 return 2*1024*1024*1024 - 2; // MonetDB supports null terminated strings of max 2GB, see function: int UTF8_strlen()
1325 } 1331 }
1326 1332
1327 /** 1333 /**
1328 * What is the maximum length for a character literal 1334 * What is the maximum length for a character literal
1329 * Is there a max?
1330 * 1335 *
1331 * @return the max literal length 1336 * @return the max literal length
1332 */ 1337 */
1333 @Override 1338 @Override
1334 public int getMaxCharLiteralLength() { 1339 public int getMaxCharLiteralLength() {
1335 return 0; // no limit 1340 return 2*1024*1024*1024 - 2; // MonetDB supports null terminated strings of max 2GB, see function: int UTF8_strlen()
1336 } 1341 }
1337 1342
1338 /** 1343 /**
1339 * Whats the limit on column name length. 1344 * Whats the limit on column name length.
1340 * I take some safety here, but it's just a varchar in MonetDB 1345 * I take some safety here, but it's just a varchar in MonetDB
1341 * 1346 *
1342 * @return the maximum column name length 1347 * @return the maximum column name length
1343 */ 1348 */
1344 @Override 1349 @Override
1345 public int getMaxColumnNameLength() { 1350 public int getMaxColumnNameLength() {
1346 return 1024; 1351 return 1024; // In MonetDB the max length of column sys._columns.name is defined as 1024
1347 } 1352 }
1348 1353
1349 /** 1354 /**
1350 * What is the maximum number of columns in a "GROUP BY" clause? 1355 * What is the maximum number of columns in a "GROUP BY" clause?
1351 * 1356 *
1352 * @return the max number of columns 1357 * @return the max number of columns
1353 */ 1358 */
1354 @Override 1359 @Override
1355 public int getMaxColumnsInGroupBy() { 1360 public int getMaxColumnsInGroupBy() {
1356 return 0; // no limit 1361 return 0; // no specific limit known
1357 } 1362 }
1358 1363
1359 /** 1364 /**
1360 * What's the maximum number of columns allowed in an index? 1365 * What's the maximum number of columns allowed in an index?
1361 * 1366 *
1362 * @return max number of columns 1367 * @return max number of columns
1363 */ 1368 */
1364 @Override 1369 @Override
1365 public int getMaxColumnsInIndex() { 1370 public int getMaxColumnsInIndex() {
1366 return 0; // unlimited I guess 1371 return 0; // no specific limit known
1367 } 1372 }
1368 1373
1369 /** 1374 /**
1370 * What's the maximum number of columns in an "ORDER BY clause? 1375 * What's the maximum number of columns in an "ORDER BY clause?
1371 * 1376 *
1372 * @return the max columns 1377 * @return the max columns
1373 */ 1378 */
1374 @Override 1379 @Override
1375 public int getMaxColumnsInOrderBy() { 1380 public int getMaxColumnsInOrderBy() {
1376 return 0; // unlimited I guess 1381 return 0; // no specific limit known
1377 } 1382 }
1378 1383
1379 /** 1384 /**
1380 * What is the maximum number of columns in a "SELECT" list? 1385 * What is the maximum number of columns in a "SELECT" list?
1381 * 1386 *
1382 * @return the max columns 1387 * @return the max columns
1383 */ 1388 */
1384 @Override 1389 @Override
1385 public int getMaxColumnsInSelect() { 1390 public int getMaxColumnsInSelect() {
1386 return 0; // unlimited I guess 1391 return 0; // no specific limit known
1387 } 1392 }
1388 1393
1389 /** 1394 /**
1390 * What is the maximum number of columns in a table? 1395 * What is the maximum number of columns in a table?
1391 * wasn't MonetDB designed for datamining? (= much columns) 1396 *
1397 * The theoretical max value of int column sys._columns.id is 2^31 -1
1398 * but this is for all columns of all tables in all schemas (including all data dictionary columns).
1399 * For one table we should reduce it to a more practical soft limit of say 100 thousand
1392 * 1400 *
1393 * @return the max columns 1401 * @return the max columns
1394 */ 1402 */
1395 @Override 1403 @Override
1396 public int getMaxColumnsInTable() { 1404 public int getMaxColumnsInTable() {
1397 return 0; 1405 return 100*1000; // soft limit it to 100 thousand
1398 } 1406 }
1399 1407
1400 /** 1408 /**
1401 * How many active connections can we have at a time to this 1409 * How many active connections can we have at a time to this
1402 * database? Well, since it depends on Mserver, which just listens 1410 * database? Well, since it depends on Mserver, which just listens
1429 * 1437 *
1430 * @return max cursor name length in bytes 1438 * @return max cursor name length in bytes
1431 */ 1439 */
1432 @Override 1440 @Override
1433 public int getMaxCursorNameLength() { 1441 public int getMaxCursorNameLength() {
1434 return 1024; 1442 return 0; // no specific limit known
1435 } 1443 }
1436 1444
1437 /** 1445 /**
1438 * Retrieves the maximum number of bytes for an index, including all 1446 * Retrieves the maximum number of bytes for an index, including all
1439 * of the parts of the index. 1447 * of the parts of the index.
1442 * of all the constituent parts of the index; a result of zero 1450 * of all the constituent parts of the index; a result of zero
1443 * means that there is no limit or the limit is not known 1451 * means that there is no limit or the limit is not known
1444 */ 1452 */
1445 @Override 1453 @Override
1446 public int getMaxIndexLength() { 1454 public int getMaxIndexLength() {
1447 return 0; // I assume it is large, but I don't know 1455 return 0; // no specific limit known
1448 } 1456 }
1449 1457
1450 /** 1458 /**
1451 * Retrieves the maximum number of characters that this database 1459 * Retrieves the maximum number of characters that this database
1452 * allows in a schema name. 1460 * allows in a schema name.
1454 * @return the number of characters or 0 if there is no limit, or the 1462 * @return the number of characters or 0 if there is no limit, or the
1455 * limit is unknown. 1463 * limit is unknown.
1456 */ 1464 */
1457 @Override 1465 @Override
1458 public int getMaxSchemaNameLength() { 1466 public int getMaxSchemaNameLength() {
1459 return 1024; 1467 return 1024; // In MonetDB the max length of column sys.schemas.name is defined as 1024
1460 } 1468 }
1461 1469
1462 /** 1470 /**
1463 * What is the maximum length of a procedure name 1471 * What is the maximum length of a procedure name
1464 * 1472 *
1465 * @return the max name length in bytes 1473 * @return the max name length in bytes
1466 */ 1474 */
1467 @Override 1475 @Override
1468 public int getMaxProcedureNameLength() { 1476 public int getMaxProcedureNameLength() {
1469 return 1024; 1477 return 256; // In MonetDB the max length of column sys.functions.name is defined as 256
1470 } 1478 }
1471 1479
1472 /** 1480 /**
1473 * What is the maximum length of a catalog 1481 * What is the maximum length of a catalog
1474 * 1482 *
1489 public int getMaxRowSize() { 1497 public int getMaxRowSize() {
1490 return 0; // very long I hope... 1498 return 0; // very long I hope...
1491 } 1499 }
1492 1500
1493 /** 1501 /**
1494 * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY 1502 * Did getMaxRowSize() include the SQL data types LONGVARCHAR and LONGVARBINARY
1495 * blobs? 1503 * blobs?
1496 * Yes I thought so... 1504 * Yes I thought so...
1497 * 1505 *
1498 * @return true if so 1506 * @return true if so
1499 */ 1507 */
1502 return true; 1510 return true;
1503 } 1511 }
1504 1512
1505 /** 1513 /**
1506 * What is the maximum length of a SQL statement? 1514 * What is the maximum length of a SQL statement?
1507 * Till a programmer makes a mistake and causes a segmentation fault
1508 * on a string overflow...
1509 * 1515 *
1510 * @return max length in bytes 1516 * @return max length in bytes
1511 */ 1517 */
1512 @Override 1518 @Override
1513 public int getMaxStatementLength() { 1519 public int getMaxStatementLength() {
1514 return 0; // actually whatever fits in size_t 1520 return 2*1024*1024*1024 - 2; // MonetDB supports null terminated strings of max 2GB, see function: int UTF8_strlen()
1515 } 1521 }
1516 1522
1517 /** 1523 /**
1518 * How many active statements can we have open at one time to 1524 * How many active statements can we have open at one time to
1519 * this database? Basically, since each Statement downloads 1525 * this database? Basically, since each Statement downloads
1521 * 1527 *
1522 * @return the maximum 1528 * @return the maximum
1523 */ 1529 */
1524 @Override 1530 @Override
1525 public int getMaxStatements() { 1531 public int getMaxStatements() {
1526 return 0; 1532 return 0; // no specific limit known
1527 } 1533 }
1528 1534
1529 /** 1535 /**
1530 * What is the maximum length of a table name 1536 * What is the maximum length of a table name
1531 * 1537 *
1532 * @return max name length in bytes 1538 * @return max name length in bytes
1533 */ 1539 */
1534 @Override 1540 @Override
1535 public int getMaxTableNameLength() { 1541 public int getMaxTableNameLength() {
1536 return 1024; 1542 return 1024; // In MonetDB the max length of column sys._tables.name is defined as 1024
1537 } 1543 }
1538 1544
1539 /** 1545 /**
1540 * What is the maximum number of tables that can be specified 1546 * What is the maximum number of tables that can be specified
1541 * in a SELECT? 1547 * in a SELECT?
1542 * 1548 *
1543 * @return the maximum 1549 * @return the maximum
1544 */ 1550 */
1545 @Override 1551 @Override
1546 public int getMaxTablesInSelect() { 1552 public int getMaxTablesInSelect() {
1547 return 0; // no limit 1553 return 0; // no specific limit known
1548 } 1554 }
1549 1555
1550 /** 1556 /**
1551 * What is the maximum length of a user name 1557 * What is the maximum length of a user name
1552 * 1558 *
1553 * @return the max name length in bytes 1559 * @return the max name length in bytes
1554 */ 1560 */
1555 @Override 1561 @Override
1556 public int getMaxUserNameLength() { 1562 public int getMaxUserNameLength() {
1557 return 512; 1563 return 1024; // In MonetDB the max length of column sys.db_user_info.name is defined as 1024
1558 } 1564 }
1559 1565
1560 /** 1566 /**
1561 * What is the database's default transaction isolation level? 1567 * What is the database's default transaction isolation level?
1562 * We only see commited data, nonrepeatable reads and phantom 1568 * We only see commited data, nonrepeatable reads and phantom
2151 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF) 2157 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
2152 * <LI><B>IS_AUTOINCREMENT</B> String => Indicates whether this column is auto incremented 2158 * <LI><B>IS_AUTOINCREMENT</B> String => Indicates whether this column is auto incremented
2153 * <UL> 2159 * <UL>
2154 * <LI> YES --- if the column is auto incremented 2160 * <LI> YES --- if the column is auto incremented
2155 * <LI> NO --- if the column is not auto incremented 2161 * <LI> NO --- if the column is not auto incremented
2156 * <LI> empty string --- if it cannot be determined whether the column is auto incremented 2162 * <LI> empty string --- if it cannot be determined whether the column is auto incremented
2157 * </UL> 2163 * </UL>
2158 * <LI><B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated column 2164 * <LI><B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated column
2159 * <UL> 2165 * <UL>
2160 * <LI> YES --- if this a generated column 2166 * <LI> YES --- if this a generated column
2161 * <LI> NO --- if this not a generated column 2167 * <LI> NO --- if this not a generated column
3525 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) 3531 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3526 * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the 3532 * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the
3527 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) 3533 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3528 * <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a 3534 * <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a
3529 * reference attribute (<code>null</code> if the DATA_TYPE isn't REF) 3535 * reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
3530 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated 3536 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
3531 * Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE 3537 * Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
3532 * isn't DISTINCT or user-generated REF) 3538 * isn't DISTINCT or user-generated REF)
3533 * </OL> 3539 * </OL>
3534 * @param catalog a catalog name; must match the catalog name as it 3540 * @param catalog a catalog name; must match the catalog name as it
3535 * is stored in the database; "" retrieves those without a catalog; 3541 * is stored in the database; "" retrieves those without a catalog;
3615 major = Integer.parseInt((start >= 0) ? env_monet_version.substring(0, start) : env_monet_version); 3621 major = Integer.parseInt((start >= 0) ? env_monet_version.substring(0, start) : env_monet_version);
3616 } catch (NumberFormatException e) { 3622 } catch (NumberFormatException e) {
3617 // ignore 3623 // ignore
3618 } 3624 }
3619 } 3625 }
3620 return major; 3626 return major;
3621 } 3627 }
3622 3628
3623 /** 3629 /**
3624 * Retrieves the minor version number of the underlying database. 3630 * Retrieves the minor version number of the underlying database.
3625 * 3631 *
3641 } 3647 }
3642 } catch (NumberFormatException e) { 3648 } catch (NumberFormatException e) {
3643 // ignore 3649 // ignore
3644 } 3650 }
3645 } 3651 }
3646 return minor; 3652 return minor;
3647 } 3653 }
3648 3654
3649 /** 3655 /**
3650 * Retrieves the major JDBC version number for this driver. 3656 * Retrieves the major JDBC version number for this driver.
3651 * 3657 *
3790 public ResultSet getClientInfoProperties() throws SQLException { 3796 public ResultSet getClientInfoProperties() throws SQLException {
3791 // for a list of connection properties see also MonetConnection.java constructor MonetConnection(Properties props) 3797 // for a list of connection properties see also MonetConnection.java constructor MonetConnection(Properties props)
3792 String query = 3798 String query =
3793 "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 " + 3799 "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 " +
3794 "SELECT 'port', 5, '50000', 'communication port number of MonetDB server process' UNION ALL " + 3800 "SELECT 'port', 5, '50000', 'communication port number of MonetDB server process' UNION ALL " +
3795 "SELECT 'user', 128, '', 'user name to login to MonetDB server' UNION ALL " + 3801 "SELECT 'user', 1024, '', 'user name to login to MonetDB server' UNION ALL " +
3796 "SELECT 'password', 128, '', 'password for user name to login to MonetDB server' UNION ALL " + 3802 "SELECT 'password', 128, '', 'password for user name to login to MonetDB server' UNION ALL " +
3797 "SELECT 'language', 16, 'sql', 'language (sql or mal) used to parse commands in MonetDB server' UNION ALL " + 3803 "SELECT 'language', 16, 'sql', 'language (sql or mal) used to parse commands in MonetDB server' UNION ALL " +
3798 "SELECT 'debug', 5, 'false', 'boolean flag true or false' UNION ALL " + 3804 "SELECT 'debug', 5, 'false', 'boolean flag true or false' UNION ALL " +
3799 "SELECT 'hash', 128, '', 'hash string' UNION ALL " + 3805 "SELECT 'hash', 128, '', 'hash string' UNION ALL " +
3800 "SELECT 'treat_blob_as_binary', 5, 'false', 'boolean flag true or false' UNION ALL " + 3806 "SELECT 'treat_blob_as_binary', 5, 'false', 'boolean flag true or false' UNION ALL " +
3919 * functionNullable - allows NULL values 3925 * functionNullable - allows NULL values
3920 * functionNullableUnknown - nullability unknown 3926 * functionNullableUnknown - nullability unknown
3921 * 13. REMARKS String => comment describing column/parameter 3927 * 13. REMARKS String => comment describing column/parameter
3922 * 14. CHAR_OCTET_LENGTH int => the maximum length of binary and character based parameters or columns. For any other datatype the returned value is a NULL 3928 * 14. CHAR_OCTET_LENGTH int => the maximum length of binary and character based parameters or columns. For any other datatype the returned value is a NULL
3923 * 15. ORDINAL_POSITION int => the ordinal position, starting from 1, for the input and output parameters. 3929 * 15. ORDINAL_POSITION int => the ordinal position, starting from 1, for the input and output parameters.
3924 * A value of 0 is returned if this row describes the function's return value. For result set columns, it is the ordinal position of the column in the result set starting from 1. 3930 * A value of 0 is returned if this row describes the function's return value. For result set columns, it is the ordinal position of the column in the result set starting from 1.
3925 * 16. IS_NULLABLE String => ISO rules are used to determine the nullability for a parameter or column. 3931 * 16. IS_NULLABLE String => ISO rules are used to determine the nullability for a parameter or column.
3926 * YES --- if the parameter or column can include NULLs 3932 * YES --- if the parameter or column can include NULLs
3927 * NO --- if the parameter or column cannot include NULLs 3933 * NO --- if the parameter or column cannot include NULLs
3928 * empty string --- if the nullability for the parameter or column is unknown 3934 * empty string --- if the nullability for the parameter or column is unknown
3929 * 17. SPECIFIC_NAME String => the name which uniquely identifies this function within its schema. 3935 * 17. SPECIFIC_NAME String => the name which uniquely identifies this function within its schema.
3930 * This is a user specified, or DBMS generated, name that may be different then the FUNCTION_NAME for example with overload functions 3936 * This is a user specified, or DBMS generated, name that may be different then the FUNCTION_NAME for example with overload functions
3931 * 3937 *
3932 * @param catalog a catalog name; must match the catalog name as 3938 * @param catalog a catalog name; must match the catalog name as
3933 * it is stored in the database; "" retrieves those without a 3939 * it is stored in the database; "" retrieves those without a
3934 * catalog; null means that the catalog name should not be 3940 * catalog; null means that the catalog name should not be
3935 * used to narrow the search 3941 * used to narrow the search