Commit e8ae0196 authored by Bruce Momjian's avatar Bruce Momjian

Adjust COPY FREEZE error message to be more accurate and consistent.

Per suggestions from Noah and Tom.
parent f4987049
...@@ -1996,6 +1996,7 @@ CopyFrom(CopyState cstate) ...@@ -1996,6 +1996,7 @@ CopyFrom(CopyState cstate)
hi_options |= HEAP_INSERT_SKIP_FSM; hi_options |= HEAP_INSERT_SKIP_FSM;
if (!XLogIsNeeded()) if (!XLogIsNeeded())
hi_options |= HEAP_INSERT_SKIP_WAL; hi_options |= HEAP_INSERT_SKIP_WAL;
}
/* /*
* Optimize if new relfilenode was created in this subxact or * Optimize if new relfilenode was created in this subxact or
...@@ -2013,19 +2014,14 @@ CopyFrom(CopyState cstate) ...@@ -2013,19 +2014,14 @@ CopyFrom(CopyState cstate)
(ERRCODE_INVALID_TRANSACTION_STATE, (ERRCODE_INVALID_TRANSACTION_STATE,
errmsg("cannot perform FREEZE because of prior transaction activity"))); errmsg("cannot perform FREEZE because of prior transaction activity")));
if (cstate->rel->rd_createSubid == GetCurrentSubTransactionId() || if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
cstate->rel->rd_newRelfilenodeSubid == GetCurrentSubTransactionId()) cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
hi_options |= HEAP_INSERT_FROZEN;
else
ereport(ERROR, ereport(ERROR,
(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE, (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
errmsg("cannot perform FREEZE because of transaction activity after table creation or truncation"))); errmsg("cannot perform FREEZE because the table was not created or truncated in the current subtransaction")));
}
hi_options |= HEAP_INSERT_FROZEN;
} }
else if (cstate->freeze)
ereport(ERROR,
(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
errmsg("cannot perform FREEZE because the table was not created or truncated in the current transaction")));
/* /*
* We need a ResultRelInfo so we can use the regular executor's * We need a ResultRelInfo so we can use the regular executor's
......
...@@ -334,12 +334,12 @@ SELECT * FROM vistest; ...@@ -334,12 +334,12 @@ SELECT * FROM vistest;
COMMIT; COMMIT;
TRUNCATE vistest; TRUNCATE vistest;
COPY vistest FROM stdin CSV FREEZE; COPY vistest FROM stdin CSV FREEZE;
ERROR: cannot perform FREEZE because the table was not created or truncated in the current transaction ERROR: cannot perform FREEZE because the table was not created or truncated in the current subtransaction
BEGIN; BEGIN;
TRUNCATE vistest; TRUNCATE vistest;
SAVEPOINT s1; SAVEPOINT s1;
COPY vistest FROM stdin CSV FREEZE; COPY vistest FROM stdin CSV FREEZE;
ERROR: cannot perform FREEZE because of transaction activity after table creation or truncation ERROR: cannot perform FREEZE because the table was not created or truncated in the current subtransaction
COMMIT; COMMIT;
BEGIN; BEGIN;
INSERT INTO vistest VALUES ('z'); INSERT INTO vistest VALUES ('z');
...@@ -347,7 +347,7 @@ SAVEPOINT s1; ...@@ -347,7 +347,7 @@ SAVEPOINT s1;
TRUNCATE vistest; TRUNCATE vistest;
ROLLBACK TO SAVEPOINT s1; ROLLBACK TO SAVEPOINT s1;
COPY vistest FROM stdin CSV FREEZE; COPY vistest FROM stdin CSV FREEZE;
ERROR: cannot perform FREEZE because the table was not created or truncated in the current transaction ERROR: cannot perform FREEZE because the table was not created or truncated in the current subtransaction
COMMIT; COMMIT;
CREATE FUNCTION truncate_in_subxact() RETURNS VOID AS CREATE FUNCTION truncate_in_subxact() RETURNS VOID AS
$$ $$
......
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