diff options
| author | Michael Paquier | 2020-11-25 03:18:26 +0000 |
|---|---|---|
| committer | Michael Paquier | 2020-11-25 03:18:26 +0000 |
| commit | 7b94e999606e2e2e10d68d544d49fc5a5d5785ac (patch) | |
| tree | 935a8f986797796649c47f4be94d11b3d34d5d9c /src/test | |
| parent | 660b89928d18386de7755565c008439ae75d1218 (diff) | |
Remove catalog function currtid()
currtid() and currtid2() are an undocumented set of functions whose sole
known user is the Postgres ODBC driver, able to retrieve the latest TID
version for a tuple given by the caller of those functions.
As used by Postgres ODBC, currtid() is a shortcut able to retrieve the
last TID loaded into a backend by passing an OID of 0 (magic value)
after a tuple insertion. This is removed in this commit, as it became
obsolete after the driver began using "RETURNING ctid" with inserts, a
clause supported since Postgres 8.2 (using RETURNING is better for
performance anyway as it reduces the number of round-trips to the
backend).
currtid2() is still used by the driver, so this remains around for now.
Note that this function is kept in its original shape for backward
compatibility reasons.
Per discussion with many people, including Andres Freund, Peter
Eisentraut, Álvaro Herrera, Hiroshi Inoue, Tom Lane and myself.
Bump catalog version.
Discussion: https://postgr.es/m/20200603021448.GB89559@paquier.xyz
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/tid.out | 32 | ||||
| -rw-r--r-- | src/test/regress/sql/tid.sql | 11 |
2 files changed, 2 insertions, 41 deletions
diff --git a/src/test/regress/expected/tid.out b/src/test/regress/expected/tid.out index e7e0d747807..8da1a455761 100644 --- a/src/test/regress/expected/tid.out +++ b/src/test/regress/expected/tid.out @@ -15,21 +15,13 @@ SELECT max(ctid) FROM tid_tab; (1 row) TRUNCATE tid_tab; --- Tests for currtid() and currtid2() with various relation kinds +-- Tests for currtid2() with various relation kinds -- Materialized view CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab; -SELECT currtid('tid_matview'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: tid (0, 1) is not valid for relation "tid_matview" SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- fails ERROR: tid (0, 1) is not valid for relation "tid_matview" INSERT INTO tid_tab VALUES (1); REFRESH MATERIALIZED VIEW tid_matview; -SELECT currtid('tid_matview'::regclass::oid, '(0,1)'::tid); -- ok - currtid ---------- - (0,1) -(1 row) - SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- ok currtid2 ---------- @@ -40,12 +32,6 @@ DROP MATERIALIZED VIEW tid_matview; TRUNCATE tid_tab; -- Sequence CREATE SEQUENCE tid_seq; -SELECT currtid('tid_seq'::regclass::oid, '(0,1)'::tid); -- ok - currtid ---------- - (0,1) -(1 row) - SELECT currtid2('tid_seq'::text, '(0,1)'::tid); -- ok currtid2 ---------- @@ -55,39 +41,25 @@ SELECT currtid2('tid_seq'::text, '(0,1)'::tid); -- ok DROP SEQUENCE tid_seq; -- Index, fails with incorrect relation type CREATE INDEX tid_ind ON tid_tab(a); -SELECT currtid('tid_ind'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: "tid_ind" is an index SELECT currtid2('tid_ind'::text, '(0,1)'::tid); -- fails ERROR: "tid_ind" is an index DROP INDEX tid_ind; -- Partitioned table, no storage CREATE TABLE tid_part (a int) PARTITION BY RANGE (a); -SELECT currtid('tid_part'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: cannot look at latest visible tid for relation "public.tid_part" SELECT currtid2('tid_part'::text, '(0,1)'::tid); -- fails ERROR: cannot look at latest visible tid for relation "public.tid_part" DROP TABLE tid_part; -- Views -- ctid not defined in the view CREATE VIEW tid_view_no_ctid AS SELECT a FROM tid_tab; -SELECT currtid('tid_view_no_ctid'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: currtid cannot handle views with no CTID SELECT currtid2('tid_view_no_ctid'::text, '(0,1)'::tid); -- fails ERROR: currtid cannot handle views with no CTID DROP VIEW tid_view_no_ctid; -- ctid fetched directly from the source table. CREATE VIEW tid_view_with_ctid AS SELECT ctid, a FROM tid_tab; -SELECT currtid('tid_view_with_ctid'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: tid (0, 1) is not valid for relation "tid_tab" SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid); -- fails ERROR: tid (0, 1) is not valid for relation "tid_tab" INSERT INTO tid_tab VALUES (1); -SELECT currtid('tid_view_with_ctid'::regclass::oid, '(0,1)'::tid); -- ok - currtid ---------- - (0,1) -(1 row) - SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid); -- ok currtid2 ---------- @@ -98,8 +70,6 @@ DROP VIEW tid_view_with_ctid; TRUNCATE tid_tab; -- ctid attribute with incorrect data type CREATE VIEW tid_view_fake_ctid AS SELECT 1 AS ctid, 2 AS a; -SELECT currtid('tid_view_fake_ctid'::regclass::oid, '(0,1)'::tid); -- fails -ERROR: ctid isn't of type TID SELECT currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid); -- fails ERROR: ctid isn't of type TID DROP VIEW tid_view_fake_ctid; diff --git a/src/test/regress/sql/tid.sql b/src/test/regress/sql/tid.sql index c0d02df34f8..34546a3cb7a 100644 --- a/src/test/regress/sql/tid.sql +++ b/src/test/regress/sql/tid.sql @@ -8,55 +8,46 @@ SELECT min(ctid) FROM tid_tab; SELECT max(ctid) FROM tid_tab; TRUNCATE tid_tab; --- Tests for currtid() and currtid2() with various relation kinds +-- Tests for currtid2() with various relation kinds -- Materialized view CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab; -SELECT currtid('tid_matview'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- fails INSERT INTO tid_tab VALUES (1); REFRESH MATERIALIZED VIEW tid_matview; -SELECT currtid('tid_matview'::regclass::oid, '(0,1)'::tid); -- ok SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- ok DROP MATERIALIZED VIEW tid_matview; TRUNCATE tid_tab; -- Sequence CREATE SEQUENCE tid_seq; -SELECT currtid('tid_seq'::regclass::oid, '(0,1)'::tid); -- ok SELECT currtid2('tid_seq'::text, '(0,1)'::tid); -- ok DROP SEQUENCE tid_seq; -- Index, fails with incorrect relation type CREATE INDEX tid_ind ON tid_tab(a); -SELECT currtid('tid_ind'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_ind'::text, '(0,1)'::tid); -- fails DROP INDEX tid_ind; -- Partitioned table, no storage CREATE TABLE tid_part (a int) PARTITION BY RANGE (a); -SELECT currtid('tid_part'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_part'::text, '(0,1)'::tid); -- fails DROP TABLE tid_part; -- Views -- ctid not defined in the view CREATE VIEW tid_view_no_ctid AS SELECT a FROM tid_tab; -SELECT currtid('tid_view_no_ctid'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_view_no_ctid'::text, '(0,1)'::tid); -- fails DROP VIEW tid_view_no_ctid; -- ctid fetched directly from the source table. CREATE VIEW tid_view_with_ctid AS SELECT ctid, a FROM tid_tab; -SELECT currtid('tid_view_with_ctid'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid); -- fails INSERT INTO tid_tab VALUES (1); -SELECT currtid('tid_view_with_ctid'::regclass::oid, '(0,1)'::tid); -- ok SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid); -- ok DROP VIEW tid_view_with_ctid; TRUNCATE tid_tab; -- ctid attribute with incorrect data type CREATE VIEW tid_view_fake_ctid AS SELECT 1 AS ctid, 2 AS a; -SELECT currtid('tid_view_fake_ctid'::regclass::oid, '(0,1)'::tid); -- fails SELECT currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid); -- fails DROP VIEW tid_view_fake_ctid; |
