| From: | "Michael Enke" <michael(dot)enke(at)wincor-nixdorf(dot)com> |
|---|---|
| To: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | BUG #2574: C function: arg TEXT data corrupt |
| Date: | 2006-08-14 13:53:34 |
| Message-ID: | 200608141353.k7EDrYPi038307@wwwmaster.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-general |
The following bug has been logged online:
Bug reference: 2574
Logged by: Michael Enke
Email address: michael(dot)enke(at)wincor-nixdorf(dot)com
PostgreSQL version: 8.1.4
Operating system: Open Suse 10.1 and CentOS 4.3
Description: C function: arg TEXT data corrupt
Details:
I created a C function:
extern Datum test_arg(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(test_arg);
Datum test_arg(PG_FUNCTION_ARGS) {
elog(INFO, "arg: %s", VARDATA(PG_GETARG_TEXT_P(0)));
PG_RETURN_INT16(0);
}
and used the
CREATE FUNCTION test_arg(TEXT) RETURNS INT4 AS 'path_to_lib.so' LANGUAGE
'C';
If I call this function "the first time"
after connecting with psql, the info output shows
corrupted data, the second and further call is ok:
me(at)noteme:~/uwx9/SVN/tpl/trunk/db/postgresql/src> psql -U tplinux
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
tplinux=> select test_arg('1');
INFO: arg: 1s(at)3
test_arg
----------
0
(1 row)
tplinux=> select test_arg('1');
INFO: arg: 1
test_arg
----------
0
(1 row)
The same problem is with input length of 2, 3, 4, 8 char (and may be more).
With input of 4 char I never get correct value.
No problem for first call with 5, 6 , 7 char,
but with 5 char problem if before called with 6 char.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-08-14 15:27:00 | Re: BUG #2574: C function: arg TEXT data corrupt |
| Previous Message | Nick Morrison | 2006-08-14 05:36:41 | no native spinlock support on os x 10.4.7 |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lee A Reum | 2006-08-14 14:18:50 | Re: problem with a dropped database |
| Previous Message | Jorge Godoy | 2006-08-14 13:23:24 | Re: Best approach for a "gap-less" sequence |