mirror of
https://github.com/postgres/postgres.git
synced 2026-04-11 20:16:33 -04:00
Avoid unsafe access to negative index in a TupleDesc.
Commitaa606b931installed a test that would reference a nonexistent TupleDesc array entry if a system column is used in COPY FROM WHERE. Typically this would be harmless, but with bad luck it could result in a phony "generated columns are not supported in COPY FROM WHERE conditions" error, and at least in principle it could cause SIGSEGV. (Compare570e2fcc0which fixed the identical problem in another place.) Also, sincec98ad086ait throws an Assert instead. In the back branches, just guard the test to make it a safe no-op for system columns. Commit21c69dc73installed a more aggressive answer in master. Reported-by: Alexander Lakhin <exclusion@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/6f435023-8ab6-47c2-ba07-035d0c4212f9@gmail.com Backpatch-through: 14-18
This commit is contained in:
parent
d6c9432cb5
commit
681a91d29d
1 changed files with 2 additions and 1 deletions
|
|
@ -174,7 +174,8 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
|
|||
* generated columns are not yet computed when the filtering
|
||||
* happens.
|
||||
*/
|
||||
if (TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated)
|
||||
if (attno > 0 &&
|
||||
TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated)
|
||||
ereport(ERROR,
|
||||
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("generated columns are not supported in COPY FROM WHERE conditions"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue