By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,781 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,781 IT Pros & Developers. It's quick & easy.

PL/C functions

P: n/a
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?
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #1
Share this Question
Share on Google+
8 Replies

P: n/a
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:
c++
http://www.google.com/search?hl=en&l...=Google+Search

php
http://www.google.com/search?hl=en&l...=Google+Search

JAVA
http://www.google.com/search?hl=en&i...=Google+Search

perl
http://www.google.com/search?hl=en&l...=Google+Search

python
http://www.google.com/search?hl=en&l...=Google+Search

Peter Eisentraut wrote:
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.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2

P: n/a
Dennis Gearon <ge*****@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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #3

P: n/a
User defined functions written in C/C++? That's _NOT_ known as PL/C? sorry for the confusion.

Tom Lane wrote:
Dennis Gearon <ge*****@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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #4

P: n/a
Dennis Gearon <ge*****@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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #5

P: n/a
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 ma*******@postgresql.org

Nov 11 '05 #6

P: n/a
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:
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 ma*******@postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #7

P: n/a
Dennis Gearon <ge*****@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 ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #8

P: n/a
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:
Dennis Gearon <ge*****@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 ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.