Re: [SQL] insert rule doesn't see id field

2003-01-13 Thread Tom Lane
Ron Peterson <[EMAIL PROTECTED]> writes: > I can find out this info > for the relation pulling the trigger easy enought, but how would I go > about getting this info when all I have is the table/field name? I > could create and execute a SQL query something like the following, but > is that really

Re: [SQL] insert rule doesn't see id field

2003-01-13 Thread Ron Peterson
On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > CREATE RULE person_insert AS > > ON INSERT TO person > > DO > > INSERT INTO person_log ( name_last, name_first, mod_type, person_id ) > > VALUES ( new.name_last, new.name_first, 'I', new

Re: [SQL] insert rule doesn't see id field

2003-01-10 Thread Ron Peterson
On Thu, Jan 09, 2003 at 11:53:42PM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote: > >> colindices = (int *) malloc (ncols * sizeof (int)); > > > Of course we should verify that malloc succeeded... > > Actually, t

Re: [SQL] insert rule doesn't see id field

2003-01-10 Thread Radu-Adrian Popescu
t;[EMAIL PROTECTED]> To: "Ron Peterson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, January 10, 2003 11:31 AM Subject: Re: [SQL] insert rule doesn't see id field To everyone interested, check out Tom Lane's and Bruce's comments on pgsql-hac

Re: [SQL] insert rule doesn't see id field

2003-01-10 Thread Radu-Adrian Popescu
u CSA, DBA, Developer Aldratech Ltd. - Original Message - From: "Ron Peterson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 09, 2003 9:12 PM Subject: Re: [SQL] insert rule doesn't see id field On Wed, Jan 08, 2003 at 01:13:03PM -0500, Ron Pete

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Tom Lane
Ron Peterson <[EMAIL PROTECTED]> writes: > On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote: >> colindices = (int *) malloc (ncols * sizeof (int)); > Of course we should verify that malloc succeeded... Actually, the correct answer is "you should not be using malloc() in backend functi

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote: > colindices = (int *) malloc (ncols * sizeof (int)); Of course we should verify that malloc succeeded... if (colindices == NULL) { elog (ERROR, "noupcol: malloc failed\n"); SPI_finish(); return PointerGetD

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
On Thu, Jan 09, 2003 at 07:54:04PM -, [EMAIL PROTECTED] wrote: > Sounds similar to the plpgsql example at: > > http://www.archonet.com/pgdocs/lock-field.html > > which silently discards changes. It's trivial (apart from quoting issues) > to write a trigger generator to customise the above in

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread dev
> On Wed, Jan 08, 2003 at 01:13:03PM -0500, Ron Peterson wrote: >> On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: >> >> > > I thought that the idea behind noup was to protect single columns >> from >> > > update. However, when I apply the noup trigger as above, I can't >> > > update /an

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
On Wed, Jan 08, 2003 at 01:13:03PM -0500, Ron Peterson wrote: > On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > > > > I thought that the idea behind noup was to protect single columns from > > > update. However, when I apply the noup trigger as above, I can't > > > update /any/ column

Re: [SQL] insert rule doesn't see id field

2003-01-08 Thread Ron Peterson
On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > > I thought that the idea behind noup was to protect single columns from > > update. However, when I apply the noup trigger as above, I can't > > update /any/ column. Is this the intended behaviour? > > Idly looking at the source code

Re: [SQL] insert rule doesn't see id field

2003-01-07 Thread Tom Lane
Ron Peterson <[EMAIL PROTECTED]> writes: > CREATE RULE person_insert AS > ON INSERT TO person > DO > INSERT INTO person_log ( name_last, name_first, mod_type, person_id ) > VALUES ( new.name_last, new.name_first, 'I', new.id ); > [where id is a serial column] > My insert rule creates a rec

Re: [SQL] insert rule doesn't see id field

2003-01-07 Thread Ron Peterson
BTW, PostgreSQL 7.2.1-2woody2 on Debian. -- Ron Peterson -o) Network & Systems Manager /\\ Mount Holyoke College_\_v http://www.mtholyoke.edu/~rpeterso ---(end of broadcast)--- TIP 5: Hav

[SQL] insert rule doesn't see id field

2003-01-07 Thread Ron Peterson
Two seperate problems, really, but first the SQL: CREATE SEQUENCE person_id_seq; CREATE TABLE person ( name_last VARCHAR( 50 ) NOT NULL, name_first VARCHAR( 50 ) NOT NULL, id INTEGER