Re: Variadic polymorpic functions

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Variadic polymorpic functions
Дата
Msg-id 162867791001270735k1591deaanb8adf55c009190f7@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Variadic polymorpic functions  (Vincenzo Romano <vincenzo.romano@notorand.it>)
Ответы Re: Variadic polymorpic functions  (Vincenzo Romano <vincenzo.romano@notorand.it>)
Список pgsql-general
Hello

I add sprintf function. Now I think, we can add new contrib module
(string functions) with both function - format and sprintf. These
functions are relative different, so they can exists separately.
Format is simpler and faster. Sprintf is more powerful but slower.

postgres=# select pst.format('now is %', current_time);
          format
---------------------------
 now is 16:34:26.203728+01
(1 row)

postgres=# select pst.sprintf('now is %s', current_time);
         sprintf
--------------------------
 now is 16:34:45.24919+01

Regards
Pavel Stehule

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( .... );
>
> 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.
>
> 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.
>
> --
> Vincenzo Romano
> NotOrAnd Information Technologies
> NON QVIETIS MARIBVS NAVTA PERITVS
>

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: 100% of CPU utilization postgres process
Следующее
От: "Igor Neyman"
Дата:
Сообщение: relation between records in "main" and "toast" tables