Re: [HACKERS] Rules: first fix on monday
Re: [HACKERS] Rules: first fix on monday
От:
Keith Parks <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. jwieck@debis.com (Jan Wieck) > > 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) # > > >
Re: [HACKERS] Rules: first fix on monday
От:
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.
>
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) #Re: [HACKERS] Rules: first fix on monday
От:
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Дата:
> > 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
Re: [HACKERS] dumping rules
От:
jwieck@debis.com (Jan Wieck)
Дата:
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`>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'!XL_TD"O==W[;<_2BT
M]TE.XLJ%?]GML#U*-;CYCAWN';'#;[[Y>O_@Z_W#I^SPQ?'SI\?/OF8T@'7?
M!^P1XOYTTZ>9C+GKLCE0P>YN>0GH%,"&,8L";CLSQTY9'<$01PYX5!,(ZBE?
M]L3X=3T0;*72/NVUWHR>O&2[YJ-:SWQ]\2WVHCLU0L(`&MDIB')9;_EWK12Z75:G0X^[.6@NL'/8JJ=WN#U/Y@3T5RG"\^:.\`4=['K^J`,
M4^9/_LWMF!&A,("ZO]0UZU&MTQM=GIZ:_ZQ7*O!P]-+0GN[YE4JKUWMI8#=X
M6A=87R>..R64T:T5IFC@&>`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ql'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) #
rewrite system and Resdom
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
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)