mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
psql: conditionally display oids and replication identity
In psql \d+, display oids only when they exist, and display replication identity only when it is non-default. Also document the defaults for replication identity for system and non-system tables. Update regression output.
This commit is contained in:
parent
c92c3d50d7
commit
4168c00a5d
@ -608,12 +608,14 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
|
|||||||
<para>
|
<para>
|
||||||
This form changes the information which is written to the write-ahead log
|
This form changes the information which is written to the write-ahead log
|
||||||
to identify rows which are updated or deleted. This option has no effect
|
to identify rows which are updated or deleted. This option has no effect
|
||||||
except when logical replication is in use. <literal>DEFAULT</> records the
|
except when logical replication is in use. <literal>DEFAULT</>
|
||||||
|
(the default for non-system tables) records the
|
||||||
old values of the columns of the primary key, if any. <literal>USING INDEX</>
|
old values of the columns of the primary key, if any. <literal>USING INDEX</>
|
||||||
records the old values of the columns covered by the named index, which
|
records the old values of the columns covered by the named index, which
|
||||||
must be unique, not partial, not deferrable, and include only columns marked
|
must be unique, not partial, not deferrable, and include only columns marked
|
||||||
<literal>NOT NULL</>. <literal>FULL</> records the old values of all columns
|
<literal>NOT NULL</>. <literal>FULL</> records the old values of all columns
|
||||||
in the row. <literal>NOTHING</> records no information about the old row.
|
in the row. <literal>NOTHING</> records no information about the old row.
|
||||||
|
(This is the default for system tables.)
|
||||||
In all cases, no old values are logged unless at least one of the columns
|
In all cases, no old values are logged unless at least one of the columns
|
||||||
that would be logged differs between the old and new versions of the row.
|
that would be logged differs between the old and new versions of the row.
|
||||||
</para>
|
</para>
|
||||||
|
@ -951,7 +951,9 @@ testdb=>
|
|||||||
The command form <literal>\d+</literal> is identical, except that
|
The command form <literal>\d+</literal> is identical, except that
|
||||||
more information is displayed: any comments associated with the
|
more information is displayed: any comments associated with the
|
||||||
columns of the table are shown, as is the presence of OIDs in the
|
columns of the table are shown, as is the presence of OIDs in the
|
||||||
table, the view definition if the relation is a view.
|
table, the view definition if the relation is a view, a non-default
|
||||||
|
<link linkend="SQL-CREATETABLE-REPLICA-IDENTITY">replica
|
||||||
|
identity</link> setting.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -2345,13 +2345,14 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printTableAddFooter(&cont, buf.data);
|
printTableAddFooter(&cont, buf.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tableinfo.relkind == 'r' || tableinfo.relkind == 'm') &&
|
if (verbose && (tableinfo.relkind == 'r' || tableinfo.relkind == 'm') &&
|
||||||
/*
|
/*
|
||||||
* No need to display default values; we already display a
|
* No need to display default values; we already display a
|
||||||
* REPLICA IDENTITY marker on indexes.
|
* REPLICA IDENTITY marker on indexes.
|
||||||
*/
|
*/
|
||||||
tableinfo.relreplident != 'd' && tableinfo.relreplident != 'i' &&
|
tableinfo.relreplident != 'i' &&
|
||||||
strcmp(schemaname, "pg_catalog") != 0)
|
((strcmp(schemaname, "pg_catalog") != 0 && tableinfo.relreplident != 'd') ||
|
||||||
|
(strcmp(schemaname, "pg_catalog") == 0 && tableinfo.relreplident != 'n')))
|
||||||
{
|
{
|
||||||
const char *s = _("Replica Identity");
|
const char *s = _("Replica Identity");
|
||||||
|
|
||||||
@ -2365,14 +2366,8 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* OIDs, if verbose and not a materialized view */
|
/* OIDs, if verbose and not a materialized view */
|
||||||
if (verbose && tableinfo.relkind != 'm')
|
if (verbose && tableinfo.relkind != 'm' && tableinfo.hasoids)
|
||||||
{
|
printTableAddFooter(&cont, _("Has OIDs: yes"));
|
||||||
const char *s = _("Has OIDs");
|
|
||||||
|
|
||||||
printfPQExpBuffer(&buf, "%s: %s", s,
|
|
||||||
(tableinfo.hasoids ? _("yes") : _("no")));
|
|
||||||
printTableAddFooter(&cont, buf.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tablespace info */
|
/* Tablespace info */
|
||||||
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
||||||
|
@ -115,7 +115,6 @@ CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING
|
|||||||
a | text | not null | main | |
|
a | text | not null | main | |
|
||||||
b | text | | extended | |
|
b | text | | extended | |
|
||||||
c | text | | external | |
|
c | text | | external | |
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
|
CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
|
||||||
\d+ ctlt12_comments
|
\d+ ctlt12_comments
|
||||||
@ -125,7 +124,6 @@ CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDIN
|
|||||||
a | text | not null | extended | | A
|
a | text | not null | extended | | A
|
||||||
b | text | | extended | | B
|
b | text | | extended | | B
|
||||||
c | text | | extended | | C
|
c | text | | extended | | C
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
|
CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
|
||||||
NOTICE: merging column "a" with inherited definition
|
NOTICE: merging column "a" with inherited definition
|
||||||
@ -140,7 +138,6 @@ NOTICE: merging constraint "ctlt1_a_check" with inherited definition
|
|||||||
Check constraints:
|
Check constraints:
|
||||||
"ctlt1_a_check" CHECK (length(a) > 2)
|
"ctlt1_a_check" CHECK (length(a) > 2)
|
||||||
Inherits: ctlt1
|
Inherits: ctlt1
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass;
|
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass;
|
||||||
description
|
description
|
||||||
@ -162,7 +159,6 @@ Check constraints:
|
|||||||
"ctlt3_a_check" CHECK (length(a) < 5)
|
"ctlt3_a_check" CHECK (length(a) < 5)
|
||||||
Inherits: ctlt1,
|
Inherits: ctlt1,
|
||||||
ctlt3
|
ctlt3
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
|
CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
|
||||||
NOTICE: merging column "a" with inherited definition
|
NOTICE: merging column "a" with inherited definition
|
||||||
@ -177,7 +173,6 @@ Check constraints:
|
|||||||
"ctlt1_a_check" CHECK (length(a) > 2)
|
"ctlt1_a_check" CHECK (length(a) > 2)
|
||||||
"ctlt3_a_check" CHECK (length(a) < 5)
|
"ctlt3_a_check" CHECK (length(a) < 5)
|
||||||
Inherits: ctlt1
|
Inherits: ctlt1
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass;
|
SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass;
|
||||||
description
|
description
|
||||||
@ -198,7 +193,6 @@ Indexes:
|
|||||||
"ctlt_all_expr_idx" btree ((a || b))
|
"ctlt_all_expr_idx" btree ((a || b))
|
||||||
Check constraints:
|
Check constraints:
|
||||||
"ctlt1_a_check" CHECK (length(a) > 2)
|
"ctlt1_a_check" CHECK (length(a) > 2)
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
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;
|
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;
|
||||||
relname | objsubid | description
|
relname | objsubid | description
|
||||||
|
@ -684,7 +684,6 @@ COMMENT ON COLUMN ft1.c1 IS 'ft1.c1';
|
|||||||
c3 | date | | | plain | |
|
c3 | date | | | plain | |
|
||||||
Server: s0
|
Server: s0
|
||||||
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
|
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
\det+
|
\det+
|
||||||
List of foreign tables
|
List of foreign tables
|
||||||
@ -743,7 +742,6 @@ ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1;
|
|||||||
c10 | integer | | (p1 'v1') | plain | |
|
c10 | integer | | (p1 'v1') | plain | |
|
||||||
Server: s0
|
Server: s0
|
||||||
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
|
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
-- can't change the column type if it's used elsewhere
|
-- can't change the column type if it's used elsewhere
|
||||||
CREATE TABLE use_ft1_column_type (x ft1);
|
CREATE TABLE use_ft1_column_type (x ft1);
|
||||||
|
@ -913,7 +913,6 @@ ALTER TABLE inhts RENAME d TO dd;
|
|||||||
dd | integer | | plain | |
|
dd | integer | | plain | |
|
||||||
Inherits: inht1,
|
Inherits: inht1,
|
||||||
inhs1
|
inhs1
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
DROP TABLE inhts;
|
DROP TABLE inhts;
|
||||||
-- Test for renaming in diamond inheritance
|
-- Test for renaming in diamond inheritance
|
||||||
@ -934,7 +933,6 @@ ALTER TABLE inht1 RENAME aa TO aaa;
|
|||||||
z | integer | | plain | |
|
z | integer | | plain | |
|
||||||
Inherits: inht2,
|
Inherits: inht2,
|
||||||
inht3
|
inht3
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
CREATE TABLE inhts (d int) INHERITS (inht2, inhs1);
|
CREATE TABLE inhts (d int) INHERITS (inht2, inhs1);
|
||||||
NOTICE: merging multiple inherited definitions of column "b"
|
NOTICE: merging multiple inherited definitions of column "b"
|
||||||
@ -952,7 +950,6 @@ ERROR: cannot rename inherited column "b"
|
|||||||
d | integer | | plain | |
|
d | integer | | plain | |
|
||||||
Inherits: inht2,
|
Inherits: inht2,
|
||||||
inhs1
|
inhs1
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
WITH RECURSIVE r AS (
|
WITH RECURSIVE r AS (
|
||||||
SELECT 'inht1'::regclass AS inhrelid
|
SELECT 'inht1'::regclass AS inhrelid
|
||||||
@ -999,7 +996,6 @@ CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
|
|||||||
Indexes:
|
Indexes:
|
||||||
"test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
|
"test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
|
||||||
Child tables: test_constraints_inh
|
Child tables: test_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
|
ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
|
||||||
\d+ test_constraints
|
\d+ test_constraints
|
||||||
@ -1010,7 +1006,6 @@ ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key
|
|||||||
val1 | character varying | | extended | |
|
val1 | character varying | | extended | |
|
||||||
val2 | integer | | plain | |
|
val2 | integer | | plain | |
|
||||||
Child tables: test_constraints_inh
|
Child tables: test_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
\d+ test_constraints_inh
|
\d+ test_constraints_inh
|
||||||
Table "public.test_constraints_inh"
|
Table "public.test_constraints_inh"
|
||||||
@ -1020,7 +1015,6 @@ Has OIDs: no
|
|||||||
val1 | character varying | | extended | |
|
val1 | character varying | | extended | |
|
||||||
val2 | integer | | plain | |
|
val2 | integer | | plain | |
|
||||||
Inherits: test_constraints
|
Inherits: test_constraints
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
DROP TABLE test_constraints_inh;
|
DROP TABLE test_constraints_inh;
|
||||||
DROP TABLE test_constraints;
|
DROP TABLE test_constraints;
|
||||||
@ -1037,7 +1031,6 @@ CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints);
|
|||||||
Indexes:
|
Indexes:
|
||||||
"test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
|
"test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
|
||||||
Child tables: test_ex_constraints_inh
|
Child tables: test_ex_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
|
ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
|
||||||
\d+ test_ex_constraints
|
\d+ test_ex_constraints
|
||||||
@ -1046,7 +1039,6 @@ ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
|
|||||||
--------+--------+-----------+---------+--------------+-------------
|
--------+--------+-----------+---------+--------------+-------------
|
||||||
c | circle | | plain | |
|
c | circle | | plain | |
|
||||||
Child tables: test_ex_constraints_inh
|
Child tables: test_ex_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
\d+ test_ex_constraints_inh
|
\d+ test_ex_constraints_inh
|
||||||
Table "public.test_ex_constraints_inh"
|
Table "public.test_ex_constraints_inh"
|
||||||
@ -1054,7 +1046,6 @@ Has OIDs: no
|
|||||||
--------+--------+-----------+---------+--------------+-------------
|
--------+--------+-----------+---------+--------------+-------------
|
||||||
c | circle | | plain | |
|
c | circle | | plain | |
|
||||||
Inherits: test_ex_constraints
|
Inherits: test_ex_constraints
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
DROP TABLE test_ex_constraints_inh;
|
DROP TABLE test_ex_constraints_inh;
|
||||||
DROP TABLE test_ex_constraints;
|
DROP TABLE test_ex_constraints;
|
||||||
@ -1071,7 +1062,6 @@ Indexes:
|
|||||||
"test_primary_constraints_pkey" PRIMARY KEY, btree (id)
|
"test_primary_constraints_pkey" PRIMARY KEY, btree (id)
|
||||||
Referenced by:
|
Referenced by:
|
||||||
TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
|
TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
\d+ test_foreign_constraints
|
\d+ test_foreign_constraints
|
||||||
Table "public.test_foreign_constraints"
|
Table "public.test_foreign_constraints"
|
||||||
@ -1081,7 +1071,6 @@ Has OIDs: no
|
|||||||
Foreign-key constraints:
|
Foreign-key constraints:
|
||||||
"test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
|
"test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
|
||||||
Child tables: test_foreign_constraints_inh
|
Child tables: test_foreign_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
|
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
|
||||||
\d+ test_foreign_constraints
|
\d+ test_foreign_constraints
|
||||||
@ -1090,7 +1079,6 @@ ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id
|
|||||||
--------+---------+-----------+---------+--------------+-------------
|
--------+---------+-----------+---------+--------------+-------------
|
||||||
id1 | integer | | plain | |
|
id1 | integer | | plain | |
|
||||||
Child tables: test_foreign_constraints_inh
|
Child tables: test_foreign_constraints_inh
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
\d+ test_foreign_constraints_inh
|
\d+ test_foreign_constraints_inh
|
||||||
Table "public.test_foreign_constraints_inh"
|
Table "public.test_foreign_constraints_inh"
|
||||||
@ -1098,7 +1086,6 @@ Has OIDs: no
|
|||||||
--------+---------+-----------+---------+--------------+-------------
|
--------+---------+-----------+---------+--------------+-------------
|
||||||
id1 | integer | | plain | |
|
id1 | integer | | plain | |
|
||||||
Inherits: test_foreign_constraints
|
Inherits: test_foreign_constraints
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
DROP TABLE test_foreign_constraints_inh;
|
DROP TABLE test_foreign_constraints_inh;
|
||||||
DROP TABLE test_foreign_constraints;
|
DROP TABLE test_foreign_constraints;
|
||||||
|
@ -152,14 +152,14 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
|
|||||||
f
|
f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
\d test_replica_identity
|
\d+ test_replica_identity
|
||||||
Table "public.test_replica_identity"
|
Table "public.test_replica_identity"
|
||||||
Column | Type | Modifiers
|
Column | Type | Modifiers | Storage | Stats target | Description
|
||||||
--------+---------+--------------------------------------------------------------------
|
--------+---------+--------------------------------------------------------------------+----------+--------------+-------------
|
||||||
id | integer | not null default nextval('test_replica_identity_id_seq'::regclass)
|
id | integer | not null default nextval('test_replica_identity_id_seq'::regclass) | plain | |
|
||||||
keya | text | not null
|
keya | text | not null | extended | |
|
||||||
keyb | text | not null
|
keyb | text | not null | extended | |
|
||||||
nonkey | text |
|
nonkey | text | | extended | |
|
||||||
Indexes:
|
Indexes:
|
||||||
"test_replica_identity_pkey" PRIMARY KEY, btree (id)
|
"test_replica_identity_pkey" PRIMARY KEY, btree (id)
|
||||||
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
|
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
|
||||||
|
@ -2609,7 +2609,6 @@ Rules:
|
|||||||
r3 AS
|
r3 AS
|
||||||
ON DELETE TO rules_src DO
|
ON DELETE TO rules_src DO
|
||||||
NOTIFY rules_src_deletion
|
NOTIFY rules_src_deletion
|
||||||
Has OIDs: no
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- check alter rename rule
|
-- check alter rename rule
|
||||||
|
@ -71,7 +71,7 @@ SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass
|
|||||||
|
|
||||||
ALTER TABLE test_replica_identity REPLICA IDENTITY FULL;
|
ALTER TABLE test_replica_identity REPLICA IDENTITY FULL;
|
||||||
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
|
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
|
||||||
\d test_replica_identity
|
\d+ test_replica_identity
|
||||||
ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING;
|
ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING;
|
||||||
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
|
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user