Re: [HACKERS] Re: [SQL] RULE questions. - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] Re: [SQL] RULE questions.
Date
Msg-id m10B0Qv-000EBRC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to Re: [HACKERS] Re: [SQL] RULE questions.  (Hannu Krosing <hannu@trust.ee>)
List pgsql-hackers
>
> D'Arcy J.M. Cain wrote:
> >
> > This makes me think of two features missing in PostgreSQL that I would
> > love to see.  I know it's probably to late to think about it now for
> > 6.5 but I wonder what others think about this.
> >
> > First, as suggested above, how about an option to automatically convert
> > data to upper case on entry?  I realize that triggers can do the job but
> > it seems to be needed often enough that putting it into the definition
> > for the field seems useful.  I guess a lower option would make sense too.
>
> These could probably be implemened more effectively using rules. Having
> the
> rules generated automatically for simple cases would of course be nice,
> but a warning at least should be given to user about creating the rule,
> like it's currently done with primary key.

    No it can't.

    Such a rule would look like

        CREATE RULE xxx AS ON INSERT TO this_table
            DO INSTEAD INSERT INTO this_table ...

    The   rule   system  will  be  triggerd  on  an  INSERT  INTO
    this_table, rewrite and generate another parsetree that is an
    INSERT  INTO this_table, which is recursively rewritten again
    applying rule xxx...

    That's an endless recursion. A rule can  never  do  the  same
    operation to a table it is fired for.

    The  old  pre-Postgres95 university version (Postgres release
    4.2) had the possibility to define  rules  that  UPDATE  NEW.
    They  where buggy and didn't worked sometimes at all. Instead
    of fixing them, this functionality got removed when  Postgres
    became 95 :-(


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) #

pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: [HACKERS] Re: [SQL] RULE questions.
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Temp tables