4
4
*
5
5
* Copyright 2003, PostgreSQL Global Development Group
6
6
*
7
- * $Id: information_schema.sql,v 1.13 2003/10/16 23:46:17 petere Exp $
7
+ * $Id: information_schema.sql,v 1.14 2003/10/18 12:53:35 petere Exp $
8
8
*/
9
9
10
10
/*
@@ -102,7 +102,8 @@ CREATE VIEW check_constraints AS
102
102
SELECT CAST(current_database() AS sql_identifier) AS constraint_catalog,
103
103
CAST(rs .nspname AS sql_identifier) AS constraint_schema,
104
104
CAST(con .conname AS sql_identifier) AS constraint_name,
105
- CAST(con .consrc AS character_data) AS check_clause
105
+ CAST(substring (pg_get_constraintdef(con .oid ) from 7 ) AS character_data)
106
+ AS check_clause
106
107
FROM pg_namespace rs,
107
108
pg_constraint con
108
109
LEFT OUTER JOIN pg_class c ON (c .oid = con .conrelid )
@@ -172,12 +173,12 @@ CREATE VIEW column_privileges AS
172
173
pg_user u_grantor,
173
174
(
174
175
SELECT usesysid, 0 , usename FROM pg_user
175
- UNION
176
+ UNION ALL
176
177
SELECT 0 , grosysid, groname FROM pg_group
177
- UNION
178
+ UNION ALL
178
179
SELECT 0 , 0 , ' PUBLIC'
179
180
) AS grantee (usesysid, grosysid, name),
180
- (SELECT ' SELECT' UNION SELECT ' INSERT' UNION SELECT ' UPDATE' UNION SELECT ' REFERENCES' ) AS pr (type)
181
+ (SELECT ' SELECT' UNION ALL SELECT ' INSERT' UNION ALL SELECT ' UPDATE' UNION ALL SELECT ' REFERENCES' ) AS pr (type)
181
182
182
183
WHERE a .attrelid = c .oid
183
184
AND c .relnamespace = nc .oid
@@ -403,29 +404,29 @@ CREATE VIEW constraint_column_usage AS
403
404
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_depend d, pg_namespace nc, pg_constraint c
404
405
WHERE nr .oid = r .relnamespace
405
406
AND r .oid = a .attrelid
406
- AND d .refclassid = ( SELECT oid FROM pg_class WHERE relname = ' pg_class' )
407
+ AND d .refclassid = ' pg_catalog. pg_class' ::regclass
407
408
AND d .refobjid = r .oid
408
409
AND d .refobjsubid = a .attnum
409
- AND d .classid = ( SELECT oid FROM pg_class WHERE relname = ' pg_constraint' )
410
+ AND d .classid = ' pg_catalog. pg_constraint' ::regclass
410
411
AND d .objid = c .oid
411
412
AND c .connamespace = nc .oid
412
413
AND c .contype = ' c'
413
414
AND r .relkind = ' r'
414
415
AND a .attnum > 0
415
416
AND NOT a .attisdropped
416
417
417
- UNION
418
+ UNION ALL
418
419
419
420
/* unique/primary key/foreign key constraints */
420
421
SELECT nr .nspname , r .relname , r .relowner , a .attname , nc .nspname , c .conname
421
422
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_namespace nc, pg_constraint c,
422
- (select 1 union select 2 union select 3 union select 4 union select 5 union
423
- select 6 union select 7 union select 8 union select 9 union select 10 union
424
- select 11 union select 12 union select 13 union select 14 union select 15 union
425
- select 16 union select 17 union select 18 union select 19 union select 20 union
426
- select 21 union select 22 union select 23 union select 24 union select 25 union
427
- select 26 union select 27 union select 28 union select 29 union select 30 union
428
- select 31 union select 32 ) AS pos(n)
423
+ (select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all
424
+ select 6 union all select 7 union all select 8 union all select 9 union all select 10 union all
425
+ select 11 union all select 12 union all select 13 union all select 14 union all select 15 union all
426
+ select 16 union all select 17 union all select 18 union all select 19 union all select 20 union all
427
+ select 21 union all select 22 union all select 23 union all select 24 union all select 25 union all
428
+ select 26 union all select 27 union all select 28 union all select 29 union all select 30 union all
429
+ select 31 union all select 32 ) AS pos(n)
429
430
WHERE nr .oid = r .relnamespace
430
431
AND r .oid = a .attrelid
431
432
AND r .oid = c .conrelid
@@ -660,13 +661,13 @@ CREATE VIEW key_column_usage AS
660
661
661
662
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_namespace nc, pg_constraint c,
662
663
pg_user u,
663
- (select 1 union select 2 union select 3 union select 4 union select 5 union
664
- select 6 union select 7 union select 8 union select 9 union select 10 union
665
- select 11 union select 12 union select 13 union select 14 union select 15 union
666
- select 16 union select 17 union select 18 union select 19 union select 20 union
667
- select 21 union select 22 union select 23 union select 24 union select 25 union
668
- select 26 union select 27 union select 28 union select 29 union select 30 union
669
- select 31 union select 32 ) AS pos(n)
664
+ (select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all
665
+ select 6 union all select 7 union all select 8 union all select 9 union all select 10 union all
666
+ select 11 union all select 12 union all select 13 union all select 14 union all select 15 union all
667
+ select 16 union all select 17 union all select 18 union all select 19 union all select 20 union all
668
+ select 21 union all select 22 union all select 23 union all select 24 union all select 25 union all
669
+ select 26 union all select 27 union all select 28 union all select 29 union all select 30 union all
670
+ select 31 union all select 32 ) AS pos(n)
670
671
671
672
WHERE nr .oid = r .relnamespace
672
673
AND r .oid = a .attrelid
@@ -726,13 +727,13 @@ CREATE VIEW parameters AS
726
727
CAST(n + 1 AS sql_identifier) AS dtd_identifier
727
728
728
729
FROM pg_namespace n, pg_proc p, pg_type t, pg_namespace nt, pg_user u,
729
- (select 0 union select 1 union select 2 union select 3 union select 4 union
730
- select 5 union select 6 union select 7 union select 8 union select 9 union
731
- select 10 union select 11 union select 12 union select 13 union select 14 union
732
- select 15 union select 16 union select 17 union select 18 union select 19 union
733
- select 20 union select 21 union select 22 union select 23 union select 24 union
734
- select 25 union select 26 union select 27 union select 28 union select 29 union
735
- select 30 union select 31 ) AS pos(n)
730
+ (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all
731
+ select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all
732
+ select 10 union all select 11 union all select 12 union all select 13 union all select 14 union all
733
+ select 15 union all select 16 union all select 17 union all select 18 union all select 19 union all
734
+ select 20 union all select 21 union all select 22 union all select 23 union all select 24 union all
735
+ select 25 union all select 26 union all select 27 union all select 28 union all select 29 union all
736
+ select 30 union all select 31 ) AS pos(n)
736
737
737
738
WHERE n .oid = p .pronamespace AND p .pronargs > pos .n
738
739
AND p .proargtypes [n] = t .oid AND t .typnamespace = nt .oid
@@ -751,13 +752,13 @@ CREATE FUNCTION _pg_keyissubset(smallint[], smallint[]) RETURNS boolean
751
752
LANGUAGE sql
752
753
IMMUTABLE
753
754
RETURNS NULL ON NULL INPUT
754
- AS ' select $1[1] is null or ($1[1] = any ($2) and coalesce(_pg_keyissubset($1[2:array_upper($1,1)], $2), true))' ;
755
+ AS ' select $1[1] is null or ($1[1] = any ($2) and coalesce(information_schema. _pg_keyissubset($1[2:array_upper($1,1)], $2), true))' ;
755
756
756
757
CREATE FUNCTION _pg_keysequal (smallint [], smallint []) RETURNS boolean
757
758
LANGUAGE sql
758
759
IMMUTABLE
759
760
RETURNS NULL ON NULL INPUT
760
- AS ' select _pg_keyissubset($1, $2) and _pg_keyissubset($2, $1)' ;
761
+ AS ' select information_schema. _pg_keyissubset($1, $2) and information_schema. _pg_keyissubset($2, $1)' ;
761
762
762
763
CREATE VIEW referential_constraints AS
763
764
SELECT CAST(current_database() AS sql_identifier) AS constraint_catalog,
@@ -830,7 +831,7 @@ CREATE VIEW role_column_grants AS
830
831
pg_namespace nc,
831
832
pg_user u_grantor,
832
833
pg_group g_grantee,
833
- (SELECT ' SELECT' UNION SELECT ' INSERT' UNION SELECT ' UPDATE' UNION SELECT ' REFERENCES' ) AS pr (type)
834
+ (SELECT ' SELECT' UNION ALL SELECT ' INSERT' UNION ALL SELECT ' UPDATE' UNION ALL SELECT ' REFERENCES' ) AS pr (type)
834
835
835
836
WHERE a .attrelid = c .oid
836
837
AND c .relnamespace = nc .oid
@@ -899,8 +900,8 @@ CREATE VIEW role_table_grants AS
899
900
pg_namespace nc,
900
901
pg_user u_grantor,
901
902
pg_group g_grantee,
902
- (SELECT ' SELECT' UNION SELECT ' DELETE' UNION SELECT ' INSERT' UNION SELECT ' UPDATE'
903
- UNION SELECT ' REFERENCES' UNION SELECT ' RULE' UNION SELECT ' TRIGGER' ) AS pr (type)
903
+ (SELECT ' SELECT' UNION ALL SELECT ' DELETE' UNION ALL SELECT ' INSERT' UNION ALL SELECT ' UPDATE'
904
+ UNION ALL SELECT ' REFERENCES' UNION ALL SELECT ' RULE' UNION ALL SELECT ' TRIGGER' ) AS pr (type)
904
905
905
906
WHERE c .relnamespace = nc .oid
906
907
AND c .relkind IN (' r' , ' v' )
@@ -958,9 +959,9 @@ CREATE VIEW routine_privileges AS
958
959
pg_user u_grantor,
959
960
(
960
961
SELECT usesysid, 0 , usename FROM pg_user
961
- UNION
962
+ UNION ALL
962
963
SELECT 0 , grosysid, groname FROM pg_group
963
- UNION
964
+ UNION ALL
964
965
SELECT 0 , 0 , ' PUBLIC'
965
966
) AS grantee (usesysid, grosysid, name)
966
967
@@ -1118,7 +1119,7 @@ INSERT INTO sql_implementation_info VALUES ('23', 'CURSOR COMMIT BEHAVIOR', 1
1118
1119
INSERT INTO sql_implementation_info VALUES (' 2' , ' DATA SOURCE NAME' , NULL , ' ' , NULL );
1119
1120
INSERT INTO sql_implementation_info VALUES (' 17' , ' DBMS NAME' , NULL , (select trim (trailing ' ' from substring (version() from ' ^[^0-9]*' ))), NULL );
1120
1121
INSERT INTO sql_implementation_info VALUES (' 18' , ' DBMS VERSION' , NULL , ' ???' , NULL ); -- filled by initdb
1121
- INSERT INTO sql_implementation_info VALUES (' 26' , ' DEFAULT TRANSACTION ISOLATION' , 2 , NULL , ' READ COMMITED ; user-settable' );
1122
+ INSERT INTO sql_implementation_info VALUES (' 26' , ' DEFAULT TRANSACTION ISOLATION' , 2 , NULL , ' READ COMMITTED ; user-settable' );
1122
1123
INSERT INTO sql_implementation_info VALUES (' 28' , ' IDENTIFIER CASE' , 3 , NULL , ' stored in mixed case - case sensitive' );
1123
1124
INSERT INTO sql_implementation_info VALUES (' 85' , ' NULL COLLATION' , 0 , NULL , ' nulls higher than non-nulls' );
1124
1125
INSERT INTO sql_implementation_info VALUES (' 13' , ' SERVER NAME' , NULL , ' ' , NULL );
@@ -1194,7 +1195,7 @@ INSERT INTO sql_sizing VALUES (34, 'MAXIMUM CATALOG NAME LENGTH', 63, NULL);
1194
1195
INSERT INTO sql_sizing VALUES (30 , ' MAXIMUM COLUMN NAME LENGTH' , 63 , NULL );
1195
1196
INSERT INTO sql_sizing VALUES (97 , ' MAXIMUM COLUMNS IN GROUP BY' , 0 , NULL );
1196
1197
INSERT INTO sql_sizing VALUES (99 , ' MAXIMUM COLUMNS IN ORDER BY' , 0 , NULL );
1197
- INSERT INTO sql_sizing VALUES (100 , ' MAXIMUM COLUMNS IN SELECT' , 0 , NULL );
1198
+ INSERT INTO sql_sizing VALUES (100 , ' MAXIMUM COLUMNS IN SELECT' , 1664 , NULL ); -- match MaxTupleAttributeNumber
1198
1199
INSERT INTO sql_sizing VALUES (101 , ' MAXIMUM COLUMNS IN TABLE' , 1600 , NULL ); -- match MaxHeapAttributeNumber
1199
1200
INSERT INTO sql_sizing VALUES (1 , ' MAXIMUM CONCURRENT ACTIVITIES' , 0 , NULL );
1200
1201
INSERT INTO sql_sizing VALUES (31 , ' MAXIMUM CURSOR NAME LENGTH' , 63 , NULL );
@@ -1304,13 +1305,13 @@ CREATE VIEW table_privileges AS
1304
1305
pg_user u_grantor,
1305
1306
(
1306
1307
SELECT usesysid, 0 , usename FROM pg_user
1307
- UNION
1308
+ UNION ALL
1308
1309
SELECT 0 , grosysid, groname FROM pg_group
1309
- UNION
1310
+ UNION ALL
1310
1311
SELECT 0 , 0 , ' PUBLIC'
1311
1312
) AS grantee (usesysid, grosysid, name),
1312
- (SELECT ' SELECT' UNION SELECT ' DELETE' UNION SELECT ' INSERT' UNION SELECT ' UPDATE'
1313
- UNION SELECT ' REFERENCES' UNION SELECT ' RULE' UNION SELECT ' TRIGGER' ) AS pr (type)
1313
+ (SELECT ' SELECT' UNION ALL SELECT ' DELETE' UNION ALL SELECT ' INSERT' UNION ALL SELECT ' UPDATE'
1314
+ UNION ALL SELECT ' REFERENCES' UNION ALL SELECT ' RULE' UNION ALL SELECT ' TRIGGER' ) AS pr (type)
1314
1315
1315
1316
WHERE c .relnamespace = nc .oid
1316
1317
AND c .relkind IN (' r' , ' v' )
@@ -1413,7 +1414,7 @@ CREATE VIEW triggers AS
1413
1414
CAST(null AS sql_identifier) AS condition_reference_new_table
1414
1415
1415
1416
FROM pg_namespace n, pg_class c, pg_trigger t, pg_user u,
1416
- (SELECT 4 , ' INSERT' UNION SELECT 8 , ' DELETE' UNION SELECT 16 , ' UPDATE' ) AS em (num, text )
1417
+ (SELECT 4 , ' INSERT' UNION ALL SELECT 8 , ' DELETE' UNION ALL SELECT 16 , ' UPDATE' ) AS em (num, text )
1417
1418
1418
1419
WHERE n .oid = c .relnamespace
1419
1420
AND c .oid = t .tgrelid
@@ -1477,13 +1478,13 @@ CREATE VIEW view_column_usage AS
1477
1478
WHERE nv .oid = v .relnamespace
1478
1479
AND v .relkind = ' v'
1479
1480
AND v .oid = dv .refobjid
1480
- AND dv .refclassid = ( SELECT oid FROM pg_class WHERE relname = ' pg_class' )
1481
- AND dv .classid = ( SELECT oid FROM pg_class WHERE relname = ' pg_rewrite' )
1481
+ AND dv .refclassid = ' pg_catalog. pg_class' ::regclass
1482
+ AND dv .classid = ' pg_catalog. pg_rewrite' ::regclass
1482
1483
AND dv .deptype = ' i'
1483
1484
AND dv .objid = dt .objid
1484
1485
AND dv .refobjid <> dt .refobjid
1485
- AND dt .classid = ( SELECT oid FROM pg_class WHERE relname = ' pg_rewrite' )
1486
- AND dt .refclassid = ( SELECT oid FROM pg_class WHERE relname = ' pg_class' )
1486
+ AND dt .classid = ' pg_catalog. pg_rewrite' ::regclass
1487
+ AND dt .refclassid = ' pg_catalog. pg_class' ::regclass
1487
1488
AND dt .refobjid = t .oid
1488
1489
AND t .relnamespace = nt .oid
1489
1490
AND t .relkind IN (' r' , ' v' )
@@ -1515,13 +1516,13 @@ CREATE VIEW view_table_usage AS
1515
1516
WHERE nv .oid = v .relnamespace
1516
1517
AND v .relkind = ' v'
1517
1518
AND v .oid = dv .refobjid
1518
- AND dv .refclassid = ( SELECT oid FROM pg_class WHERE relname = ' pg_class' )
1519
- AND dv .classid = ( SELECT oid FROM pg_class WHERE relname = ' pg_rewrite' )
1519
+ AND dv .refclassid = ' pg_catalog. pg_class' ::regclass
1520
+ AND dv .classid = ' pg_catalog. pg_rewrite' ::regclass
1520
1521
AND dv .deptype = ' i'
1521
1522
AND dv .objid = dt .objid
1522
1523
AND dv .refobjid <> dt .refobjid
1523
- AND dt .classid = ( SELECT oid FROM pg_class WHERE relname = ' pg_rewrite' )
1524
- AND dt .refclassid = ( SELECT oid FROM pg_class WHERE relname = ' pg_class' )
1524
+ AND dt .classid = ' pg_catalog. pg_rewrite' ::regclass
1525
+ AND dt .refclassid = ' pg_catalog. pg_class' ::regclass
1525
1526
AND dt .refobjid = t .oid
1526
1527
AND t .relnamespace = nt .oid
1527
1528
AND t .relkind IN (' r' , ' v' )
@@ -1582,11 +1583,11 @@ CREATE VIEW data_type_privileges AS
1582
1583
FROM
1583
1584
(
1584
1585
SELECT table_schema, table_name, ' TABLE' ::text , dtd_identifier FROM columns
1585
- UNION
1586
+ UNION ALL
1586
1587
SELECT domain_schema, domain_name, ' DOMAIN' ::text , dtd_identifier FROM domains
1587
- UNION
1588
+ UNION ALL
1588
1589
SELECT specific_schema, specific_name, ' ROUTINE' ::text , dtd_identifier FROM parameters
1589
- UNION
1590
+ UNION ALL
1590
1591
SELECT specific_schema, specific_name, ' ROUTINE' ::text , dtd_identifier FROM routines
1591
1592
) AS x (objschema, objname, objtype, objdtdid);
1592
1593
@@ -1645,28 +1646,28 @@ CREATE VIEW element_types AS
1645
1646
AND c .relkind IN (' r' , ' v' )
1646
1647
AND attnum > 0 AND NOT attisdropped
1647
1648
1648
- UNION
1649
+ UNION ALL
1649
1650
1650
1651
/* domains */
1651
1652
SELECT t .typnamespace , t .typname , ' DOMAIN' ::text , 1 , t .typbasetype
1652
1653
FROM pg_type t
1653
1654
WHERE t .typtype = ' d'
1654
1655
1655
- UNION
1656
+ UNION ALL
1656
1657
1657
1658
/* parameters */
1658
1659
SELECT p .pronamespace , p .proname , ' ROUTINE' ::text , pos .n + 1 , p .proargtypes [n]
1659
1660
FROM pg_proc p,
1660
- (select 0 union select 1 union select 2 union select 3 union select 4 union
1661
- select 5 union select 6 union select 7 union select 8 union select 9 union
1662
- select 10 union select 11 union select 12 union select 13 union select 14 union
1663
- select 15 union select 16 union select 17 union select 18 union select 19 union
1664
- select 20 union select 21 union select 22 union select 23 union select 24 union
1665
- select 25 union select 26 union select 27 union select 28 union select 29 union
1666
- select 30 union select 31 ) AS pos(n)
1661
+ (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all
1662
+ select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all
1663
+ select 10 union all select 11 union all select 12 union all select 13 union all select 14 union all
1664
+ select 15 union all select 16 union all select 17 union all select 18 union all select 19 union all
1665
+ select 20 union all select 21 union all select 22 union all select 23 union all select 24 union all
1666
+ select 25 union all select 26 union all select 27 union all select 28 union all select 29 union all
1667
+ select 30 union all select 31 ) AS pos(n)
1667
1668
WHERE p .pronargs > pos .n
1668
1669
1669
- UNION
1670
+ UNION ALL
1670
1671
1671
1672
/* result types */
1672
1673
SELECT p .pronamespace , p .proname , ' ROUTINE' ::text , 0 , p .prorettype
@@ -1680,7 +1681,7 @@ CREATE VIEW element_types AS
1680
1681
AND at .typelem = bt .oid
1681
1682
AND nbt .oid = bt .typnamespace
1682
1683
1683
- AND (n .nspname , x .objname , x .objtype , x .objtypeid ) IN
1684
+ AND (n .nspname , x .objname , x .objtype , x .objdtdid ) IN
1684
1685
( SELECT object_schema, object_name, object_type, dtd_identifier
1685
1686
FROM data_type_privileges );
1686
1687
0 commit comments