pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedinsert values
4+ messages / 2 participants
[nested] [flat]
* insert values
@ 2001-02-22 12:52 Ines.Klimann@liafa.jussieu.fr
2001-02-23 04:01 ` Re: insert values Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Ines.Klimann@liafa.jussieu.fr @ 2001-02-22 12:52 UTC (permalink / raw)
To: pgsql-sql
Hi,
I have the following type :
--------------------------------------------
CREATE FUNCTION entier_in(opaque)
RETURNS entier
AS '/ens/klimann/PostgreSQL/entier.o'
LANGUAGE 'c';
CREATE FUNCTION entier_out(opaque)
RETURNS opaque
AS '/ens/klimann/PostgreSQL/entier.o'
LANGUAGE 'c';
CREATE TYPE entier (
internallength = 8,
input = entier_in,
output = entier_out
);
--------------------------------------------
where entier.c is the following program :
--------------------------------------------
#include <stdio.h>
typedef struct entier {
long x;
} entier;
entier * entier_in(char *s)
{
entier *result;
result = (entier *)malloc(sizeof(entier));
result->x = atoi(s);
return (result);
}
char * entier_out(entier *n)
{
char *result;
if (n == NULL)
return(NULL);
result = (char *) malloc(60);
sprintf(result, "%d", n->x);
return(result);
}
----------------------------------------------
then I create the table entiers as follows :
----------------------------------------------
CREATE TABLE entiers (
val entier
);
----------------------------------------------
How can I insert a value in this table ?
I have tried several methods, but I can't find
a correct one.
Does someone have an idea ?
Thanks a lot,
Ines.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: insert values
2001-02-22 12:52 insert values Ines.Klimann@liafa.jussieu.fr
@ 2001-02-23 04:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-02-23 08:35 ` Re: insert values Ines.Klimann@liafa.jussieu.fr
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2001-02-23 04:01 UTC (permalink / raw)
To: Ines.Klimann@liafa.jussieu.fr; +Cc: pgsql-sql
Ines.Klimann@liafa.jussieu.fr writes:
> I have the following type :
> ...
> How can I insert a value in this table ?
INSERT INTO entiers VALUES('1234') should work fine.
BTW, change the "malloc" calls to "palloc" if you don't want to suffer
from severe memory leakage problems. Otherwise the code seems OK,
though I'd recommend a tad more validity checking in the input
routine...
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: insert values
2001-02-22 12:52 insert values Ines.Klimann@liafa.jussieu.fr
2001-02-23 04:01 ` Re: insert values Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-02-23 08:35 ` Ines.Klimann@liafa.jussieu.fr
2001-02-23 15:14 ` Re: insert values Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Ines.Klimann@liafa.jussieu.fr @ 2001-02-23 08:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Ines.Klimann@liafa.jussieu.fr; pgsql-sql
On Thu, Feb 22, 2001 at 11:01:11PM -0500, Tom Lane wrote:
> Ines.Klimann@liafa.jussieu.fr writes:
> > I have the following type :
> > ...
> > How can I insert a value in this table ?
>
> INSERT INTO entiers VALUES('1234') should work fine.
>
I have tried and I have this message :
ex1=# insert into entiers
ex1-# values ('1234');
ERROR: Load of file /ens/klimann/PostgreSQL/entier.o failed: Exec format error
ex1=#
what do you think it could be ?
Thanks,
Ines.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: insert values
2001-02-22 12:52 insert values Ines.Klimann@liafa.jussieu.fr
2001-02-23 04:01 ` Re: insert values Tom Lane <tgl@sss.pgh.pa.us>
2001-02-23 08:35 ` Re: insert values Ines.Klimann@liafa.jussieu.fr
@ 2001-02-23 15:14 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2001-02-23 15:14 UTC (permalink / raw)
To: Ines.Klimann@liafa.jussieu.fr; +Cc: pgsql-sql
Ines.Klimann@liafa.jussieu.fr writes:
> ERROR: Load of file /ens/klimann/PostgreSQL/entier.o failed: Exec format error
.o? Did you convert this file into a shared library? I'd expect .so or
.sl depending on platform...
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-02-23 15:14 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-22 12:52 insert values Ines.Klimann@liafa.jussieu.fr
2001-02-23 04:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-02-23 08:35 ` Ines.Klimann@liafa.jussieu.fr
2001-02-23 15:14 ` Tom Lane <tgl@sss.pgh.pa.us>
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