From 46651ce6fe013220ed397add242004d764fc0153 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:15:05 +0200 Subject: Adding upstream version 14.5. Signed-off-by: Daniel Baumann --- src/test/regress/sql/tid.sql | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/test/regress/sql/tid.sql (limited to 'src/test/regress/sql/tid.sql') diff --git a/src/test/regress/sql/tid.sql b/src/test/regress/sql/tid.sql new file mode 100644 index 0000000..34546a3 --- /dev/null +++ b/src/test/regress/sql/tid.sql @@ -0,0 +1,54 @@ +-- tests for functions related to TID handling + +CREATE TABLE tid_tab (a int); + +-- min() and max() for TIDs +INSERT INTO tid_tab VALUES (1), (2); +SELECT min(ctid) FROM tid_tab; +SELECT max(ctid) FROM tid_tab; +TRUNCATE tid_tab; + +-- Tests for currtid2() with various relation kinds + +-- Materialized view +CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab; +SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- fails +INSERT INTO tid_tab VALUES (1); +REFRESH MATERIALIZED VIEW tid_matview; +SELECT currtid2('tid_matview'::text, '(0,1)'::tid); -- ok +DROP MATERIALIZED VIEW tid_matview; +TRUNCATE tid_tab; + +-- Sequence +CREATE SEQUENCE tid_seq; +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 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 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 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 currtid2('tid_view_with_ctid'::text, '(0,1)'::tid); -- fails +INSERT INTO tid_tab VALUES (1); +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 currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid); -- fails +DROP VIEW tid_view_fake_ctid; + +DROP TABLE tid_tab CASCADE; -- cgit v1.2.3