Re: [HACKERS] minimal update

2008-10-29 Thread Andrew Dunstan
Kenneth Marshall wrote: On Wed, Oct 22, 2008 at 06:05:26PM -0400, Tom Lane wrote: Simon Riggs [EMAIL PROTECTED] writes: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Minimal really fails to convey the point here IMHO. How about something like

Re: [HACKERS] minimal update

2008-10-29 Thread Magnus Hagander
Andrew Dunstan wrote: Kenneth Marshall wrote: On Wed, Oct 22, 2008 at 06:05:26PM -0400, Tom Lane wrote: Simon Riggs [EMAIL PROTECTED] writes: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Minimal really fails to convey the point here IMHO. How about

Re: [HACKERS] minimal update

2008-10-29 Thread Alvaro Herrera
Andrew Dunstan escribió: + /* make sure it's called as a trigger */ + if (!CALLED_AS_TRIGGER(fcinfo)) + elog(ERROR, suppress_redundant_updates_trigger: must be called as trigger); Shouldn't these all be ereport()? -- Alvaro Herrera

Re: [HACKERS] minimal update

2008-10-29 Thread Andrew Dunstan
Alvaro Herrera wrote: Andrew Dunstan escribió: + /* make sure it's called as a trigger */ + if (!CALLED_AS_TRIGGER(fcinfo)) + elog(ERROR, suppress_redundant_updates_trigger: must be called as trigger); Shouldn't these all be ereport()? Good point. I'll fix

Re: [HACKERS] minimal update

2008-10-29 Thread David Fetter
On Wed, Oct 29, 2008 at 03:48:09PM -0400, Andrew Dunstan wrote: + /* make sure it's called as a trigger */ + if (!CALLED_AS_TRIGGER(fcinfo)) + elog(ERROR, suppress_redundant_updates_trigger: must be called as trigger); Shouldn't these all be ereport()? Good point. I'll

Re: [HACKERS] minimal update

2008-10-29 Thread Andrew Dunstan
David Fetter wrote: Maybe we should fix our C sample trigger, from which this was taken. Yes :) Does the attached have the right error code? -elog(ERROR, trigf: not called by trigger manager); +ereport(ERROR, +(error(TRIGGERED_DATA_CHANGE_VIOLATION), +

Re: [HACKERS] minimal update

2008-10-29 Thread Andrew Dunstan
Andrew Dunstan wrote: David Fetter wrote: Maybe we should fix our C sample trigger, from which this was taken. Yes :) Does the attached have the right error code? -elog(ERROR, trigf: not called by trigger manager); +ereport(ERROR, +

Re: [HACKERS] minimal update

2008-10-29 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: Not sure that's appropriate, but I can't see anything else that is very appropriate either. The plpgsql code uses errcode(ERRCODE_FEATURE_NOT_SUPPORTED) for this situation, so I guess we should be consistent with that.

Re: [HACKERS] minimal update

2008-10-29 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: I think I like this best of all the suggestions - suppress_redundant_updates_trigger() is what I have now. If there's no further discussion, I'll go ahead and commit this in a day or two. The documentation seems a bit lacking: it gives neither a

Re: [HACKERS] minimal update

2008-10-24 Thread Decibel!
On Oct 22, 2008, at 1:43 PM, Andrew Dunstan wrote: + if (!CALLED_AS_TRIGGER(fcinfo)) + elog(ERROR, min_update_trigger: not called by trigger manager); The error I get in 8.2 when calling a trigger function directly is: ERROR: trigger functions may only be called as triggers To

Re: [HACKERS] minimal update

2008-10-22 Thread Andrew Dunstan
Andrew Dunstan wrote: Tom Lane wrote: Magnus Hagander [EMAIL PROTECTED] writes: In that case, why not put the trigger in core so people can use it easily? One advantage of making it a contrib module is that discussing how/when to use it would fit more easily into the structure of

Re: [HACKERS] minimal update

2008-10-22 Thread Kevin Grittner
Andrew Dunstan [EMAIL PROTECTED] wrote: Here is a patch that does it that way, along with docs s/mare/more/ -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] minimal update

2008-10-22 Thread Andrew Dunstan
Kevin Grittner wrote: Andrew Dunstan [EMAIL PROTECTED] wrote: Here is a patch that does it that way, along with docs s/mare/more/ Thanks. fixed in my tree.. cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to

Re: [HACKERS] minimal update

2008-10-22 Thread Simon Riggs
On Wed, 2008-10-22 at 14:43 -0400, Andrew Dunstan wrote: There seems to be a preponderance of opinion for doing this as a builtin. Here is a patch that does it that way, along with docs and regression test. In your example you use an underscore as the first character. The way you have

Re: [HACKERS] minimal update

2008-10-22 Thread Tom Lane
Simon Riggs [EMAIL PROTECTED] writes: Can we call the function minimal_update_trigger, rather than min_... Minimal really fails to convey the point here IMHO. How about something like suppress_no_op_updates_trigger? regards, tom lane -- Sent via pgsql-hackers mailing

Re: [HACKERS] minimal update

2008-10-22 Thread Andrew Dunstan
Simon Riggs wrote: On Wed, 2008-10-22 at 14:43 -0400, Andrew Dunstan wrote: There seems to be a preponderance of opinion for doing this as a builtin. Here is a patch that does it that way, along with docs and regression test. In your example you use an underscore as the first

Re: [HACKERS] minimal update

2008-10-22 Thread Robert Haas
On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Simon Riggs [EMAIL PROTECTED] writes: Can we call the function minimal_update_trigger, rather than min_... Minimal really fails to convey the point here IMHO. How about something like suppress_no_op_updates_trigger? +1.

Re: [HACKERS] minimal update

2008-10-22 Thread Simon Riggs
On Wed, 2008-10-22 at 17:24 -0400, Robert Haas wrote: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Simon Riggs [EMAIL PROTECTED] writes: Can we call the function minimal_update_trigger, rather than min_... Minimal really fails to convey the point here IMHO. How

Re: [HACKERS] minimal update

2008-10-22 Thread Tom Lane
Simon Riggs [EMAIL PROTECTED] writes: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Minimal really fails to convey the point here IMHO. How about something like suppress_no_op_updates_trigger? I think it means something to us, but no op is a very technical phrase that

Re: [HACKERS] minimal update

2008-10-22 Thread Kenneth Marshall
On Wed, Oct 22, 2008 at 06:05:26PM -0400, Tom Lane wrote: Simon Riggs [EMAIL PROTECTED] writes: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: Minimal really fails to convey the point here IMHO. How about something like suppress_no_op_updates_trigger? I think it

Re: [HACKERS] minimal update

2008-10-22 Thread Kevin Grittner
Simon Riggs [EMAIL PROTECTED] wrote: On Wed, Oct 22, 2008 at 3:24 PM, Tom Lane [EMAIL PROTECTED] wrote: How about something like suppress_no_op_updates_trigger? I think it means something to us, but no op is a very technical phrase that probably doesn't travel very well. Not everybody

Re: [HACKERS] minimal update

2008-10-22 Thread Robert Haas
How about one of these?: suppress_same_value_updates_trigger suppress_no_change_updates_trigger suppress_no_effect_updates_trigger I like the first one. A trigger firing would be an effect, and possibly a change, but same value seems very clear. ...Robert -- Sent via pgsql-hackers

Re: [HACKERS] minimal update

2008-10-21 Thread Magnus Hagander
On 20 okt 2008, at 16.51, Andrew Dunstan [EMAIL PROTECTED] wrote: Magnus Hagander wrote: Andrew Dunstan wrote: Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a new file src/backend/utils/adt/trigger_utils.c ? I

Re: [HACKERS] minimal update

2008-10-21 Thread David Fetter
On Tue, Oct 21, 2008 at 03:34:04PM +0200, Magnus Hagander wrote: On 20 okt 2008, at 16.51, Andrew Dunstan [EMAIL PROTECTED] wrote: Magnus Hagander wrote: Andrew Dunstan wrote: Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a

Re: [HACKERS] minimal update

2008-10-21 Thread Merlin Moncure
On Tue, Oct 21, 2008 at 9:34 AM, Magnus Hagander [EMAIL PROTECTED] wrote: On 20 okt 2008, at 16.51, Andrew Dunstan [EMAIL PROTECTED] wrote: No, it's not just a hack. It's very close to what we'd probably do if we built the facility right into the language, although it does involve the

Re: [HACKERS] minimal update

2008-10-21 Thread Tom Lane
Magnus Hagander [EMAIL PROTECTED] writes: In that case, why not put the trigger in core so people can use it easily? One advantage of making it a contrib module is that discussing how/when to use it would fit more easily into the structure of the documentation. There is no place in our docs

Re: [HACKERS] minimal update

2008-10-21 Thread Andrew Dunstan
Tom Lane wrote: Magnus Hagander [EMAIL PROTECTED] writes: In that case, why not put the trigger in core so people can use it easily? One advantage of making it a contrib module is that discussing how/when to use it would fit more easily into the structure of the documentation.

Re: [HACKERS] minimal update

2008-10-20 Thread Magnus Hagander
Andrew Dunstan wrote: Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a new file src/backend/utils/adt/trigger_utils.c ? I thought the plan was to make it a contrib module. Well, previous

Re: [HACKERS] minimal update

2008-10-20 Thread Andrew Dunstan
Magnus Hagander wrote: Andrew Dunstan wrote: Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a new file src/backend/utils/adt/trigger_utils.c ? I thought the plan was to make it a contrib module.

Re: [HACKERS] minimal update

2008-10-16 Thread Andrew Dunstan
Bruce Momjian wrote: Andrew Dunstan wrote: Bruce, did you ever look at completing this? No, it is still in my email box unaddressed. Feel free to work on it; I doubt I can do it for 8.4. OK. Where would be a good place to put the code? Maybe a new file

Re: [HACKERS] minimal update

2008-10-16 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a new file src/backend/utils/adt/trigger_utils.c ? I thought the plan was to make it a contrib module. regards, tom lane -- Sent via pgsql-hackers mailing list

Re: [HACKERS] minimal update

2008-10-16 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: OK. Where would be a good place to put the code? Maybe a new file src/backend/utils/adt/trigger_utils.c ? I thought the plan was to make it a contrib module. Well, previous discussion did mention

Re: [HACKERS] minimal update

2008-10-15 Thread Bruce Momjian
Andrew Dunstan wrote: Bruce, did you ever look at completing this? No, it is still in my email box unaddressed. Feel free to work on it; I doubt I can do it for 8.4. --- cheers andrew Andrew Dunstan wrote:

Re: [HACKERS] minimal update

2008-10-14 Thread Andrew Dunstan
Bruce, did you ever look at completing this? cheers andrew Andrew Dunstan wrote: Bruce Momjian wrote: Andrew Dunstan wrote: Right. In fact, I already had that part in fact - see http://people.planetpostgresql.org/andrew/index.php?/archives/22-Minimal-Update-Trigger.html What I was

Re: [HACKERS] minimal update

2008-05-07 Thread Bruce Momjian
Is there a version of this patch ready for application? --- Gurjeet Singh wrote: On Tue, Mar 18, 2008 at 7:46 PM, Andrew Dunstan [EMAIL PROTECTED] wrote: Gurjeet Singh wrote: On Fri, Mar 7, 2008 at 9:40

Re: [HACKERS] minimal update

2008-05-07 Thread Andrew Dunstan
Not that I know of. I never saw Gurjeet's completed code. cheers andrew Bruce Momjian wrote: Is there a version of this patch ready for application? --- Gurjeet Singh wrote: On Tue, Mar 18, 2008 at 7:46 PM, Andrew

Re: [HACKERS] minimal update

2008-05-07 Thread Bruce Momjian
Andrew Dunstan wrote: Not that I know of. I never saw Gurjeet's completed code. This is Gurjeet's code, but it is not complete. http://archives.postgresql.org/pgsql-hackers/2008-03/msg00668.php --- cheers

Re: [HACKERS] minimal update

2008-05-07 Thread Andrew Dunstan
Right. In fact, I already had that part in fact - see http://people.planetpostgresql.org/andrew/index.php?/archives/22-Minimal-Update-Trigger.html What I was waiting for was the part where it gets put in the catalog, documented, etc. cheers andrew Bruce Momjian wrote: Andrew Dunstan

Re: [HACKERS] minimal update

2008-05-07 Thread Bruce Momjian
Andrew Dunstan wrote: Right. In fact, I already had that part in fact - see http://people.planetpostgresql.org/andrew/index.php?/archives/22-Minimal-Update-Trigger.html What I was waiting for was the part where it gets put in the catalog, documented, etc. I can probably do that part.

Re: [HACKERS] minimal update

2008-05-07 Thread Andrew Dunstan
Bruce Momjian wrote: Andrew Dunstan wrote: Right. In fact, I already had that part in fact - see http://people.planetpostgresql.org/andrew/index.php?/archives/22-Minimal-Update-Trigger.html What I was waiting for was the part where it gets put in the catalog, documented, etc. I

Re: [HACKERS] minimal update

2008-03-18 Thread Gurjeet Singh
On Fri, Mar 7, 2008 at 9:40 PM, Bruce Momjian [EMAIL PROTECTED] wrote: I assume don't want a TODO for this? (Suppress UPDATE no changed columns) I am starting to implement this. Do we want to have this trigger function in the server, or in an external module? Best regards,

Re: [HACKERS] minimal update

2008-03-18 Thread Andrew Dunstan
Gurjeet Singh wrote: On Fri, Mar 7, 2008 at 9:40 PM, Bruce Momjian [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I assume don't want a TODO for this? (Suppress UPDATE no changed columns) I am starting to implement this. Do we want to have this trigger function in the

Re: [HACKERS] minimal update

2008-03-18 Thread Gurjeet Singh
On Tue, Mar 18, 2008 at 7:46 PM, Andrew Dunstan [EMAIL PROTECTED] wrote: Gurjeet Singh wrote: On Fri, Mar 7, 2008 at 9:40 PM, Bruce Momjian [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I assume don't want a TODO for this? (Suppress UPDATE no changed columns)

Re: [HACKERS] minimal update

2008-03-07 Thread Bruce Momjian
I assume don't want a TODO for this? (Suppress UPDATE no changed columns) --- Andrew Dunstan wrote: Tom Lane wrote: Michael Glaesemann [EMAIL PROTECTED] writes: What would be the disadvantages of always doing

Re: [HACKERS] minimal update trigger

2008-02-20 Thread David Fetter
On Tue, Feb 19, 2008 at 09:32:30PM -0500, Andrew Dunstan wrote: As discussed a little while back, I would like to add a generic trigger function which will force an update to skip if the new and old tuples are identical. This one has lots of use cases. Did the earlier discussion settle on

Re: [HACKERS] minimal update trigger

2008-02-20 Thread Andrew Dunstan
David Fetter wrote: On Tue, Feb 19, 2008 at 09:32:30PM -0500, Andrew Dunstan wrote: As discussed a little while back, I would like to add a generic trigger function which will force an update to skip if the new and old tuples are identical. This one has lots of use cases. Did the

Re: [HACKERS] minimal update

2007-12-28 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: Tom Lane wrote: Well, you could write the trigger in C and it'd work for any table. I think it could be as simple as a memcmp of the tuples' data areas, since we now require padding bytes to be 0 ... Something like

Re: [HACKERS] minimal update

2007-12-28 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: How does this look? if (newtuple-t_len == oldtuple-t_len newtuple-t_data-t_hoff == oldtuple-t_data-t_hoff HeapTupleHeaderGetNatts(newtuple) == HeapTupleHeaderGetNatts(oldtuple) (newtuple-t_data-t_infomask

Re: [HACKERS] minimal update

2007-12-28 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: How does this look? if (newtuple-t_len == oldtuple-t_len newtuple-t_data-t_hoff == oldtuple-t_data-t_hoff HeapTupleHeaderGetNatts(newtuple) == HeapTupleHeaderGetNatts(oldtuple)

Re: [HACKERS] minimal update

2007-12-28 Thread Andrew Dunstan
Andrew Dunstan wrote: Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: How does this look? if (newtuple-t_len == oldtuple-t_len newtuple-t_data-t_hoff == oldtuple-t_data-t_hoff HeapTupleHeaderGetNatts(newtuple) == HeapTupleHeaderGetNatts(oldtuple)

Re: [HACKERS] minimal update

2007-11-12 Thread Decibel!
On Nov 2, 2007, at 10:49 AM, Andrew Dunstan wrote: update tname set foo = bar ... where foo is null or foo bar ... FYI, you should be able to do WHERE foo IS DISTINCT FROM bar instead. -- Decibel!, aka Jim C. Nasby, Database Architect [EMAIL PROTECTED] Give your computer some brain candy!

Re: [HACKERS] minimal update

2007-11-12 Thread Andrew Dunstan
Decibel! wrote: On Nov 2, 2007, at 10:49 AM, Andrew Dunstan wrote: update tname set foo = bar ... where foo is null or foo bar ... FYI, you should be able to do WHERE foo IS DISTINCT FROM bar instead. True, that's a bit nicer. It's still more than somewhat ugly and fragile if there a

Re: [HACKERS] minimal update

2007-11-10 Thread Michael Glaesemann
On Nov 8, 2007, at 10:46 , Andrew Dunstan wrote: Tom Lane wrote: Michael Glaesemann [EMAIL PROTECTED] writes: What would be the disadvantages of always doing this, i.e., just making this part of the normal update path in the backend? (1) cycles wasted to no purpose in the vast

Re: [HACKERS] minimal update

2007-11-08 Thread Michael Glaesemann
On Nov 2, 2007, at 13:44 , Andrew Dunstan wrote: Ah. Good. Thanks, that's the piece I was missing. What would be the disadvantages of always doing this, i.e., just making this part of the normal update path in the backend? I'd think it should save on unnecessarily dead tuples as well.

Re: [HACKERS] minimal update

2007-11-08 Thread Tom Lane
Michael Glaesemann [EMAIL PROTECTED] writes: What would be the disadvantages of always doing this, i.e., just making this part of the normal update path in the backend? (1) cycles wasted to no purpose in the vast majority of cases. (2) visibly inconsistent behavior for apps that pay

Re: [HACKERS] minimal update

2007-11-08 Thread Andrew Dunstan
Tom Lane wrote: Michael Glaesemann [EMAIL PROTECTED] writes: What would be the disadvantages of always doing this, i.e., just making this part of the normal update path in the backend? (1) cycles wasted to no purpose in the vast majority of cases. (2) visibly inconsistent behavior

Re: [HACKERS] minimal update

2007-11-05 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: Tom Lane wrote: A BEFORE UPDATE trigger would be better, and probably hardly more expensive than a wired-in facility (especially if you were willing to write it in C). Yes. I also prefer the trigger idea to a rule

Re: [HACKERS] minimal update

2007-11-05 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes: Tom Lane wrote: Well, you could write the trigger in C and it'd work for any table. I think it could be as simple as a memcmp of the tuples' data areas, since we now require padding bytes to be 0 ... Something like this fragment? newtuple =

Re: [HACKERS] minimal update

2007-11-02 Thread Tom Lane
David Fetter [EMAIL PROTECTED] writes: On Fri, Nov 02, 2007 at 11:49:38AM -0400, Andrew Dunstan wrote: At the moment I have to write things like: update tname set foo = bar ... where foo is null or foo bar One way I've done this is make RULEs which basically drop non-updating UPDATEs on

Re: [HACKERS] minimal update

2007-11-02 Thread Andrew Dunstan
Tom Lane wrote: David Fetter [EMAIL PROTECTED] writes: On Fri, Nov 02, 2007 at 11:49:38AM -0400, Andrew Dunstan wrote: At the moment I have to write things like: update tname set foo = bar ... where foo is null or foo bar One way I've done this is make RULEs which

Re: [HACKERS] minimal update

2007-11-02 Thread David Fetter
On Fri, Nov 02, 2007 at 11:49:38AM -0400, Andrew Dunstan wrote: For some time I have been working on removing some inefficiencies from a large DW-type app. This app does a large daily batch update, and this is what is the major bottleneck. One of the things I have been doing is to remove

Re: [HACKERS] minimal update

2007-11-02 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan [EMAIL PROTECTED] writes: Tom Lane wrote: A BEFORE UPDATE trigger would be better, and probably hardly more expensive than a wired-in facility (especially if you were willing to write it in C). Yes. I also prefer the trigger idea to a rule