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

Commit0daeba0

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 parent86437dd commit0daeba0

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
@@ -5967,7 +5967,8 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
59675967

59685968
tle=get_tle_by_resno(dpns->inner_tlist,var->varattno);
59695969
if (!tle)
5970-
elog(ERROR,"bogus varattno for subquery var: %d",var->varattno);
5970+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
5971+
var->varattno,rte->eref->aliasname);
59715972

59725973
Assert(netlevelsup==0);
59735974
push_child_plan(dpns,dpns->inner_planstate,&save_dpns);
@@ -6028,9 +6029,13 @@ get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
60286029
elseif (attnum>0)
60296030
{
60306031
/* Get column name to use from the colinfo struct */
6031-
Assert(attnum <=colinfo->num_cols);
6032+
if (attnum>colinfo->num_cols)
6033+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
6034+
attnum,rte->eref->aliasname);
60326035
attname=colinfo->colnames[attnum-1];
6033-
Assert(attname!=NULL);
6036+
if (attname==NULL)/* dropped column? */
6037+
elog(ERROR,"invalid attnum %d for relation \"%s\"",
6038+
attnum,rte->eref->aliasname);
60346039
}
60356040
else
60366041
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp