Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f023f9

Browse files
Optimize COPY FREEZE with CREATE TABLE also.
Jeff Davis, additional test by me
1 parent1eb6cee commit1f023f9

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

‎src/backend/commands/copy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,8 @@ CopyFrom(CopyState cstate)
20022002
if (cstate->freeze&&
20032003
ThereAreNoPriorRegisteredSnapshots()&&
20042004
ThereAreNoReadyPortals()&&
2005-
cstate->rel->rd_newRelfilenodeSubid==GetCurrentSubTransactionId())
2005+
(cstate->rel->rd_newRelfilenodeSubid==GetCurrentSubTransactionId()||
2006+
cstate->rel->rd_createSubid==GetCurrentSubTransactionId()))
20062007
hi_options |=HEAP_INSERT_FROZEN;
20072008
}
20082009

‎src/test/regress/expected/copy2.out

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,17 @@ SELECT * FROM testnull;
254254
|
255255
(4 rows)
256256

257+
BEGIN;
257258
CREATE TABLE vistest (LIKE testeoc);
259+
COPY vistest FROM stdin CSV;
260+
COMMIT;
261+
SELECT xmax, * FROM vistest;
262+
xmax | a
263+
------+----
264+
0 | a0
265+
0 | b
266+
(2 rows)
267+
258268
BEGIN;
259269
TRUNCATE vistest;
260270
COPY vistest FROM stdin CSV;
@@ -324,14 +334,12 @@ SELECT * FROM vistest;
324334
COMMIT;
325335
TRUNCATE vistest;
326336
COPY vistest FROM stdin CSV FREEZE;
327-
NOTICE: FREEZE option specified but pre-conditions not met
328337
BEGIN;
329338
INSERT INTO vistest VALUES ('z');
330339
SAVEPOINT s1;
331340
TRUNCATE vistest;
332341
ROLLBACK TO SAVEPOINT s1;
333342
COPY vistest FROM stdin CSV FREEZE;
334-
NOTICE: FREEZE option specified but pre-conditions not met
335343
SELECT * FROM vistest;
336344
a
337345
----

‎src/test/regress/sql/copy2.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,14 @@ COPY testnull FROM stdin WITH NULL AS E'\\0';
178178

179179
SELECT*FROM testnull;
180180

181-
181+
BEGIN;
182182
CREATETABLEvistest (LIKE testeoc);
183+
COPY vistestFROM stdin CSV;
184+
a0
185+
b
186+
\.
187+
COMMIT;
188+
SELECT*FROM vistest;
183189
BEGIN;
184190
TRUNCATE vistest;
185191
COPY vistestFROM stdin CSV;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp