Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8020C133740B for ; Fri, 14 Jan 2011 17:45:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 66494-05 for ; Fri, 14 Jan 2011 21:45:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from snt0-omc1-s23.snt0.hotmail.com (snt0-omc1-s23.snt0.hotmail.com [65.55.90.34]) by mail.postgresql.org (Postfix) with ESMTP id 509D11336B42 for ; Fri, 14 Jan 2011 17:45:16 -0400 (AST) Received: from SNT139-W4 ([65.55.90.8]) by snt0-omc1-s23.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 14 Jan 2011 13:45:13 -0800 Message-ID: Content-Type: multipart/alternative; boundary="_f61d9761-433e-4b2b-ac16-ef3b5d850c67_" X-Originating-IP: [189.186.159.225] From: Fabricio To: Subject: PostgreSQL 9.0.2. This is a Bug? Date: Fri, 14 Jan 2011 14:45:13 -0700 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 14 Jan 2011 21:45:13.0941 (UTC) FILETIME=[53529050:01CBB434] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.354 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/92 X-Sequence-Number: 36532 --_f61d9761-433e-4b2b-ac16-ef3b5d850c67_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This is a bug? A developer is writing a function in C code and when he makes some change a= nd replace the old library with the new one and if run CREATE OR REPLACE FU= NCTION Postgre crash and restart. After restart CREATE OR REPLACE FUNCTION = does not crash postgres=2C only the first time. He makes a function test. = =20 Function's Sorce code:=20 #include "postgres.h" #include "fmgr.h" #include #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC=3B #endif PG_FUNCTION_INFO_V1(testfuncion)=3B Datum testfuncion( PG_FUNCTION_ARGS ) { int32 iParam01=2C iParam02=3B char cTexto[30]=3D{0}=3B iParam01 =3D PG_GETARG_INT32(0)=3B iParam02 =3D PG_GETARG_INT32(1)=3B sprintf(cTexto=2C "iParam01: %i iParam02: %i"=2C iParam01=2C iParam02 )=3B elog( NOTICE=2C cTexto )=3B PG_RETURN_INT32(iParam01 * -1)=3B } makefile: CC =3D gcc CFLAGS =3D -fPIC=20 CPPFLAGS =3D -I/usr/include -I/usr/local/pgsql/include/server/ -I/usr/local= /include -I./ all: rm -f *.o rm -f *.so $(CC) $(CPPFLAGS) $(CFLAGS) -c -o ./bin/testFuncion.o testFuncion.c $(CC) $(CFLAGS) $(CPPFLAGS) -shared -o ./bin/testFuncion.so ./bin/testFunci= on.o @cp ./bin/testFuncion.so /somefolder/testFuncion.so @echo " " @echo OK ... Compilado ... OK @echo " " PostgreSQL' logs: <2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 idle 64>= DEBUG: StartTransactionCommand <2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 idle 65>= DEBUG: StartTransaction <2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 idle 66>= DEBUG: name: unnamed=3B blockState: DEFAULT=3B state: INPROGR=2C xid/subid= /cid: 0/1/0=2C nestlvl: 1=2C children: <2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 idle 67>= LOG: statement: CREATE OR REPLACE FUNCTION testfuncion(integer=2Cinteger) RETURNS int AS '/somefolder/testFuncion.so'=2C 'testfuncion' LANGUAGE c IMMUTABLE STRICT=3B <2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 CREATE F= UNCTION 68> DEBUG: ProcessUtility <2011-01-14 12:52:49 MST 18297 654> DEBUG: reaping dead processes <2011-01-14 12:52:49 MST 18297 655> DEBUG: server process (PID 18484) was t= erminated by signal 11: Segmentation fault <2011-01-14 12:52:49 MST 18297 656> LOG: server process (PID 18484) was ter= minated by signal 11: Segmentation fault <2011-01-14 12:52:49 MST 18297 657> LOG: terminating any other active serve= r processes = --_f61d9761-433e-4b2b-ac16-ef3b5d850c67_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable


This is a bug?

= A developer is writing a function in C code and when he makes some change a= nd replace the old library with the new one and if run CREATE OR REPLACE FU= NCTION Postgre crash and restart. After restart CREATE OR REPLACE FUNCTION = does not crash postgres=2C only the first time. =3B
He makes = a function test.  =3B



Functi= on's Sorce code:
 =3B
#include "postgr= es.h"
#include "fmgr.h"
#include <=3Bsys/utsname.h>=3B

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC=3B
#endif

PG_FUNCTION_= INFO_V1(testfuncion)=3B
Datum testfuncion( PG_FUNCTION_ARGS )
{
in= t32 iParam01=2C
iParam02=3B
char cTexto[30]=3D{0}=3B

iParam01 = =3D PG_GETARG_INT32(0)=3B
iParam02 =3D PG_GETARG_INT32(1)=3B

spri= ntf(cTexto=2C "iParam01: %i iParam02: %i"=2C iParam01=2C iParam02 )=3B
e= log( NOTICE=2C cTexto )=3B

PG_RETURN_INT32(iParam01 * -1)=3B
}
 =3Bmakefile:

CC = =3D gcc
CFLAGS =3D -fPIC =3B
CPPFLAGS =3D -I/usr/include -I/usr/l= ocal/pgsql/include/server/ -I/usr/local/include -I./

all:
rm -f *= .o
rm -f *.so

$(CC) $(CPPFLAGS) $(CFLAGS) -c -o ./bin/testFuncion= .o testFuncion.c
$(CC) $(CFLAGS) $(CPPFLAGS) -shared -o ./bin/testFuncio= n.so ./bin/testFuncion.o

 =3B@cp ./bin/testFuncion.so /somefolde= r/testFuncion.so

@echo " "
@echo OK ... Compilado ... OK
@echo= " "


PostgreSQL' logs:

=

<=3B2011-01-14 12:52:49 MST 10.43.69.141(5= 5946) somedb someuser 18484 idle 64>=3B DEBUG: StartTransactionCommand<=3B2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 id= le 65>=3B DEBUG: StartTransaction
<=3B2011-01-14 12:52:49 MST 10.43.= 69.141(55946) somedb someuser 18484 idle 66>=3B DEBUG: name: unnamed=3B b= lockState: DEFAULT=3B state: INPROGR=2C xid/subid/cid: 0/1/0=2C nestlvl: 1= =2C children:
<=3B2011-01-14 12:52:49 MST 10.43.69.141(55946) somedb s= omeuser 18484 idle 67>=3B LOG: statement: CREATE OR REPLACE FUNCTION test= funcion(integer=2Cinteger)
RETURNS int AS
'/somefolder/testFuncion.so= '=2C 'testfuncion'
LANGUAGE c IMMUTABLE STRICT=3B

<=3B2011-01-1= 4 12:52:49 MST 10.43.69.141(55946) somedb someuser 18484 CREATE FUNCTION 68= >=3B DEBUG: ProcessUtility
<=3B2011-01-14 12:52:49 MST 18297 654>= =3B DEBUG: reaping dead processes
<=3B2011-01-14 12:52:49 MST 18297 65= 5>=3B DEBUG: server process (PID 18484) was terminated by signal 11: Segm= entation fault
<=3B2011-01-14 12:52:49 MST 18297 656>=3B LOG: server= process (PID 18484) was terminated by signal 11: Segmentation fault
<= =3B2011-01-14 12:52:49 MST 18297 657>=3B LOG: terminating any other activ= e server processes


= --_f61d9761-433e-4b2b-ac16-ef3b5d850c67_--