Re: [HACKERS] Auto-updated fields

2009-02-05 Thread Robert Haas
> At the very least it should not have a hard-coded field name in it. You > should pass the field name to be set as a parameter in the trigger setup. > > That's probably a lot more doable if the trigger is written in C, and in any > case I think any prepackaged triggers we provide should be written

Re: [HACKERS] Auto-updated fields

2009-02-05 Thread Andrew Dunstan
Christopher Browne wrote: I think this is a TODO, but not sure who is working on it or what needs to be done. The generic version in pagila is perhaps not generic enough: CREATE FUNCTION last_updated() RETURNS trigger AS $$ BEGIN NEW.last_update = CURRENT_TIMESTAMP; RETURN NEW; EN

Re: [HACKERS] Auto-updated fields

2009-02-05 Thread Stephen R. van den Berg
Christopher Browne wrote: >On Wed, Feb 4, 2009 at 1:23 PM, Bruce Momjian wrote: >> Robert Treat wrote: >>> On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote: >>> CREATE FUNCTION last_updated() RETURNS trigger >>> AS $$ >>> BEGIN >>> NEW.last_update = CURRENT_TIMESTAMP; >>> RETU

Re: [HACKERS] Auto-updated fields

2009-02-04 Thread Christopher Browne
On Wed, Feb 4, 2009 at 1:23 PM, Bruce Momjian wrote: > Robert Treat wrote: >> On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote: >> > Alvaro Herrera wrote: >> > > Robert Treat wrote: >> > > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: >> > > > > David Fetter wrote: >> > > >> >

Re: [HACKERS] Auto-updated fields

2009-02-04 Thread David Fetter
On Wed, Feb 04, 2009 at 01:23:04PM -0500, Bruce Momjian wrote: > Robert Treat wrote: > > On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote: > > > Alvaro Herrera wrote: > > > > Robert Treat wrote: > > > > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > > > > > > David Fetter wrot

Re: [HACKERS] Auto-updated fields

2009-02-04 Thread Bruce Momjian
Robert Treat wrote: > On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote: > > Alvaro Herrera wrote: > > > Robert Treat wrote: > > > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > > > > > David Fetter wrote: > > > > > > Ref: http://archives.postgresql.org/pgsql-hackers/2008-05/ms

Re: [HACKERS] Auto-updated fields

2009-01-22 Thread Robert Treat
On Wednesday 21 January 2009 20:21:41 Bruce Momjian wrote: > Alvaro Herrera wrote: > > Robert Treat wrote: > > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > > > > David Fetter wrote: > > > > Ref: http://archives.postgresql.org/pgsql-hackers/2008-05/msg00198.php > > > > > > > 1. Creat

Re: [HACKERS] Auto-updated fields

2009-01-21 Thread Bruce Momjian
Alvaro Herrera wrote: > Robert Treat wrote: > > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > > > David Fetter wrote: > > Ref: http://archives.postgresql.org/pgsql-hackers/2008-05/msg00198.php > > > > > 1. Create a generic (possibly overloaded) trigger function, bundled > > > > with

Re: [HACKERS] Auto-updated fields

2009-01-02 Thread Alvaro Herrera
Robert Treat wrote: > On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > > David Fetter wrote: Ref: http://archives.postgresql.org/pgsql-hackers/2008-05/msg00198.php > > > 1. Create a generic (possibly overloaded) trigger function, bundled > > > with PostgreSQL, which sets a field to some

Re: [HACKERS] Auto-updated fields

2008-05-09 Thread David Fetter
On Thu, May 08, 2008 at 08:44:46AM +0200, Martijn van Oosterhout wrote: > On Wed, May 07, 2008 at 03:04:49PM -0700, David Fetter wrote: > > 1. Create a generic (possibly overloaded) trigger function, > > bundled with PostgreSQL, which sets a field to some value. For > > example, a timestamptz ver

Re: [HACKERS] Auto-updated fields

2008-05-09 Thread Hannu Krosing
On Thu, 2008-05-08 at 00:41 -0400, Tom Lane wrote: > Tino Wildenhain <[EMAIL PROTECTED]> writes: > > I may be wrong but my feeling is, not to much weirdness in the core > > please :) > > +1 ... we have wasted more than enough man-hours trying to get the magic > "serial" type to play nicely. If I

Re: [HACKERS] Auto-updated fields

2008-05-08 Thread Josh Berkus
DF, > 2. Have some kind of pre-processing of CREATE and ALTER statements on > tables which would attach the above function to the field at hand, > something like: > > CREATE TABLE foo( > last_updated TIMESTAMPTZ_UPDATED(), So you're suggesting a user-definable version of SERIAL? -- Josh Be

Re: [HACKERS] Auto-updated fields

2008-05-08 Thread Robert Treat
On Thursday 08 May 2008 00:27:10 Tino Wildenhain wrote: > David Fetter wrote: > > Folks, > > > > A co-worker pointed out to me that MySQL has a feature that, properly > > implemented and maybe extended, could be handy, namely what MySQL > > calls a "timestamp" field, so here's a proposal: > > > > 1

Re: [HACKERS] Auto-updated fields

2008-05-08 Thread Zoltan Boszormenyi
Zoltan Boszormenyi írta: Martijn van Oosterhout írta: On Wed, May 07, 2008 at 03:04:49PM -0700, David Fetter wrote: 1. Create a generic (possibly overloaded) trigger function, bundled with PostgreSQL, which sets a field to some value. For example, a timestamptz version might set the field t

Re: [HACKERS] Auto-updated fields

2008-05-08 Thread Zoltan Boszormenyi
Martijn van Oosterhout írta: On Wed, May 07, 2008 at 03:04:49PM -0700, David Fetter wrote: 1. Create a generic (possibly overloaded) trigger function, bundled with PostgreSQL, which sets a field to some value. For example, a timestamptz version might set the field to now(). Doesn't t

Re: [HACKERS] Auto-updated fields

2008-05-07 Thread Martijn van Oosterhout
On Wed, May 07, 2008 at 03:04:49PM -0700, David Fetter wrote: > 1. Create a generic (possibly overloaded) trigger function, bundled > with PostgreSQL, which sets a field to some value. For example, a > timestamptz version might set the field to now(). Doesn't the SQL standard GENERATED BY functi

Re: [HACKERS] Auto-updated fields

2008-05-07 Thread Tom Lane
Tino Wildenhain <[EMAIL PROTECTED]> writes: > I may be wrong but my feeling is, not to much weirdness in the core > please :) +1 ... we have wasted more than enough man-hours trying to get the magic "serial" type to play nicely. If I had it to do over, we'd never have put that in at all. The und

Re: [HACKERS] Auto-updated fields

2008-05-07 Thread Tino Wildenhain
David Fetter wrote: Folks, A co-worker pointed out to me that MySQL has a feature that, properly implemented and maybe extended, could be handy, namely what MySQL calls a "timestamp" field, so here's a proposal: 1. Create a generic (possibly overloaded) trigger function, bundled with PostgreSQ

[HACKERS] Auto-updated fields

2008-05-07 Thread David Fetter
Folks, A co-worker pointed out to me that MySQL has a feature that, properly implemented and maybe extended, could be handy, namely what MySQL calls a "timestamp" field, so here's a proposal: 1. Create a generic (possibly overloaded) trigger function, bundled with PostgreSQL, which sets a field