Commit 1f023f92 authored by Simon Riggs's avatar Simon Riggs

Optimize COPY FREEZE with CREATE TABLE also.

Jeff Davis, additional test by me
parent 1eb6cee4
......@@ -2002,7 +2002,8 @@ CopyFrom(CopyState cstate)
if (cstate->freeze &&
ThereAreNoPriorRegisteredSnapshots() &&
ThereAreNoReadyPortals() &&
cstate->rel->rd_newRelfilenodeSubid == GetCurrentSubTransactionId())
(cstate->rel->rd_newRelfilenodeSubid == GetCurrentSubTransactionId() ||
cstate->rel->rd_createSubid == GetCurrentSubTransactionId()))
hi_options |= HEAP_INSERT_FROZEN;
}
......
......@@ -254,7 +254,17 @@ SELECT * FROM testnull;
|
(4 rows)
BEGIN;
CREATE TABLE vistest (LIKE testeoc);
COPY vistest FROM stdin CSV;
COMMIT;
SELECT xmax, * FROM vistest;
xmax | a
------+----
0 | a0
0 | b
(2 rows)
BEGIN;
TRUNCATE vistest;
COPY vistest FROM stdin CSV;
......@@ -324,14 +334,12 @@ SELECT * FROM vistest;
COMMIT;
TRUNCATE vistest;
COPY vistest FROM stdin CSV FREEZE;
NOTICE: FREEZE option specified but pre-conditions not met
BEGIN;
INSERT INTO vistest VALUES ('z');
SAVEPOINT s1;
TRUNCATE vistest;
ROLLBACK TO SAVEPOINT s1;
COPY vistest FROM stdin CSV FREEZE;
NOTICE: FREEZE option specified but pre-conditions not met
SELECT * FROM vistest;
a
----
......
......@@ -178,8 +178,14 @@ COPY testnull FROM stdin WITH NULL AS E'\\0';
SELECT * FROM testnull;
BEGIN;
CREATE TABLE vistest (LIKE testeoc);
COPY vistest FROM stdin CSV;
a0
b
\.
COMMIT;
SELECT * FROM vistest;
BEGIN;
TRUNCATE vistest;
COPY vistest FROM stdin CSV;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment