Обсуждение: Problems with 8.4, FLOAT8PASSBYVAL and x86_64 GNU/Linux
-----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.m.guerrero@usit.uio.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-----
On Thursday 16 July 2009 12:14:48 Rafael Martinez wrote: > ERROR: incompatible library "/usr/local/lib/pg_uname_8.4.so": magic > block mismatch > DETAIL: Server has FLOAT8PASSBYVAL = true, library has false. You need to recompile your module.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Peter Eisentraut wrote:
> On Thursday 16 July 2009 12:14:48 Rafael Martinez wrote:
>> ERROR: incompatible library "/usr/local/lib/pg_uname_8.4.so": magic
>> block mismatch
>> DETAIL: Server has FLOAT8PASSBYVAL = true, library has false.
>
> You need to recompile your module.
Hei
We recompile the module automatically when a new postgres cluster gets
installed. The module has been compiled locally on the 64bit server that
is going to use it.
Any other ideas?
This is the Makefile we use:
- ---------------------------------------
PG_SRC=/usr/local/src
PG_LIB=/usr/local/lib
SERVER_INCLUDES += -I $(shell /local/opt/pgsql-8.4/bin/pg_config
- --includedir)
SERVER_INCLUDES += -I $(shell /local/opt/pgsql-8.4/bin/pg_config
- --includedir-server)
CFLAGS = $(SERVER_INCLUDES)
CC = gcc
all: clean pg_uname_8.4 install
pg_uname_8.4: pg_uname_8.4.c
$(CC) $(CFLAGS) -fpic -c $<
$(CC) $(CFLAGS) -shared -o $(basename $<).so $(basename
$<).o
install:
cp $(PG_SRC)/pg_uname_8.4.so $(PG_LIB)/pg_uname_8.4.so
clean:
rm -f *.o
rm -f *.so
rm -f *~
- ---------------------------------------
regards,
- --
Rafael Martinez, <r.m.guerrero@usit.uio.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)
iD8DBQFKXvoZBhuKQurGihQRAiJdAJ9HBG33gDF16Uiu+Z5QvGDHtnzj7gCaAmBz
Lfll6Lshy8shhLK62lb3fMs=
=sIud
-----END PGP SIGNATURE-----
On 7/16/09, Rafael Martinez <r.m.guerrero@usit.uio.no> wrote: > Peter Eisentraut wrote: > > On Thursday 16 July 2009 12:14:48 Rafael Martinez wrote: > >> ERROR: incompatible library "/usr/local/lib/pg_uname_8.4.so": magic > >> block mismatch > >> DETAIL: Server has FLOAT8PASSBYVAL = true, library has false. > > > > You need to recompile your module. > > We recompile the module automatically when a new postgres cluster gets > installed. The module has been compiled locally on the 64bit server that > is going to use it. > > Any other ideas? The version you compile against is not the version you have running. -- marko
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marko Kreen wrote: > On 7/16/09, Rafael Martinez <r.m.guerrero@usit.uio.no> wrote: >> Peter Eisentraut wrote: >> > >> > You need to recompile your module. >> >> We recompile the module automatically when a new postgres cluster gets >> installed. The module has been compiled locally on the 64bit server that >> is going to use it. >> >> Any other ideas? > > The version you compile against is not the version you have running. > Well, the only version I have installed on this server is 8.4.0 - -- Rafael Martinez, <r.m.guerrero@usit.uio.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) iD4DBQFKXxucBhuKQurGihQRAi66AJiNoPt8BWw/Re7/pWY+hDCS/5ZzAKCJt/P+ psR8cTaHE8NNFC/ZjtxHFA== =wKmk -----END PGP SIGNATURE-----
On 7/16/09, Rafael Martinez <r.m.guerrero@usit.uio.no> wrote: > Marko Kreen wrote: > > On 7/16/09, Rafael Martinez <r.m.guerrero@usit.uio.no> wrote: > >> Peter Eisentraut wrote: > >> > > > >> > You need to recompile your module. > >> > >> We recompile the module automatically when a new postgres cluster gets > >> installed. The module has been compiled locally on the 64bit server that > >> is going to use it. > >> > >> Any other ideas? > > > > The version you compile against is not the version you have running. > > > > > Well, the only version I have installed on this server is 8.4.0 Yes, but the 8.4.0 you have running seems to be compiled with different options than the 8.4.0 you compile against. -- marko
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marko Kreen wrote: > On 7/16/09, Rafael Martinez <r.m.guerrero@usit.uio.no> wrote: >> >> Any other ideas? >> > >> > The version you compile against is not the version you have running. >> > >> >> Well, the only version I have installed on this server is 8.4.0 > > Yes, but the 8.4.0 you have running seems to be compiled with different > options than the 8.4.0 you compile against. > It is the same installation and I have checked that we only have one/same version installed. Are you sure this problem is related to compilation? Could the problem be anywhere else? Thanks so far for your time regards, - -- Rafael Martinez, <r.m.guerrero@usit.uio.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) iD8DBQFKXyE4BhuKQurGihQRAlqQAJ9Gv12fWZHZmwRGJRwHH54WMVb1OwCgkIa3 q9Dt3nWe9UYGzjfxq1UawEA= =5G4F -----END PGP SIGNATURE-----
Rafael Martinez wrote: > This is the Makefile we use: > - --------------------------------------- > PG_SRC=/usr/local/src > PG_LIB=/usr/local/lib > SERVER_INCLUDES += -I $(shell /local/opt/pgsql-8.4/bin/pg_config > - --includedir) > SERVER_INCLUDES += -I $(shell /local/opt/pgsql-8.4/bin/pg_config > - --includedir-server) I suggest you rewrite your makefile to use PGXS. The problem might be a difference in CFLAGS. It would make the makefile a lot simpler too. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.