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

Commitb69c4e6

Browse files
committed
psql: update "replica identity" display for \d+
Display "replica identity" only for \d plus mode, exclude system schemaobjects, and display all possible values, not just non-default,non-index ones.
1 parentba08155 commitb69c4e6

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

‎src/bin/psql/describe.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,14 +2345,19 @@ describeOneTableDetails(const char *schemaname,
23452345
printTableAddFooter(&cont,buf.data);
23462346
}
23472347

2348-
if ((tableinfo.relkind=='r'||tableinfo.relkind=='m')&&
2349-
tableinfo.relreplident!='d'&&tableinfo.relreplident!='i')
2348+
if (verbose&&(tableinfo.relkind=='r'||tableinfo.relkind=='m')&&
2349+
strcmp(schemaname,"pg_catalog")!=0)
23502350
{
23512351
constchar*s=_("Replica Identity");
23522352

23532353
printfPQExpBuffer(&buf,"%s: %s",
23542354
s,
2355-
tableinfo.relreplident=='n' ?"NOTHING" :"FULL");
2355+
tableinfo.relreplident=='d' ?"DEFAULT" :
2356+
tableinfo.relreplident=='f' ?"FULL" :
2357+
tableinfo.relreplident=='i' ?"USING INDEX" :
2358+
tableinfo.relreplident=='n' ?"NOTHING" :
2359+
"???");
2360+
23562361
printTableAddFooter(&cont,buf.data);
23572362
}
23582363

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING
115115
a | text | not null | main | |
116116
b | text | | extended | |
117117
c | text | | external | |
118+
Replica Identity: DEFAULT
118119
Has OIDs: no
119120

120121
CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
@@ -125,6 +126,7 @@ CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDIN
125126
a | text | not null | extended | | A
126127
b | text | | extended | | B
127128
c | text | | extended | | C
129+
Replica Identity: DEFAULT
128130
Has OIDs: no
129131

130132
CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
@@ -140,6 +142,7 @@ NOTICE: merging constraint "ctlt1_a_check" with inherited definition
140142
Check constraints:
141143
"ctlt1_a_check" CHECK (length(a) > 2)
142144
Inherits: ctlt1
145+
Replica Identity: DEFAULT
143146
Has OIDs: no
144147

145148
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass;
@@ -162,6 +165,7 @@ Check constraints:
162165
"ctlt3_a_check" CHECK (length(a) < 5)
163166
Inherits: ctlt1,
164167
ctlt3
168+
Replica Identity: DEFAULT
165169
Has OIDs: no
166170

167171
CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
@@ -177,6 +181,7 @@ Check constraints:
177181
"ctlt1_a_check" CHECK (length(a) > 2)
178182
"ctlt3_a_check" CHECK (length(a) < 5)
179183
Inherits: ctlt1
184+
Replica Identity: DEFAULT
180185
Has OIDs: no
181186

182187
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass;
@@ -198,6 +203,7 @@ Indexes:
198203
"ctlt_all_expr_idx" btree ((a || b))
199204
Check constraints:
200205
"ctlt1_a_check" CHECK (length(a) > 2)
206+
Replica Identity: DEFAULT
201207
Has OIDs: no
202208

203209
SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 'ctlt_all'::regclass ORDER BY c.relname, objsubid;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ ALTER TABLE inhts RENAME d TO dd;
913913
dd | integer | | plain | |
914914
Inherits: inht1,
915915
inhs1
916+
Replica Identity: DEFAULT
916917
Has OIDs: no
917918

918919
DROP TABLE inhts;
@@ -934,6 +935,7 @@ ALTER TABLE inht1 RENAME aa TO aaa;
934935
z | integer | | plain | |
935936
Inherits: inht2,
936937
inht3
938+
Replica Identity: DEFAULT
937939
Has OIDs: no
938940

939941
CREATE TABLE inhts (d int) INHERITS (inht2, inhs1);
@@ -952,6 +954,7 @@ ERROR: cannot rename inherited column "b"
952954
d | integer | | plain | |
953955
Inherits: inht2,
954956
inhs1
957+
Replica Identity: DEFAULT
955958
Has OIDs: no
956959

957960
WITH RECURSIVE r AS (
@@ -999,6 +1002,7 @@ CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
9991002
Indexes:
10001003
"test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
10011004
Child tables: test_constraints_inh
1005+
Replica Identity: DEFAULT
10021006
Has OIDs: no
10031007

10041008
ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
@@ -1010,6 +1014,7 @@ ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key
10101014
val1 | character varying | | extended | |
10111015
val2 | integer | | plain | |
10121016
Child tables: test_constraints_inh
1017+
Replica Identity: DEFAULT
10131018
Has OIDs: no
10141019

10151020
\d+ test_constraints_inh
@@ -1020,6 +1025,7 @@ Has OIDs: no
10201025
val1 | character varying | | extended | |
10211026
val2 | integer | | plain | |
10221027
Inherits: test_constraints
1028+
Replica Identity: DEFAULT
10231029
Has OIDs: no
10241030

10251031
DROP TABLE test_constraints_inh;
@@ -1037,6 +1043,7 @@ CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints);
10371043
Indexes:
10381044
"test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
10391045
Child tables: test_ex_constraints_inh
1046+
Replica Identity: DEFAULT
10401047
Has OIDs: no
10411048

10421049
ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
@@ -1046,6 +1053,7 @@ ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
10461053
--------+--------+-----------+---------+--------------+-------------
10471054
c | circle | | plain | |
10481055
Child tables: test_ex_constraints_inh
1056+
Replica Identity: DEFAULT
10491057
Has OIDs: no
10501058

10511059
\d+ test_ex_constraints_inh
@@ -1054,6 +1062,7 @@ Has OIDs: no
10541062
--------+--------+-----------+---------+--------------+-------------
10551063
c | circle | | plain | |
10561064
Inherits: test_ex_constraints
1065+
Replica Identity: DEFAULT
10571066
Has OIDs: no
10581067

10591068
DROP TABLE test_ex_constraints_inh;
@@ -1071,6 +1080,7 @@ Indexes:
10711080
"test_primary_constraints_pkey" PRIMARY KEY, btree (id)
10721081
Referenced by:
10731082
TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
1083+
Replica Identity: DEFAULT
10741084
Has OIDs: no
10751085

10761086
\d+ test_foreign_constraints
@@ -1081,6 +1091,7 @@ Has OIDs: no
10811091
Foreign-key constraints:
10821092
"test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
10831093
Child tables: test_foreign_constraints_inh
1094+
Replica Identity: DEFAULT
10841095
Has OIDs: no
10851096

10861097
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
@@ -1090,6 +1101,7 @@ ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id
10901101
--------+---------+-----------+---------+--------------+-------------
10911102
id1 | integer | | plain | |
10921103
Child tables: test_foreign_constraints_inh
1104+
Replica Identity: DEFAULT
10931105
Has OIDs: no
10941106

10951107
\d+ test_foreign_constraints_inh
@@ -1098,6 +1110,7 @@ Has OIDs: no
10981110
--------+---------+-----------+---------+--------------+-------------
10991111
id1 | integer | | plain | |
11001112
Inherits: test_foreign_constraints
1113+
Replica Identity: DEFAULT
11011114
Has OIDs: no
11021115

11031116
DROP TABLE test_foreign_constraints_inh;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ View definition:
104104
tv.totamt
105105
FROM tv
106106
ORDER BY tv.type;
107+
Replica Identity: DEFAULT
107108

108109
\d+ tvm
109110
Materialized view "public.tvm"
@@ -116,6 +117,7 @@ View definition:
116117
tv.totamt
117118
FROM tv
118119
ORDER BY tv.type;
120+
Replica Identity: DEFAULT
119121

120122
\d+ tvvm
121123
Materialized view "public.tvvm"
@@ -125,6 +127,7 @@ View definition:
125127
View definition:
126128
SELECT tvv.grandtot
127129
FROM tvv;
130+
Replica Identity: DEFAULT
128131

129132
\d+ bb
130133
Materialized view "public.bb"
@@ -136,6 +139,7 @@ Indexes:
136139
View definition:
137140
SELECT tvvmv.grandtot
138141
FROM tvvmv;
142+
Replica Identity: DEFAULT
139143

140144
-- test schema behavior
141145
CREATE SCHEMA mvschema;
@@ -152,6 +156,7 @@ Indexes:
152156
View definition:
153157
SELECT sum(tvm.totamt) AS grandtot
154158
FROM mvschema.tvm;
159+
Replica Identity: DEFAULT
155160

156161
SET search_path = mvschema, public;
157162
\d+ tvm
@@ -165,6 +170,7 @@ View definition:
165170
tv.totamt
166171
FROM tv
167172
ORDER BY tv.type;
173+
Replica Identity: DEFAULT
168174

169175
-- modify the underlying table data
170176
INSERT INTO t VALUES (6, 'z', 13);
@@ -369,6 +375,7 @@ UNION ALL
369375
SELECT v_test2.moo,
370376
3 * v_test2.moo
371377
FROM v_test2;
378+
Replica Identity: DEFAULT
372379

373380
CREATE MATERIALIZED VIEW mv_test3 AS SELECT * FROM mv_test2 WHERE moo = 12345;
374381
SELECT relispopulated FROM pg_class WHERE oid = 'mv_test3'::regclass;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ Indexes:
170170
"test_replica_identity_unique_nondefer" UNIQUE CONSTRAINT, btree (keya, keyb)
171171
"test_replica_identity_hash" hash (nonkey)
172172
"test_replica_identity_keyab" btree (keya, keyb)
173-
Replica Identity: FULL
174173

175174
ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING;
176175
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,7 @@ Rules:
26092609
r3 AS
26102610
ON DELETE TO rules_src DO
26112611
NOTIFY rules_src_deletion
2612+
Replica Identity: DEFAULT
26122613
Has OIDs: no
26132614

26142615
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp