From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Takahiro Itagaki <itagaki(dot)takahiro(at)gmail(dot)com> |
Subject: | string function - "format" function proposal |
Date: | 2010-08-30 10:58:31 |
Message-ID: | AANLkTinMPvVm_iztJ2zPtAj0jNThONrcCo+TwTQm3V6X@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
I am returning back to string functions. For me, the most important
function isn't commited still. There was discussion about "format" or
"sprintf" fuction. So I'll do a small resume.
goal: to get function that helps with formatting a message texts and
helps with building a SQL commands (used as dynamic SQL)
propsals:
* "format" function - uses same formatting as PL/pgSQL RAISE statement
* "sprintf" function
Itagaki objectives to "format" function:
* there are not possibility put two parameters without a space between
* it is too simple
My objectives to sprintf function:
* it is designed to different environment than SQL - missing support
NULL, missing support for date, timestamp, boolean, ...
* it is too complex, some parameters has different meaning for different tags
* we have a "to_char" function for complex formatting now.
Now I propose a compromise - "format" function with only three tags:
%s .. some string
%i .. SQL identifier
%l .. string literal
using a NULL:
for %s NULL is transformed to empty string - like "concat"
for %i NULL raises an exception
for %l NULL is transformed to ' NULL ' string.
This system is still simple and enough.
Implemented sprintf function can be moved to "sprintf" contrib module.
comments
Regards
Pavel Stehule
From | Date | Subject | |
---|---|---|---|
Next Message | Itagaki Takahiro | 2010-08-30 11:20:54 | Re: string function - "format" function proposal |
Previous Message | Simon Riggs | 2010-08-30 09:18:54 | cost_hashjoin |