Mercurial > hg > monetdb-java
changeset 405:6242351e8802
Corrected output of resultset columns UPDATE_RULE and DELETE_RULE when calling DatabaseMetaData API methods getImportedKeys() or getExportedKeys() or getCrossReference().
These columns used to always return DatabaseMetaData.importedKeyNoAction but now they can also report the other values when set: DatabaseMetaData.importedKeyCascade or DatabaseMetaData.importedKeyRestrict or DatabaseMetaData.importedKeySetNull or DatabaseMetaData.importedKeySetDefault.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 06 Jan 2021 20:15:13 +0100 (2021-01-06) |
parents | 559aa626b550 |
children | bf9f6b6ecf40 |
files | ChangeLog src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java |
diffstat | 2 files changed, 56 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,17 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog +* Wed Jan 6 2021 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> +- Corrected output of resultset columns UPDATE_RULE and DELETE_RULE + when calling DatabaseMetaData API methods getImportedKeys() or + getExportedKeys() or getCrossReference(). These columns used to + always return DatabaseMetaData.importedKeyNoAction but now they + can also report the other values when set: + DatabaseMetaData.importedKeyCascade + or DatabaseMetaData.importedKeyRestrict + or DatabaseMetaData.importedKeySetNull + or DatabaseMetaData.importedKeySetDefault. + * Thu Nov 12 2020 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> - Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.* This naming complies to the Java Package @@ -41,7 +52,7 @@ * Thu Oct 8 2020 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> - Improved performance of ResultSetMetaData methods isAutoIncrement(), - getPrecision() and getScale() significant for columns of specific data + getPrecision() and getScale() significantly for columns of specific data types as in some cases no costly meta data query is executed anymore. - The connection properties treat_clob_as_varchar and treat_blob_as_binary are now set to true by default within the JDBC driver. This is done
--- a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -2588,11 +2588,25 @@ public class MonetDatabaseMetaData "fktable.\"name\" AS \"FKTABLE_NAME\", " + "fkkeycol.\"name\" AS \"FKCOLUMN_NAME\", " + "cast(1 + \"pkkeycol\".\"nr\" AS smallint) AS \"KEY_SEQ\", " + - DatabaseMetaData.importedKeyNoAction + " AS \"UPDATE_RULE\", " + - DatabaseMetaData.importedKeyNoAction + " AS \"DELETE_RULE\", " + + "cast(CASE ((fkkey.\"action\" >> 8) & 255)" + // logic pulled from clients/mapiclient/dump.c dump_foreign_keys() + " WHEN 0 THEN " + DatabaseMetaData.importedKeyNoAction + + " WHEN 1 THEN " + DatabaseMetaData.importedKeyCascade + + " WHEN 2 THEN " + DatabaseMetaData.importedKeyRestrict + + " WHEN 3 THEN " + DatabaseMetaData.importedKeySetNull + + " WHEN 4 THEN " + DatabaseMetaData.importedKeySetDefault + + " ELSE " + DatabaseMetaData.importedKeyNoAction + + " END AS smallint) AS \"UPDATE_RULE\", " + + "cast(CASE (fkkey.\"action\" & 255)" + // logic pulled from clients/mapiclient/dump.c dump_foreign_keys() + " WHEN 0 THEN " + DatabaseMetaData.importedKeyNoAction + + " WHEN 1 THEN " + DatabaseMetaData.importedKeyCascade + + " WHEN 2 THEN " + DatabaseMetaData.importedKeyRestrict + + " WHEN 3 THEN " + DatabaseMetaData.importedKeySetNull + + " WHEN 4 THEN " + DatabaseMetaData.importedKeySetDefault + + " ELSE " + DatabaseMetaData.importedKeyNoAction + + " END AS smallint) AS \"DELETE_RULE\", " + "fkkey.\"name\" AS \"FK_NAME\", " + "pkkey.\"name\" AS \"PK_NAME\", " + - DatabaseMetaData.importedKeyNotDeferrable + " AS \"DEFERRABILITY\" " + + "cast(" + DatabaseMetaData.importedKeyNotDeferrable + " AS smallint) AS \"DEFERRABILITY\" " + "FROM \"sys\".\"keys\" pkkey " + "JOIN \"sys\".\"objects\" pkkeycol ON pkkey.\"id\" = pkkeycol.\"id\" " + "JOIN \"sys\".\"tables\" pktable ON pktable.\"id\" = pkkey.\"table_id\" " + @@ -2625,26 +2639,21 @@ public class MonetDatabaseMetaData * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name * <LI><B>KEY_SEQ</B> short => sequence number within foreign key * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). - * <LI><B>UPDATE_RULE</B> short => What happens to - * foreign key when primary is updated: + * <LI><B>UPDATE_RULE</B> short => What happens to foreign key when primary is updated: * <UL> * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported - * <LI> importedKeyCascade - change imported key to agree - * with primary key update - * <LI> importedKeyRestrict - do not allow update of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been updated + * <LI> importedKeyCascade - change imported key to agree with primary key update + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated * </UL> - * <LI><B>DELETE_RULE</B> short => What happens to - * the foreign key when primary is deleted. + * <LI><B>DELETE_RULE</B> short => What happens to the foreign key when primary is deleted. * <UL> * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported * <LI> importedKeyCascade - delete rows that import a deleted key - * <LI> importedKeyRestrict - do not allow delete of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been deleted + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted * </UL> * <LI><B>FK_NAME</B> String => foreign key name (may be null) * <LI><B>PK_NAME</B> String => primary key name (may be null) @@ -2713,26 +2722,21 @@ public class MonetDatabaseMetaData * being exported * <LI><B>KEY_SEQ</B> short => sequence number within foreign key * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). - * <LI><B>UPDATE_RULE</B> short => What happens to - * foreign key when primary is updated: + * <LI><B>UPDATE_RULE</B> short => What happens to foreign key when primary is updated: * <UL> * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported - * <LI> importedKeyCascade - change imported key to agree - * with primary key update - * <LI> importedKeyRestrict - do not allow update of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been updated + * <LI> importedKeyCascade - change imported key to agree with primary key update + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated * </UL> - * <LI><B>DELETE_RULE</B> short => What happens to - * the foreign key when primary is deleted. + * <LI><B>DELETE_RULE</B> short => What happens to the foreign key when primary is deleted. * <UL> * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported * <LI> importedKeyCascade - delete rows that import a deleted key - * <LI> importedKeyRestrict - do not allow delete of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been deleted + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted * </UL> * <LI><B>FK_NAME</B> String => foreign key identifier (may be null) * <LI><B>PK_NAME</B> String => primary key identifier (may be null) @@ -2804,26 +2808,21 @@ public class MonetDatabaseMetaData * being exported * <LI><B>KEY_SEQ</B> short => sequence number within foreign key * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). - * <LI><B>UPDATE_RULE</B> short => What happens to - * foreign key when primary is updated: + * <LI><B>UPDATE_RULE</B> short => What happens to foreign key when primary is updated: * <UL> * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported - * <LI> importedKeyCascade - change imported key to agree - * with primary key update - * <LI> importedKeyRestrict - do not allow update of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been updated + * <LI> importedKeyCascade - change imported key to agree with primary key update + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated * </UL> - * <LI><B>DELETE_RULE</B> short => What happens to - * the foreign key when primary is deleted. + * <LI><B>DELETE_RULE</B> short => What happens to the foreign key when primary is deleted. * <UL> * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported * <LI> importedKeyCascade - delete rows that import a deleted key - * <LI> importedKeyRestrict - do not allow delete of primary - * key if it has been imported - * <LI> importedKeySetNull - change imported key to NULL if - * its primary key has been deleted + * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) + * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted + * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted * </UL> * <LI><B>FK_NAME</B> String => foreign key identifier (may be null) * <LI><B>PK_NAME</B> String => primary key identifier (may be null)