Rules: first fix on monday
Hi,
got a lot of things working up to now. Most things on the
relation level are fixed now, including qualified instead
rules. Update rules can now correctly refer to *new* and
*current*.
Must check if instead nothing with/without qualification is
O.K. and if the regression tests are still happy with the
changes.
What I haven't touched yet are rules on the attribute level
and the update new stuff. If regression tests walk through
and the instead nothing is O.K. I'll send a first patch with
some test queries on monday. Next todo is then update new.
Have a nice wieckend :-)
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
Jan,
Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.
If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.
I looked at this some while ago myself but never got close to
making it work.
Keith.
jwieck@debis.com (Jan Wieck)
Show quoted text
Hi,
got a lot of things working up to now. Most things on the
relation level are fixed now, including qualified instead
rules. Update rules can now correctly refer to *new* and
*current*.Must check if instead nothing with/without qualification is
O.K. and if the regression tests are still happy with the
changes.What I haven't touched yet are rules on the attribute level
and the update new stuff. If regression tests walk through
and the instead nothing is O.K. I'll send a first patch with
some test queries on monday. Next todo is then update new.Have a nice wieckend :-)
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
Import Notes
Resolved by subject fallback
Jan,
Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.I looked at this some while ago myself but never got close to
making it work.Keith.
Yes, that would really be nice and I had something the like
already in mind.
I'm not really sure if it's a good thing to save the rules
definition text instead of the parsetree. The advantages of
doing so would be that the rule could easily be dumped and
(more important) that the rules can have more complicated
actions (remember that the currently stored parsetrees can
quickly override the size limit of a text type).
Storing the definition text only would require to parse at
least the actions any time, a rule should be fired on a
query. Bad for performance - but must check if significant
bad.
At least I can't do this for 6.4 I think. But I'm willing to
take a look at it after.
On the other hand wouldn't it be too complicated to
reconstruct a command from the parsetree, that exactly
creates the rule. Reading a parsetree isn't fun, but after
all I did on the rewrite system I'm somewhat familiar with it
now (sometimes I see the cup in a targetlist, the coffee
machine in the rangetable and all the buttons in the
qualification when pulling a coffee out of it - think I
should I consult a psychist when the rule system is fixed
:-).
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.
If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.Yes, that would really be nice and I had something the like
already in mind.
I'm not really sure if it's a good thing to save the rules
definition text instead of the parsetree. The advantages of
doing so would be that the rule could easily be dumped and
(more important) that the rules can have more complicated
actions (remember that the currently stored parsetrees can
quickly override the size limit of a text type).Storing the definition text only would require to parse at
least the actions any time, a rule should be fired on a
query. Bad for performance - but must check if significant
bad.
How about storing both an internal form and the plain text source? That
way you can use the fast form internally and dump the plain text...
- Tom
Tom, Jan,
These were my thought too.
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.
Perhaps someone who knows how to graft in new columns could do
that now before we finalise 6.4, even if we don't use it straight
away it would serve as a marker.
I believe a dump/restore is required for 6.3 to 6.4 so we might as
well get the catalog change in sooner rather than later.
Keith.
Thomas G. Lockhart <lockhart@alumni.caltech.edu>
Show quoted text
Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.
If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.Yes, that would really be nice and I had something the like
already in mind.
I'm not really sure if it's a good thing to save the rules
definition text instead of the parsetree. The advantages of
doing so would be that the rule could easily be dumped and
(more important) that the rules can have more complicated
actions (remember that the currently stored parsetrees can
quickly override the size limit of a text type).Storing the definition text only would require to parse at
least the actions any time, a rule should be fired on a
query. Bad for performance - but must check if significant
bad.How about storing both an internal form and the plain text source? That
way you can use the fast form internally and dump the plain text...- Tom
Import Notes
Resolved by subject fallback
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.Perhaps someone who knows how to graft in new columns could do
that now before we finalise 6.4, even if we don't use it straight
away it would serve as a marker.I believe a dump/restore is required for 6.3 to 6.4 so we might as
well get the catalog change in sooner rather than later.
Adding a column will take away from the already-tight space needed
to keep the plan.
Perhaps a better way is to have a new non-cached system table that
would be joined to pg_rewrite to show the plain-text plan when needed.
Rather than require the user to know this join, postgres could (or
should) have some system views (ala Oracle) to hide the underlying
table structures and prevent any user except the superuser from
modifying a system table without using a postgres command.
darrenk
[Charset iso-8859-1 unsupported, filtering to ASCII...]
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.Perhaps someone who knows how to graft in new columns could do
that now before we finalise 6.4, even if we don't use it straight
away it would serve as a marker.I believe a dump/restore is required for 6.3 to 6.4 so we might as
well get the catalog change in sooner rather than later.Adding a column will take away from the already-tight space needed
to keep the plan.Perhaps a better way is to have a new non-cached system table that
would be joined to pg_rewrite to show the plain-text plan when needed.Rather than require the user to know this join, postgres could (or
should) have some system views (ala Oracle) to hide the underlying
table structures and prevent any user except the superuser from
modifying a system table without using a postgres command.
Obviously the real fix is for larger block sizes.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.Perhaps someone who knows how to graft in new columns could do
that now before we finalise 6.4, even if we don't use it straight
away it would serve as a marker.I believe a dump/restore is required for 6.3 to 6.4 so we might as
well get the catalog change in sooner rather than later.Adding a column will take away from the already-tight space needed
to keep the plan.Perhaps a better way is to have a new non-cached system table that
would be joined to pg_rewrite to show the plain-text plan when needed.Rather than require the user to know this join, postgres could (or
should) have some system views (ala Oracle) to hide the underlying
table structures and prevent any user except the superuser from
modifying a system table without using a postgres command.darrenk
I don't think we should save plans in persistant storage at all. We did this
at Sybase and it was a major headache. Suddenly you can't dump/restore across
architectures. Minor changes to the structure of a plan require wholesale
upgrades or boatloads of compatibility code. Much more shared update access to
catalogs. Somehow the plan read and write code got very complex and tended
to screw up the saved plans which was no fun at all to debug (since the crash
comes a lot later than the damage) All this to save a bit of parsing.
You can get pretty much the same benefits without most of the problems by just
caching the plans in memory and reusing them. If we had a sharable cache that
would be even better.
-dg
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612
- If simplicity worked, the world would be overrun with insects. -
I wrote:
Jan,
Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.I looked at this some while ago myself but never got close to
making it work.Keith.
Yes, that would really be nice and I had something the like
already in mind.[...]
On the other hand wouldn't it be too complicated to
reconstruct a command from the parsetree, that exactly
creates the rule. Reading a parsetree isn't fun, but after
all I did on the rewrite system I'm somewhat familiar with it
now (sometimes I see the cup in a targetlist, the coffee
machine in the rangetable and all the buttons in the
qualification when pulling a coffee out of it - think I
should I consult a psychist when the rule system is fixed
:-).Jan
To demonstrate that it really isn't that complicated as it
looks, here is a C function that if defined in the backend as
CREATE FUNCTION get_ruledef(name)
RETURNS text AS '.../get_ruledef.so'
LANGUAGE 'C';
can be used to see a textual representation of the rule given
as argument.
It is able to handle ALL the rules I defined in the test
suite for my first fix (sent yesterday). In addition I tested
a
... WHERE (att, att) IN (SELECT ...)
in the definition of a view. Worked too. The output can
easily be fed back into a psql and produces exactly the same
pg_rewrite entries that where there before.
It is not complete (aggregates are not handled up to now and
there might be some other expression constructs, that could
occur). But it's a starting point I think. At least we could
produce a view
CREATE VIEW pg_rule AS
SELECT rulename, get_ruledef(rulename) AS definition
FROM pg_rewrite;
Now pg_dump could output views as commands for regular tables
and add commands for the rules. It must omit the rule
_retpg_user in the dump, but that's all. All views and rules
are restored.
pg_dump should not select all rules at once, because if only
one of the rules cannot be converted back to it's definition
string, none could be dumped. Instead it should get a list of
all the rule names in pg_rewrite (without _retpg_user) and
then loop over it getting one at a time.
As soon as anybody reports an error (pg_dump cannot save rule
...) we know what case isn't handled by get_ruledef() and
could implement it.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
begin 644 get_ruledef.tar.gz
M'XL(`,:UV34"`^P\^7?;-M+YE?HK$#6I)44^<[2U-]FG2'+,_63)E61WNVV?
M'T5!-C<4R?*(H^W+__[-#``2I*C#3=)CMWIY,0D",X.9P5P`></CZS!Q^93/
M]A]\IA][=O#5\^?L`8/?TP/Z>W@D_LK?`6,OGK]X\?3IT8L7<'UX^/3I\P?L
M^8/?X)=$L14R]B"XB7YVU_2;3JP'_X6_&TW^Y]9;/G-<_JEQ'!X<O'CV;*7\
M#[]Z_I64_]'1BV='T/+T\.#I`W;PE_P_^^^+W4_UJWQ1^8(I%8)+^*D[-O-#
MIFE:K<YFB6?'CN_1*+/3[8_-4[/=&IN#OAC[Z(Q;4QX>L_TD"O==W[;<_2BT
M]TE.XLJ%?]GML#U*-;CYCAWN';'#;[[Y>O_@Z_W#I^SPQ?'SI\?/OF8T@'7?
M!^P1XOYTTZ>9C+GKLCE0P>YN><A9?,M9X$?Q3<@1;>0GH<TCYCKO@$65T;#=
M,8<O5TY1P#0]VTVF`M:-ZT\LEUG>%,"&,8L";CLSQTY9'<$01PYX5!,(ZBE?
M]L3X=3T0;*72/NVUWHR>O&2[YJ-:SWQ]\2WVHCLU0L(`&MDIB'<VOPGW;O,#
M5=>)9;_EWK12Z75:G0X^[.6@NL'/8JJ=WN#U/Y@3T5RG"\^:.\`4=['K^J`,
M4^9/_LWMF!&A,("ZO]0UZU&MTQM=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``````
`
end
BTW: get_ruledef() would be useful for psql's \d too.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
Stupor Genius <stuporg@erols.com>
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.Perhaps someone who knows how to graft in new columns could do
that now before we finalise 6.4, even if we don't use it straight
away it would serve as a marker.I believe a dump/restore is required for 6.3 to 6.4 so we might as
well get the catalog change in sooner rather than later.Adding a column will take away from the already-tight space needed
to keep the plan.
Ah, yes, I remember, the 8k limit.
Perhaps a better way is to have a new non-cached system table that
would be joined to pg_rewrite to show the plain-text plan when needed.
Another table would be the answer, and no need to have it cached.
Rather than require the user to know this join, postgres could (or
should) have some system views (ala Oracle) to hide the underlying
table structures and prevent any user except the superuser from
modifying a system table without using a postgres command.
I use Oracle at work and I must admit I find the views useful.
It seems quite natural to use SQL to to look at these things
and views to combine information.
Keith.
Import Notes
Resolved by subject fallback
Jan,
I'm absolutely amazed by this piece of magic.
I updated postrgreSQL from CVS, built postgres and the get_ruledef()
function and gave it a try.
A simple VIEW I have goes in as:-
SELECT t.artist, t.song, t.trackno, d.cdname
FROM disks d, tracks t
WHERE d.diskid = t.diskid
And comes out as :-
disks=> select get_ruledef('_RETsongs');
get_ruledef
--------------------------------------------------------------------------------
---------------------------------------------------------------------
CREATE RULE _RETsongs AS ON SELECT TO songs DO INSTEAD SELECT t.artist, t.song,
t.trackno, d.cdname FROM disks d, tracks t WHERE d.diskid = t.diskid;
(1 row)
disks=>
Absolutely perfect rule definition for the VIEW.
One slight bug I found was that ANDs come out as ORs but that's
easily fixed with the following patch.
What can I say.....
Thanks,
Keith.
*** get_ruledef/get_ruledef.c.orig Tue Aug 18 19:34:34 1998
--- get_ruledef/get_ruledef.c Tue Aug 18 19:34:53 1998
***************
*** 738,744 ****
strcat(buf, get_rule_expr(rtable, rt_index,
(Node *)get_leftop(expr),
varprefix));
! strcat(buf, ") OR (");
strcat(buf, get_rule_expr(rtable, rt_index,
(Node *)get_rightop(expr),
varprefix));
--- 738,744 ----
strcat(buf, get_rule_expr(rtable, rt_index,
(Node *)get_leftop(expr),
varprefix));
! strcat(buf, ") AND (");
strcat(buf, get_rule_expr(rtable, rt_index,
(Node *)get_rightop(expr),
varprefix));
jwieck@debis.com (Jan Wieck)
Show quoted text
emkxp01@mtcc.demon.co.uk
Jan,Whilst you are working on the rules system it would be nice if
you could look for an oportunity to store the plain text rule
definition at creation time.If the definition were stored in a table column it would allow us
to dump and restore databases in a more complete way.I looked at this some while ago myself but never got close to
making it work.Keith.
Yes, that would really be nice and I had something the like
already in mind.[...]
On the other hand wouldn't it be too complicated to
reconstruct a command from the parsetree, that exactly
creates the rule. Reading a parsetree isn't fun, but after
all I did on the rewrite system I'm somewhat familiar with it
now (sometimes I see the cup in a targetlist, the coffee
machine in the rangetable and all the buttons in the
qualification when pulling a coffee out of it - think I
should I consult a psychist when the rule system is fixed
:-).Jan
To demonstrate that it really isn't that complicated as it
looks, here is a C function that if defined in the backend asCREATE FUNCTION get_ruledef(name)
RETURNS text AS '.../get_ruledef.so'
LANGUAGE 'C';can be used to see a textual representation of the rule given
as argument.
Import Notes
Resolved by subject fallback
Jan,
I'm absolutely amazed by this piece of magic.
Written just to check if I understand parsetrees now.
:-)
A simple VIEW I have goes in as:-
SELECT t.artist, t.song, t.trackno, d.cdname
FROM disks d, tracks t
WHERE d.diskid = t.diskidAnd comes out as :-
disks=> select get_ruledef('_RETsongs');
get_ruledef
--------------------------------------------------------------------------------
---------------------------------------------------------------------
CREATE RULE _RETsongs AS ON SELECT TO songs DO INSTEAD SELECT t.artist, t.song,
t.trackno, d.cdname FROM disks d, tracks t WHERE d.diskid = t.diskid;
(1 row)disks=>
Absolutely perfect rule definition for the VIEW.
One slight bug I found was that ANDs come out as ORs but that's
easily fixed with the following patch.
cut-n-paste error, tnx.
Another one might be ISNULL (I think I missed it). But as I said,
it's just a point to start from.
What can I say.....
Thanks,
Keith.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
We could add another column to "pg_rewrite" which contained the
source for the rule. This could be used by pg_dump to dump the
rule creation statement, or by the user to see what the rule
actually does.[...]
Adding a column will take away from the already-tight space needed
to keep the plan.[...]
darrenk
The limited space for the querytrees and event qualification
is really a problem, that we should fix. And since we now
really support multiple action rewrite rules, it will become
more important.
I had something different in mind to make the space
unlimited. I could add an Oid field to pg_rewrite, pointing
to an extension record.
If a rule does not fit into one tuple, it is splitted into
multiple ones in rewriteDefine.c. All the extension tuples
have the event realtion set to the invalid Oid value to not
get fired everywhere.
I don't think that reading some extension records is too much
overhead compared against the rewrite work and the actions,
those MONSTER-rules will result in.
Comments?
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
I had something different in mind to make the space
unlimited. I could add an Oid field to pg_rewrite, pointing
to an extension record.If a rule does not fit into one tuple, it is splitted into
multiple ones in rewriteDefine.c. All the extension tuples
have the event realtion set to the invalid Oid value to not
get fired everywhere.
I think it would actually be better to allow postgresql data pages to be chained,
so allowing all rows to be larger than 8k.
Usual limits are 32k independent of page size.
The trick is to add pointers to followup pages if the record does not fit in.
This will usually be the following pages, but might be somwhere completely different.
In this case performance will be bad, but all major players suffer from this.
I really think doing tricks for system tables to overcome the 8k limit
is putting work into the wrong direction.
Andreas
Import Notes
Resolved by subject fallback
I really think doing tricks for system tables to overcome the 8k limit
is putting work into the wrong direction.Andreas
Right!
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
I have fixed the parser to all update/insert queries will have a
resdomno equal to the attribute number of the base relation.
At least, I hope so. Can you remove the rewrite renumbering code and
let me know. Thanks.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)