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

Commit40d0bd8

Browse files
committed
Be more paranoid in ruleutils.c's get_variable().
We were merely Assert'ing that the Var matched the RTE it's supposedlyfrom. But if the user passes incorrect information to pg_get_expr(),the RTE might in fact not match; this led either to Assert failuresor core dumps, as reported by Chris Hanks in bug #14220. To fix, justconvert the Asserts to test-and-elog. Adjust an existing test-and-elogelsewhere in the same function to be consistent in wording.(If we really felt these were user-facing errors, we might promote them toereport's; but I can't convince myself that they're worth translating.)Back-patch to 9.3; the problematic code doesn't exist before that, anda quick check says that 9.2 doesn't crash on such cases.Michael Paquier and Thomas MunroReport: <20160629224349.1407.32667@wrigleys.postgresql.org>
1 parent8f4a369 commit40d0bd8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6012,7 +6012,8 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
60126012

60136013
tle=get_tle_by_resno(dpns->inner_tlist,var->varattno);
60146014
if (!tle)
6015-
elog(ERROR,"bogus varattno for subquery var: %d",var->varattno);
6015+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
6016+
var->varattno,rte->eref->aliasname);
60166017

60176018
Assert(netlevelsup==0);
60186019
push_child_plan(dpns,dpns->inner_planstate,&save_dpns);
@@ -6073,9 +6074,13 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
60736074
elseif (attnum>0)
60746075
{
60756076
/* Get column name to use from the colinfo struct */
6076-
Assert(attnum <=colinfo->num_cols);
6077+
if (attnum>colinfo->num_cols)
6078+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
6079+
attnum,rte->eref->aliasname);
60776080
attname=colinfo->colnames[attnum-1];
6078-
Assert(attname!=NULL);
6081+
if (attname==NULL)/* dropped column? */
6082+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
6083+
attnum,rte->eref->aliasname);
60796084
}
60806085
else
60816086
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp