PL/C functions
Is it possible to write functions for PL/C that have variable argument lists?
I.E.
UPPER( arg )
UPPER( arg, encoding_list )
LOWER( arg )
LOWER( arg, encoding_list )
SUBSTR( arg, arg, arg )
SUBSTR( arg, arg, arg, encoding_list );
Obviously, these would have to take the place of the original functions, is that possible?
Dennis Gearon writes:
Is it possible to write functions for PL/C that have variable argument lists?
You cannot write functions with variable argument lists in any language.
--
Peter Eisentraut peter_e@gmx.net
Uuuuuuuuuuuh, C++ can do it, PHP can do it, JAVA can do it, I just want to know if PL/C can do it for UDF's.
Peter Eisentraut wrote:
Show quoted text
Dennis Gearon writes:
Is it possible to write functions for PL/C that have variable argument lists?
You cannot write functions with variable argument lists in any language.
I haven't seen anything saying it's possible to use either default arguments or variable argument lists in C functions used iin PL/C, but otherwise:
Peter Eisentraut wrote:
Show quoted text
Dennis Gearon writes:
Is it possible to write functions for PL/C that have variable argument lists?
You cannot write functions with variable argument lists in any language.
Dennis Gearon <gearond@cvc.net> writes:
Uuuuuuuuuuuh, C++ can do it, PHP can do it, JAVA can do it, I just
want to know if PL/C can do it for UDF's.
We have no animal called "PL/C". Kindly be more clear about what your
question is.
regards, tom lane
User defined functions written in C/C++? That's _NOT_ known as PL/C? sorry for the confusion.
Tom Lane wrote:
Show quoted text
Dennis Gearon <gearond@cvc.net> writes:
Uuuuuuuuuuuh, C++ can do it, PHP can do it, JAVA can do it, I just
want to know if PL/C can do it for UDF's.We have no animal called "PL/C". Kindly be more clear about what your
question is.regards, tom lane
Dennis Gearon <gearond@cvc.net> writes:
We have no animal called "PL/C". Kindly be more clear about what your
question is.
User defined functions written in C/C++?
Okay. The answer is:
1. There is no provision for a single pg_proc entry to have a variable
number of arguments.
2. You can make multiple pg_proc entries referencing the same C
function. The C function can find out how many arguments it was
actually passed (use PG_NARGS()).
So you could make several different pg_proc entries and get the desired
effect, at some tedium.
Joe Conway has posted a few examples using this approach, IIRC.
regards, tom lane
Tom Lane wrote:
1. There is no provision for a single pg_proc entry to have a variable
number of arguments.2. You can make multiple pg_proc entries referencing the same C
function. The C function can find out how many arguments it was
actually passed (use PG_NARGS()).So you could make several different pg_proc entries and get the desired
effect, at some tedium.Joe Conway has posted a few examples using this approach, IIRC.
See contrib/dblink in 7.4beta -- there are several functions using this
method, e.g. dblink_connect().
Joe
Dennis Gearon <gearond@cvc.net> writes:
One final note on this topic, (for me), if I write a C function that changes one of the LOCALES:
... you will probably break things. Read the comments in
/src/backend/utils/adt/pg_locale.c.
regards, tom lane
Import Notes
Reply to msg id not found: 3F395F65.4040508@cvc.net
One final note on this topic, (for me), if I write a C function that changes one of the LOCALES:
1/ Will it change the LOCALE at all?
2/ Does it change it for the whole program, affecting other, asynchronous
execution within any of the modules of the dbase?
Joe Conway wrote:
Show quoted text
Tom Lane wrote:
1. There is no provision for a single pg_proc entry to have a variable
number of arguments.2. You can make multiple pg_proc entries referencing the same C
function. The C function can find out how many arguments it was
actually passed (use PG_NARGS()).So you could make several different pg_proc entries and get the desired
effect, at some tedium.Joe Conway has posted a few examples using this approach, IIRC.
See contrib/dblink in 7.4beta -- there are several functions using this
method, e.g. dblink_connect().Joe
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
This is where a variable argument list for a function would come in handy, if ISO C had such for 'strxfrm()'. The locale could be supplied INLINE, instead of taken from the machine LOCALE. Maybe I'll just copy the library functions and change them to use an extra argument for LOCALE.
Tom Lane wrote:
Show quoted text
Dennis Gearon <gearond@cvc.net> writes:
One final note on this topic, (for me), if I write a C function that changes one of the LOCALES:
... you will probably break things. Read the comments in
/src/backend/utils/adt/pg_locale.c.regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: 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