mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Rename rule CURRENT to OLD in source tree. Add mapping for backward
compatiblity with old rules.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: view.c,v 1.42 2000/02/15 03:36:39 thomas Exp $
|
||||
* $Id: view.c,v 1.43 2000/06/12 19:40:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -189,7 +189,7 @@ DefineViewRules(char *viewName, Query *viewParse)
|
||||
* This update consists of adding two new entries IN THE BEGINNING
|
||||
* of the range table (otherwise the rule system will die a slow,
|
||||
* horrible and painful death, and we do not want that now, do we?)
|
||||
* one for the CURRENT relation and one for the NEW one (both of
|
||||
* one for the OLD relation and one for the NEW one (both of
|
||||
* them refer in fact to the "view" relation).
|
||||
*
|
||||
* Of course we must also increase the 'varnos' of all the Var nodes
|
||||
@@ -224,10 +224,10 @@ UpdateRangeTableOfViewParse(char *viewName, Query *viewParse)
|
||||
|
||||
/*
|
||||
* create the 2 new range table entries and form the new range
|
||||
* table... CURRENT first, then NEW....
|
||||
* table... OLD first, then NEW....
|
||||
*/
|
||||
rt_entry1 = addRangeTableEntry(NULL, (char *) viewName,
|
||||
makeAttr("*CURRENT*", NULL),
|
||||
makeAttr("*OLD*", NULL),
|
||||
FALSE, FALSE, FALSE);
|
||||
rt_entry2 = addRangeTableEntry(NULL, (char *) viewName,
|
||||
makeAttr("*NEW*", NULL),
|
||||
@@ -276,7 +276,7 @@ DefineView(char *viewName, Query *viewParse)
|
||||
|
||||
/*
|
||||
* The range table of 'viewParse' does not contain entries for the
|
||||
* "CURRENT" and "NEW" relations. So... add them! NOTE: we make the
|
||||
* "OLD" and "NEW" relations. So... add them! NOTE: we make the
|
||||
* update in place! After this call 'viewParse' will never be what it
|
||||
* used to be...
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: analyze.c,v 1.146 2000/06/09 01:44:18 momjian Exp $
|
||||
* $Id: analyze.c,v 1.147 2000/06/12 19:40:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1351,7 +1351,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
|
||||
nothing_qry->commandType = CMD_NOTHING;
|
||||
|
||||
addRangeTableEntry(pstate, stmt->object->relname,
|
||||
makeAttr("*CURRENT*", NULL),
|
||||
makeAttr("*OLD*", NULL),
|
||||
FALSE, FALSE, FALSE);
|
||||
addRangeTableEntry(pstate, stmt->object->relname,
|
||||
makeAttr("*NEW*", NULL),
|
||||
@@ -1371,11 +1371,11 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
|
||||
{
|
||||
|
||||
/*
|
||||
* NOTE: 'CURRENT' must always have a varno equal to 1 and 'NEW'
|
||||
* NOTE: 'OLD' must always have a varno equal to 1 and 'NEW'
|
||||
* equal to 2.
|
||||
*/
|
||||
addRangeTableEntry(pstate, stmt->object->relname,
|
||||
makeAttr("*CURRENT*", NULL),
|
||||
makeAttr("*OLD*", NULL),
|
||||
FALSE, FALSE, FALSE);
|
||||
addRangeTableEntry(pstate, stmt->object->relname,
|
||||
makeAttr("*NEW*", NULL),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.172 2000/06/12 03:40:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.173 2000/06/12 19:40:40 momjian Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -298,7 +298,7 @@ static void doNegateFloat(Value *v);
|
||||
BEGIN_TRANS, BETWEEN, BOTH, BY,
|
||||
CASCADE, CASE, CAST, CHAR, CHARACTER, CHECK, CLOSE,
|
||||
COALESCE, COLLATE, COLUMN, COMMIT,
|
||||
CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT, CURRENT_DATE,
|
||||
CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT_DATE,
|
||||
CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
|
||||
DAY_P, DEC, DECIMAL, DECLARE, DEFAULT, DELETE, DESC,
|
||||
DISTINCT, DOUBLE, DROP,
|
||||
@@ -309,7 +309,7 @@ static void doNegateFloat(Value *v);
|
||||
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
|
||||
MATCH, MINUTE_P, MONTH_P, NAMES,
|
||||
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
|
||||
OF, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
|
||||
OF, OLD, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
|
||||
PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
|
||||
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
|
||||
SCROLL, SECOND_P, SELECT, SESSION_USER, SET, SOME, SUBSTRING,
|
||||
@@ -5509,7 +5509,6 @@ ColLabel: ColId { $$ = $1; }
|
||||
| CONSTRAINT { $$ = "constraint"; }
|
||||
| COPY { $$ = "copy"; }
|
||||
| CROSS { $$ = "cross"; }
|
||||
| CURRENT { $$ = "current"; }
|
||||
| CURRENT_DATE { $$ = "current_date"; }
|
||||
| CURRENT_TIME { $$ = "current_time"; }
|
||||
| CURRENT_TIMESTAMP { $$ = "current_timestamp"; }
|
||||
@@ -5564,6 +5563,7 @@ ColLabel: ColId { $$ = $1; }
|
||||
| NUMERIC { $$ = "numeric"; }
|
||||
| OFF { $$ = "off"; }
|
||||
| OFFSET { $$ = "offset"; }
|
||||
| OLD { $$ = "old"; }
|
||||
| ON { $$ = "on"; }
|
||||
| ONLY { $$ = "only"; }
|
||||
| OR { $$ = "or"; }
|
||||
@@ -5601,12 +5601,12 @@ ColLabel: ColId { $$ = $1; }
|
||||
| WHERE { $$ = "where"; }
|
||||
;
|
||||
|
||||
SpecialRuleRelation: CURRENT
|
||||
SpecialRuleRelation: OLD
|
||||
{
|
||||
if (QueryIsRule)
|
||||
$$ = "*CURRENT*";
|
||||
$$ = "*OLD*";
|
||||
else
|
||||
elog(ERROR,"CURRENT used in non-rule query");
|
||||
elog(ERROR,"OLD used in non-rule query");
|
||||
}
|
||||
| NEW
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
*
|
||||
* IDENTIFICATION
|
||||
<<<<<<< keywords.c
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.76 2000/06/12 03:40:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.77 2000/06/12 19:40:41 momjian Exp $
|
||||
=======
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.76 2000/06/12 03:40:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.77 2000/06/12 19:40:41 momjian Exp $
|
||||
>>>>>>> 1.73
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -77,6 +77,8 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"createdb", CREATEDB},
|
||||
{"createuser", CREATEUSER},
|
||||
{"cross", CROSS},
|
||||
/* for portability with old rules bjm 2000-06-12 */
|
||||
{"current", OLD},
|
||||
{"current_date", CURRENT_DATE},
|
||||
{"current_time", CURRENT_TIME},
|
||||
{"current_timestamp", CURRENT_TIMESTAMP},
|
||||
@@ -183,7 +185,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"off", OFF},
|
||||
{"offset", OFFSET},
|
||||
{"oids", OIDS},
|
||||
{"old", CURRENT},
|
||||
{"old", OLD},
|
||||
{"on", ON},
|
||||
{"only", ONLY},
|
||||
{"operator", OPERATOR},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.42 2000/06/08 22:37:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.43 2000/06/12 19:40:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -250,7 +250,7 @@ addRangeTableEntry(ParseState *pstate,
|
||||
|
||||
if (rt_index != 0 && (!inFromCl || sublevels_up == 0))
|
||||
{
|
||||
if (!strcmp(ref->relname, "*CURRENT*") || !strcmp(ref->relname, "*NEW*"))
|
||||
if (!strcmp(ref->relname, "*OLD*") || !strcmp(ref->relname, "*NEW*"))
|
||||
return (RangeTblEntry *) nth(rt_index - 1, pstate->p_rtable);
|
||||
elog(ERROR, "Table name '%s' specified more than once", ref->relname);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.74 2000/05/30 00:49:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.75 2000/06/12 19:40:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -107,11 +107,11 @@ gatherRewriteMeta(Query *parsetree,
|
||||
OffsetVarNodes((Node *) info->rule_action->targetList, rt_length, 0);
|
||||
OffsetVarNodes(info->rule_qual, rt_length, 0);
|
||||
ChangeVarNodes((Node *) info->rule_action->qual,
|
||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
ChangeVarNodes((Node *) info->rule_action->targetList,
|
||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
ChangeVarNodes(info->rule_qual,
|
||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
|
||||
/*
|
||||
* bug here about replace CURRENT -- sort of replace current is
|
||||
@@ -125,7 +125,7 @@ gatherRewriteMeta(Query *parsetree,
|
||||
result_reln = info->rule_action->resultRelation;
|
||||
switch (result_reln)
|
||||
{
|
||||
case PRS2_CURRENT_VARNO:
|
||||
case PRS2_OLD_VARNO:
|
||||
new_result_reln = rt_index;
|
||||
break;
|
||||
case PRS2_NEW_VARNO: /* XXX */
|
||||
@@ -796,9 +796,9 @@ ApplyRetrieveRule(Query *parsetree,
|
||||
OffsetVarNodes((Node *) rule_action, rt_length, 0);
|
||||
|
||||
ChangeVarNodes((Node *) rule_qual,
|
||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
ChangeVarNodes((Node *) rule_action,
|
||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
|
||||
if (relation_level)
|
||||
{
|
||||
@@ -1061,7 +1061,7 @@ CopyAndAddQual(Query *parsetree,
|
||||
rtable = nconc(rtable, copyObject(rule_action->rtable));
|
||||
new_tree->rtable = rtable;
|
||||
OffsetVarNodes(new_qual, rt_length, 0);
|
||||
ChangeVarNodes(new_qual, PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
||||
ChangeVarNodes(new_qual, PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||
}
|
||||
/* XXX -- where current doesn't work for instead nothing.... yet */
|
||||
AddNotQual(new_tree, new_qual);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* out of its tuple
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.52 2000/06/10 05:17:23 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.53 2000/06/12 19:40:43 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -912,7 +912,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
||||
|
||||
/* ----------
|
||||
* Now check if any of the used rangetable entries is different
|
||||
* from *NEW* and *CURRENT*. If so we must provide the FROM clause
|
||||
* from *NEW* and *OLD*. If so we must provide the FROM clause
|
||||
* later.
|
||||
* ----------
|
||||
*/
|
||||
@@ -927,7 +927,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
||||
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||
continue;
|
||||
|
||||
rt_constonly = FALSE;
|
||||
@@ -973,7 +973,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
||||
quote_identifier(tle->resdom->resname));
|
||||
}
|
||||
|
||||
/* If we need other tables than *NEW* or *CURRENT* add the FROM clause */
|
||||
/* If we need other tables than *NEW* or *OLD* add the FROM clause */
|
||||
if (!rt_constonly && rt_numused > 0)
|
||||
{
|
||||
sep = " FROM ";
|
||||
@@ -988,7 +988,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
||||
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||
continue;
|
||||
|
||||
appendStringInfo(buf, sep);
|
||||
@@ -1074,7 +1074,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
||||
List *l;
|
||||
|
||||
/* ----------
|
||||
* We need to know if other tables than *NEW* or *CURRENT*
|
||||
* We need to know if other tables than *NEW* or *OLD*
|
||||
* are used in the query. If not, it's an INSERT ... VALUES,
|
||||
* otherwise an INSERT ... SELECT.
|
||||
* ----------
|
||||
@@ -1105,7 +1105,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||
continue;
|
||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
||||
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||
continue;
|
||||
|
||||
rt_constonly = FALSE;
|
||||
@@ -1278,7 +1278,7 @@ get_rule_expr(Node *node, deparse_context *context)
|
||||
quote_identifier(rte->relname));
|
||||
else if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||
appendStringInfo(buf, "new.");
|
||||
else if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
||||
else if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||
appendStringInfo(buf, "old.");
|
||||
else
|
||||
appendStringInfo(buf, "%s.",
|
||||
|
||||
Reference in New Issue
Block a user