Fix breakage of rules using NOTIFY actions, per bug report and patch

from sergiop@sinectis.com.ar.
This commit is contained in:
Tom Lane 2001-01-03 22:01:05 +00:00
parent 676cf18c5b
commit 60500d58bc
2 changed files with 28 additions and 2 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.86 2000/12/07 01:22:25 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.87 2001/01/03 22:01:05 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -124,6 +124,7 @@ gatherRewriteMeta(Query *parsetree,
* Note that if the rule refers to OLD, its jointree will add back * Note that if the rule refers to OLD, its jointree will add back
* a reference to rt_index. * a reference to rt_index.
*/ */
if (sub_action->jointree != NULL)
{ {
bool found; bool found;
List *newjointree = adjustJoinTreeList(parsetree, List *newjointree = adjustJoinTreeList(parsetree,

View File

@ -3,7 +3,7 @@
* back to source text * back to source text
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.70 2000/11/18 04:40:18 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.71 2001/01/03 22:01:05 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
@ -97,6 +97,7 @@ static void get_select_query_def(Query *query, deparse_context *context);
static void get_insert_query_def(Query *query, deparse_context *context); static void get_insert_query_def(Query *query, deparse_context *context);
static void get_update_query_def(Query *query, deparse_context *context); static void get_update_query_def(Query *query, deparse_context *context);
static void get_delete_query_def(Query *query, deparse_context *context); static void get_delete_query_def(Query *query, deparse_context *context);
static void get_utility_query_def(Query *query, deparse_context *context);
static void get_basic_select_query(Query *query, deparse_context *context); static void get_basic_select_query(Query *query, deparse_context *context);
static void get_setop_query(Node *setOp, Query *query, static void get_setop_query(Node *setOp, Query *query,
deparse_context *context, bool toplevel); deparse_context *context, bool toplevel);
@ -874,6 +875,10 @@ get_query_def(Query *query, StringInfo buf, List *parentrtables)
appendStringInfo(buf, "NOTHING"); appendStringInfo(buf, "NOTHING");
break; break;
case CMD_UTILITY:
get_utility_query_def(query, &context);
break;
default: default:
elog(ERROR, "get_ruledef of %s: query command type %d not implemented yet", elog(ERROR, "get_ruledef of %s: query command type %d not implemented yet",
rulename, query->commandType); rulename, query->commandType);
@ -1310,6 +1315,26 @@ get_delete_query_def(Query *query, deparse_context *context)
} }
} }
/* ----------
* get_utility_query_def - Parse back a UTILITY parsetree
* ----------
*/
static void
get_utility_query_def(Query *query, deparse_context *context)
{
StringInfo buf = context->buf;
if (query->utilityStmt && IsA(query->utilityStmt, NotifyStmt))
{
NotifyStmt *stmt = (NotifyStmt *) query->utilityStmt;
appendStringInfo(buf, "NOTIFY %s", quote_identifier(stmt->relname));
}
else
elog(ERROR, "get_utility_query_def: unexpected statement type");
}
/* /*
* Find the RTE referenced by a (possibly nonlocal) Var. * Find the RTE referenced by a (possibly nonlocal) Var.
*/ */