string function - "format" function proposal
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Takahiro Itagaki <itagaki.takahiro@gmail.com>
Date: 2010-08-30T10:58:31Z
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