date_in function

Started by Dragos Manzateanualmost 24 years ago5 messageshackers
Jump to latest
#1Dragos Manzateanu
dragon@mail.dntis.ro

I want to change the date from a field in a tuple in a trigger_function

create table example (
my_date datetime
...
);

int na;
char select[20];

na = SPI_fnumber(trigdata->tg_relation->rd_att, "my_date");
memset(select, 0, sizeof(select));
sprintf(select, "1/1/2002");
newval = DirectFunctionCall1(date_in, CStringGetDatum(select));
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &na, &newval,
NULL);
if(rettuple == NULL) elog(ERROR, "my_function: %d returned by
SPI_modifytuple", SPI_result);

when i test that my server goes down. What I missed ?

#2Dragos Manzateanu
dragon@mail.dntis.ro
In reply to: Dragos Manzateanu (#1)
Re: date_in function

On Tuesday 16 April 2002 05:48 pm, you wrote:

I want to change the date from a field in a tuple in a trigger_function

create table example (
my_date datetime
...
);

int na;
char select[20];

na = SPI_fnumber(trigdata->tg_relation->rd_att, "my_date");
memset(select, 0, sizeof(select));
sprintf(select, "1/1/2002");
newval = DirectFunctionCall1(date_in, CStringGetDatum(select));
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &na,
&newval, NULL);
if(rettuple == NULL) elog(ERROR, "my_function: %d returned by
SPI_modifytuple", SPI_result);

when i test that my server goes down. What I missed ?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Not my function is about, but date_in.
Have anybody worked with these ?

#3Dragos Manzateanu
dragon@mail.dntis.ro
In reply to: Dragos Manzateanu (#2)
Re: date_in function
Show quoted text

On Tuesday 16 April 2002 10:32 pm, you wrote:

On Tuesday 16 April 2002 05:48 pm, you wrote:

I want to change the date from a field in a tuple in a trigger_function

create table example (
my_date datetime
...
);

int na;
char select[20];

na = SPI_fnumber(trigdata->tg_relation->rd_att, "my_date");
memset(select, 0, sizeof(select));
sprintf(select, "1/1/2002");
newval = DirectFunctionCall1(date_in, CStringGetDatum(select));
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &na,
&newval, NULL);
if(rettuple == NULL) elog(ERROR, "my_function: %d returned by
SPI_modifytuple", SPI_result);

when i test that my server goes down. What I missed ?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Not my function is about, but date_in.
Have anybody worked with these ?

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

#4Dragos Manzateanu
dragon@mail.dntis.ro
In reply to: Dragos Manzateanu (#3)

I want to change the date from a field in a tuple in a trigger_function

create table example (
my_date datetime
...
);

int na;
char select[20];

na = SPI_fnumber(trigdata->tg_relation->rd_att, "my_date");
memset(select, 0, sizeof(select));
sprintf(select, "1/1/2002");
newval = DirectFunctionCall1(date_in, CStringGetDatum(select));
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &na, &newval,
NULL);
if(rettuple == NULL) elog(ERROR, "my_function: %d returned by
SPI_modifytuple", SPI_result);

when i test that my server goes down. What I missed ?

Not my function is about, but date_in.
Have anybody worked with this function ?
Can somebody give me a sample to use date_in. Thanks.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dragos Manzateanu (#4)
Re: date_in function

Dragos Manzateanu <dragon@mail.dntis.ro> writes:

na = SPI_fnumber(trigdata->tg_relation->rd_att, "my_date");
memset(select, 0, sizeof(select));
sprintf(select, "1/1/2002");
newval = DirectFunctionCall1(date_in, CStringGetDatum(select));
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &na, &newval,
NULL);
if(rettuple == NULL) elog(ERROR, "my_function: %d returned by
SPI_modifytuple", SPI_result);

when i test that my server goes down. What I missed ?

I doubt that the problem is with date_in. Have you tried backtracing
in the core dump?

regards, tom lane