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

Commitfdbd6ca

Browse files
committed
Simplify definition of pg_tables and pg_views views by making use of
new separate relkind for views (per some discussion back in September).I didn't force initdb, but rules regress test will show differencesuntil you do one.
1 parent3030189 commitfdbd6ca

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

‎src/bin/initdb/initdb.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#
2525
# Copyright (c) 1994, Regents of the University of California
2626
#
27-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.114 2000/11/14 18:37:45 tgl Exp $
27+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.115 2000/11/21 01:11:49 tgl Exp $
2828
#
2929
#-------------------------------------------------------------------------
3030

@@ -583,13 +583,11 @@ echo "CREATE VIEW pg_views AS \
583583
pg_get_userbyid(C.relowner) AS viewowner,\
584584
pg_get_viewdef(C.relname) AS definition\
585585
FROM pg_class C\
586-
WHERE C.relhasrules\
587-
ANDEXISTS (\
588-
SELECT rulename FROM pg_rewrite R\
589-
WHERE ev_class = C.oid AND ev_type = '1'\
590-
)" \
586+
WHERE C.relkind = 'v';" \
591587
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
592588

589+
# XXX why does pg_tables include sequences?
590+
593591
echo"CREATE VIEW pg_tables AS\
594592
SELECT\
595593
C.relname AS tablename,\
@@ -598,11 +596,7 @@ echo "CREATE VIEW pg_tables AS \
598596
C.relhasrules AS hasrules,\
599597
(C.reltriggers > 0) AS hastriggers\
600598
FROM pg_class C\
601-
WHERE C.relkind IN ('r', 's')\
602-
AND NOT EXISTS (\
603-
SELECT rulename FROM pg_rewrite\
604-
WHERE ev_class = C.oid AND ev_type = '1'\
605-
)" \
599+
WHERE C.relkind IN ('r', 's');" \
606600
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
607601

608602
echo"CREATE VIEW pg_indexes AS\
@@ -611,8 +605,9 @@ echo "CREATE VIEW pg_indexes AS \
611605
I.relname AS indexname,\
612606
pg_get_indexdef(X.indexrelid) AS indexdef\
613607
FROM pg_index X, pg_class C, pg_class I\
614-
WHERE C.oid = X.indrelid\
615-
AND I.oid = X.indexrelid" \
608+
WHERE C.relkind = 'r' AND I.relkind = 'i'\
609+
AND C.oid = X.indrelid\
610+
AND I.oid = X.indexrelid;" \
616611
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
617612

618613
echo"Loading pg_description."

‎src/test/regress/expected/rules.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,14 +1203,14 @@ drop table foo2;
12031203
-- Check that ruleutils are working
12041204
--
12051205
SELECT viewname, definition FROM pg_views ORDER BY viewname;
1206-
viewname |definition
1207-
--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1206+
viewname | definition
1207+
--------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
12081208
iexit | SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM ihighway ih, ramp r WHERE (ih.thepath ## r.thepath);
1209-
pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((c.oid = x.indrelid) AND (i.oid = x.indexrelid));
1209+
pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char")) AND (c.oid = x.indrelid)) AND (i.oid = x.indexrelid));
12101210
pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
1211-
pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE (((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char")) AND (NOT (EXISTS (SELECT pg_rewrite.rulename FROM pg_rewrite WHERE ((pg_rewrite.ev_class = c.oid) AND (pg_rewrite.ev_type = '1'::"char"))))));
1211+
pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE ((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char"));
12121212
pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
1213-
pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relhasrules AND (EXISTS (SELECT r.rulename FROM pg_rewrite r WHERE ((r.ev_class = c.oid) AND (r.ev_type = '1'::"char")))));
1213+
pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relkind = 'v'::"char");
12141214
rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
12151215
rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
12161216
rtest_vview1 | SELECT x.a, x.b FROM rtest_view1 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp