variadic args to C functions

Started by Alan Nilssonalmost 13 years ago3 messagesgeneral
Jump to latest
#1Alan Nilsson
anilsson@apple.com

Has anyone got any pointers on implementing a C function in an extension that takes variadic args? I would like to do something like:

select my_function(XXX,...); where XXX will be between 1 and many integers.

Possible? I didn't see any examples in the contrib directory.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Alan Nilsson (#1)
Re: variadic args to C functions

Hello

I wrote lot of C VARIADIC functions - some examples are in core -
"format" function

Schema | Name | Result data type | Argument data types | Type
------------+-----------+------------------+----------------------+--------
pg_catalog | concat | text | VARIADIC "any" | normal
pg_catalog | concat_ws | text | text, VARIADIC "any" | normal
pg_catalog | format | text | text, VARIADIC "any" | normal
(3 rows)

look to http://okbob.blogspot.cz/2010/11/new-version-of-pst-collection-is.html
source code (string functions)

Code should be same without differences between external and internal functions.

Regards

Pavel

2013/6/20 Alan Nilsson <anilsson@apple.com>:

Has anyone got any pointers on implementing a C function in an extension that takes variadic args? I would like to do something like:

select my_function(XXX,...); where XXX will be between 1 and many integers.

Possible? I didn't see any examples in the contrib directory.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Alan Nilsson
anilsson@apple.com
In reply to: Pavel Stehule (#2)
Re: variadic args to C functions

perfect, thanks much

alan

On Jun 20, 2013, at 1:27 AM, Pavel Stehule wrote:

Hello

I wrote lot of C VARIADIC functions - some examples are in core -
"format" function

Schema | Name | Result data type | Argument data types | Type
------------+-----------+------------------+----------------------+--------
pg_catalog | concat | text | VARIADIC "any" | normal
pg_catalog | concat_ws | text | text, VARIADIC "any" | normal
pg_catalog | format | text | text, VARIADIC "any" | normal
(3 rows)

look to http://okbob.blogspot.cz/2010/11/new-version-of-pst-collection-is.html
source code (string functions)

Code should be same without differences between external and internal functions.

Regards

Pavel

2013/6/20 Alan Nilsson <anilsson@apple.com>:

Has anyone got any pointers on implementing a C function in an extension that takes variadic args? I would like to do something like:

select my_function(XXX,...); where XXX will be between 1 and many integers.

Possible? I didn't see any examples in the contrib directory.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general