Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ea6d0f

Browse files
committed
Information schema fixes:
Use pg_get_constraintdef instead of pg_constraint.consrcUse UNION ALL instread of UNIONMake use of regclass type for getting OID of system catalogsAdd schema qualifications where necessaryFix typos
1 parentf2f7107 commit9ea6d0f

File tree

1 file changed

+66
-65
lines changed

1 file changed

+66
-65
lines changed

‎src/backend/catalog/information_schema.sql

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright 2003, PostgreSQL Global Development Group
66
*
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 $
88
*/
99

1010
/*
@@ -102,7 +102,8 @@ CREATE VIEW check_constraints AS
102102
SELECT CAST(current_database()AS sql_identifier)AS constraint_catalog,
103103
CAST(rs.nspnameAS sql_identifier)AS constraint_schema,
104104
CAST(con.connameAS sql_identifier)AS constraint_name,
105-
CAST(con.consrcAS character_data)AS check_clause
105+
CAST(substring(pg_get_constraintdef(con.oid)from7)AS character_data)
106+
AS check_clause
106107
FROM pg_namespace rs,
107108
pg_constraint con
108109
LEFT OUTER JOIN pg_class cON (c.oid=con.conrelid)
@@ -172,12 +173,12 @@ CREATE VIEW column_privileges AS
172173
pg_user u_grantor,
173174
(
174175
SELECT usesysid,0, usenameFROM pg_user
175-
UNION
176+
UNION ALL
176177
SELECT0, grosysid, gronameFROM pg_group
177-
UNION
178+
UNION ALL
178179
SELECT0,0,'PUBLIC'
179180
)AS grantee (usesysid, grosysid, name),
180-
(SELECT'SELECT'UNIONSELECT'INSERT'UNIONSELECT'UPDATE'UNIONSELECT'REFERENCES')AS pr (type)
181+
(SELECT'SELECT'UNIONALLSELECT'INSERT'UNIONALLSELECT'UPDATE'UNION ALLSELECT'REFERENCES')AS pr (type)
181182

182183
WHEREa.attrelid=c.oid
183184
ANDc.relnamespace=nc.oid
@@ -403,29 +404,29 @@ CREATE VIEW constraint_column_usage AS
403404
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_depend d, pg_namespace nc, pg_constraint c
404405
WHEREnr.oid=r.relnamespace
405406
ANDr.oid=a.attrelid
406-
ANDd.refclassid=(SELECToidFROM pg_classWHERE relname='pg_class')
407+
ANDd.refclassid='pg_catalog.pg_class'::regclass
407408
ANDd.refobjid=r.oid
408409
ANDd.refobjsubid=a.attnum
409-
ANDd.classid=(SELECToidFROM pg_classWHERE relname='pg_constraint')
410+
ANDd.classid='pg_catalog.pg_constraint'::regclass
410411
ANDd.objid=c.oid
411412
ANDc.connamespace=nc.oid
412413
ANDc.contype='c'
413414
ANDr.relkind='r'
414415
ANDa.attnum>0
415416
AND NOTa.attisdropped
416417

417-
UNION
418+
UNION ALL
418419

419420
/* unique/primary key/foreign key constraints*/
420421
SELECTnr.nspname,r.relname,r.relowner,a.attname,nc.nspname,c.conname
421422
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_namespace nc, pg_constraint c,
422-
(select1unionselect2unionselect3unionselect4unionselect5union
423-
select6unionselect7unionselect8unionselect9unionselect10union
424-
select11unionselect12unionselect13unionselect14unionselect15union
425-
select16unionselect17unionselect18unionselect19unionselect20union
426-
select21unionselect22unionselect23unionselect24unionselect25union
427-
select26unionselect27unionselect28unionselect29unionselect30union
428-
select31unionselect32)AS pos(n)
423+
(select1unionallselect2unionallselect3unionallselect4unionallselect5union all
424+
select6unionallselect7unionallselect8unionallselect9unionallselect10union all
425+
select11unionallselect12unionallselect13unionallselect14unionallselect15union all
426+
select16unionallselect17unionallselect18unionallselect19unionallselect20union all
427+
select21unionallselect22unionallselect23unionallselect24unionallselect25union all
428+
select26unionallselect27unionallselect28unionallselect29unionallselect30union all
429+
select31unionallselect32)AS pos(n)
429430
WHEREnr.oid=r.relnamespace
430431
ANDr.oid=a.attrelid
431432
ANDr.oid=c.conrelid
@@ -660,13 +661,13 @@ CREATE VIEW key_column_usage AS
660661

661662
FROM pg_namespace nr, pg_class r, pg_attribute a, pg_namespace nc, pg_constraint c,
662663
pg_user u,
663-
(select1unionselect2unionselect3unionselect4unionselect5union
664-
select6unionselect7unionselect8unionselect9unionselect10union
665-
select11unionselect12unionselect13unionselect14unionselect15union
666-
select16unionselect17unionselect18unionselect19unionselect20union
667-
select21unionselect22unionselect23unionselect24unionselect25union
668-
select26unionselect27unionselect28unionselect29unionselect30union
669-
select31unionselect32)AS pos(n)
664+
(select1unionallselect2unionallselect3unionallselect4unionallselect5union all
665+
select6unionallselect7unionallselect8unionallselect9unionallselect10union all
666+
select11unionallselect12unionallselect13unionallselect14unionallselect15union all
667+
select16unionallselect17unionallselect18unionallselect19unionallselect20union all
668+
select21unionallselect22unionallselect23unionallselect24unionallselect25union all
669+
select26unionallselect27unionallselect28unionallselect29unionallselect30union all
670+
select31unionallselect32)AS pos(n)
670671

671672
WHEREnr.oid=r.relnamespace
672673
ANDr.oid=a.attrelid
@@ -726,13 +727,13 @@ CREATE VIEW parameters AS
726727
CAST(n+1AS sql_identifier)AS dtd_identifier
727728

728729
FROM pg_namespace n, pg_proc p, pg_type t, pg_namespace nt, pg_user u,
729-
(select0unionselect1unionselect2unionselect3unionselect4union
730-
select5unionselect6unionselect7unionselect8unionselect9union
731-
select10unionselect11unionselect12unionselect13unionselect14union
732-
select15unionselect16unionselect17unionselect18unionselect19union
733-
select20unionselect21unionselect22unionselect23unionselect24union
734-
select25unionselect26unionselect27unionselect28unionselect29union
735-
select30unionselect31)AS pos(n)
730+
(select0unionallselect1unionallselect2unionallselect3unionallselect4union all
731+
select5unionallselect6unionallselect7unionallselect8unionallselect9union all
732+
select10unionallselect11unionallselect12unionallselect13unionallselect14union all
733+
select15unionallselect16unionallselect17unionallselect18unionallselect19union all
734+
select20unionallselect21unionallselect22unionallselect23unionallselect24union all
735+
select25unionallselect26unionallselect27unionallselect28unionallselect29union all
736+
select30unionallselect31)AS pos(n)
736737

737738
WHEREn.oid=p.pronamespaceANDp.pronargs>pos.n
738739
ANDp.proargtypes[n]=t.oidANDt.typnamespace=nt.oid
@@ -751,13 +752,13 @@ CREATE FUNCTION _pg_keyissubset(smallint[], smallint[]) RETURNS boolean
751752
LANGUAGE sql
752753
IMMUTABLE
753754
RETURNSNULLONNULL 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))';
755756

756757
CREATEFUNCTION_pg_keysequal(smallint[],smallint[]) RETURNSboolean
757758
LANGUAGE sql
758759
IMMUTABLE
759760
RETURNSNULLONNULL INPUT
760-
AS'select _pg_keyissubset($1, $2) and _pg_keyissubset($2, $1)';
761+
AS'selectinformation_schema._pg_keyissubset($1, $2) andinformation_schema._pg_keyissubset($2, $1)';
761762

762763
CREATEVIEWreferential_constraintsAS
763764
SELECT CAST(current_database()AS sql_identifier)AS constraint_catalog,
@@ -830,7 +831,7 @@ CREATE VIEW role_column_grants AS
830831
pg_namespace nc,
831832
pg_user u_grantor,
832833
pg_group g_grantee,
833-
(SELECT'SELECT'UNIONSELECT'INSERT'UNIONSELECT'UPDATE'UNIONSELECT'REFERENCES')AS pr (type)
834+
(SELECT'SELECT'UNIONALLSELECT'INSERT'UNIONALLSELECT'UPDATE'UNION ALLSELECT'REFERENCES')AS pr (type)
834835

835836
WHEREa.attrelid=c.oid
836837
ANDc.relnamespace=nc.oid
@@ -899,8 +900,8 @@ CREATE VIEW role_table_grants AS
899900
pg_namespace nc,
900901
pg_user u_grantor,
901902
pg_group g_grantee,
902-
(SELECT'SELECT'UNIONSELECT'DELETE'UNIONSELECT'INSERT'UNIONSELECT'UPDATE'
903-
UNIONSELECT'REFERENCES'UNIONSELECT'RULE'UNIONSELECT'TRIGGER')AS pr (type)
903+
(SELECT'SELECT'UNIONALLSELECT'DELETE'UNIONALLSELECT'INSERT'UNION ALLSELECT'UPDATE'
904+
UNIONALLSELECT'REFERENCES'UNIONALLSELECT'RULE'UNION ALLSELECT'TRIGGER')AS pr (type)
904905

905906
WHEREc.relnamespace=nc.oid
906907
ANDc.relkindIN ('r','v')
@@ -958,9 +959,9 @@ CREATE VIEW routine_privileges AS
958959
pg_user u_grantor,
959960
(
960961
SELECT usesysid,0, usenameFROM pg_user
961-
UNION
962+
UNION ALL
962963
SELECT0, grosysid, gronameFROM pg_group
963-
UNION
964+
UNION ALL
964965
SELECT0,0,'PUBLIC'
965966
)AS grantee (usesysid, grosysid, name)
966967

@@ -1118,7 +1119,7 @@ INSERT INTO sql_implementation_info VALUES ('23', 'CURSOR COMMIT BEHAVIOR', 1
11181119
INSERT INTO sql_implementation_infoVALUES ('2','DATA SOURCE NAME',NULL,'',NULL);
11191120
INSERT INTO sql_implementation_infoVALUES ('17','DBMS NAME',NULL, (selecttrim(trailing''fromsubstring(version()from'^[^0-9]*'))),NULL);
11201121
INSERT INTO sql_implementation_infoVALUES ('18','DBMS VERSION',NULL,'???',NULL);-- filled by initdb
1121-
INSERT INTO sql_implementation_infoVALUES ('26','DEFAULT TRANSACTION ISOLATION',2,NULL,'READCOMMITED; user-settable');
1122+
INSERT INTO sql_implementation_infoVALUES ('26','DEFAULT TRANSACTION ISOLATION',2,NULL,'READCOMMITTED; user-settable');
11221123
INSERT INTO sql_implementation_infoVALUES ('28','IDENTIFIER CASE',3,NULL,'stored in mixed case - case sensitive');
11231124
INSERT INTO sql_implementation_infoVALUES ('85','NULL COLLATION',0,NULL,'nulls higher than non-nulls');
11241125
INSERT INTO sql_implementation_infoVALUES ('13','SERVER NAME',NULL,'',NULL);
@@ -1194,7 +1195,7 @@ INSERT INTO sql_sizing VALUES (34, 'MAXIMUM CATALOG NAME LENGTH', 63, NULL);
11941195
INSERT INTO sql_sizingVALUES (30,'MAXIMUM COLUMN NAME LENGTH',63,NULL);
11951196
INSERT INTO sql_sizingVALUES (97,'MAXIMUM COLUMNS IN GROUP BY',0,NULL);
11961197
INSERT INTO sql_sizingVALUES (99,'MAXIMUM COLUMNS IN ORDER BY',0,NULL);
1197-
INSERT INTO sql_sizingVALUES (100,'MAXIMUM COLUMNS IN SELECT',0,NULL);
1198+
INSERT INTO sql_sizingVALUES (100,'MAXIMUM COLUMNS IN SELECT',1664,NULL);-- match MaxTupleAttributeNumber
11981199
INSERT INTO sql_sizingVALUES (101,'MAXIMUM COLUMNS IN TABLE',1600,NULL);-- match MaxHeapAttributeNumber
11991200
INSERT INTO sql_sizingVALUES (1,'MAXIMUM CONCURRENT ACTIVITIES',0,NULL);
12001201
INSERT INTO sql_sizingVALUES (31,'MAXIMUM CURSOR NAME LENGTH',63,NULL);
@@ -1304,13 +1305,13 @@ CREATE VIEW table_privileges AS
13041305
pg_user u_grantor,
13051306
(
13061307
SELECT usesysid,0, usenameFROM pg_user
1307-
UNION
1308+
UNION ALL
13081309
SELECT0, grosysid, gronameFROM pg_group
1309-
UNION
1310+
UNION ALL
13101311
SELECT0,0,'PUBLIC'
13111312
)AS grantee (usesysid, grosysid, name),
1312-
(SELECT'SELECT'UNIONSELECT'DELETE'UNIONSELECT'INSERT'UNIONSELECT'UPDATE'
1313-
UNIONSELECT'REFERENCES'UNIONSELECT'RULE'UNIONSELECT'TRIGGER')AS pr (type)
1313+
(SELECT'SELECT'UNIONALLSELECT'DELETE'UNIONALLSELECT'INSERT'UNION ALLSELECT'UPDATE'
1314+
UNIONALLSELECT'REFERENCES'UNIONALLSELECT'RULE'UNION ALLSELECT'TRIGGER')AS pr (type)
13141315

13151316
WHEREc.relnamespace=nc.oid
13161317
ANDc.relkindIN ('r','v')
@@ -1413,7 +1414,7 @@ CREATE VIEW triggers AS
14131414
CAST(nullAS sql_identifier)AS condition_reference_new_table
14141415

14151416
FROM pg_namespace n, pg_class c, pg_trigger t, pg_user u,
1416-
(SELECT4,'INSERT'UNIONSELECT8,'DELETE'UNIONSELECT16,'UPDATE')AS em (num,text)
1417+
(SELECT4,'INSERT'UNIONALLSELECT8,'DELETE'UNION ALLSELECT16,'UPDATE')AS em (num,text)
14171418

14181419
WHEREn.oid=c.relnamespace
14191420
ANDc.oid=t.tgrelid
@@ -1477,13 +1478,13 @@ CREATE VIEW view_column_usage AS
14771478
WHEREnv.oid=v.relnamespace
14781479
ANDv.relkind='v'
14791480
ANDv.oid=dv.refobjid
1480-
ANDdv.refclassid=(SELECToidFROM pg_classWHERE relname='pg_class')
1481-
ANDdv.classid=(SELECToidFROM pg_classWHERE relname='pg_rewrite')
1481+
ANDdv.refclassid='pg_catalog.pg_class'::regclass
1482+
ANDdv.classid='pg_catalog.pg_rewrite'::regclass
14821483
ANDdv.deptype='i'
14831484
ANDdv.objid=dt.objid
14841485
ANDdv.refobjid<>dt.refobjid
1485-
ANDdt.classid=(SELECToidFROM pg_classWHERE relname='pg_rewrite')
1486-
ANDdt.refclassid=(SELECToidFROM pg_classWHERE relname='pg_class')
1486+
ANDdt.classid='pg_catalog.pg_rewrite'::regclass
1487+
ANDdt.refclassid='pg_catalog.pg_class'::regclass
14871488
ANDdt.refobjid=t.oid
14881489
ANDt.relnamespace=nt.oid
14891490
ANDt.relkindIN ('r','v')
@@ -1515,13 +1516,13 @@ CREATE VIEW view_table_usage AS
15151516
WHEREnv.oid=v.relnamespace
15161517
ANDv.relkind='v'
15171518
ANDv.oid=dv.refobjid
1518-
ANDdv.refclassid=(SELECToidFROM pg_classWHERE relname='pg_class')
1519-
ANDdv.classid=(SELECToidFROM pg_classWHERE relname='pg_rewrite')
1519+
ANDdv.refclassid='pg_catalog.pg_class'::regclass
1520+
ANDdv.classid='pg_catalog.pg_rewrite'::regclass
15201521
ANDdv.deptype='i'
15211522
ANDdv.objid=dt.objid
15221523
ANDdv.refobjid<>dt.refobjid
1523-
ANDdt.classid=(SELECToidFROM pg_classWHERE relname='pg_rewrite')
1524-
ANDdt.refclassid=(SELECToidFROM pg_classWHERE relname='pg_class')
1524+
ANDdt.classid='pg_catalog.pg_rewrite'::regclass
1525+
ANDdt.refclassid='pg_catalog.pg_class'::regclass
15251526
ANDdt.refobjid=t.oid
15261527
ANDt.relnamespace=nt.oid
15271528
ANDt.relkindIN ('r','v')
@@ -1582,11 +1583,11 @@ CREATE VIEW data_type_privileges AS
15821583
FROM
15831584
(
15841585
SELECT table_schema, table_name,'TABLE'::text, dtd_identifierFROM columns
1585-
UNION
1586+
UNION ALL
15861587
SELECT domain_schema, domain_name,'DOMAIN'::text, dtd_identifierFROM domains
1587-
UNION
1588+
UNION ALL
15881589
SELECT specific_schema, specific_name,'ROUTINE'::text, dtd_identifierFROM parameters
1589-
UNION
1590+
UNION ALL
15901591
SELECT specific_schema, specific_name,'ROUTINE'::text, dtd_identifierFROM routines
15911592
)AS x (objschema, objname, objtype, objdtdid);
15921593

@@ -1645,28 +1646,28 @@ CREATE VIEW element_types AS
16451646
ANDc.relkindIN ('r','v')
16461647
AND attnum>0AND NOT attisdropped
16471648

1648-
UNION
1649+
UNION ALL
16491650

16501651
/* domains*/
16511652
SELECTt.typnamespace,t.typname,'DOMAIN'::text,1,t.typbasetype
16521653
FROM pg_type t
16531654
WHEREt.typtype='d'
16541655

1655-
UNION
1656+
UNION ALL
16561657

16571658
/* parameters*/
16581659
SELECTp.pronamespace,p.proname,'ROUTINE'::text,pos.n+1,p.proargtypes[n]
16591660
FROM pg_proc p,
1660-
(select0unionselect1unionselect2unionselect3unionselect4union
1661-
select5unionselect6unionselect7unionselect8unionselect9union
1662-
select10unionselect11unionselect12unionselect13unionselect14union
1663-
select15unionselect16unionselect17unionselect18unionselect19union
1664-
select20unionselect21unionselect22unionselect23unionselect24union
1665-
select25unionselect26unionselect27unionselect28unionselect29union
1666-
select30unionselect31)AS pos(n)
1661+
(select0unionallselect1unionallselect2unionallselect3unionallselect4union all
1662+
select5unionallselect6unionallselect7unionallselect8unionallselect9union all
1663+
select10unionallselect11unionallselect12unionallselect13unionallselect14union all
1664+
select15unionallselect16unionallselect17unionallselect18unionallselect19union all
1665+
select20unionallselect21unionallselect22unionallselect23unionallselect24union all
1666+
select25unionallselect26unionallselect27unionallselect28unionallselect29union all
1667+
select30unionallselect31)AS pos(n)
16671668
WHEREp.pronargs>pos.n
16681669

1669-
UNION
1670+
UNION ALL
16701671

16711672
/* result types*/
16721673
SELECTp.pronamespace,p.proname,'ROUTINE'::text,0,p.prorettype
@@ -1680,7 +1681,7 @@ CREATE VIEW element_types AS
16801681
ANDat.typelem=bt.oid
16811682
ANDnbt.oid=bt.typnamespace
16821683

1683-
AND (n.nspname,x.objname,x.objtype,x.objtypeid)IN
1684+
AND (n.nspname,x.objname,x.objtype,x.objdtdid)IN
16841685
(SELECT object_schema, object_name, object_type, dtd_identifier
16851686
FROM data_type_privileges );
16861687

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp