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

Commit8b358b4

Browse files
committed
Change the relkind for partitioned tables from 'P' to 'p'.
Seven of the eight other relkind codes are lower-case, so it wasn'tconsistent for this one to be upper-case. Fix it while we still can.Historical notes: the reason for the lone exception, i.e. sequences being'S', is that 's' was once used for "special" relations. Also, at one timethe partitioned-tables patch used both 'P' and 'p', but that got changed,leaving only a surprising choice behind.This also fixes a couple little bits of technical debt, such astype_sanity.sql not knowing that 'm' is a legal value for relkind.Discussion:https://postgr.es/m/27899.1488909319@sss.pgh.pa.us
1 parenta83e4b4 commit8b358b4

File tree

11 files changed

+47
-41
lines changed

11 files changed

+47
-41
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,12 +1758,15 @@
17581758
<entry><type>char</type></entry>
17591759
<entry></entry>
17601760
<entry>
1761-
<literal>r</> = ordinary table, <literal>P</> = partitioned table,
1762-
<literal>i</> = index
1763-
<literal>S</> = sequence, <literal>v</> = view,
1761+
<literal>r</> = ordinary table,
1762+
<literal>i</> = index,
1763+
<literal>S</> = sequence,
1764+
<literal>t</> = TOAST table,
1765+
<literal>v</> = view,
17641766
<literal>m</> = materialized view,
1765-
<literal>c</> = composite type, <literal>t</> = TOAST table,
1766-
<literal>f</> = foreign table
1767+
<literal>c</> = composite type,
1768+
<literal>f</> = foreign table,
1769+
<literal>p</> = partitioned table
17671770
</entry>
17681771
</row>
17691772

‎src/backend/catalog/information_schema.sql

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ CREATE VIEW attributes AS
365365
ONa.attcollation=co.oidAND (nco.nspname,co.collname)<> ('pg_catalog','default')
366366

367367
WHEREa.attnum>0AND NOTa.attisdropped
368-
ANDc.relkindin ('c')
368+
ANDc.relkindIN ('c')
369369
AND (pg_has_role(c.relowner,'USAGE')
370370
OR has_type_privilege(c.reltype,'USAGE'));
371371

@@ -453,7 +453,7 @@ CREATE VIEW check_constraints AS
453453
ANDa.attnum>0
454454
AND NOTa.attisdropped
455455
ANDa.attnotnull
456-
ANDr.relkindIN ('r','P')
456+
ANDr.relkindIN ('r','p')
457457
AND pg_has_role(r.relowner,'USAGE');
458458

459459
GRANTSELECTON check_constraints TO PUBLIC;
@@ -525,7 +525,7 @@ CREATE VIEW column_domain_usage AS
525525
ANDa.attrelid=c.oid
526526
ANDa.atttypid=t.oid
527527
ANDt.typtype='d'
528-
ANDc.relkindIN ('r','v','f','P')
528+
ANDc.relkindIN ('r','v','f','p')
529529
ANDa.attnum>0
530530
AND NOTa.attisdropped
531531
AND pg_has_role(t.typowner,'USAGE');
@@ -564,7 +564,7 @@ CREATE VIEW column_privileges AS
564564
pr_c.relowner
565565
FROM (SELECToid, relname, relnamespace, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).*
566566
FROM pg_class
567-
WHERE relkindIN ('r','v','f','P')
567+
WHERE relkindIN ('r','v','f','p')
568568
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
569569
pg_attribute a
570570
WHEREa.attrelid=pr_c.oid
@@ -586,7 +586,7 @@ CREATE VIEW column_privileges AS
586586
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
587587
pg_class c
588588
WHEREpr_a.attrelid=c.oid
589-
AND relkindIN ('r','v','f','P')
589+
AND relkindIN ('r','v','f','p')
590590
) x,
591591
pg_namespace nc,
592592
pg_authid u_grantor,
@@ -629,7 +629,8 @@ CREATE VIEW column_udt_usage AS
629629
WHEREa.attrelid=c.oid
630630
ANDa.atttypid=t.oid
631631
ANDnc.oid=c.relnamespace
632-
ANDa.attnum>0AND NOTa.attisdroppedANDc.relkindin ('r','v','f','P')
632+
ANDa.attnum>0AND NOTa.attisdropped
633+
ANDc.relkindin ('r','v','f','p')
633634
AND pg_has_role(coalesce(bt.typowner,t.typowner),'USAGE');
634635

635636
GRANTSELECTON column_udt_usage TO PUBLIC;
@@ -738,7 +739,7 @@ CREATE VIEW columns AS
738739
CAST('NEVER'AS character_data)AS is_generated,
739740
CAST(nullAS character_data)AS generation_expression,
740741

741-
CAST(CASE WHENc.relkindIN ('r','P')OR
742+
CAST(CASE WHENc.relkindIN ('r','p')OR
742743
(c.relkindIN ('v','f')AND
743744
pg_column_is_updatable(c.oid,a.attnum, false))
744745
THEN'YES' ELSE'NO' ENDAS yes_or_no)AS is_updatable
@@ -753,7 +754,8 @@ CREATE VIEW columns AS
753754

754755
WHERE (NOT pg_is_other_temp_schema(nc.oid))
755756

756-
ANDa.attnum>0AND NOTa.attisdroppedANDc.relkindin ('r','v','f','P')
757+
ANDa.attnum>0AND NOTa.attisdropped
758+
ANDc.relkindIN ('r','v','f','p')
757759

758760
AND (pg_has_role(c.relowner,'USAGE')
759761
OR has_column_privilege(c.oid,a.attnum,
@@ -789,7 +791,7 @@ CREATE VIEW constraint_column_usage AS
789791
ANDd.objid=c.oid
790792
ANDc.connamespace=nc.oid
791793
ANDc.contype='c'
792-
ANDr.relkindIN ('r','P')
794+
ANDr.relkindIN ('r','p')
793795
AND NOTa.attisdropped
794796

795797
UNION ALL
@@ -805,7 +807,7 @@ CREATE VIEW constraint_column_usage AS
805807
ANDa.attnum= ANY (CASEc.contype WHEN'f' THENc.confkey ELSEc.conkey END)
806808
AND NOTa.attisdropped
807809
ANDc.contypeIN ('p','u','f')
808-
ANDr.relkindIN ('r','P')
810+
ANDr.relkindIN ('r','p')
809811

810812
)AS x (tblschema, tblname, tblowner, colname, cstrschema, cstrname)
811813

@@ -841,7 +843,7 @@ CREATE VIEW constraint_table_usage AS
841843
WHEREc.connamespace=nc.oidANDr.relnamespace=nr.oid
842844
AND ( (c.contype='f'ANDc.confrelid=r.oid)
843845
OR (c.contypeIN ('p','u')ANDc.conrelid=r.oid) )
844-
ANDr.relkindIN ('r','P')
846+
ANDr.relkindIN ('r','p')
845847
AND pg_has_role(r.relowner,'USAGE');
846848

847849
GRANTSELECTON constraint_table_usage TO PUBLIC;
@@ -1058,7 +1060,7 @@ CREATE VIEW key_column_usage AS
10581060
ANDr.oid=c.conrelid
10591061
ANDnc.oid=c.connamespace
10601062
ANDc.contypeIN ('p','u','f')
1061-
ANDr.relkindIN ('r','P')
1063+
ANDr.relkindIN ('r','p')
10621064
AND (NOT pg_is_other_temp_schema(nr.oid)) )AS ss
10631065
WHEREss.roid=a.attrelid
10641066
ANDa.attnum= (ss.x).x
@@ -1774,7 +1776,7 @@ CREATE VIEW table_constraints AS
17741776
WHEREnc.oid=c.connamespaceANDnr.oid=r.relnamespace
17751777
ANDc.conrelid=r.oid
17761778
ANDc.contype NOTIN ('t','x')-- ignore nonstandard constraints
1777-
ANDr.relkindIN ('r','P')
1779+
ANDr.relkindIN ('r','p')
17781780
AND (NOT pg_is_other_temp_schema(nr.oid))
17791781
AND (pg_has_role(r.relowner,'USAGE')
17801782
-- SELECT privilege omitted, per SQL standard
@@ -1804,7 +1806,7 @@ CREATE VIEW table_constraints AS
18041806
ANDa.attnotnull
18051807
ANDa.attnum>0
18061808
AND NOTa.attisdropped
1807-
ANDr.relkindIN ('r','P')
1809+
ANDr.relkindIN ('r','p')
18081810
AND (NOT pg_is_other_temp_schema(nr.oid))
18091811
AND (pg_has_role(r.relowner,'USAGE')
18101812
-- SELECT privilege omitted, per SQL standard
@@ -1854,7 +1856,7 @@ CREATE VIEW table_privileges AS
18541856
)AS grantee (oid, rolname)
18551857

18561858
WHEREc.relnamespace=nc.oid
1857-
ANDc.relkindIN ('r','v','P')
1859+
ANDc.relkindIN ('r','v','p')
18581860
ANDc.grantee=grantee.oid
18591861
ANDc.grantor=u_grantor.oid
18601862
ANDc.prtypeIN ('INSERT','SELECT','UPDATE','DELETE','TRUNCATE','REFERENCES','TRIGGER')
@@ -1898,7 +1900,7 @@ CREATE VIEW tables AS
18981900

18991901
CAST(
19001902
CASE WHENnc.oid= pg_my_temp_schema() THEN'LOCAL TEMPORARY'
1901-
WHENc.relkindIN ('r','P') THEN'BASE TABLE'
1903+
WHENc.relkindIN ('r','p') THEN'BASE TABLE'
19021904
WHENc.relkind='v' THEN'VIEW'
19031905
WHENc.relkind='f' THEN'FOREIGN TABLE'
19041906
ELSEnull END
@@ -1911,7 +1913,7 @@ CREATE VIEW tables AS
19111913
CAST(nt.nspnameAS sql_identifier)AS user_defined_type_schema,
19121914
CAST(t.typnameAS sql_identifier)AS user_defined_type_name,
19131915

1914-
CAST(CASE WHENc.relkindIN ('r','P')OR
1916+
CAST(CASE WHENc.relkindIN ('r','p')OR
19151917
(c.relkindIN ('v','f')AND
19161918
-- 1 << CMD_INSERT
19171919
pg_relation_is_updatable(c.oid, false) &8=8)
@@ -1923,7 +1925,7 @@ CREATE VIEW tables AS
19231925
FROM pg_namespace ncJOIN pg_class cON (nc.oid=c.relnamespace)
19241926
LEFT JOIN (pg_type tJOIN pg_namespace ntON (t.typnamespace=nt.oid))ON (c.reloftype=t.oid)
19251927

1926-
WHEREc.relkindIN ('r','v','f','P')
1928+
WHEREc.relkindIN ('r','v','f','p')
19271929
AND (NOT pg_is_other_temp_schema(nc.oid))
19281930
AND (pg_has_role(c.relowner,'USAGE')
19291931
OR has_table_privilege(c.oid,'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
@@ -2442,7 +2444,7 @@ CREATE VIEW view_column_usage AS
24422444
ANDdt.refclassid='pg_catalog.pg_class'::regclass
24432445
ANDdt.refobjid=t.oid
24442446
ANDt.relnamespace=nt.oid
2445-
ANDt.relkindIN ('r','v','f','P')
2447+
ANDt.relkindIN ('r','v','f','p')
24462448
ANDt.oid=a.attrelid
24472449
ANDdt.refobjsubid=a.attnum
24482450
AND pg_has_role(t.relowner,'USAGE');
@@ -2520,7 +2522,7 @@ CREATE VIEW view_table_usage AS
25202522
ANDdt.refclassid='pg_catalog.pg_class'::regclass
25212523
ANDdt.refobjid=t.oid
25222524
ANDt.relnamespace=nt.oid
2523-
ANDt.relkindIN ('r','v','f','P')
2525+
ANDt.relkindIN ('r','v','f','p')
25242526
AND pg_has_role(t.relowner,'USAGE');
25252527

25262528
GRANTSELECTON view_table_usage TO PUBLIC;
@@ -2673,7 +2675,7 @@ CREATE VIEW element_types AS
26732675
a.attnum,a.atttypid,a.attcollation
26742676
FROM pg_class c, pg_attribute a
26752677
WHEREc.oid=a.attrelid
2676-
ANDc.relkindIN ('r','v','f','c','P')
2678+
ANDc.relkindIN ('r','v','f','c','p')
26772679
AND attnum>0AND NOT attisdropped
26782680

26792681
UNION ALL

‎src/backend/catalog/system_views.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ CREATE VIEW pg_tables AS
136136
C.relrowsecurityAS rowsecurity
137137
FROM pg_class CLEFT JOIN pg_namespace NON (N.oid=C.relnamespace)
138138
LEFT JOIN pg_tablespace TON (T.oid=C.reltablespace)
139-
WHEREC.relkindIN ('r','P');
139+
WHEREC.relkindIN ('r','p');
140140

141141
CREATEVIEWpg_matviewsAS
142142
SELECT
@@ -294,7 +294,7 @@ CREATE VIEW pg_prepared_statements AS
294294
CREATEVIEWpg_seclabelsAS
295295
SELECT
296296
l.objoid,l.classoid,l.objsubid,
297-
CASE WHENrel.relkindIN ('r','P') THEN'table'::text
297+
CASE WHENrel.relkindIN ('r','p') THEN'table'::text
298298
WHENrel.relkind='v' THEN'view'::text
299299
WHENrel.relkind='m' THEN'materialized view'::text
300300
WHENrel.relkind='S' THEN'sequence'::text

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201703081
56+
#defineCATALOG_VERSION_NO201703101
5757

5858
#endif

‎src/include/catalog/pg_class.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ DESCR("");
162162
#defineRELKIND_SEQUENCE 'S'/* sequence object */
163163
#defineRELKIND_TOASTVALUE 't'/* for out-of-line values */
164164
#defineRELKIND_VIEW 'v'/* view */
165+
#defineRELKIND_MATVIEW 'm'/* materialized view */
165166
#defineRELKIND_COMPOSITE_TYPE 'c'/* composite type */
166167
#defineRELKIND_FOREIGN_TABLE 'f'/* foreign table */
167-
#defineRELKIND_MATVIEW 'm'/* materialized view */
168-
#defineRELKIND_PARTITIONED_TABLE 'P'/* partitioned table */
168+
#defineRELKIND_PARTITIONED_TABLE 'p'/* partitioned table */
169169

170170
#defineRELPERSISTENCE_PERMANENT'p'/* regular table */
171171
#defineRELPERSISTENCE_UNLOGGED'u'/* unlogged permanent table */
@@ -178,9 +178,10 @@ DESCR("");
178178
/* all columns are logged as replica identity */
179179
#defineREPLICA_IDENTITY_FULL'f'
180180
/*
181-
* an explicitly chosen candidate key's columns are used as identity;
182-
* will still be set if the index has been dropped, in that case it
183-
* has the same meaning as 'd'
181+
* an explicitly chosen candidate key's columns are used asreplicaidentity.
182+
*Note thiswill still be set if the index has been dropped; in that case it
183+
* has the same meaning as 'd'.
184184
*/
185185
#defineREPLICA_IDENTITY_INDEX'i'
186+
186187
#endif/* PG_CLASS_H */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ CREATE TABLE partitioned (
404404
SELECT relkind FROM pg_class WHERE relname = 'partitioned';
405405
relkind
406406
---------
407-
P
407+
p
408408
(1 row)
409409

410410
-- check that range partition key columns are marked NOT NULL

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ pg_seclabels| SELECT l.objoid,
14811481
l.classoid,
14821482
l.objsubid,
14831483
CASE
1484-
WHEN (rel.relkind = ANY (ARRAY['r'::"char", 'P'::"char"])) THEN 'table'::text
1484+
WHEN (rel.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])) THEN 'table'::text
14851485
WHEN (rel.relkind = 'v'::"char") THEN 'view'::text
14861486
WHEN (rel.relkind = 'm'::"char") THEN 'materialized view'::text
14871487
WHEN (rel.relkind = 'S'::"char") THEN 'sequence'::text
@@ -2171,7 +2171,7 @@ pg_tables| SELECT n.nspname AS schemaname,
21712171
FROM ((pg_class c
21722172
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
21732173
LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace)))
2174-
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'P'::"char"]));
2174+
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]));
21752175
pg_timezone_abbrevs| SELECT pg_timezone_abbrevs.abbrev,
21762176
pg_timezone_abbrevs.utc_offset,
21772177
pg_timezone_abbrevs.is_dst

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VACUUM;
99
\a\t
1010
SELECT relname, relhasindex
1111
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
12-
WHERE relkind IN ('r', 'P') AND (nspname ~ '^pg_temp_') IS NOT TRUE
12+
WHERE relkind IN ('r', 'p') AND (nspname ~ '^pg_temp_') IS NOT TRUE
1313
ORDER BY relname;
1414
a|f
1515
a_star|f

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ ORDER BY 1;
464464
-- Look for illegal values in pg_class fields
465465
SELECT p1.oid, p1.relname
466466
FROM pg_class as p1
467-
WHERE relkind NOT IN ('r', 'i', 's', 'S', 'c', 't', 'v', 'f') OR
467+
WHERE relkind NOT IN ('r', 'i', 'S', 't', 'v', 'm', 'c', 'f', 'p') OR
468468
relpersistence NOT IN ('p', 'u', 't') OR
469469
relreplident NOT IN ('d', 'n', 'f', 'i');
470470
oid | relname

‎src/test/regress/sql/sanity_check.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ VACUUM;
1212

1313
SELECT relname, relhasindex
1414
FROM pg_class cLEFT JOIN pg_namespace nONn.oid= relnamespace
15-
WHERE relkindIN ('r','P')AND (nspname ~'^pg_temp_') IS NOT TRUE
15+
WHERE relkindIN ('r','p')AND (nspname ~'^pg_temp_') IS NOT TRUE
1616
ORDER BY relname;
1717

1818
-- restore normal output mode

‎src/test/regress/sql/type_sanity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ ORDER BY 1;
339339

340340
SELECTp1.oid,p1.relname
341341
FROM pg_classas p1
342-
WHERE relkind NOTIN ('r','i','s','S','c','t','v','f')OR
342+
WHERE relkind NOTIN ('r','i','S','t','v','m','c','f','p')OR
343343
relpersistence NOTIN ('p','u','t')OR
344344
relreplident NOTIN ('d','n','f','i');
345345

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp