1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Optimize COPY FREEZE with CREATE TABLE also.

Jeff Davis, additional test by me
This commit is contained in:
Simon Riggs
2012-12-07 13:26:52 +00:00
parent 1eb6cee499
commit 1f023f9297
3 changed files with 19 additions and 4 deletions

View File

@ -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;
}

View File

@ -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
----

View File

@ -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;