Problems with 8.4, FLOAT8PASSBYVAL and x86_64 GNU/Linux

From: Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Problems with 8.4, FLOAT8PASSBYVAL and x86_64 GNU/Linux
Date: 2009-07-16 09:14:48
Message-ID: 4A5EEF88.2010807@usit.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello

We have a C function that works without problems when we use it with
postgresql 8.3 (32/64bit) and with postgreSQL 8.4 (32bit).

But with 8.4 in a 64bit server, postgresql generates this error when we
try to install the function:

ERROR: incompatible library "/usr/local/lib/pg_uname_8.4.so": magic
block mismatch
DETAIL: Server has FLOAT8PASSBYVAL = true, library has false.

This is the query we use to install the function:

CREATE OR REPLACE FUNCTION pg_uname(text) RETURNS text
AS '/usr/local/lib/pg_uname_8.4.so', 'pg_uname'
LANGUAGE c STRICT;

The only reference we have found about this is in the 8.4 changelog:

" ... Pass float8, int8, and related datatypes by value inside the
server on 64-bit platforms (Zoltan Boszormenyi)

Add configure option --disable-float8-byval to use the old behavior. As
above, this change might break old-style external C functions. ..."

We cannot find more information in the documentation about things we
should change so the function works with 8.4 without using
- --disable-float8-byval under the compilation of postgresql.

What do we need to change in the function to avoid this problem?

The function we are talking about is this one:
- -------------------------------------------------------------------
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#include <sys/utsname.h>

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(pg_uname);

Datum
pg_uname(PG_FUNCTION_ARGS)
{
text *argument = PG_GETARG_TEXT_P(0);
size_t argumentlen = VARSIZE(argument)-VARHDRSZ;

text *result = (text *) palloc(256);
char *option = (char *) palloc(argumentlen+1);

char sysname[] = "sysname";
char nodename[] = "nodename";
char release[] = "release";
char version[] = "version";
char machine[] = "machine";
char null[] = "null";

struct utsname uname_pointer;
uname(&uname_pointer);

memcpy(option,VARDATA(argument),argumentlen);
option[argumentlen] = '\0';

if (strcmp(option,sysname) == 0){
SET_VARSIZE(result, strlen(uname_pointer.sysname) + VARHDRSZ);

memcpy(VARDATA(result),uname_pointer.sysname,strlen(uname_pointer.sysname));
}
else if (strcmp(option,nodename) == 0){
SET_VARSIZE(result, strlen(uname_pointer.nodename) + VARHDRSZ);

memcpy(VARDATA(result),uname_pointer.nodename,strlen(uname_pointer.nodename));
}
else if (strcmp(option,release) == 0){
SET_VARSIZE(result, strlen(uname_pointer.release) + VARHDRSZ);

memcpy(VARDATA(result),uname_pointer.release,strlen(uname_pointer.release));
}
else if (strcmp(option,version) == 0){
SET_VARSIZE(result, strlen(uname_pointer.version) + VARHDRSZ);

memcpy(VARDATA(result),uname_pointer.version,strlen(uname_pointer.version));
}
else if (strcmp(option,machine) == 0){
SET_VARSIZE(result, strlen(uname_pointer.machine) + VARHDRSZ);

memcpy(VARDATA(result),uname_pointer.machine,strlen(uname_pointer.machine));
}
else{
memcpy(VARDATA(result),null,sizeof(null));
}

pfree(option);
PG_RETURN_TEXT_P(result);
}

- -------------------------------------------------------------------
Thanks in advance.

regards,
- --
Rafael Martinez, <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
Center for Information Technology Services
University of Oslo, Norway

PGP Public Key: http://folk.uio.no/rafael/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFKXu+GBhuKQurGihQRAqP/AJ4p7DPCwMYzEdO/cykEqf2QpSuiygCeMp9D
GGwluLrii7FRy6+GLo86P3I=
=APUL
-----END PGP SIGNATURE-----

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2009-07-16 09:15:24 Re: [PERFORM] Concurrency issue under very heay loads
Previous Message Massa, Harald Armin 2009-07-16 08:53:37 overwrite the encoding of a database