From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: RfD: more powerful "any" types |
Date: | 2009-09-09 19:41:02 |
Message-ID: | 162867790909091241h2b416493iad95afd3b5473e0d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/9/9 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
> Pavel Stehule escribió:
>> 2009/9/9 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>> > Pavel Stehule escribió:
>> >
>> >> we are able to write sprintf(text, variadic "any") returns text, but only in C
>> >
>> > Hmm, should we provide that function in core?
>>
>> We should it, but I prefer some pgfoundry or contrib package. sprintf
>> is really far to SQL. What more, we knows types, so some format tags
>> are useless. Using original sprintf function is possible, but needs
>> lot of code, because you need to transform PostgreSQL types to C
>> types, and we have not any helping function for this task.
>>
>> Some similar to plpgsql's RAISE statement is some +/- 20 rows
>
> I already published a pseudo-sprintf function in the wiki here:
> http://wiki.postgresql.org/wiki/Sprintf I'm looking for something
> better, not just the same hacks.
>
> I don't see any good reason that the function needs to be far from core.
what is use case? Why you need sprintf function, when you have ||
operator. This functionality is redundant and out of standard. What I
know, only MySQL has similar function.
Please, try to compile and run sprintf function from attachment
postgres=# select sprintf('1:% 2:% 3:%', 10,null, 'kuku');
sprintf
--------------------
1:10 2:NULL 3:kuku
(1 row)
postgres=# select sprintf('Today is %, I am %.', current_date, current_user);
sprintf
----------------------------------
Today is 2009-09-09, I am pavel.
(1 row)
Regards
Pavel
>
> --
> Alvaro Herrera http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
Attachment | Content-Type | Size |
---|---|---|
sprintf.tgz | application/x-gzip | 3.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2009-09-09 19:44:45 | Re: RfD: more powerful "any" types |
Previous Message | Alvaro Herrera | 2009-09-09 19:36:06 | Re: RfD: more powerful "any" types |