Calling V1 function from within the server

From: Don Y <pgsql(at)DakotaCom(dot)Net>
To: pgsql-general(at)postgresql(dot)org
Subject: Calling V1 function from within the server
Date: 2006-05-02 18:24:34
Message-ID: 4457A3E2.5050602@DakotaCom.Net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

If I define:

Datum barcode_checksum(PG_FUNCTION_ARGS)

PG_FUNCTION_INFO_V1(barcode_checksum)

Datum barcode_checksum(PG_FUNCTION_ARGS)
{
barcode value;
short result;

label = (barcode) PG_GETARG_INT32(0);

// compute barcode

PG_RETURN_INT16(result);
}

and now want to *use* that function within some other
(related) function, how can I invoke it? The intuitive
syntax:
short foo;
barcode label;
foo = barcode_checksum(label);
gives compiler warnings (pointer from int without cast)
as well as SIGSEGV's at run time.

The model used for the complex sample data type avoids this
issue by creating an "internal" function that is used by
other functions -- and *wrapped* in the PG_FUNCTION_INFO_V1
framework under another name (i.e. that name is never used
directly in the rest of the code)

--don

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christo Romberg 2006-05-02 19:02:17 FATAL: database "dspace" does not exist"
Previous Message Matthew T. O'Connor 2006-05-02 18:20:03 8.1.4 anytime soon?