Rename rule CURRENT to OLD in source tree. Add mapping for backward
compatiblity with old rules.
This commit is contained in:
parent
767e6d17b4
commit
332f0f5fc0
src
backend
commands
parser
rewrite
utils/adt
include
interfaces/ecpg/preproc
test/regress/expected
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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
|
* This update consists of adding two new entries IN THE BEGINNING
|
||||||
* of the range table (otherwise the rule system will die a slow,
|
* 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?)
|
* 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).
|
* them refer in fact to the "view" relation).
|
||||||
*
|
*
|
||||||
* Of course we must also increase the 'varnos' of all the Var nodes
|
* 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
|
* 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,
|
rt_entry1 = addRangeTableEntry(NULL, (char *) viewName,
|
||||||
makeAttr("*CURRENT*", NULL),
|
makeAttr("*OLD*", NULL),
|
||||||
FALSE, FALSE, FALSE);
|
FALSE, FALSE, FALSE);
|
||||||
rt_entry2 = addRangeTableEntry(NULL, (char *) viewName,
|
rt_entry2 = addRangeTableEntry(NULL, (char *) viewName,
|
||||||
makeAttr("*NEW*", NULL),
|
makeAttr("*NEW*", NULL),
|
||||||
@ -276,7 +276,7 @@ DefineView(char *viewName, Query *viewParse)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The range table of 'viewParse' does not contain entries for the
|
* 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
|
* update in place! After this call 'viewParse' will never be what it
|
||||||
* used to be...
|
* used to be...
|
||||||
*/
|
*/
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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;
|
nothing_qry->commandType = CMD_NOTHING;
|
||||||
|
|
||||||
addRangeTableEntry(pstate, stmt->object->relname,
|
addRangeTableEntry(pstate, stmt->object->relname,
|
||||||
makeAttr("*CURRENT*", NULL),
|
makeAttr("*OLD*", NULL),
|
||||||
FALSE, FALSE, FALSE);
|
FALSE, FALSE, FALSE);
|
||||||
addRangeTableEntry(pstate, stmt->object->relname,
|
addRangeTableEntry(pstate, stmt->object->relname,
|
||||||
makeAttr("*NEW*", NULL),
|
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.
|
* equal to 2.
|
||||||
*/
|
*/
|
||||||
addRangeTableEntry(pstate, stmt->object->relname,
|
addRangeTableEntry(pstate, stmt->object->relname,
|
||||||
makeAttr("*CURRENT*", NULL),
|
makeAttr("*OLD*", NULL),
|
||||||
FALSE, FALSE, FALSE);
|
FALSE, FALSE, FALSE);
|
||||||
addRangeTableEntry(pstate, stmt->object->relname,
|
addRangeTableEntry(pstate, stmt->object->relname,
|
||||||
makeAttr("*NEW*", NULL),
|
makeAttr("*NEW*", NULL),
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -298,7 +298,7 @@ static void doNegateFloat(Value *v);
|
|||||||
BEGIN_TRANS, BETWEEN, BOTH, BY,
|
BEGIN_TRANS, BETWEEN, BOTH, BY,
|
||||||
CASCADE, CASE, CAST, CHAR, CHARACTER, CHECK, CLOSE,
|
CASCADE, CASE, CAST, CHAR, CHARACTER, CHECK, CLOSE,
|
||||||
COALESCE, COLLATE, COLUMN, COMMIT,
|
COALESCE, COLLATE, COLUMN, COMMIT,
|
||||||
CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT, CURRENT_DATE,
|
CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT_DATE,
|
||||||
CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
|
CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
|
||||||
DAY_P, DEC, DECIMAL, DECLARE, DEFAULT, DELETE, DESC,
|
DAY_P, DEC, DECIMAL, DECLARE, DEFAULT, DELETE, DESC,
|
||||||
DISTINCT, DOUBLE, DROP,
|
DISTINCT, DOUBLE, DROP,
|
||||||
@ -309,7 +309,7 @@ static void doNegateFloat(Value *v);
|
|||||||
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
|
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
|
||||||
MATCH, MINUTE_P, MONTH_P, NAMES,
|
MATCH, MINUTE_P, MONTH_P, NAMES,
|
||||||
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
|
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,
|
PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
|
||||||
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
|
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
|
||||||
SCROLL, SECOND_P, SELECT, SESSION_USER, SET, SOME, SUBSTRING,
|
SCROLL, SECOND_P, SELECT, SESSION_USER, SET, SOME, SUBSTRING,
|
||||||
@ -5509,7 +5509,6 @@ ColLabel: ColId { $$ = $1; }
|
|||||||
| CONSTRAINT { $$ = "constraint"; }
|
| CONSTRAINT { $$ = "constraint"; }
|
||||||
| COPY { $$ = "copy"; }
|
| COPY { $$ = "copy"; }
|
||||||
| CROSS { $$ = "cross"; }
|
| CROSS { $$ = "cross"; }
|
||||||
| CURRENT { $$ = "current"; }
|
|
||||||
| CURRENT_DATE { $$ = "current_date"; }
|
| CURRENT_DATE { $$ = "current_date"; }
|
||||||
| CURRENT_TIME { $$ = "current_time"; }
|
| CURRENT_TIME { $$ = "current_time"; }
|
||||||
| CURRENT_TIMESTAMP { $$ = "current_timestamp"; }
|
| CURRENT_TIMESTAMP { $$ = "current_timestamp"; }
|
||||||
@ -5564,6 +5563,7 @@ ColLabel: ColId { $$ = $1; }
|
|||||||
| NUMERIC { $$ = "numeric"; }
|
| NUMERIC { $$ = "numeric"; }
|
||||||
| OFF { $$ = "off"; }
|
| OFF { $$ = "off"; }
|
||||||
| OFFSET { $$ = "offset"; }
|
| OFFSET { $$ = "offset"; }
|
||||||
|
| OLD { $$ = "old"; }
|
||||||
| ON { $$ = "on"; }
|
| ON { $$ = "on"; }
|
||||||
| ONLY { $$ = "only"; }
|
| ONLY { $$ = "only"; }
|
||||||
| OR { $$ = "or"; }
|
| OR { $$ = "or"; }
|
||||||
@ -5601,12 +5601,12 @@ ColLabel: ColId { $$ = $1; }
|
|||||||
| WHERE { $$ = "where"; }
|
| WHERE { $$ = "where"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
SpecialRuleRelation: CURRENT
|
SpecialRuleRelation: OLD
|
||||||
{
|
{
|
||||||
if (QueryIsRule)
|
if (QueryIsRule)
|
||||||
$$ = "*CURRENT*";
|
$$ = "*OLD*";
|
||||||
else
|
else
|
||||||
elog(ERROR,"CURRENT used in non-rule query");
|
elog(ERROR,"OLD used in non-rule query");
|
||||||
}
|
}
|
||||||
| NEW
|
| NEW
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
<<<<<<< keywords.c
|
<<<<<<< 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
|
>>>>>>> 1.73
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
@ -77,6 +77,8 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"createdb", CREATEDB},
|
{"createdb", CREATEDB},
|
||||||
{"createuser", CREATEUSER},
|
{"createuser", CREATEUSER},
|
||||||
{"cross", CROSS},
|
{"cross", CROSS},
|
||||||
|
/* for portability with old rules bjm 2000-06-12 */
|
||||||
|
{"current", OLD},
|
||||||
{"current_date", CURRENT_DATE},
|
{"current_date", CURRENT_DATE},
|
||||||
{"current_time", CURRENT_TIME},
|
{"current_time", CURRENT_TIME},
|
||||||
{"current_timestamp", CURRENT_TIMESTAMP},
|
{"current_timestamp", CURRENT_TIMESTAMP},
|
||||||
@ -183,7 +185,7 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"off", OFF},
|
{"off", OFF},
|
||||||
{"offset", OFFSET},
|
{"offset", OFFSET},
|
||||||
{"oids", OIDS},
|
{"oids", OIDS},
|
||||||
{"old", CURRENT},
|
{"old", OLD},
|
||||||
{"on", ON},
|
{"on", ON},
|
||||||
{"only", ONLY},
|
{"only", ONLY},
|
||||||
{"operator", OPERATOR},
|
{"operator", OPERATOR},
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 (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);
|
return (RangeTblEntry *) nth(rt_index - 1, pstate->p_rtable);
|
||||||
elog(ERROR, "Table name '%s' specified more than once", ref->relname);
|
elog(ERROR, "Table name '%s' specified more than once", ref->relname);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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((Node *) info->rule_action->targetList, rt_length, 0);
|
||||||
OffsetVarNodes(info->rule_qual, rt_length, 0);
|
OffsetVarNodes(info->rule_qual, rt_length, 0);
|
||||||
ChangeVarNodes((Node *) info->rule_action->qual,
|
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,
|
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,
|
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
|
* bug here about replace CURRENT -- sort of replace current is
|
||||||
@ -125,7 +125,7 @@ gatherRewriteMeta(Query *parsetree,
|
|||||||
result_reln = info->rule_action->resultRelation;
|
result_reln = info->rule_action->resultRelation;
|
||||||
switch (result_reln)
|
switch (result_reln)
|
||||||
{
|
{
|
||||||
case PRS2_CURRENT_VARNO:
|
case PRS2_OLD_VARNO:
|
||||||
new_result_reln = rt_index;
|
new_result_reln = rt_index;
|
||||||
break;
|
break;
|
||||||
case PRS2_NEW_VARNO: /* XXX */
|
case PRS2_NEW_VARNO: /* XXX */
|
||||||
@ -796,9 +796,9 @@ ApplyRetrieveRule(Query *parsetree,
|
|||||||
OffsetVarNodes((Node *) rule_action, rt_length, 0);
|
OffsetVarNodes((Node *) rule_action, rt_length, 0);
|
||||||
|
|
||||||
ChangeVarNodes((Node *) rule_qual,
|
ChangeVarNodes((Node *) rule_qual,
|
||||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||||
ChangeVarNodes((Node *) rule_action,
|
ChangeVarNodes((Node *) rule_action,
|
||||||
PRS2_CURRENT_VARNO + rt_length, rt_index, 0);
|
PRS2_OLD_VARNO + rt_length, rt_index, 0);
|
||||||
|
|
||||||
if (relation_level)
|
if (relation_level)
|
||||||
{
|
{
|
||||||
@ -1061,7 +1061,7 @@ CopyAndAddQual(Query *parsetree,
|
|||||||
rtable = nconc(rtable, copyObject(rule_action->rtable));
|
rtable = nconc(rtable, copyObject(rule_action->rtable));
|
||||||
new_tree->rtable = rtable;
|
new_tree->rtable = rtable;
|
||||||
OffsetVarNodes(new_qual, rt_length, 0);
|
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 */
|
/* XXX -- where current doesn't work for instead nothing.... yet */
|
||||||
AddNotQual(new_tree, new_qual);
|
AddNotQual(new_tree, new_qual);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* out of its tuple
|
* out of its tuple
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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.
|
* 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
|
* 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.
|
* later.
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
@ -927,7 +927,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
|||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rt_constonly = FALSE;
|
rt_constonly = FALSE;
|
||||||
@ -973,7 +973,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
|||||||
quote_identifier(tle->resdom->resname));
|
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)
|
if (!rt_constonly && rt_numused > 0)
|
||||||
{
|
{
|
||||||
sep = " FROM ";
|
sep = " FROM ";
|
||||||
@ -988,7 +988,7 @@ get_select_query_def(Query *query, deparse_context *context)
|
|||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
appendStringInfo(buf, sep);
|
appendStringInfo(buf, sep);
|
||||||
@ -1074,7 +1074,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
|||||||
List *l;
|
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,
|
* are used in the query. If not, it's an INSERT ... VALUES,
|
||||||
* otherwise an INSERT ... SELECT.
|
* otherwise an INSERT ... SELECT.
|
||||||
* ----------
|
* ----------
|
||||||
@ -1105,7 +1105,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
|||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*NEW*"))
|
if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rt_constonly = FALSE;
|
rt_constonly = FALSE;
|
||||||
@ -1278,7 +1278,7 @@ get_rule_expr(Node *node, deparse_context *context)
|
|||||||
quote_identifier(rte->relname));
|
quote_identifier(rte->relname));
|
||||||
else if (!strcmp(rte->ref->relname, "*NEW*"))
|
else if (!strcmp(rte->ref->relname, "*NEW*"))
|
||||||
appendStringInfo(buf, "new.");
|
appendStringInfo(buf, "new.");
|
||||||
else if (!strcmp(rte->ref->relname, "*CURRENT*"))
|
else if (!strcmp(rte->ref->relname, "*OLD*"))
|
||||||
appendStringInfo(buf, "old.");
|
appendStringInfo(buf, "old.");
|
||||||
else
|
else
|
||||||
appendStringInfo(buf, "%s.",
|
appendStringInfo(buf, "%s.",
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: primnodes.h,v 1.42 2000/05/25 22:42:19 tgl Exp $
|
* $Id: primnodes.h,v 1.43 2000/06/12 19:40:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -142,7 +142,7 @@ typedef struct Expr
|
|||||||
#define INNER 65000
|
#define INNER 65000
|
||||||
#define OUTER 65001
|
#define OUTER 65001
|
||||||
|
|
||||||
#define PRS2_CURRENT_VARNO 1
|
#define PRS2_OLD_VARNO 1
|
||||||
#define PRS2_NEW_VARNO 2
|
#define PRS2_NEW_VARNO 2
|
||||||
|
|
||||||
typedef struct Var
|
typedef struct Var
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: parsetree.h,v 1.9 2000/02/15 03:38:29 thomas Exp $
|
* $Id: parsetree.h,v 1.10 2000/06/12 19:40:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -39,7 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define rt_relname(rt_entry) \
|
#define rt_relname(rt_entry) \
|
||||||
((!strcmp(((rt_entry)->ref->relname),"*CURRENT*") ||\
|
((!strcmp(((rt_entry)->ref->relname),"*OLD*") ||\
|
||||||
!strcmp(((rt_entry)->ref->relname),"*NEW*")) ? ((rt_entry)->ref->relname) : \
|
!strcmp(((rt_entry)->ref->relname),"*NEW*")) ? ((rt_entry)->ref->relname) : \
|
||||||
((char *)(rt_entry)->relname))
|
((char *)(rt_entry)->relname))
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.27 2000/06/09 01:44:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.28 2000/06/12 19:40:55 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -73,6 +73,8 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"createdb", CREATEDB},
|
{"createdb", CREATEDB},
|
||||||
{"createuser", CREATEUSER},
|
{"createuser", CREATEUSER},
|
||||||
{"cross", CROSS},
|
{"cross", CROSS},
|
||||||
|
/* for portability with old rules bjm 2000-06-12 */
|
||||||
|
{"current", OLD},
|
||||||
{"current_date", CURRENT_DATE},
|
{"current_date", CURRENT_DATE},
|
||||||
{"current_time", CURRENT_TIME},
|
{"current_time", CURRENT_TIME},
|
||||||
{"current_timestamp", CURRENT_TIMESTAMP},
|
{"current_timestamp", CURRENT_TIMESTAMP},
|
||||||
@ -178,7 +180,7 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"of", OF},
|
{"of", OF},
|
||||||
{"offset", OFFSET},
|
{"offset", OFFSET},
|
||||||
{"oids", OIDS},
|
{"oids", OIDS},
|
||||||
{"old", CURRENT},
|
{"old", OLD},
|
||||||
{"on", ON},
|
{"on", ON},
|
||||||
{"only", ONLY},
|
{"only", ONLY},
|
||||||
{"operator", OPERATOR},
|
{"operator", OPERATOR},
|
||||||
|
@ -196,7 +196,7 @@ make_name(void)
|
|||||||
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
|
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
|
||||||
MATCH, MINUTE_P, MONTH_P, NAMES,
|
MATCH, MINUTE_P, MONTH_P, NAMES,
|
||||||
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
|
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,
|
PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
|
||||||
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
|
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
|
||||||
SCROLL, SECOND_P, SELECT, SESSION_USER, SET, SOME, SUBSTRING,
|
SCROLL, SECOND_P, SELECT, SESSION_USER, SET, SOME, SUBSTRING,
|
||||||
@ -223,20 +223,19 @@ make_name(void)
|
|||||||
* - Todd A. Brandys 1998-01-01?
|
* - Todd A. Brandys 1998-01-01?
|
||||||
*/
|
*/
|
||||||
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE,
|
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE,
|
||||||
BACKWARD, BEFORE, BINARY, BIT
|
BACKWARD, BEFORE, BINARY, BIT, CACHE, CLUSTER, COMMENT,
|
||||||
CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
|
COPY, CREATEDB, CREATEUSER, CYCLE, DATABASE,
|
||||||
DATABASE, DELIMITERS, DO,
|
DELIMITERS, DO, EACH, ENCODING, EXCLUSIVE, EXPLAIN,
|
||||||
EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND,
|
EXTEND, FORCE, FORWARD, FUNCTION, HANDLER, INCREMENT,
|
||||||
FORCE, FORWARD, FUNCTION, HANDLER,
|
INDEX, INHERITS, INSTEAD, ISNULL, LANCOMPILER, LIMIT,
|
||||||
INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
|
LISTEN, UNLISTEN, LOAD, LOCATION, LOCK_P, MAXVALUE,
|
||||||
LANCOMPILER, LIMIT, LISTEN, UNLISTEN, LOAD, LOCATION, LOCK_P,
|
MINVALUE, MODE, MOVE, NEW, NOCREATEDB, NOCREATEUSER,
|
||||||
MAXVALUE, MINVALUE, MODE, MOVE,
|
NONE, NOTHING, NOTIFY, NOTNULL, OFFSET, OLD, OIDS,
|
||||||
NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
|
OPERATOR, PASSWORD, PROCEDURAL, REINDEX, RENAME, RESET,
|
||||||
OFFSET, OIDS, OPERATOR, PASSWORD, PROCEDURAL,
|
RETURNS, ROW, RULE, SEQUENCE, SERIAL, SETOF, SHARE,
|
||||||
REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
|
SHOW, START, STATEMENT, STDIN, STDOUT, SYSID TEMP,
|
||||||
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID
|
TRUNCATE, TRUSTED, UNDER, UNLISTEN, UNTIL, VACUUM,
|
||||||
TEMP, TRUNCATE, TRUSTED,
|
VALID, VERBOSE, VERSION
|
||||||
UNDER, UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION
|
|
||||||
|
|
||||||
/* Special keywords, not in the query language - see the "lex" file */
|
/* Special keywords, not in the query language - see the "lex" file */
|
||||||
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE
|
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE
|
||||||
@ -3911,12 +3910,12 @@ ColLabel: ECPGLabelTypeName { $$ = $1; }
|
|||||||
| ECPGColLabel { $$ = $1; }
|
| ECPGColLabel { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
SpecialRuleRelation: CURRENT
|
SpecialRuleRelation: OLD
|
||||||
{
|
{
|
||||||
if (QueryIsRule)
|
if (QueryIsRule)
|
||||||
$$ = make_str("current");
|
$$ = make_str("old");
|
||||||
else
|
else
|
||||||
mmerror(ET_ERROR, "CURRENT used in non-rule query");
|
mmerror(ET_ERROR, "OLD used in non-rule query");
|
||||||
}
|
}
|
||||||
| NEW
|
| NEW
|
||||||
{
|
{
|
||||||
@ -5122,7 +5121,6 @@ ECPGColLabel: ECPGColId { $$ = $1; }
|
|||||||
| CONSTRAINT { $$ = make_str("constraint"); }
|
| CONSTRAINT { $$ = make_str("constraint"); }
|
||||||
| COPY { $$ = make_str("copy"); }
|
| COPY { $$ = make_str("copy"); }
|
||||||
| CROSS { $$ = make_str("cross"); }
|
| CROSS { $$ = make_str("cross"); }
|
||||||
| CURRENT { $$ = make_str("current"); }
|
|
||||||
| CURRENT_DATE { $$ = make_str("current_date"); }
|
| CURRENT_DATE { $$ = make_str("current_date"); }
|
||||||
| CURRENT_TIME { $$ = make_str("current_time"); }
|
| CURRENT_TIME { $$ = make_str("current_time"); }
|
||||||
| CURRENT_TIMESTAMP { $$ = make_str("current_timestamp"); }
|
| CURRENT_TIMESTAMP { $$ = make_str("current_timestamp"); }
|
||||||
@ -5174,6 +5172,7 @@ ECPGColLabel: ECPGColId { $$ = $1; }
|
|||||||
| NULL_P { $$ = make_str("null"); }
|
| NULL_P { $$ = make_str("null"); }
|
||||||
| NUMERIC { $$ = make_str("numeric"); }
|
| NUMERIC { $$ = make_str("numeric"); }
|
||||||
| OFFSET { $$ = make_str("offset"); }
|
| OFFSET { $$ = make_str("offset"); }
|
||||||
|
| OLD { $$ = make_str("old"); }
|
||||||
| ON { $$ = make_str("on"); }
|
| ON { $$ = make_str("on"); }
|
||||||
| OR { $$ = make_str("or"); }
|
| OR { $$ = make_str("or"); }
|
||||||
| ORDER { $$ = make_str("order"); }
|
| ORDER { $$ = make_str("order"); }
|
||||||
|
@ -1168,7 +1168,7 @@ SELECT viewname, definition FROM pg_views ORDER BY viewname;
|
|||||||
pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((c.oid = x.indrelid) AND (i.oid = x.indexrelid));
|
pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((c.oid = x.indrelid) AND (i.oid = x.indexrelid));
|
||||||
pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
|
pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
|
||||||
pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE (((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char")) AND (NOT (EXISTS (SELECT pg_rewrite.rulename FROM pg_rewrite WHERE ((pg_rewrite.ev_class = c.oid) AND (pg_rewrite.ev_type = '1'::"char"))))));
|
pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE (((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char")) AND (NOT (EXISTS (SELECT pg_rewrite.rulename FROM pg_rewrite WHERE ((pg_rewrite.ev_class = c.oid) AND (pg_rewrite.ev_type = '1'::"char"))))));
|
||||||
pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usecreatetable, pg_shadow.uselocktable, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
|
pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
|
||||||
pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relhasrules AND (EXISTS (SELECT r.rulename FROM pg_rewrite r WHERE ((r.ev_class = c.oid) AND (r.ev_type = '1'::"char")))));
|
pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relhasrules AND (EXISTS (SELECT r.rulename FROM pg_rewrite r WHERE ((r.ev_class = c.oid) AND (r.ev_type = '1'::"char")))));
|
||||||
rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
|
rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
|
||||||
rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
|
rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user