Re: Variadic polymorpic functions - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Variadic polymorpic functions
Date
Msg-id 162867791001250132u5f84325el20f464db95005e9e@mail.gmail.com
Whole thread Raw
In response to Re: Variadic polymorpic functions  (Vincenzo Romano <vincenzo.romano@notorand.it>)
List pgsql-general
2010/1/25 Vincenzo Romano <vincenzo.romano@notorand.it>:
> 2010/1/25 Pavel Stehule <pavel.stehule@gmail.com>:
>> 2010/1/25 Vincenzo Romano <vincenzo.romano@notorand.it>:
>>> 2010/1/23 Pavel Stehule <pavel.stehule@gmail.com>:
>>>> 2010/1/22 Vincenzo Romano <vincenzo.romano@notorand.it>:
>>>>> 2010/1/22 Tom Lane <tgl@sss.pgh.pa.us>:
>>>>>> Vincenzo Romano <vincenzo.romano@notorand.it> writes:
>>>>>>> 2010/1/22 Tom Lane <tgl@sss.pgh.pa.us>:
>>>>>>>> regression=# CREATE FUNCTION q( fmt text, variadic args "any" )
>>>>>>
>>>>>>> And this would allow for a stdarg-like argument list?
>>>>>>
>>>>>> Yeah, it should work, given suitable C code.
>>>>>
>>>>> Great!
>>>>>
>>>>
>>>> I wrote this function year ago.
>>>>
>>>> look on content
>>>>
>>>> http://pgfoundry.org/projects/pstcollection/
>>>
>>> Pavel,
>>> that format() function should be included into official contribs.
>>> What about HOWTO compile?
>>
>> There are not consensus about final semantic - some people prefer
>> sprintf like, some others PostgreSQL RAISE NOTICE like.
>
> Whatever you prefer would be OK as far as it is documented.
> In my opinion, the main usage for such a function is in the dynamic SQL code
> generation in PL/PgSQL functions:
>
> EXECUTE pst.format( .... );

It could be used for expansion packed values - like formated error messages, ...

>
> In this very case the sprintf-like syntax/semantics would be much more
> powerful, but
> the current one is OK if you think that there's nothing similar at the moment.
>

sprintf is more powerful, but more complex too. You don't need some
specific number formating. We have a formating function to_char, so
sprintf is duplicate.

> Again, this function looks to be a badly missing one and including it
> at least into the
> default contrib collection would help a lot of users.
>

I can remove date function from pstcol and I can move it to some
string helper function contrib module.

Pavel

> --
> Vincenzo Romano
> NotOrAnd Information Technologies
> NON QVIETIS MARIBVS NAVTA PERITVS
>

pgsql-general by date:

Previous
From: Jayadevan M
Date:
Subject: Re: Slow Query / Check Point Segments
Next
From: Adrian von Bidder
Date:
Subject: Re: Updates: all or partial records