From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used |
Date: | 2012-11-16 09:42:26 |
Message-ID: | CAFj8pRB95BMye6eaRZzpNf3N8HLnZjE+N43DFadHRJ6u+536qA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
I found so we doesn't have functionality for simply text aligning - so
I propose support width for %s like printf's behave. glibc
implementation knows a rule for precision, that I don't would to
implement, because it is oriented to bytes and not to chars - and it
can be confusing. Still I would to have implementation and design of
"format" function maximally simple - and a rule for "s" specifier and
width is clean and simple.
postgres=# select format('||%4s|| ||%-4s||', 'ab', 'ab');
format
-------------------
|| ab|| ||ab ||
I also found so our implementation of positional and ordered
placeholders are not correct.
-- correct
postgres=# select format('%s %2$s %s', 'Hello', 'World');
format
-------------------
Hello World World
-- our current behave
postgres=# select format('%s %2$s %s', 'Hello', 'World');
ERROR: too few arguments for format
postgres=#
Comments, notices?
Regards
Pavel Stehule
Attachment | Content-Type | Size |
---|---|---|
format_with_width.diff | application/octet-stream | 11.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2012-11-16 09:58:06 | Re: Proposal for Allow postgresql.conf values to be changed via SQL |
Previous Message | Etsuro Fujita | 2012-11-16 09:41:44 | Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY |