pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcalling elog possibly causing problem in DirectFunctionCall1
4+ messages / 2 participants
[nested] [flat]
* calling elog possibly causing problem in DirectFunctionCall1
@ 2006-12-01 16:40 Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Rajesh Kumar Mallah @ 2006-12-01 16:40 UTC (permalink / raw)
To: pgsql-sql
Hi ,
In certain C trigger function following code snippet causes ERROR:
---------------------------------------------------
elog (NOTICE , "before calling DirectFunctionCall1");
data->time_stamp =
DirectFunctionCall1(timestamptz_in, CStringGetDatum("now"));
elog (NOTICE , "after calling DirectFunctionCall1");
----------------------------------------------------
begin work;INSERT INTO audittest.test_table (name,foo) values
('test','test'); rollback;
BEGIN
NOTICE: before calling DirectFunctionCall1
ERROR: timestamp(-1073748880) precision must be between 0 and 6
ROLLBACK
If the elog before DirectFunctionCall1 is removed the code works fine.
begin work;INSERT INTO audittest.test_table (name,foo) values
('test','test'); rollback;
BEGIN
NOTICE: after calling DirectFunctionCall1
INSERT 0 1
ROLLBACK
Can anyone please explain how removing a elog makes a difference?
Regds
Mallah.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: calling elog possibly causing problem in DirectFunctionCall1
@ 2006-12-01 17:47 Tom Lane <tgl@sss.pgh.pa.us>
parent: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Tom Lane @ 2006-12-01 17:47 UTC (permalink / raw)
To: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>; +Cc: pgsql-sql
"Rajesh Kumar Mallah" <mallah.rajesh@gmail.com> writes:
> data->time_stamp =
> DirectFunctionCall1(timestamptz_in, CStringGetDatum("now"));
This code is incorrect, as timestamptz_in takes three arguments.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: calling elog possibly causing problem in DirectFunctionCall1
@ 2006-12-01 17:59 Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Rajesh Kumar Mallah @ 2006-12-01 17:59 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
On 12/1/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Rajesh Kumar Mallah" <mallah.rajesh@gmail.com> writes:
> > data->time_stamp =
> > DirectFunctionCall1(timestamptz_in, CStringGetDatum("now"));
>
> This code is incorrect, as timestamptz_in takes three arguments.
Dear Sir,
thanks for the kind reply.
field time_stamp of data is declared as:
Datum time_stamp;
it is supposed to be populated with current timestamp , (now())
can you please tell me what should be passed as the third argument?
Regds
Mallah.
regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: calling elog possibly causing problem in DirectFunctionCall1
@ 2006-12-01 18:58 Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Rajesh Kumar Mallah @ 2006-12-01 18:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
On 12/1/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Rajesh Kumar Mallah" <mallah.rajesh@gmail.com> writes:
> > data->time_stamp =
> > DirectFunctionCall1(timestamptz_in, CStringGetDatum("now"));
>
> This code is incorrect, as timestamptz_in takes three arguments.
replaced it with:
data->time_stamp = DirectFunctionCall3(timestamptz_in,
CStringGetDatum("now"),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1))
now it works fine. (code lifted from contrib/spi/moddatetime.c(line 73)
hopefully its correct.
regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-12-01 18:58 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-12-01 16:40 calling elog possibly causing problem in DirectFunctionCall1 Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
2006-12-01 17:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-12-01 17:59 ` Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
2006-12-01 18:58 ` Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
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