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

Commite8ae019

Browse files
committed
Adjust COPY FREEZE error message to be more accurate and consistent.
Per suggestions from Noah and Tom.
1 parentf498704 commite8ae019

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

‎src/backend/commands/copy.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,36 +1996,32 @@ CopyFrom(CopyState cstate)
19961996
hi_options |=HEAP_INSERT_SKIP_FSM;
19971997
if (!XLogIsNeeded())
19981998
hi_options |=HEAP_INSERT_SKIP_WAL;
1999+
}
19992000

2000-
/*
2001-
* Optimize if new relfilenode was created in this subxact or
2002-
* one of its committed children and we won't see those rows later
2003-
* as part of an earlier scan or command. This ensures that if this
2004-
* subtransaction aborts then the frozen rows won't be visible
2005-
* after xact cleanup. Note that the stronger test of exactly
2006-
* which subtransaction created it is crucial for correctness
2007-
* of this optimisation.
2008-
*/
2009-
if (cstate->freeze)
2010-
{
2011-
if (!ThereAreNoPriorRegisteredSnapshots()|| !ThereAreNoReadyPortals())
2012-
ereport(ERROR,
2013-
(ERRCODE_INVALID_TRANSACTION_STATE,
2014-
errmsg("cannot perform FREEZE because of prior transaction activity")));
2001+
/*
2002+
* Optimize if new relfilenode was created in this subxact or
2003+
* one of its committed children and we won't see those rows later
2004+
* as part of an earlier scan or command. This ensures that if this
2005+
* subtransaction aborts then the frozen rows won't be visible
2006+
* after xact cleanup. Note that the stronger test of exactly
2007+
* which subtransaction created it is crucial for correctness
2008+
* of this optimisation.
2009+
*/
2010+
if (cstate->freeze)
2011+
{
2012+
if (!ThereAreNoPriorRegisteredSnapshots()|| !ThereAreNoReadyPortals())
2013+
ereport(ERROR,
2014+
(ERRCODE_INVALID_TRANSACTION_STATE,
2015+
errmsg("cannot perform FREEZE because of prior transaction activity")));
20152016

2016-
if (cstate->rel->rd_createSubid==GetCurrentSubTransactionId()||
2017-
cstate->rel->rd_newRelfilenodeSubid==GetCurrentSubTransactionId())
2018-
hi_options |=HEAP_INSERT_FROZEN;
2019-
else
2020-
ereport(ERROR,
2021-
(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
2022-
errmsg("cannot perform FREEZE because of transaction activity after table creation or truncation")));
2023-
}
2017+
if (cstate->rel->rd_createSubid!=GetCurrentSubTransactionId()&&
2018+
cstate->rel->rd_newRelfilenodeSubid!=GetCurrentSubTransactionId())
2019+
ereport(ERROR,
2020+
(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
2021+
errmsg("cannot perform FREEZE because the table was not created or truncated in the current subtransaction")));
2022+
2023+
hi_options |=HEAP_INSERT_FROZEN;
20242024
}
2025-
elseif (cstate->freeze)
2026-
ereport(ERROR,
2027-
(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
2028-
errmsg("cannot perform FREEZE because the table was not created or truncated in the current transaction")));
20292025

20302026
/*
20312027
* We need a ResultRelInfo so we can use the regular executor's

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,20 @@ SELECT * FROM vistest;
334334
COMMIT;
335335
TRUNCATE vistest;
336336
COPY vistest FROM stdin CSV FREEZE;
337-
ERROR: cannot perform FREEZE because the table was not created or truncated in the currenttransaction
337+
ERROR: cannot perform FREEZE because the table was not created or truncated in the currentsubtransaction
338338
BEGIN;
339339
TRUNCATE vistest;
340340
SAVEPOINT s1;
341341
COPY vistest FROM stdin CSV FREEZE;
342-
ERROR: cannot perform FREEZE becauseof transaction activity after table creationortruncation
342+
ERROR: cannot perform FREEZE becausethe table was not createdortruncated in the current subtransaction
343343
COMMIT;
344344
BEGIN;
345345
INSERT INTO vistest VALUES ('z');
346346
SAVEPOINT s1;
347347
TRUNCATE vistest;
348348
ROLLBACK TO SAVEPOINT s1;
349349
COPY vistest FROM stdin CSV FREEZE;
350-
ERROR: cannot perform FREEZE because the table was not created or truncated in the currenttransaction
350+
ERROR: cannot perform FREEZE because the table was not created or truncated in the currentsubtransaction
351351
COMMIT;
352352
CREATE FUNCTION truncate_in_subxact() RETURNS VOID AS
353353
$$

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp