Skip to content

Commit b504af7

Browse files
author
Commitfest Bot
committed
[CF 5836] v59 - SQL:2011 Application Time Update & Delete
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5836 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CA+renyUodzxAvMnpa_LTvo+Ru1ZKH+Su8KaPvD4iMtguFKzq4g@mail.gmail.com Author(s): Paul Jungwirth
2 parents a4fd971 + 64c7c25 commit b504af7

File tree

117 files changed

+25848
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+25848
-526
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,19 @@ CREATE TABLE "S 1"."T 4" (
5050
c3 text,
5151
CONSTRAINT t4_pkey PRIMARY KEY (c1)
5252
);
53+
CREATE TABLE "S 1"."T 5" (
54+
c1 int4range NOT NULL,
55+
c2 int NOT NULL,
56+
c3 text,
57+
c4 daterange NOT NULL,
58+
CONSTRAINT t5_pkey PRIMARY KEY (c1, c4 WITHOUT OVERLAPS)
59+
);
5360
-- Disable autovacuum for these tables to avoid unexpected effects of that
5461
ALTER TABLE "S 1"."T 1" SET (autovacuum_enabled = 'false');
5562
ALTER TABLE "S 1"."T 2" SET (autovacuum_enabled = 'false');
5663
ALTER TABLE "S 1"."T 3" SET (autovacuum_enabled = 'false');
5764
ALTER TABLE "S 1"."T 4" SET (autovacuum_enabled = 'false');
65+
ALTER TABLE "S 1"."T 5" SET (autovacuum_enabled = 'false');
5866
INSERT INTO "S 1"."T 1"
5967
SELECT id,
6068
id % 10,
@@ -81,10 +89,17 @@ INSERT INTO "S 1"."T 4"
8189
'AAA' || to_char(id, 'FM000')
8290
FROM generate_series(1, 100) id;
8391
DELETE FROM "S 1"."T 4" WHERE c1 % 3 != 0; -- delete for outer join tests
92+
INSERT INTO "S 1"."T 5"
93+
SELECT int4range(id, id + 1),
94+
id + 1,
95+
'AAA' || to_char(id, 'FM000'),
96+
'[2000-01-01,2020-01-01)'
97+
FROM generate_series(1, 100) id;
8498
ANALYZE "S 1"."T 1";
8599
ANALYZE "S 1"."T 2";
86100
ANALYZE "S 1"."T 3";
87101
ANALYZE "S 1"."T 4";
102+
ANALYZE "S 1"."T 5";
88103
-- ===================================================================
89104
-- create foreign tables
90105
-- ===================================================================
@@ -132,6 +147,12 @@ CREATE FOREIGN TABLE ft7 (
132147
c2 int NOT NULL,
133148
c3 text
134149
) SERVER loopback3 OPTIONS (schema_name 'S 1', table_name 'T 4');
150+
CREATE FOREIGN TABLE ft8 (
151+
c1 int4range NOT NULL,
152+
c2 int NOT NULL,
153+
c3 text,
154+
c4 daterange NOT NULL
155+
) SERVER loopback OPTIONS (schema_name 'S 1', table_name 'T 5');
135156
-- ===================================================================
136157
-- tests for validator
137158
-- ===================================================================
@@ -214,7 +235,8 @@ ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1');
214235
public | ft5 | loopback | (schema_name 'S 1', table_name 'T 4') |
215236
public | ft6 | loopback2 | (schema_name 'S 1', table_name 'T 4') |
216237
public | ft7 | loopback3 | (schema_name 'S 1', table_name 'T 4') |
217-
(6 rows)
238+
public | ft8 | loopback | (schema_name 'S 1', table_name 'T 5') |
239+
(7 rows)
218240

219241
-- Test that alteration of server options causes reconnection
220242
-- Remote's errors might be non-English, so hide them to ensure stable results
@@ -6303,6 +6325,27 @@ DELETE FROM ft2 WHERE c1 = 1200 RETURNING tableoid::regclass;
63036325
ft2
63046326
(1 row)
63056327

6328+
-- Test UPDATE FOR PORTION OF
6329+
UPDATE ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01'
6330+
SET c2 = c2 + 1
6331+
WHERE c1 = '[1,2)';
6332+
ERROR: foreign tables don't support FOR PORTION OF
6333+
SELECT * FROM ft8 WHERE c1 = '[1,2)' ORDER BY c1, c4;
6334+
c1 | c2 | c3 | c4
6335+
-------+----+--------+-------------------------
6336+
[1,2) | 2 | AAA001 | [01-01-2000,01-01-2020)
6337+
(1 row)
6338+
6339+
-- Test DELETE FOR PORTION OF
6340+
DELETE FROM ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01'
6341+
WHERE c1 = '[2,3)';
6342+
ERROR: foreign tables don't support FOR PORTION OF
6343+
SELECT * FROM ft8 WHERE c1 = '[2,3)' ORDER BY c1, c4;
6344+
c1 | c2 | c3 | c4
6345+
-------+----+--------+-------------------------
6346+
[2,3) | 3 | AAA002 | [01-01-2000,01-01-2020)
6347+
(1 row)
6348+
63066349
-- Test UPDATE/DELETE with RETURNING on a three-table join
63076350
INSERT INTO ft2 (c1,c2,c3)
63086351
SELECT id, id - 1200, to_char(id, 'FM00000') FROM generate_series(1201, 1300) id;

contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,20 @@ CREATE TABLE "S 1"."T 4" (
5454
c3 text,
5555
CONSTRAINT t4_pkey PRIMARY KEY (c1)
5656
);
57+
CREATE TABLE "S 1"."T 5" (
58+
c1 int4range NOT NULL,
59+
c2 int NOT NULL,
60+
c3 text,
61+
c4 daterange NOT NULL,
62+
CONSTRAINT t5_pkey PRIMARY KEY (c1, c4 WITHOUT OVERLAPS)
63+
);
5764

5865
-- Disable autovacuum for these tables to avoid unexpected effects of that
5966
ALTER TABLE "S 1"."T 1" SET (autovacuum_enabled = 'false');
6067
ALTER TABLE "S 1"."T 2" SET (autovacuum_enabled = 'false');
6168
ALTER TABLE "S 1"."T 3" SET (autovacuum_enabled = 'false');
6269
ALTER TABLE "S 1"."T 4" SET (autovacuum_enabled = 'false');
70+
ALTER TABLE "S 1"."T 5" SET (autovacuum_enabled = 'false');
6371

6472
INSERT INTO "S 1"."T 1"
6573
SELECT id,
@@ -87,11 +95,18 @@ INSERT INTO "S 1"."T 4"
8795
'AAA' || to_char(id, 'FM000')
8896
FROM generate_series(1, 100) id;
8997
DELETE FROM "S 1"."T 4" WHERE c1 % 3 != 0; -- delete for outer join tests
98+
INSERT INTO "S 1"."T 5"
99+
SELECT int4range(id, id + 1),
100+
id + 1,
101+
'AAA' || to_char(id, 'FM000'),
102+
'[2000-01-01,2020-01-01)'
103+
FROM generate_series(1, 100) id;
90104

91105
ANALYZE "S 1"."T 1";
92106
ANALYZE "S 1"."T 2";
93107
ANALYZE "S 1"."T 3";
94108
ANALYZE "S 1"."T 4";
109+
ANALYZE "S 1"."T 5";
95110

96111
-- ===================================================================
97112
-- create foreign tables
@@ -146,6 +161,14 @@ CREATE FOREIGN TABLE ft7 (
146161
c3 text
147162
) SERVER loopback3 OPTIONS (schema_name 'S 1', table_name 'T 4');
148163

164+
CREATE FOREIGN TABLE ft8 (
165+
c1 int4range NOT NULL,
166+
c2 int NOT NULL,
167+
c3 text,
168+
c4 daterange NOT NULL
169+
) SERVER loopback OPTIONS (schema_name 'S 1', table_name 'T 5');
170+
171+
149172
-- ===================================================================
150173
-- tests for validator
151174
-- ===================================================================
@@ -1538,6 +1561,17 @@ EXPLAIN (verbose, costs off)
15381561
DELETE FROM ft2 WHERE c1 = 1200 RETURNING tableoid::regclass; -- can be pushed down
15391562
DELETE FROM ft2 WHERE c1 = 1200 RETURNING tableoid::regclass;
15401563

1564+
-- Test UPDATE FOR PORTION OF
1565+
UPDATE ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01'
1566+
SET c2 = c2 + 1
1567+
WHERE c1 = '[1,2)';
1568+
SELECT * FROM ft8 WHERE c1 = '[1,2)' ORDER BY c1, c4;
1569+
1570+
-- Test DELETE FOR PORTION OF
1571+
DELETE FROM ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01'
1572+
WHERE c1 = '[2,3)';
1573+
SELECT * FROM ft8 WHERE c1 = '[2,3)' ORDER BY c1, c4;
1574+
15411575
-- Test UPDATE/DELETE with RETURNING on a three-table join
15421576
INSERT INTO ft2 (c1,c2,c3)
15431577
SELECT id, id - 1200, to_char(id, 'FM00000') FROM generate_series(1201, 1300) id;

doc/src/sgml/catalogs.sgml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@
230230
<entry>information about partition key of tables</entry>
231231
</row>
232232

233+
<row>
234+
<entry><link linkend="catalog-pg-period"><structname>pg_period</structname></link></entry>
235+
<entry>periods</entry>
236+
</row>
237+
233238
<row>
234239
<entry><link linkend="catalog-pg-policy"><structname>pg_policy</structname></link></entry>
235240
<entry>row-security policies</entry>
@@ -5773,6 +5778,113 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
57735778
are simple references.
57745779
</para></entry>
57755780
</row>
5781+
5782+
</tbody>
5783+
</tgroup>
5784+
</table>
5785+
</sect1>
5786+
5787+
5788+
<sect1 id="catalog-pg-period">
5789+
<title><structname>pg_period</structname></title>
5790+
5791+
<indexterm zone="catalog-pg-period">
5792+
<primary>pg_period</primary>
5793+
</indexterm>
5794+
5795+
<para>
5796+
The catalog <structname>pg_period</structname> stores
5797+
information about system and application time periods.
5798+
</para>
5799+
5800+
<para>
5801+
Periods are described in <xref linkend="ddl-periods"/>.
5802+
</para>
5803+
5804+
<table>
5805+
<title><structname>pg_period</structname> Columns</title>
5806+
5807+
<tgroup cols="1">
5808+
<thead>
5809+
<row>
5810+
<entry role="catalog_table_entry"><para role="column_definition">
5811+
Column Type
5812+
</para>
5813+
<para>
5814+
Description
5815+
</para></entry>
5816+
</row>
5817+
</thead>
5818+
5819+
<tbody>
5820+
<row>
5821+
<entry role="catalog_table_entry"><para role="column_definition">
5822+
<structfield>oid</structfield> <type>oid</type>
5823+
</para>
5824+
<para>
5825+
Row identifier
5826+
</para></entry>
5827+
</row>
5828+
5829+
<row>
5830+
<entry role="catalog_table_entry"><para role="column_definition">
5831+
<structfield>pername</structfield> <type>text</type>
5832+
</para>
5833+
<para>
5834+
Period name
5835+
</para></entry>
5836+
</row>
5837+
5838+
<row>
5839+
<entry role="catalog_table_entry"><para role="column_definition">
5840+
<structfield>perrelid</structfield> <type>oid</type>
5841+
(references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>)
5842+
</para>
5843+
<para>
5844+
The table this period belongs to
5845+
</para></entry>
5846+
</row>
5847+
5848+
<row>
5849+
<entry role="catalog_table_entry"><para role="column_definition">
5850+
<structfield>perstart</structfield> <type>int2</type>
5851+
(references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>)
5852+
</para>
5853+
<para>
5854+
The number of the start column
5855+
</para></entry>
5856+
</row>
5857+
5858+
<row>
5859+
<entry role="catalog_table_entry"><para role="column_definition">
5860+
<structfield>perend</structfield> <type>int2</type>
5861+
(references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>)
5862+
</para>
5863+
<para>
5864+
The number of the end column
5865+
</para></entry>
5866+
</row>
5867+
5868+
<row>
5869+
<entry role="catalog_table_entry"><para role="column_definition">
5870+
<structfield>perrange</structfield> <type>int2</type>
5871+
(references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>)
5872+
</para>
5873+
<para>
5874+
The number of the <literal>GENERATED</literal> column that implements the <literal>PERIOD</literal>.
5875+
</para></entry>
5876+
</row>
5877+
5878+
<row>
5879+
<entry role="catalog_table_entry"><para role="column_definition">
5880+
<structfield>perconstraint</structfield> <type>oid</type>
5881+
(references <link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link>.<structfield>oid</structfield>)
5882+
</para>
5883+
<para>
5884+
The OID of the period's <literal>CHECK</literal> constraint
5885+
</para></entry>
5886+
</row>
5887+
57765888
</tbody>
57775889
</tgroup>
57785890
</table>

0 commit comments

Comments
 (0)