comparison src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @ 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 f523727db392
children bf9f6b6ecf40
comparison
equal deleted inserted replaced
404:559aa626b550 405:6242351e8802
2586 "cast(null AS char(1)) AS \"FKTABLE_CAT\", " + 2586 "cast(null AS char(1)) AS \"FKTABLE_CAT\", " +
2587 "fkschema.\"name\" AS \"FKTABLE_SCHEM\", " + 2587 "fkschema.\"name\" AS \"FKTABLE_SCHEM\", " +
2588 "fktable.\"name\" AS \"FKTABLE_NAME\", " + 2588 "fktable.\"name\" AS \"FKTABLE_NAME\", " +
2589 "fkkeycol.\"name\" AS \"FKCOLUMN_NAME\", " + 2589 "fkkeycol.\"name\" AS \"FKCOLUMN_NAME\", " +
2590 "cast(1 + \"pkkeycol\".\"nr\" AS smallint) AS \"KEY_SEQ\", " + 2590 "cast(1 + \"pkkeycol\".\"nr\" AS smallint) AS \"KEY_SEQ\", " +
2591 DatabaseMetaData.importedKeyNoAction + " AS \"UPDATE_RULE\", " + 2591 "cast(CASE ((fkkey.\"action\" >> 8) & 255)" + // logic pulled from clients/mapiclient/dump.c dump_foreign_keys()
2592 DatabaseMetaData.importedKeyNoAction + " AS \"DELETE_RULE\", " + 2592 " WHEN 0 THEN " + DatabaseMetaData.importedKeyNoAction +
2593 " WHEN 1 THEN " + DatabaseMetaData.importedKeyCascade +
2594 " WHEN 2 THEN " + DatabaseMetaData.importedKeyRestrict +
2595 " WHEN 3 THEN " + DatabaseMetaData.importedKeySetNull +
2596 " WHEN 4 THEN " + DatabaseMetaData.importedKeySetDefault +
2597 " ELSE " + DatabaseMetaData.importedKeyNoAction +
2598 " END AS smallint) AS \"UPDATE_RULE\", " +
2599 "cast(CASE (fkkey.\"action\" & 255)" + // logic pulled from clients/mapiclient/dump.c dump_foreign_keys()
2600 " WHEN 0 THEN " + DatabaseMetaData.importedKeyNoAction +
2601 " WHEN 1 THEN " + DatabaseMetaData.importedKeyCascade +
2602 " WHEN 2 THEN " + DatabaseMetaData.importedKeyRestrict +
2603 " WHEN 3 THEN " + DatabaseMetaData.importedKeySetNull +
2604 " WHEN 4 THEN " + DatabaseMetaData.importedKeySetDefault +
2605 " ELSE " + DatabaseMetaData.importedKeyNoAction +
2606 " END AS smallint) AS \"DELETE_RULE\", " +
2593 "fkkey.\"name\" AS \"FK_NAME\", " + 2607 "fkkey.\"name\" AS \"FK_NAME\", " +
2594 "pkkey.\"name\" AS \"PK_NAME\", " + 2608 "pkkey.\"name\" AS \"PK_NAME\", " +
2595 DatabaseMetaData.importedKeyNotDeferrable + " AS \"DEFERRABILITY\" " + 2609 "cast(" + DatabaseMetaData.importedKeyNotDeferrable + " AS smallint) AS \"DEFERRABILITY\" " +
2596 "FROM \"sys\".\"keys\" pkkey " + 2610 "FROM \"sys\".\"keys\" pkkey " +
2597 "JOIN \"sys\".\"objects\" pkkeycol ON pkkey.\"id\" = pkkeycol.\"id\" " + 2611 "JOIN \"sys\".\"objects\" pkkeycol ON pkkey.\"id\" = pkkeycol.\"id\" " +
2598 "JOIN \"sys\".\"tables\" pktable ON pktable.\"id\" = pkkey.\"table_id\" " + 2612 "JOIN \"sys\".\"tables\" pktable ON pktable.\"id\" = pkkey.\"table_id\" " +
2599 "JOIN \"sys\".\"schemas\" pkschema ON pkschema.\"id\" = pktable.\"schema_id\" " + 2613 "JOIN \"sys\".\"schemas\" pkschema ON pkschema.\"id\" = pktable.\"schema_id\" " +
2600 "JOIN \"sys\".\"keys\" fkkey ON fkkey.\"rkey\" = pkkey.\"id\" " + 2614 "JOIN \"sys\".\"keys\" fkkey ON fkkey.\"rkey\" = pkkey.\"id\" " +
2623 * <LI><B>FKTABLE_SCHEM</B> String =&gt; foreign key table schema (may be null) 2637 * <LI><B>FKTABLE_SCHEM</B> String =&gt; foreign key table schema (may be null)
2624 * <LI><B>FKTABLE_NAME</B> String =&gt; foreign key table name 2638 * <LI><B>FKTABLE_NAME</B> String =&gt; foreign key table name
2625 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name 2639 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name
2626 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key 2640 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key
2627 * (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). 2641 * (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).
2628 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to 2642 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to foreign key when primary is updated:
2629 * foreign key when primary is updated:
2630 * <UL> 2643 * <UL>
2631 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported 2644 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported
2632 * <LI> importedKeyCascade - change imported key to agree 2645 * <LI> importedKeyCascade - change imported key to agree with primary key update
2633 * with primary key update 2646 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2634 * <LI> importedKeyRestrict - do not allow update of primary 2647 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated
2635 * key if it has been imported 2648 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated
2636 * <LI> importedKeySetNull - change imported key to NULL if
2637 * its primary key has been updated
2638 * </UL> 2649 * </UL>
2639 * <LI><B>DELETE_RULE</B> short =&gt; What happens to 2650 * <LI><B>DELETE_RULE</B> short =&gt; What happens to the foreign key when primary is deleted.
2640 * the foreign key when primary is deleted.
2641 * <UL> 2651 * <UL>
2642 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported 2652 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported
2643 * <LI> importedKeyCascade - delete rows that import a deleted key 2653 * <LI> importedKeyCascade - delete rows that import a deleted key
2644 * <LI> importedKeyRestrict - do not allow delete of primary 2654 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2645 * key if it has been imported 2655 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted
2646 * <LI> importedKeySetNull - change imported key to NULL if 2656 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted
2647 * its primary key has been deleted
2648 * </UL> 2657 * </UL>
2649 * <LI><B>FK_NAME</B> String =&gt; foreign key name (may be null) 2658 * <LI><B>FK_NAME</B> String =&gt; foreign key name (may be null)
2650 * <LI><B>PK_NAME</B> String =&gt; primary key name (may be null) 2659 * <LI><B>PK_NAME</B> String =&gt; primary key name (may be null)
2651 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit 2660 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit
2652 * <UL> 2661 * <UL>
2711 * being exported 2720 * being exported
2712 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name 2721 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name
2713 * being exported 2722 * being exported
2714 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key 2723 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key
2715 * (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). 2724 * (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).
2716 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to 2725 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to foreign key when primary is updated:
2717 * foreign key when primary is updated:
2718 * <UL> 2726 * <UL>
2719 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported 2727 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported
2720 * <LI> importedKeyCascade - change imported key to agree 2728 * <LI> importedKeyCascade - change imported key to agree with primary key update
2721 * with primary key update 2729 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2722 * <LI> importedKeyRestrict - do not allow update of primary 2730 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated
2723 * key if it has been imported 2731 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated
2724 * <LI> importedKeySetNull - change imported key to NULL if
2725 * its primary key has been updated
2726 * </UL> 2732 * </UL>
2727 * <LI><B>DELETE_RULE</B> short =&gt; What happens to 2733 * <LI><B>DELETE_RULE</B> short =&gt; What happens to the foreign key when primary is deleted.
2728 * the foreign key when primary is deleted.
2729 * <UL> 2734 * <UL>
2730 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported 2735 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported
2731 * <LI> importedKeyCascade - delete rows that import a deleted key 2736 * <LI> importedKeyCascade - delete rows that import a deleted key
2732 * <LI> importedKeyRestrict - do not allow delete of primary 2737 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2733 * key if it has been imported 2738 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted
2734 * <LI> importedKeySetNull - change imported key to NULL if 2739 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted
2735 * its primary key has been deleted
2736 * </UL> 2740 * </UL>
2737 * <LI><B>FK_NAME</B> String =&gt; foreign key identifier (may be null) 2741 * <LI><B>FK_NAME</B> String =&gt; foreign key identifier (may be null)
2738 * <LI><B>PK_NAME</B> String =&gt; primary key identifier (may be null) 2742 * <LI><B>PK_NAME</B> String =&gt; primary key identifier (may be null)
2739 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit 2743 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit
2740 * <UL> 2744 * <UL>
2802 * being exported 2806 * being exported
2803 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name 2807 * <LI><B>FKCOLUMN_NAME</B> String =&gt; foreign key column name
2804 * being exported 2808 * being exported
2805 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key 2809 * <LI><B>KEY_SEQ</B> short =&gt; sequence number within foreign key
2806 * (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). 2810 * (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).
2807 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to 2811 * <LI><B>UPDATE_RULE</B> short =&gt; What happens to foreign key when primary is updated:
2808 * foreign key when primary is updated:
2809 * <UL> 2812 * <UL>
2810 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported 2813 * <LI> importedKeyNoAction - do not allow update of primary key if it has been imported
2811 * <LI> importedKeyCascade - change imported key to agree 2814 * <LI> importedKeyCascade - change imported key to agree with primary key update
2812 * with primary key update 2815 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2813 * <LI> importedKeyRestrict - do not allow update of primary 2816 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been updated
2814 * key if it has been imported 2817 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been updated
2815 * <LI> importedKeySetNull - change imported key to NULL if
2816 * its primary key has been updated
2817 * </UL> 2818 * </UL>
2818 * <LI><B>DELETE_RULE</B> short =&gt; What happens to 2819 * <LI><B>DELETE_RULE</B> short =&gt; What happens to the foreign key when primary is deleted.
2819 * the foreign key when primary is deleted.
2820 * <UL> 2820 * <UL>
2821 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported 2821 * <LI> importedKeyNoAction - do not allow delete of primary key if it has been imported
2822 * <LI> importedKeyCascade - delete rows that import a deleted key 2822 * <LI> importedKeyCascade - delete rows that import a deleted key
2823 * <LI> importedKeyRestrict - do not allow delete of primary 2823 * <LI> importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
2824 * key if it has been imported 2824 * <LI> importedKeySetNull - change imported key to NULL if its primary key has been deleted
2825 * <LI> importedKeySetNull - change imported key to NULL if 2825 * <LI> importedKeySetDefault - change imported key to the default values if its primary key has been deleted
2826 * its primary key has been deleted
2827 * </UL> 2826 * </UL>
2828 * <LI><B>FK_NAME</B> String =&gt; foreign key identifier (may be null) 2827 * <LI><B>FK_NAME</B> String =&gt; foreign key identifier (may be null)
2829 * <LI><B>PK_NAME</B> String =&gt; primary key identifier (may be null) 2828 * <LI><B>PK_NAME</B> String =&gt; primary key identifier (may be null)
2830 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit 2829 * <LI><B>DEFERRABILITY</B> short =&gt; can the evaluation of foreign key constraints be deferred until commit
2831 * <UL> 2830 * <UL>