Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-14 Thread Josh Berkus
Tom, Those would be real users who are not on any PG mailing list? Cause I have not seen any complaints, much less any proposals for a solution... On the Hibernate user mailing list. --Josh ---(end of broadcast)--- TIP 3: Have you checked

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-14 Thread Joshua D. Drake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tom Lane wrote: Josh Berkus [EMAIL PROTECTED] writes: FYI, after some tinkering around, I've found that RETURNING is 100% incompatible with any table which has conditional DO INSTEAD rules; there's just no way to make it work and return any

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-14 Thread Bruce Momjian
Josh Berkus wrote: All, I'll note that we currently prevent adding RETURNING to a *conditional* DO INSTEAD rule. This means that if we have a conditional DO INSTEAD rule which inserts into a different table than the final unconditional rule, we'll be RETURNING wrong or empty values.

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-14 Thread Joshua D. Drake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bruce Momjian wrote: Josh Berkus wrote: All, -- Make it possible to use RETURNING together with conditional DO INSTEAD rules, such as for partitioning setups. Added to TODO: * Make it possible to use RETURNING together with conditional DO

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-14 Thread Pavel Stehule
Would it make sense to expand this to something like: Make it possible for rules to return affected tuples? I come to this because if you use a rule to create an updateable view, you never know how many rows the view actually updated. Updatable views can be (maybe) implemented with

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-13 Thread Josh Berkus
All, I'll note that we currently prevent adding RETURNING to a *conditional* DO INSTEAD rule. This means that if we have a conditional DO INSTEAD rule which inserts into a different table than the final unconditional rule, we'll be RETURNING wrong or empty values. Mind you, that's a pretty

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-13 Thread Tom Lane
Josh Berkus [EMAIL PROTECTED] writes: FYI, after some tinkering around, I've found that RETURNING is 100% incompatible with any table which has conditional DO INSTEAD rules; there's just no way to make it work and return any intelligible data. This would be a completely corner case, except

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Joshua D. Drake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Josh Berkus wrote: All, A Hibernate developer pointed out the following odd behavior to me in 8.2.1: create table test ( test1 text ); create table test2 ( test_col text ); create rule test_insert as on insert to test do instead insert into

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Tom Lane
Josh Berkus [EMAIL PROTECTED] writes: A Hibernate developer pointed out the following odd behavior to me in 8.2.1: create table test ( test1 text ); create table test2 ( test_col text ); create rule test_insert as on insert to test do instead insert into test2 values ( NEW.test1 ) RETURNING

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Josh Berkus
Tom, What the RETURNING clause in the rule does is let you define the data that should be returned if the rewritten INSERT had a returning clause to start with. Hmmm. Aha, that works: postgres=# insert into test values ( 'mary' ) returning test1; test1 --- mary So, this should

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Richard Huxton
Tom Lane wrote: Josh Berkus [EMAIL PROTECTED] writes: A Hibernate developer pointed out the following odd behavior to me in 8.2.1: create table test ( test1 text ); create table test2 ( test_col text ); create rule test_insert as on insert to test do instead insert into test2 values (

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Tom Lane
Richard Huxton [EMAIL PROTECTED] writes: Tom Lane wrote: What the RETURNING clause in the rule does is let you define the data that should be returned if the rewritten INSERT had a returning clause to start with. Sorry - haven't got a CSV download here, or I'd check myself. Does this just

Re: [HACKERS] RETURNING and DO INSTEAD ... Intentional or not?

2007-09-12 Thread Josh Berkus
Tom, Josh, this *is* documented; see the CREATE RULE reference page for full details, and there's at least passing references here: http://developer.postgresql.org/pgdocs/postgres/rules-update.html#RULES-UPD ATE-VIEWS Yeah, it's just hard to find since it's buried in an offhand example in a