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

Commitd79f00e

Browse files
committed
In transformRowExpr(), check for too many columns in the row.
A RowExpr with more than MaxTupleAttributeNumber columns would fail atexecution anyway, since we cannot form a tuple datum with more than thatmany columns. While heap_form_tuple() has a check for too many columns,it emerges that there are some intermediate bits of code that don'tcheck and can be driven to failure with sufficiently many columns.Checking this at parse time seems like the most appropriate place toinstall a defense, since we already check SELECT list length there.While at it, make the SELECT-list-length error use the same errcode(TOO_MANY_COLUMNS) as heap_form_tuple does, rather than the genericPROGRAM_LIMIT_EXCEEDED.Per bug #17561 from Egor Chindyaskin. The given test case crashesin all supported branches (and probably a lot further back),so patch all.Discussion:https://postgr.es/m/17561-80350151b9ad2ad4@postgresql.org
1 parent658e5d5 commitd79f00e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,14 @@ transformRowExpr(ParseState *pstate, RowExpr *r, bool allowDefault)
22672267
newr->args=transformExpressionList(pstate,r->args,
22682268
pstate->p_expr_kind,allowDefault);
22692269

2270+
/* Disallow more columns than will fit in a tuple */
2271+
if (list_length(newr->args)>MaxTupleAttributeNumber)
2272+
ereport(ERROR,
2273+
(errcode(ERRCODE_TOO_MANY_COLUMNS),
2274+
errmsg("ROW expressions can have at most %d entries",
2275+
MaxTupleAttributeNumber),
2276+
parser_errposition(pstate,r->location)));
2277+
22702278
/* Barring later casting, we consider the type RECORD */
22712279
newr->row_typeid=RECORDOID;
22722280
newr->row_format=COERCE_IMPLICIT_CAST;

‎src/backend/parser/parse_node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ free_parsestate(ParseState *pstate)
8383
*/
8484
if (pstate->p_next_resno-1>MaxTupleAttributeNumber)
8585
ereport(ERROR,
86-
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
86+
(errcode(ERRCODE_TOO_MANY_COLUMNS),
8787
errmsg("target lists can have at most %d entries",
8888
MaxTupleAttributeNumber)));
8989

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp