Commit 8e958b8a authored by Bruce Momjian's avatar Bruce Momjian

Fix create_rule is->as.

parent 7ab88a16
...@@ -235,7 +235,7 @@ At the time of publication, the following platforms have been tested: ...@@ -235,7 +235,7 @@ At the time of publication, the following platforms have been tested:
<ENTRY>x86</ENTRY> <ENTRY>x86</ENTRY>
<ENTRY>v6.4</ENTRY> <ENTRY>v6.4</ENTRY>
<ENTRY>1998-10-08</ENTRY> <ENTRY>1998-10-08</ENTRY>
<ENTRY>Mostly working with the Cygwin library. No DLLs yet. <ENTRY>Working with the Cygwin library.
(<ulink url="mailto:Dan.Horak@email.cz">Horak Daniel</ulink>) </ENTRY> (<ulink url="mailto:Dan.Horak@email.cz">Horak Daniel</ulink>) </ENTRY>
</ROW> </ROW>
</TBODY> </TBODY>
...@@ -251,11 +251,7 @@ confirmation of such at the time this list was compiled. ...@@ -251,11 +251,7 @@ confirmation of such at the time this list was compiled.
<para> <para>
For <productname>Windows NT</productname>, For <productname>Windows NT</productname>,
the server-side port of <productname>Postgres</productname> has recently been the server-side port of <productname>Postgres</productname> has recently been
accomplished. Check accomplished. The Cygnus library is required to compile it.
<ulink url="http://www.askesis.nl/AskesisPostgresIndex.html">the Askesis Postgres Home Page</ulink>
for up to date information. You may also want to
look for possible patches on the
<ulink url="http://postgresql.org">Postgres web site</ulink>.
</para> </para>
</note> </note>
</sect1> </sect1>
......
...@@ -198,11 +198,11 @@ Without ...@@ -198,11 +198,11 @@ Without
<example> <example>
<title>Example of a circular rewrite rule combination.</title> <title>Example of a circular rewrite rule combination.</title>
<programlisting> <programlisting>
create rule bad_rule_combination_1 is create rule bad_rule_combination_1 as
on select to EMP on select to EMP
do instead select to TOYEMP do instead select to TOYEMP
create rule bad_rule_combination_2 is create rule bad_rule_combination_2 as
on select to TOYEMP on select to TOYEMP
do instead select to EMP do instead select to EMP
</programlisting> </programlisting>
...@@ -232,7 +232,7 @@ select * from EMP ...@@ -232,7 +232,7 @@ select * from EMP
Make Sam get the same salary adjustment as Joe: Make Sam get the same salary adjustment as Joe:
<programlisting> <programlisting>
create rule example_1 is create rule example_1 as
on update EMP.salary where current.name = "Joe" on update EMP.salary where current.name = "Joe"
do update EMP (salary = new.salary) do update EMP (salary = new.salary)
where EMP.name = "Sam" where EMP.name = "Sam"
...@@ -248,7 +248,7 @@ create rule example_1 is ...@@ -248,7 +248,7 @@ create rule example_1 is
<para> <para>
Make Bill get Joe's salary when it is accessed: Make Bill get Joe's salary when it is accessed:
<programlisting> <programlisting>
create rule example_2 is create rule example_2 as
on select to EMP.salary on select to EMP.salary
where current.name = "Bill" where current.name = "Bill"
do instead do instead
...@@ -261,7 +261,7 @@ create rule example_2 is ...@@ -261,7 +261,7 @@ create rule example_2 is
department (<function>current_user</function> returns the name of department (<function>current_user</function> returns the name of
the current user): the current user):
<programlisting> <programlisting>
create rule example_3 is create rule example_3 as
on select to EMP.salary on select to EMP.salary
where current.dept = "shoe" and current_user = "Joe" where current.dept = "shoe" and current_user = "Joe"
do instead nothing do instead nothing
...@@ -272,7 +272,7 @@ create rule example_3 is ...@@ -272,7 +272,7 @@ create rule example_3 is
<programlisting> <programlisting>
create TOYEMP(name = char16, salary = int4) create TOYEMP(name = char16, salary = int4)
create rule example_4 is create rule example_4 as
on select to TOYEMP on select to TOYEMP
do instead do instead
select (EMP.name, EMP.salary) from EMP select (EMP.name, EMP.salary) from EMP
...@@ -282,7 +282,7 @@ create rule example_4 is ...@@ -282,7 +282,7 @@ create rule example_4 is
<para> <para>
All new employees must make 5,000 or less All new employees must make 5,000 or less
<programlisting> <programlisting>
create rule example_5 is create rule example_5 as
on insert to EMP where new.salary > 5000 on insert to EMP where new.salary > 5000
do update newset salary = 5000 do update newset salary = 5000
</programlisting> </programlisting>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.38 1999/01/25 18:02:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.39 1999/02/02 17:46:14 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -235,11 +235,10 @@ union_planner(Query *parse) ...@@ -235,11 +235,10 @@ union_planner(Query *parse)
/***S*H***/ /***S*H***/
/* Use 'new_tlist' instead of 'tlist' */ /* Use 'new_tlist' instead of 'tlist' */
result_plan = result_plan = make_groupPlan(&new_tlist,
make_groupPlan(&new_tlist, tuplePerGroup,
tuplePerGroup, parse->groupClause,
parse->groupClause, result_plan);
result_plan);
} }
/* /*
...@@ -255,13 +254,12 @@ union_planner(Query *parse) ...@@ -255,13 +254,12 @@ union_planner(Query *parse)
result_plan = (Plan *) make_agg(tlist, result_plan); result_plan = (Plan *) make_agg(tlist, result_plan);
/* /*
* set the varno/attno entries to the appropriate references to * get the varno/attno entries to the appropriate references to
* the result tuple of the subplans. * the result tuple of the subplans.
*/ */
((Agg *) result_plan)->aggs = ((Agg *) result_plan)->aggs =
get_agg_tlist_references((Agg *) result_plan); get_agg_tlist_references((Agg *) result_plan);
/***S*H***/ /***S*H***/
if(parse->havingQual!=NULL) if(parse->havingQual!=NULL)
{ {
...@@ -299,11 +297,13 @@ union_planner(Query *parse) ...@@ -299,11 +297,13 @@ union_planner(Query *parse)
((Agg *) result_plan)->plan.qual=(List *) parse->havingQual; ((Agg *) result_plan)->plan.qual=(List *) parse->havingQual;
/* Check every clause of the havingQual for aggregates used and append /* Check every clause of the havingQual for aggregates used and append
* them to result_plan->aggs */ * them to result_plan->aggs
*/
foreach(clause, ((Agg *) result_plan)->plan.qual) foreach(clause, ((Agg *) result_plan)->plan.qual)
{ {
/* Make sure there are aggregates in the havingQual /* Make sure there are aggregates in the havingQual
* if so, the list must be longer after check_having_qual_for_aggs */ * if so, the list must be longer after check_having_qual_for_aggs
*/
old_length=length(((Agg *) result_plan)->aggs); old_length=length(((Agg *) result_plan)->aggs);
((Agg *) result_plan)->aggs = nconc(((Agg *) result_plan)->aggs, ((Agg *) result_plan)->aggs = nconc(((Agg *) result_plan)->aggs,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.34 1999/01/26 05:57:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.35 1999/02/02 17:46:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -701,7 +701,7 @@ OperandIsInner(Node *opnd, int inner_relid) ...@@ -701,7 +701,7 @@ OperandIsInner(Node *opnd, int inner_relid)
/*--------------------------------------------------------- /*---------------------------------------------------------
* *
* get_agg_tlist_references - * get_agg_tlist_references -
* changes the target list of an Agg node so that it points to * generates the target list of an Agg node so that it points to
* the tuples returned by its left tree subplan. * the tuples returned by its left tree subplan.
* *
* We now also generate a linked list of Aggref pointers for Agg. * We now also generate a linked list of Aggref pointers for Agg.
...@@ -1177,8 +1177,7 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla ...@@ -1177,8 +1177,7 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla
foreach(t, ((List *) ((SubLink *) ((SubPlan *) foreach(t, ((List *) ((SubLink *) ((SubPlan *)
((Expr *) clause)->oper)->sublink)->lefthand)) ((Expr *) clause)->oper)->sublink)->lefthand))
{ {
agg_list = agg_list = nconc(agg_list,
nconc(agg_list,
check_having_qual_for_aggs(lfirst(t), check_having_qual_for_aggs(lfirst(t),
subplanTargetList, groupClause)); subplanTargetList, groupClause));
} }
...@@ -1190,9 +1189,8 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla ...@@ -1190,9 +1189,8 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla
foreach(tmp_ptr, ((SubLink *) ((SubPlan *) foreach(tmp_ptr, ((SubLink *) ((SubPlan *)
((Expr *) clause)->oper)->sublink)->oper) ((Expr *) clause)->oper)->sublink)->oper)
{ {
agg_list = agg_list = nconc(agg_list,
nconc(agg_list, check_having_qual_for_aggs((Node *) lfirst(((Expr *)
check_having_qual_for_aggs((Node *) lfirst(((Expr *)
lfirst(tmp_ptr))->args), lfirst(tmp_ptr))->args),
subplanTargetList, groupClause)); subplanTargetList, groupClause));
} }
...@@ -1220,9 +1218,8 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla ...@@ -1220,9 +1218,8 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla
*/ */
if (contained_in_group_clause) if (contained_in_group_clause)
{ {
agg_list = agg_list = nconc(agg_list,
nconc(agg_list, check_having_qual_for_aggs(lfirst(t),
check_having_qual_for_aggs(lfirst(t),
subplanTargetList, groupClause)); subplanTargetList, groupClause));
} }
else else
...@@ -1235,7 +1232,6 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla ...@@ -1235,7 +1232,6 @@ check_having_qual_for_aggs(Node *clause, List *subplanTargetList, List *groupCla
} }
else else
{ {
/* /*
* Ooops! we can not handle that! * Ooops! we can not handle that!
*/ */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: planmain.h,v 1.18 1999/01/25 18:02:28 momjian Exp $ * $Id: planmain.h,v 1.19 1999/02/02 17:46:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -51,7 +51,7 @@ extern void add_missing_vars_to_tlist(Query *root, List *tlist); ...@@ -51,7 +51,7 @@ extern void add_missing_vars_to_tlist(Query *root, List *tlist);
*/ */
extern void set_tlist_references(Plan *plan); extern void set_tlist_references(Plan *plan);
extern List *join_references(List *clauses, List *outer_tlist, extern List *join_references(List *clauses, List *outer_tlist,
List *inner_tlist); List *inner_tlist);
extern List *index_outerjoin_references(List *inner_indxqual, extern List *index_outerjoin_references(List *inner_indxqual,
List *outer_tlist, Index inner_relid); List *outer_tlist, Index inner_relid);
extern List *get_agg_tlist_references(Agg *aggNode); extern List *get_agg_tlist_references(Agg *aggNode);
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_rule.l,v 1.9 1998/06/24 13:21:24 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/create_rule.l,v 1.10 1999/02/02 17:46:17 momjian Exp $
.TH "CREATE RULE" SQL 11/05/95 PostgreSQL PostgreSQL .TH "CREATE RULE" SQL 11/05/95 PostgreSQL PostgreSQL
.SH NAME .SH NAME
create rule - define a new rule create rule - define a new rule
...@@ -124,11 +124,11 @@ Postgres to ...@@ -124,11 +124,11 @@ Postgres to
-- --
--Example of a circular rewrite rule combination. --Example of a circular rewrite rule combination.
-- --
create rule bad_rule_combination_1 is create rule bad_rule_combination_1 as
on select to EMP on select to EMP
do instead select to TOYEMP do instead select to TOYEMP
create rule bad_rule_combination_2 is create rule bad_rule_combination_2 as
on select to TOYEMP on select to TOYEMP
do instead select to EMP do instead select to EMP
...@@ -146,7 +146,7 @@ access to a class in order to define a rule on it. ...@@ -146,7 +146,7 @@ access to a class in order to define a rule on it.
-- --
--Make Sam get the same salary adjustment as Joe --Make Sam get the same salary adjustment as Joe
-- --
create rule example_1 is create rule example_1 as
on update EMP.salary where current.name = "Joe" on update EMP.salary where current.name = "Joe"
do update EMP (salary = new.salary) do update EMP (salary = new.salary)
where EMP.name = "Sam" where EMP.name = "Sam"
...@@ -161,7 +161,7 @@ Joe's salary on to Sam. ...@@ -161,7 +161,7 @@ Joe's salary on to Sam.
-- --
--Make Bill get Joe's salary when it is accessed --Make Bill get Joe's salary when it is accessed
-- --
create rule example_2 is create rule example_2 as
on select to EMP.salary on select to EMP.salary
where current.name = "Bill" where current.name = "Bill"
do instead do instead
...@@ -172,7 +172,7 @@ create rule example_2 is ...@@ -172,7 +172,7 @@ create rule example_2 is
--Deny Joe access to the salary of employees in the shoe --Deny Joe access to the salary of employees in the shoe
--department. (pg_username() returns the name of the current user) --department. (pg_username() returns the name of the current user)
-- --
create rule example_3 is create rule example_3 as
on select to EMP.salary on select to EMP.salary
where current.dept = "shoe" where current.dept = "shoe"
and pg_username() = "Joe" and pg_username() = "Joe"
...@@ -184,7 +184,7 @@ create rule example_3 is ...@@ -184,7 +184,7 @@ create rule example_3 is
-- --
create TOYEMP(name = name, salary = int4) create TOYEMP(name = name, salary = int4)
create rule example_4 is create rule example_4 as
on select to TOYEMP on select to TOYEMP
do instead select (EMP.name, EMP.salary) from EMP do instead select (EMP.name, EMP.salary) from EMP
where EMP.dept = "toy" where EMP.dept = "toy"
...@@ -193,7 +193,7 @@ create rule example_4 is ...@@ -193,7 +193,7 @@ create rule example_4 is
-- --
--All new employees must make 5,000 or less --All new employees must make 5,000 or less
-- --
create rule example_5 is create rule example_5 as
on insert to EMP where new.salary > 5000 on insert to EMP where new.salary > 5000
do update newset salary = 5000 do update newset salary = 5000
.fi .fi
......
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