| @@ 753-770 (lines=18) @@ | ||
| 750 | *  | 
                                |
| 751 | * @todo Where is this used? Which information should be retrieved?  | 
                                |
| 752 | */  | 
                                |
| 753 | public function getListTableConstraintsSQL($table)  | 
                                |
| 754 |     { | 
                                |
| 755 | $user = '';  | 
                                |
| 756 | ||
| 757 |         if (strpos($table, '.') !== false) { | 
                                |
| 758 |             list($user, $table) = explode('.', $table); | 
                                |
| 759 | $user = $this->quoteStringLiteral($user);  | 
                                |
| 760 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 761 |         } else { | 
                                |
| 762 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 763 | }  | 
                                |
| 764 | ||
| 765 | return "SELECT con.*  | 
                                |
| 766 | FROM SYS.SYSCONSTRAINT AS con  | 
                                |
| 767 | JOIN SYS.SYSTAB AS tab ON con.table_object_id = tab.object_id  | 
                                |
| 768 | WHERE tab.table_name = $table  | 
                                |
| 769 | AND tab.creator = USER_ID($user)";  | 
                                |
| 770 | }  | 
                                |
| 771 | ||
| 772 | /**  | 
                                |
| 773 |      * {@inheritdoc} | 
                                |
| @@ 775-856 (lines=82) @@ | ||
| 772 | /**  | 
                                |
| 773 |      * {@inheritdoc} | 
                                |
| 774 | */  | 
                                |
| 775 | public function getListTableForeignKeysSQL($table)  | 
                                |
| 776 |     { | 
                                |
| 777 | $user = '';  | 
                                |
| 778 | ||
| 779 |         if (strpos($table, '.') !== false) { | 
                                |
| 780 |             list($user, $table) = explode('.', $table); | 
                                |
| 781 | $user = $this->quoteStringLiteral($user);  | 
                                |
| 782 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 783 |         } else { | 
                                |
| 784 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 785 | }  | 
                                |
| 786 | ||
| 787 | return "SELECT fcol.column_name AS local_column,  | 
                                |
| 788 | ptbl.table_name AS foreign_table,  | 
                                |
| 789 | pcol.column_name AS foreign_column,  | 
                                |
| 790 | idx.index_name,  | 
                                |
| 791 | IF fk.nulls = 'N'  | 
                                |
| 792 | THEN 1  | 
                                |
| 793 | ELSE NULL  | 
                                |
| 794 | ENDIF AS notnull,  | 
                                |
| 795 | CASE ut.referential_action  | 
                                |
| 796 | WHEN 'C' THEN 'CASCADE'  | 
                                |
| 797 | WHEN 'D' THEN 'SET DEFAULT'  | 
                                |
| 798 | WHEN 'N' THEN 'SET NULL'  | 
                                |
| 799 | WHEN 'R' THEN 'RESTRICT'  | 
                                |
| 800 | ELSE NULL  | 
                                |
| 801 | END AS on_update,  | 
                                |
| 802 | CASE dt.referential_action  | 
                                |
| 803 | WHEN 'C' THEN 'CASCADE'  | 
                                |
| 804 | WHEN 'D' THEN 'SET DEFAULT'  | 
                                |
| 805 | WHEN 'N' THEN 'SET NULL'  | 
                                |
| 806 | WHEN 'R' THEN 'RESTRICT'  | 
                                |
| 807 | ELSE NULL  | 
                                |
| 808 | END AS on_delete,  | 
                                |
| 809 | IF fk.check_on_commit = 'Y'  | 
                                |
| 810 | THEN 1  | 
                                |
| 811 | ELSE NULL  | 
                                |
| 812 | ENDIF AS check_on_commit, -- check_on_commit flag  | 
                                |
| 813 | IF ftbl.clustered_index_id = idx.index_id  | 
                                |
| 814 | THEN 1  | 
                                |
| 815 | ELSE NULL  | 
                                |
| 816 | ENDIF AS 'clustered', -- clustered flag  | 
                                |
| 817 | IF fk.match_type = 0  | 
                                |
| 818 | THEN NULL  | 
                                |
| 819 | ELSE fk.match_type  | 
                                |
| 820 | ENDIF AS 'match', -- match option  | 
                                |
| 821 | IF pidx.max_key_distance = 1  | 
                                |
| 822 | THEN 1  | 
                                |
| 823 | ELSE NULL  | 
                                |
| 824 | ENDIF AS for_olap_workload -- for_olap_workload flag  | 
                                |
| 825 | FROM SYS.SYSFKEY AS fk  | 
                                |
| 826 | JOIN SYS.SYSIDX AS idx  | 
                                |
| 827 | ON fk.foreign_table_id = idx.table_id  | 
                                |
| 828 | AND fk.foreign_index_id = idx.index_id  | 
                                |
| 829 | JOIN SYS.SYSPHYSIDX pidx  | 
                                |
| 830 | ON idx.table_id = pidx.table_id  | 
                                |
| 831 | AND idx.phys_index_id = pidx.phys_index_id  | 
                                |
| 832 | JOIN SYS.SYSTAB AS ptbl  | 
                                |
| 833 | ON fk.primary_table_id = ptbl.table_id  | 
                                |
| 834 | JOIN SYS.SYSTAB AS ftbl  | 
                                |
| 835 | ON fk.foreign_table_id = ftbl.table_id  | 
                                |
| 836 | JOIN SYS.SYSIDXCOL AS idxcol  | 
                                |
| 837 | ON idx.table_id = idxcol.table_id  | 
                                |
| 838 | AND idx.index_id = idxcol.index_id  | 
                                |
| 839 | JOIN SYS.SYSTABCOL AS pcol  | 
                                |
| 840 | ON ptbl.table_id = pcol.table_id  | 
                                |
| 841 | AND idxcol.primary_column_id = pcol.column_id  | 
                                |
| 842 | JOIN SYS.SYSTABCOL AS fcol  | 
                                |
| 843 | ON ftbl.table_id = fcol.table_id  | 
                                |
| 844 | AND idxcol.column_id = fcol.column_id  | 
                                |
| 845 | LEFT JOIN SYS.SYSTRIGGER ut  | 
                                |
| 846 | ON fk.foreign_table_id = ut.foreign_table_id  | 
                                |
| 847 | AND fk.foreign_index_id = ut.foreign_key_id  | 
                                |
| 848 | AND ut.event = 'C'  | 
                                |
| 849 | LEFT JOIN SYS.SYSTRIGGER dt  | 
                                |
| 850 | ON fk.foreign_table_id = dt.foreign_table_id  | 
                                |
| 851 | AND fk.foreign_index_id = dt.foreign_key_id  | 
                                |
| 852 | AND dt.event = 'D'  | 
                                |
| 853 | WHERE ftbl.table_name = $table  | 
                                |
| 854 | AND ftbl.creator = USER_ID($user)  | 
                                |
| 855 | ORDER BY fk.foreign_index_id ASC, idxcol.sequence ASC";  | 
                                |
| 856 | }  | 
                                |
| 857 | ||
| 858 | /**  | 
                                |
| 859 |      * {@inheritdoc} | 
                                |
| @@ 861-909 (lines=49) @@ | ||
| 858 | /**  | 
                                |
| 859 |      * {@inheritdoc} | 
                                |
| 860 | */  | 
                                |
| 861 | public function getListTableIndexesSQL($table, $currentDatabase = null)  | 
                                |
| 862 |     { | 
                                |
| 863 | $user = '';  | 
                                |
| 864 | ||
| 865 |         if (strpos($table, '.') !== false) { | 
                                |
| 866 |             list($user, $table) = explode('.', $table); | 
                                |
| 867 | $user = $this->quoteStringLiteral($user);  | 
                                |
| 868 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 869 |         } else { | 
                                |
| 870 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 871 | }  | 
                                |
| 872 | ||
| 873 | return "SELECT idx.index_name AS key_name,  | 
                                |
| 874 | IF idx.index_category = 1  | 
                                |
| 875 | THEN 1  | 
                                |
| 876 | ELSE 0  | 
                                |
| 877 | ENDIF AS 'primary',  | 
                                |
| 878 | col.column_name,  | 
                                |
| 879 | IF idx.\"unique\" IN(1, 2, 5)  | 
                                |
| 880 | THEN 0  | 
                                |
| 881 | ELSE 1  | 
                                |
| 882 | ENDIF AS non_unique,  | 
                                |
| 883 | IF tbl.clustered_index_id = idx.index_id  | 
                                |
| 884 | THEN 1  | 
                                |
| 885 | ELSE NULL  | 
                                |
| 886 | ENDIF AS 'clustered', -- clustered flag  | 
                                |
| 887 | IF idx.\"unique\" = 5  | 
                                |
| 888 | THEN 1  | 
                                |
| 889 | ELSE NULL  | 
                                |
| 890 | ENDIF AS with_nulls_not_distinct, -- with_nulls_not_distinct flag  | 
                                |
| 891 | IF pidx.max_key_distance = 1  | 
                                |
| 892 | THEN 1  | 
                                |
| 893 | ELSE NULL  | 
                                |
| 894 | ENDIF AS for_olap_workload -- for_olap_workload flag  | 
                                |
| 895 | FROM SYS.SYSIDX AS idx  | 
                                |
| 896 | JOIN SYS.SYSPHYSIDX pidx  | 
                                |
| 897 | ON idx.table_id = pidx.table_id  | 
                                |
| 898 | AND idx.phys_index_id = pidx.phys_index_id  | 
                                |
| 899 | JOIN SYS.SYSIDXCOL AS idxcol  | 
                                |
| 900 | ON idx.table_id = idxcol.table_id AND idx.index_id = idxcol.index_id  | 
                                |
| 901 | JOIN SYS.SYSTABCOL AS col  | 
                                |
| 902 | ON idxcol.table_id = col.table_id AND idxcol.column_id = col.column_id  | 
                                |
| 903 | JOIN SYS.SYSTAB AS tbl  | 
                                |
| 904 | ON idx.table_id = tbl.table_id  | 
                                |
| 905 | WHERE tbl.table_name = $table  | 
                                |
| 906 | AND tbl.creator = USER_ID($user)  | 
                                |
| 907 | AND idx.index_category != 2 -- exclude indexes implicitly created by foreign key constraints  | 
                                |
| 908 | ORDER BY idx.index_id ASC, idxcol.sequence ASC";  | 
                                |
| 909 | }  | 
                                |
| 910 | ||
| 911 | /**  | 
                                |
| 912 |      * {@inheritdoc} | 
                                |
| @@ 956-968 (lines=13) @@ | ||
| 953 | *  | 
                                |
| 954 | * @return string  | 
                                |
| 955 | */  | 
                                |
| 956 | private function getTableWhereClause($table, $schemaColumn, $tableColumn)  | 
                                |
| 957 |     { | 
                                |
| 958 |         if (strpos($table, ".") !== false) { | 
                                |
| 959 |             list($schema, $table) = explode(".", $table); | 
                                |
| 960 | $schema = $this->quoteStringLiteral($schema);  | 
                                |
| 961 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 962 |         } else { | 
                                |
| 963 | $schema = "SCHEMA_NAME()";  | 
                                |
| 964 | $table = $this->quoteStringLiteral($table);  | 
                                |
| 965 | }  | 
                                |
| 966 | ||
| 967 |         return "({$tableColumn} = {$table} AND {$schemaColumn} = {$schema})"; | 
                                |
| 968 | }  | 
                                |
| 969 | ||
| 970 | /**  | 
                                |
| 971 |      * {@inheritDoc} | 
                                |