From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Hannu Krosing <hannu(at)krosing(dot)net> |
Cc: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, 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 20:46:51 |
Message-ID: | 162867790909091346t3e2ecc4i1001a0a2d26b0097@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/9/9 Hannu Krosing <hannu(at)krosing(dot)net>:
> On Wed, 2009-09-09 at 21:57 +0200, Pavel Stehule wrote:
>> 2009/9/9 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>> > Pavel Stehule escribió:
>> >> 2009/9/9 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>> >
>> >> > 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.
>> >
>> > Extensive use of || turns into horrible messes quickly. sprintf() makes
>> > this kind of thing much cleaner. You could use strcat/strcpy in C too,
>> > but do you? You could argue that sprintf is redundant in C, yet it
>> > turns out to be extremely useful.
>> >
>>
>> Yes, I agree. But this functionality you will use only in plpgsql
>> language. I thing, so there could be some library that should be
>> separated from standard functions. It would be nice, when people
>> clearly understand if use some enhancing functionality or some base
>> sql functionality.
>
> There is lots of stuff in postgreSQL, especially functions, that is not
> "some base sql functionality", yet is in core.
>
>>
>> we could to have schema plpgsql. And there could be function subst,
>>
>> then in your plpgsql proc you can call
>>
>> if (...) then
>> message := plpgsql.subst('some message:% ...', some value, ...);
>> ....
>>
>> if you would, then you can add plpgsql schema to search path.
>>
>> I dislike to use name sprintf, because this or similar function isn't
>> real sprintf function - it doesn't use compatible format string with
>> sprintf function.
>
> call it format(txt, variadic "any") - that's what it does
why not?
this function should be in contrib - as variadic function sample.
Pavel
>
>> regards
>> Pavel Stehule
>>
>> > One use case is using it for error messages in RAISE/USING. Yes, I am
>> > aware you can use concatenation there.
>> >
>> > --
>> > Alvaro Herrera http://www.CommandPrompt.com/
>> > PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>> >
>>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2009-09-09 20:46:59 | Re: Ragged CSV import |
Previous Message | Hannu Krosing | 2009-09-09 20:43:28 | Re: RfD: more powerful "any" types |