pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedC LIBRARY EXTENSION SEGFAULT
3+ messages / 3 participants
[nested] [flat]
* C LIBRARY EXTENSION SEGFAULT
@ 2006-11-21 11:29 James M Doherty <jim@jdoherty.net>
2006-11-21 16:21 ` Re: C LIBRARY EXTENSION SEGFAULT Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: James M Doherty @ 2006-11-21 11:29 UTC (permalink / raw)
To: pgsql-interfaces
Hopefully someone can help with this;
I have an extension library which basically adds some common financial
functions from gnumeric. This has worked
just fine for a couple of years on a 32 bit machine running 8.1.0. and still
does. I have recently built a new
dual core 64 bit gentoo system with 8.1.0 installed.
The library in question compiles and links just fine. I install it in
/usr/lib.
When I execute the create or replace function call that also succeeds
however when I execute
the command .. for example:
select * from eomonth('10/22/2006',0);
1. Is there anything special I should have done when building postgres ?
PG_CONFIG OUTPUT:
BINDIR = /usr/local/pgsql/bin
DOCDIR = /usr/local/pgsql/doc
INCLUDEDIR = /usr/local/pgsql/include
PKGINCLUDEDIR = /usr/local/pgsql/include
INCLUDEDIR-SERVER = /usr/local/pgsql/include/server
LIBDIR = /usr/local/pgsql/lib
PKGLIBDIR = /usr/local/pgsql/lib
LOCALEDIR =
MANDIR = /usr/local/pgsql/man
SHAREDIR = /usr/local/pgsql/share
SYSCONFDIR = /usr/local/pgsql/etc
PGXS = /usr/local/pgsql/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--enable-thread-safety' '--with-perl' '--with-pam'
'--with-python' '--enable-depend' '--with-gnu-ld'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
CFLAGS_SL = -fpic
LDFLAGS = -Wl,-rpath,/usr/local/pgsql/lib
LDFLAGS_SL =
LIBS = -lpgport -lpam -lz -lreadline -lcrypt -lresolv -lnsl -ldl -lm -lbsd
VERSION = PostgreSQL 8.1.4
which should return the end of month for argument one I get a seg fault:
********************************* FAULT MESSAGE IN LOG FILE
********************************
Nov 21 05:10:49 gideon postmaster[12461]: segfault at 0000000000000000 rip
00002b3af2c2f3b9 rsp 00007fffb8914398 error 4
CODE FOR EOMONTH:***************************** SNIPPIT
***************************************
PG_FUNCTION_INFO_V1(eomonth);
Datum
eomonth(PG_FUNCTION_ARGS)
{
text *date = PG_GETARG_TEXT_P(0);
int months = PG_GETARG_INT32(1);
GDate sDate;
int serialDate;
int tmp = months;
char mySDate[12];
char *pyear = NULL;
char *pmonth = NULL;
char *pday = NULL;
/* NOW FOR DATE VARS USED WITH parse_date */
char *pdate = NULL;
char pbuf[255];
struct tm tm;
text *myRDate = (text *) palloc(VARHDRSZ + 12);
VARATT_SIZEP(myRDate) = VARHDRSZ + 12;
g_date_clear(&sDate,1);
memset(pbuf,'\0',sizeof(pbuf)); /*initialize buffer */
memcpy(pbuf,VARDATA(date),VARSIZE(date)-VARHDRSZ); /* copy
input string to buffer */
pdate = parse_date(pbuf,&tm); /*call parse date and see if
we know about format*/
g_date_set_parse(&sDate,pdate);/* now set the GDate object
sDate with pdate buf*/
if(g_date_valid(&sDate)) /* is the date we set valid */
{
/*
* now figure the eomonth calc
*/
if(months > 0)
{
g_date_add_months(&sDate,months);
}
if( months < 0)
{
g_date_subtract_months(&sDate,-months);
}
/*
* Now this is the real calculation
*/
g_date_set_day(&sDate,g_date_get_days_in_month(
g_date_get_month(&sDate),
g_date_get_year(&sDate)));
sprintf(VARDATA(myRDate),"%d/%d/%d",
g_date_get_month(&sDate),
g_date_get_day(&sDate),
g_date_get_year(&sDate));
/*
elog(NOTICE,"EOMONTH(%s)",VARDATA(myRDate));
*/
/*
serialDate = datetime_g_to_serial(&sDate);
PG_RETURN_INT32(serialDate);
*/
pfree(myRDate);
PG_RETURN_TEXT_P(myRDate);
}
else
{
elog(ERROR,"EOMONTH date invalid %s
",VARDATA(date));
}
}
James M Doherty
Principal
D. V. (Deus Volantis)
An IRISH Proverb
"There is no success without discipline"
Phil 3: 13 - 15 ("Press On")
JMD CONSULTING
411 Thunderbay Dr
Georgetown, TX 78626
A reputation is something others give you, HONOR is something you give
yourself.
Una reputación es algo que otras le dan, El HONOR es algo que usted se da.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: C LIBRARY EXTENSION SEGFAULT
2006-11-21 11:29 C LIBRARY EXTENSION SEGFAULT James M Doherty <jim@jdoherty.net>
@ 2006-11-21 16:21 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-11-22 11:23 ` Re: C LIBRARY EXTENSION SEGFAULT Eric March <sales@ebmpl.com.au>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2006-11-21 16:21 UTC (permalink / raw)
To: James M Doherty <jim@jdoherty.net>; +Cc: pgsql-interfaces
"James M Doherty" <jim@jdoherty.net> writes:
> pfree(myRDate);
> PG_RETURN_TEXT_P(myRDate);
Egad.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: C LIBRARY EXTENSION SEGFAULT
2006-11-21 11:29 C LIBRARY EXTENSION SEGFAULT James M Doherty <jim@jdoherty.net>
2006-11-21 16:21 ` Re: C LIBRARY EXTENSION SEGFAULT Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-11-22 11:23 ` Eric March <sales@ebmpl.com.au>
0 siblings, 0 replies; 3+ messages in thread
From: Eric March @ 2006-11-22 11:23 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: James M Doherty <jim@jdoherty.net>; pgsql-interfaces
Hi
Are you the Jim Doherty I know in South Australia?
Eric March
Electronic Business Management Pty Ltd
PO Box 475
Hahndorf SA 5245
Ph 08 8388 1991
Mob 0418 418 995
Fax 8388 1998
On Tue, 21 Nov 2006, Tom Lane wrote:
> "James M Doherty" <jim@jdoherty.net> writes:
>> pfree(myRDate);
>> PG_RETURN_TEXT_P(myRDate);
>
> Egad.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-11-22 11:23 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-21 11:29 C LIBRARY EXTENSION SEGFAULT James M Doherty <jim@jdoherty.net>
2006-11-21 16:21 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-11-22 11:23 ` Eric March <sales@ebmpl.com.au>
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