472,972 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 software developers and data experts.

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

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

Nov 11 '05 #1
8 2329
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
21
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
14
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.