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:
@ -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;
|
||||
|
Reference in New Issue
Block a user