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

Commit44430db

Browse files
committed
Fix bugs in referential_constraints view.
1 parent4a48c67 commit44430db

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

‎doc/src/sgml/information_schema.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/information_schema.sgml,v 1.9 2003/09/20 20:12:05 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/information_schema.sgml,v 1.10 2003/10/16 23:46:17 petere Exp $ -->
22

33
<chapter id="information-schema">
44
<title>The Information Schema</title>
@@ -2146,7 +2146,7 @@ ORDER BY c.ordinal_position;
21462146
<entry>
21472147
Update rule of the foreign key constraint:
21482148
<literal>CASCADE</literal>, <literal>SET NULL</literal>,
2149-
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
2149+
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
21502150
<literal>NO ACTION</literal>.
21512151
</entry>
21522152
</row>
@@ -2157,7 +2157,7 @@ ORDER BY c.ordinal_position;
21572157
<entry>
21582158
Delete rule of the foreign key constraint:
21592159
<literal>CASCADE</literal>, <literal>SET NULL</literal>,
2160-
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
2160+
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
21612161
<literal>NO ACTION</literal>.
21622162
</entry>
21632163
</row>

‎src/backend/catalog/information_schema.sql

Lines changed: 28 additions & 16 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.12 2003/06/29 15:14:41 petere Exp $
7+
* $Id: information_schema.sql,v 1.13 2003/10/16 23:46:17 petere Exp $
88
*/
99

1010
/*
@@ -747,11 +747,26 @@ GRANT SELECT ON parameters TO PUBLIC;
747747
* REFERENTIAL_CONSTRAINTS view
748748
*/
749749

750+
CREATEFUNCTION_pg_keyissubset(smallint[],smallint[]) RETURNSboolean
751+
LANGUAGE sql
752+
IMMUTABLE
753+
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+
756+
CREATEFUNCTION_pg_keysequal(smallint[],smallint[]) RETURNSboolean
757+
LANGUAGE sql
758+
IMMUTABLE
759+
RETURNSNULLONNULL INPUT
760+
AS'select _pg_keyissubset($1, $2) and _pg_keyissubset($2, $1)';
761+
750762
CREATEVIEWreferential_constraintsAS
751763
SELECT CAST(current_database()AS sql_identifier)AS constraint_catalog,
752764
CAST(ncon.nspnameAS sql_identifier)AS constraint_schema,
753765
CAST(con.connameAS sql_identifier)AS constraint_name,
754-
CAST(current_database()AS sql_identifier)AS unique_constraint_catalog,
766+
CAST(
767+
CASE WHENnpkc.nspname ISNULL THENNULL
768+
ELSE current_database() END
769+
AS sql_identifier)AS unique_constraint_catalog,
755770
CAST(npkc.nspnameAS sql_identifier)AS unique_constraint_schema,
756771
CAST(pkc.connameAS sql_identifier)AS unique_constraint_name,
757772

@@ -766,30 +781,27 @@ CREATE VIEW referential_constraints AS
766781
WHEN'n' THEN'SET NULL'
767782
WHEN'd' THEN'SET DEFAULT'
768783
WHEN'r' THEN'RESTRICT'
769-
WHEN'a' THEN'NOACTION' END
784+
WHEN'a' THEN'NO ACTION' END
770785
AS character_data)AS update_rule,
771786

772787
CAST(
773788
CASEcon.confdeltype WHEN'c' THEN'CASCADE'
774789
WHEN'n' THEN'SET NULL'
775790
WHEN'd' THEN'SET DEFAULT'
776791
WHEN'r' THEN'RESTRICT'
777-
WHEN'a' THEN'NOACTION' END
792+
WHEN'a' THEN'NO ACTION' END
778793
AS character_data)AS delete_rule
779794

780-
FROM pg_namespace ncon,
781-
pg_constraintcon,
782-
pg_class c,
783-
pg_constraint pkc,
784-
pg_namespace npkc,
785-
pg_user u
795+
FROM(pg_namespace nconINNER JOIN pg_constraint conONncon.oid=con.connamespace
796+
INNER JOIN pg_class cONcon.conrelid=c.oid
797+
INNER JOIN pg_user uONc.relowner=u.usesysid)
798+
LEFT JOIN
799+
(pg_constraint pkcINNER JOINpg_namespace npkcONpkc.connamespace=npkc.oid)
800+
ONcon.confrelid=pkc.conrelidAND _pg_keysequal(con.confkey,pkc.conkey)
786801

787-
WHEREncon.oid=con.connamespace
788-
ANDcon.conrelid=c.oid
789-
ANDcon.confkey=pkc.conkey
790-
ANDpkc.connamespace=npkc.oid
791-
ANDc.relowner=u.usesysid
792-
ANDc.relkind='r'
802+
WHEREc.relkind='r'
803+
ANDcon.contype='f'
804+
AND (pkc.contypeIN ('p','u')ORpkc.contype ISNULL)
793805
ANDu.usename=current_user;
794806

795807
GRANTSELECTON referential_constraints TO PUBLIC;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp