Re: selfmade datatype in C and server-crash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Schulz <msc(at)antzsystem(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: selfmade datatype in C and server-crash
Date: 2005-10-05 03:01:30
Message-ID: 13242.1128481290@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Markus Schulz <msc(at)antzsystem(dot)de> writes:
> This works fine and then i've created the new Type like:

> CREATE OR REPLACE FUNCTION etextin(cstring)
> RETURNS etext AS
> '$libdir/new_types.so', 'etextin'
> LANGUAGE 'c' VOLATILE;

> CREATE OR REPLACE FUNCTION etextout(etext)
> RETURNS cstring AS
> '$libdir/new_types.so', 'etextout'
> LANGUAGE 'c' VOLATILE;

You'd likely be well advised to declare these STRICT (hint: is the C
code checking for null input?) ... and unless the datatype has weird
semantics, its I/O functions should be IMMUTABLE. This doesn't matter
too much for the system's ordinary use of I/O functions, but for
security you want to make sure the functions are properly marked in
case they get called directly.

> But if i'm trying to use the type in a table (for instance table with
> only one etext column) the server crashed after inserting the second
> (first insert works) tuple or on every select.

Getting a stack trace from the crash would be helpful. But the fact
that it only fails on the second try makes me suspicious that it's
a memory-management issue. Count thy pallocs.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nitin Tarkar 2005-10-05 05:24:47 PostgreSQL Database export from Linux to Windows
Previous Message Michael Fuhr 2005-10-05 02:39:36 Re: Isolated transactions?