diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 67157829fdfc67d5f0e64b6e024712d4232c00a9..9af4697a47b5491ad7d0caad298dfde33c82e00f 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -5038,14 +5038,6 @@ <entry>The table this rule is for</entry> </row> - <row> - <entry><structfield>ev_attr</structfield></entry> - <entry><type>int2</type></entry> - <entry></entry> - <entry>The column this rule is for (currently, always -1 to - indicate the whole table)</entry> - </row> - <row> <entry><structfield>ev_type</structfield></entry> <entry><type>char</type></entry> diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index 0e9f515a09c8a74f79fba8ee47a436f8d81c31ca..9c4a5d47e28ecca46d38e872a239a77c390715c8 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -58,7 +58,6 @@ static Oid InsertRule(char *rulname, int evtype, Oid eventrel_oid, - AttrNumber evslot_index, bool evinstead, Node *event_qual, List *action, @@ -86,7 +85,6 @@ InsertRule(char *rulname, namestrcpy(&rname, rulname); values[Anum_pg_rewrite_rulename - 1] = NameGetDatum(&rname); values[Anum_pg_rewrite_ev_class - 1] = ObjectIdGetDatum(eventrel_oid); - values[Anum_pg_rewrite_ev_attr - 1] = Int16GetDatum(evslot_index); values[Anum_pg_rewrite_ev_type - 1] = CharGetDatum(evtype + '0'); values[Anum_pg_rewrite_ev_enabled - 1] = CharGetDatum(RULE_FIRES_ON_ORIGIN); values[Anum_pg_rewrite_is_instead - 1] = BoolGetDatum(evinstead); @@ -117,7 +115,6 @@ InsertRule(char *rulname, * When replacing, we don't need to replace every attribute */ MemSet(replaces, false, sizeof(replaces)); - replaces[Anum_pg_rewrite_ev_attr - 1] = true; replaces[Anum_pg_rewrite_ev_type - 1] = true; replaces[Anum_pg_rewrite_is_instead - 1] = true; replaces[Anum_pg_rewrite_ev_qual - 1] = true; @@ -238,7 +235,6 @@ DefineQueryRewrite(char *rulename, List *action) { Relation event_relation; - int event_attno; ListCell *l; Query *query; bool RelisBecomingView = false; @@ -495,7 +491,6 @@ DefineQueryRewrite(char *rulename, /* * This rule is allowed - prepare to install it. */ - event_attno = -1; /* discard rule if it's null action and not INSTEAD; it's a no-op */ if (action != NIL || is_instead) @@ -503,7 +498,6 @@ DefineQueryRewrite(char *rulename, ruleId = InsertRule(rulename, event_type, event_relid, - event_attno, is_instead, event_qual, action, diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index c55fb14e081d50efc41a871b7ac9c2c81f3f0df1..8a9a703c1291729676c3e905316bfae880327cc7 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -1276,10 +1276,7 @@ matchLocks(CmdType event, if (oneLock->event == event) { if (parsetree->commandType != CMD_SELECT || - (oneLock->attrno == -1 ? - rangeTableEntry_used((Node *) parsetree, varno, 0) : - attribute_used((Node *) parsetree, - varno, oneLock->attrno, 0))) + rangeTableEntry_used((Node *) parsetree, varno, 0)) matching_locks = lappend(matching_locks, oneLock); } } @@ -1295,7 +1292,6 @@ static Query * ApplyRetrieveRule(Query *parsetree, RewriteRule *rule, int rt_index, - bool relation_level, Relation relation, List *activeRIRs, bool forUpdatePushedDown) @@ -1309,8 +1305,6 @@ ApplyRetrieveRule(Query *parsetree, elog(ERROR, "expected just one rule action"); if (rule->qual != NULL) elog(ERROR, "cannot handle qualified ON SELECT rule"); - if (!relation_level) - elog(ERROR, "cannot handle per-attribute ON SELECT rule"); if (rt_index == parsetree->resultRelation) { @@ -1632,14 +1626,6 @@ fireRIRrules(Query *parsetree, List *activeRIRs, bool forUpdatePushedDown) if (rule->event != CMD_SELECT) continue; - if (rule->attrno > 0) - { - /* per-attr rule; do we need it? */ - if (!attribute_used((Node *) parsetree, rt_index, - rule->attrno, 0)) - continue; - } - locks = lappend(locks, rule); } @@ -1664,7 +1650,6 @@ fireRIRrules(Query *parsetree, List *activeRIRs, bool forUpdatePushedDown) parsetree = ApplyRetrieveRule(parsetree, rule, rt_index, - rule->attrno == -1, rel, activeRIRs, forUpdatePushedDown); diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 6ea91f5b211da1427da3549ed887308fb1a9ef0a..b2626f1f44fb3f6b24a88cc8e5672be356f3b99a 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -857,70 +857,6 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) } -/* - * attribute_used - - * Check if a specific attribute number of a RTE is used - * somewhere in the query or expression. - */ - -typedef struct -{ - int rt_index; - int attno; - int sublevels_up; -} attribute_used_context; - -static bool -attribute_used_walker(Node *node, - attribute_used_context *context) -{ - if (node == NULL) - return false; - if (IsA(node, Var)) - { - Var *var = (Var *) node; - - if (var->varlevelsup == context->sublevels_up && - var->varno == context->rt_index && - var->varattno == context->attno) - return true; - return false; - } - if (IsA(node, Query)) - { - /* Recurse into subselects */ - bool result; - - context->sublevels_up++; - result = query_tree_walker((Query *) node, attribute_used_walker, - (void *) context, 0); - context->sublevels_up--; - return result; - } - return expression_tree_walker(node, attribute_used_walker, - (void *) context); -} - -bool -attribute_used(Node *node, int rt_index, int attno, int sublevels_up) -{ - attribute_used_context context; - - context.rt_index = rt_index; - context.attno = attno; - context.sublevels_up = sublevels_up; - - /* - * Must be prepared to start with a Query or a bare expression tree; if - * it's a Query, we don't want to increment sublevels_up. - */ - return query_or_expression_tree_walker(node, - attribute_used_walker, - (void *) &context, - 0); -} - - /* * If the given Query is an INSERT ... SELECT construct, extract and * return the sub-Query node that represents the SELECT part. Otherwise diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 37d66e18e8f4d19ec04478330e29b7632ee47624..9a1d12eb9a9a7b14bfabea3411ba590bba5ea2b8 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3734,7 +3734,6 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, char *rulename; char ev_type; Oid ev_class; - int16 ev_attr; bool is_instead; char *ev_qual; char *ev_action; @@ -3761,11 +3760,6 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, Assert(!isnull); ev_class = DatumGetObjectId(dat); - fno = SPI_fnumber(rulettc, "ev_attr"); - dat = SPI_getbinval(ruletup, rulettc, fno, &isnull); - Assert(!isnull); - ev_attr = DatumGetInt16(dat); - fno = SPI_fnumber(rulettc, "is_instead"); dat = SPI_getbinval(ruletup, rulettc, fno, &isnull); Assert(!isnull); @@ -3820,10 +3814,6 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, /* The relation the rule is fired on */ appendStringInfo(buf, " TO %s", generate_relation_name(ev_class, NIL)); - if (ev_attr > 0) - appendStringInfo(buf, ".%s", - quote_identifier(get_relid_attribute_name(ev_class, - ev_attr))); /* If the rule has an event qualification, add it */ if (ev_qual == NULL) @@ -3925,7 +3915,6 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, Query *query; char ev_type; Oid ev_class; - int16 ev_attr; bool is_instead; char *ev_qual; char *ev_action; @@ -3943,9 +3932,6 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, fno = SPI_fnumber(rulettc, "ev_class"); ev_class = (Oid) SPI_getbinval(ruletup, rulettc, fno, &isnull); - fno = SPI_fnumber(rulettc, "ev_attr"); - ev_attr = (int16) SPI_getbinval(ruletup, rulettc, fno, &isnull); - fno = SPI_fnumber(rulettc, "is_instead"); is_instead = (bool) SPI_getbinval(ruletup, rulettc, fno, &isnull); @@ -3965,7 +3951,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, query = (Query *) linitial(actions); - if (ev_type != '1' || ev_attr >= 0 || !is_instead || + if (ev_type != '1' || !is_instead || strcmp(ev_qual, "<>") != 0 || query->commandType != CMD_SELECT) { appendStringInfo(buf, "Not a view"); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 66fb63b9e4820b49584531c37d49514d4e329175..b4cc6ad221063867c4a5fc1cb781d6773f2e10aa 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -682,7 +682,6 @@ RelationBuildRuleLock(Relation relation) rule->ruleId = HeapTupleGetOid(rewrite_tuple); rule->event = rewrite_form->ev_type - '0'; - rule->attrno = rewrite_form->ev_attr; rule->enabled = rewrite_form->ev_enabled; rule->isInstead = rewrite_form->is_instead; @@ -798,8 +797,6 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2) return false; if (rule1->event != rule2->event) return false; - if (rule1->attrno != rule2->attrno) - return false; if (rule1->enabled != rule2->enabled) return false; if (rule1->isInstead != rule2->isInstead) diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 9e46c55ed5614969dc97b86ccbc459443c8e8367..3a18935072e81a17eac2762902297846f5336d68 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201309031 +#define CATALOG_VERSION_NO 201309051 #endif diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h index 54bc42677abb7a1a1792d118a0dda599ff36ec78..bdd9fc5d1525df640c4d70d6b752009fe53a9a02 100644 --- a/src/include/catalog/pg_rewrite.h +++ b/src/include/catalog/pg_rewrite.h @@ -35,7 +35,6 @@ CATALOG(pg_rewrite,2618) { NameData rulename; Oid ev_class; - int16 ev_attr; char ev_type; char ev_enabled; bool is_instead; @@ -57,14 +56,13 @@ typedef FormData_pg_rewrite *Form_pg_rewrite; * compiler constants for pg_rewrite * ---------------- */ -#define Natts_pg_rewrite 8 +#define Natts_pg_rewrite 7 #define Anum_pg_rewrite_rulename 1 #define Anum_pg_rewrite_ev_class 2 -#define Anum_pg_rewrite_ev_attr 3 -#define Anum_pg_rewrite_ev_type 4 -#define Anum_pg_rewrite_ev_enabled 5 -#define Anum_pg_rewrite_is_instead 6 -#define Anum_pg_rewrite_ev_qual 7 -#define Anum_pg_rewrite_ev_action 8 +#define Anum_pg_rewrite_ev_type 3 +#define Anum_pg_rewrite_ev_enabled 4 +#define Anum_pg_rewrite_is_instead 5 +#define Anum_pg_rewrite_ev_qual 6 +#define Anum_pg_rewrite_ev_action 7 #endif /* PG_REWRITE_H */ diff --git a/src/include/rewrite/prs2lock.h b/src/include/rewrite/prs2lock.h index 88d57d2d1f84fbc25efdc04b9cb068203f33b12f..aaca2113aa84645939a2267a14b3ceae70637cbe 100644 --- a/src/include/rewrite/prs2lock.h +++ b/src/include/rewrite/prs2lock.h @@ -25,7 +25,6 @@ typedef struct RewriteRule { Oid ruleId; CmdType event; - AttrNumber attrno; Node *qual; List *actions; char enabled; diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h index eadf8f1179755a6480073ff40d0648b25a0d93b9..bd5cf62a19eeb58036344d9d89d9047d4bab41d4 100644 --- a/src/include/rewrite/rewriteManip.h +++ b/src/include/rewrite/rewriteManip.h @@ -49,8 +49,6 @@ extern void IncrementVarSublevelsUp_rtable(List *rtable, extern bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up); -extern bool attribute_used(Node *node, int rt_index, int attno, - int sublevels_up); extern Query *getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr); diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 452235de8afdcfe014fe2fa89a8e5996567ababa..b20eb0d5ac9951ff7ee69d043d43da9a0eeb51cd 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -1955,7 +1955,6 @@ adjust_appendrel_attrs_context allocfunc array_unnest_fctx assign_collations_context -attribute_used_context autovac_table av_relation avl_dbase