Commit 02db1f58 authored by Bryan Henderson's avatar Bryan Henderson

Fix access through null pointer info->rule_action. Thanks Darren King.

parent 9602150a
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.1.1.1 1996/07/09 06:21:51 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.2 1996/11/24 05:58:57 bryanh Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,50 +57,47 @@ gatherRewriteMeta(Query *parsetree, ...@@ -57,50 +57,47 @@ gatherRewriteMeta(Query *parsetree,
info->rt_index = rt_index; info->rt_index = rt_index;
info->event = event; info->event = event;
info->instead_flag = *instead_flag; info->instead_flag = *instead_flag;
/* info->rule_action = rule_action; this needs to be a copy here, I think! - jolly*/
info->rule_action = (Query*)copyObject(rule_action); info->rule_action = (Query*)copyObject(rule_action);
info->rule_qual = (Node*)copyObject(rule_qual); info->rule_qual = (Node*)copyObject(rule_qual);
info->nothing = FALSE;
info->action = info->rule_action->commandType;
if (info->rule_action == NULL) info->nothing = TRUE; if (info->rule_action == NULL) info->nothing = TRUE;
if (info->nothing) else {
return info; info->nothing = FALSE;
info->action = info->rule_action->commandType;
info->current_varno = rt_index; info->current_varno = rt_index;
info->rt = parsetree->rtable; info->rt = parsetree->rtable;
rt_length = length(info->rt); rt_length = length(info->rt);
info->rt = append(info->rt, info->rule_action->rtable); info->rt = append(info->rt, info->rule_action->rtable);
info->new_varno = PRS2_NEW_VARNO + rt_length;
info->new_varno = PRS2_NEW_VARNO + rt_length; OffsetVarNodes(info->rule_action->qual, rt_length);
OffsetVarNodes(info->rule_action->qual, rt_length); OffsetVarNodes((Node*)info->rule_action->targetList, rt_length);
OffsetVarNodes((Node*)info->rule_action->targetList, rt_length); OffsetVarNodes(info->rule_qual, rt_length);
OffsetVarNodes(info->rule_qual, rt_length); ChangeVarNodes((Node*)info->rule_action->qual,
ChangeVarNodes((Node*)info->rule_action->qual, PRS2_CURRENT_VARNO+rt_length, rt_index);
PRS2_CURRENT_VARNO+rt_length, rt_index); ChangeVarNodes((Node*)info->rule_action->targetList,
ChangeVarNodes((Node*)info->rule_action->targetList, PRS2_CURRENT_VARNO+rt_length, rt_index);
PRS2_CURRENT_VARNO+rt_length, rt_index); ChangeVarNodes(info->rule_qual,
ChangeVarNodes(info->rule_qual, PRS2_CURRENT_VARNO+rt_length, rt_index); PRS2_CURRENT_VARNO+rt_length, rt_index);
/* /*
* bug here about replace CURRENT -- sort of * bug here about replace CURRENT -- sort of
* replace current is deprecated now so this code shouldn't really * replace current is deprecated now so this code shouldn't really
* need to be so clutzy but..... * need to be so clutzy but.....
*/ */
if (info->action != CMD_SELECT) { /* i.e update XXXXX */ if (info->action != CMD_SELECT) { /* i.e update XXXXX */
int new_result_reln = 0; int new_result_reln = 0;
result_reln = info->rule_action->resultRelation; result_reln = info->rule_action->resultRelation;
switch (result_reln) { switch (result_reln) {
case PRS2_CURRENT_VARNO: new_result_reln = rt_index; case PRS2_CURRENT_VARNO: new_result_reln = rt_index;
break; break;
case PRS2_NEW_VARNO: /* XXX */ case PRS2_NEW_VARNO: /* XXX */
default: default:
new_result_reln = result_reln + rt_length; new_result_reln = result_reln + rt_length;
break; break;
} }
info->rule_action->resultRelation = new_result_reln; info->rule_action->resultRelation = new_result_reln;
}
} }
return info; return info;
} }
......
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