pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Rules, Select, Union
2+ messages / 2 participants
[nested] [flat]

* Rules, Select, Union
@ 2000-08-06 23:32 Itai Zukerman <zukerman@math-hat.com>
  2000-08-07 01:09 ` Re: Rules, Select, Union Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Itai Zukerman @ 2000-08-06 23:32 UTC (permalink / raw)
  To: pgsql-sql

I'm doing this:

  CREATE TABLE data ( val int4 );
  CREATE TABLE pos ( ) INHERITS ( data );
  CREATE TABLE neg ( ) INHERITS ( data );

  CREATE RULE data_to_pos AS
  ON INSERT TO data WHERE NEW.val > 0
  DO INSTEAD
    INSERT INTO pos ( val ) VALUES ( NEW.val );

  CREATE RULE data_to_neg AS
  ON INSERT TO data WHERE NEW.val < 0
  DO INSTEAD
    INSERT INTO neg ( val ) VALUES ( NEW.val );

So far, I think, so good.  (Though, sometimes it looks like the second
rule is never triggered even though val < 0.  The real application
that this simple example comes from has a bunch of triggers, though,
so it could be some weird interaction...)  Now I want to do:

  CREATE RULE data_val AS
  ON SELECT TO data
  DO INSTEAD
    SELECT * FROM pos
    UNION
    SELECT * FROM neg;

Can this be done?  I'm not having much success...

This is 7.0.2...

-itai



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Rules, Select, Union
  2000-08-06 23:32 Rules, Select, Union Itai Zukerman <zukerman@math-hat.com>
@ 2000-08-07 01:09 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2000-08-07 01:09 UTC (permalink / raw)
  To: Itai Zukerman <zukerman@math-hat.com>; +Cc: pgsql-sql

Itai Zukerman <zukerman@math-hat.com> writes:
>   CREATE RULE data_val AS
>   ON SELECT TO data
>   DO INSTEAD
>     SELECT * FROM pos
>     UNION
>     SELECT * FROM neg;

IIRC, UNION doesn't work in rules at the moment (a fix is planned for
7.2).  But what's the point of splitting the data into the two tables
like that?  This example is far from compelling, so I wonder whether
you shouldn't be considering a schema redesign anyway ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-08-07 01:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-06 23:32 Rules, Select, Union Itai Zukerman <zukerman@math-hat.com>
2000-08-07 01:09 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox