pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
"format" function documentation fix
6+ messages / 3 participants
[nested] [flat]

* "format" function documentation fix
@ 2013-09-14 08:29 rudolf <stu3.1@eq.cz>
  2013-09-17 08:49 ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: rudolf @ 2013-09-14 08:29 UTC (permalink / raw)
  To: pgsql-docs

(Please CC me the reply, since I'm not subscribed to the list.)

Hi,

The last example from 
http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT 
- "examples using width fields and the - flag" seems to be incorrect, 
see the attached patch.

Regards,

r.

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Attachments:

patch.diff (text/x-patch, 398B) download --- doc/src/sgml/func.sgml.orig 2013-09-14 10:02:56.000000000 +0200 +++ doc/src/sgml/func.sgml 2013-09-14 10:03:25.000000000 +0200 @@ -3021,7 +3021,7 @@ <lineannotation>Result: </><computeroutput>|foo |</> SELECT format('|%-*s|', -10, 'foo'); -<lineannotation>Result: </><computeroutput>|foo |</> +<lineannotation>Result: </><computeroutput>| foo|</> </screen> </para>
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: "format" function documentation fix
  2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
@ 2013-09-17 08:49 ` Dean Rasheed <dean.a.rasheed@gmail.com>
  2013-09-17 09:00   ` Re: "format" function documentation fix rudolf <stu3.1@eq.cz>
  0 siblings, 1 reply; 6+ messages in thread

From: Dean Rasheed @ 2013-09-17 08:49 UTC (permalink / raw)
  To: rudolf <stu3.1@eq.cz>; +Cc: pgsql-docs

On 14 September 2013 09:29, rudolf <stu3.1@eq.cz> wrote:
> (Please CC me the reply, since I'm not subscribed to the list.)
>
> Hi,
>
> The last example from
> http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT
> - "examples using width fields and the - flag" seems to be incorrect, see
> the attached patch.
>

No, the example is correct. Referring to the documentation above that:

    If the width argument is negative, the result is left aligned (as
if the - flag had been specified) ...

This applies even if the "-" flag is also specified. So the last
example is meant to illustrate that 2 minuses don't make a plus here.

Regards,
Dean


-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "format" function documentation fix
  2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
  2013-09-17 08:49 ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
@ 2013-09-17 09:00   ` rudolf <stu3.1@eq.cz>
  2013-09-17 10:41     ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
  2013-09-18 19:46     ` Re: "format" function documentation fix Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: rudolf @ 2013-09-17 09:00 UTC (permalink / raw)
  To: Dean Rasheed <dean.a.rasheed@gmail.com>; +Cc: pgsql-docs

(Please CC me the reply, since I'm not subscribed to the list.)

Dean Rasheed wrote:
> On 14 September 2013 09:29, rudolf <stu3.1@eq.cz> wrote:
>> The last example from
>> http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT
>> - "examples using width fields and the - flag" seems to be incorrect, see
>> the attached patch.
>
> No, the example is correct. Referring to the documentation above that:
>
>      If the width argument is negative, the result is left aligned (as
> if the - flag had been specified) ...
>
> This applies even if the "-" flag is also specified. So the last
> example is meant to illustrate that 2 minuses don't make a plus here.

That's very unusual, IMO. This behavior follows some SQL standard or is 
it an invention of PostgreSQL?

Thanks,

r.



-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "format" function documentation fix
  2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
  2013-09-17 08:49 ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
  2013-09-17 09:00   ` Re: "format" function documentation fix rudolf <stu3.1@eq.cz>
@ 2013-09-17 10:41     ` Dean Rasheed <dean.a.rasheed@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2013-09-17 10:41 UTC (permalink / raw)
  To: rudolf <stu3.1@eq.cz>; +Cc: pgsql-docs

On 17 September 2013 10:00, rudolf <stu3.1@eq.cz> wrote:
> (Please CC me the reply, since I'm not subscribed to the list.)
>
> Dean Rasheed wrote:
>>
>> On 14 September 2013 09:29, rudolf <stu3.1@eq.cz> wrote:
>>>
>>> The last example from
>>>
>>> http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT
>>> - "examples using width fields and the - flag" seems to be incorrect, see
>>> the attached patch.
>>
>>
>> No, the example is correct. Referring to the documentation above that:
>>
>>      If the width argument is negative, the result is left aligned (as
>> if the - flag had been specified) ...
>>
>> This applies even if the "-" flag is also specified. So the last
>> example is meant to illustrate that 2 minuses don't make a plus here.
>
>
> That's very unusual, IMO. This behavior follows some SQL standard or is it
> an invention of PostgreSQL?
>

It's not part of the SQL standard, but it is based on C printf() and
friends from the Single UNIX Specification, see for example
http://pubs.opengroup.org/onlinepubs/7908799/xsh/fprintf.html

My reading of that is that "-" is to be treated as a flag, not as a
minus sign, so specifying it multiple times has the same effect as
specifying it once. On my linux box, the following both produce
left-justified output:

  printf("'%-10s'\n", "foo");
  printf("'%--10s'\n", "foo");

Regards,
Dean


-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "format" function documentation fix
  2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
  2013-09-17 08:49 ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
  2013-09-17 09:00   ` Re: "format" function documentation fix rudolf <stu3.1@eq.cz>
@ 2013-09-18 19:46     ` Pavel Stehule <pavel.stehule@gmail.com>
  2013-09-20 08:05       ` Re: "format" function documentation fix rudolf <stu3.1@eq.cz>
  1 sibling, 1 reply; 6+ messages in thread

From: Pavel Stehule @ 2013-09-18 19:46 UTC (permalink / raw)
  To: rudolf <stu3.1@eq.cz>; +Cc: Dean Rasheed <dean.a.rasheed@gmail.com>; pgsql-docs

hello


2013/9/17 rudolf <stu3.1@eq.cz>

> (Please CC me the reply, since I'm not subscribed to the list.)
>
> Dean Rasheed wrote:
>
>> On 14 September 2013 09:29, rudolf <stu3.1@eq.cz> wrote:
>>
>>> The last example from
>>> http://www.postgresql.org/**docs/9.3/static/functions-**
>>> string.html#FUNCTIONS-STRING-**FORMAT<http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT;
>>> - "examples using width fields and the - flag" seems to be incorrect, see
>>> the attached patch.
>>>
>>
>> No, the example is correct. Referring to the documentation above that:
>>
>>      If the width argument is negative, the result is left aligned (as
>> if the - flag had been specified) ...
>>
>> This applies even if the "-" flag is also specified. So the last
>> example is meant to illustrate that 2 minuses don't make a plus here.
>>
>
> That's very unusual, IMO. This behavior follows some SQL standard or is it
> an invention of PostgreSQL?
>
>
this is postgresql feature - standard doesn't support any similar
functionality - and printf is some like developer Esperanto. We
significantly reduced complexity of printf function and we modified basic
rules for usage in SQL, but some very typical rules - like format
placeholders, we share - we don't introduce own rules there.

Regards

Pavel Stehule



> Thanks,
>
> r.
>
>
>
> --
> Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/**mailpref/pgsql-docs<http://www.postgresql.org/mailpref/pgsql-docs;
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "format" function documentation fix
  2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
  2013-09-17 08:49 ` Re: "format" function documentation fix Dean Rasheed <dean.a.rasheed@gmail.com>
  2013-09-17 09:00   ` Re: "format" function documentation fix rudolf <stu3.1@eq.cz>
  2013-09-18 19:46     ` Re: "format" function documentation fix Pavel Stehule <pavel.stehule@gmail.com>
@ 2013-09-20 08:05       ` rudolf <stu3.1@eq.cz>
  0 siblings, 0 replies; 6+ messages in thread

From: rudolf @ 2013-09-20 08:05 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Dean Rasheed <dean.a.rasheed@gmail.com>; pgsql-docs

(Please CC me the reply, since I'm not subscribed to the list.)

Pavel Stehule wrote:
> 2013/9/17 rudolf
>     Dean Rasheed wrote:
[...]
>         This applies even if the "-" flag is also specified. So the last
>         example is meant to illustrate that 2 minuses don't make a plus
>         here.
>
>     That's very unusual, IMO. This behavior follows some SQL standard or
>     is it an invention of PostgreSQL?
>
> this is postgresql feature - standard doesn't support any similar
> functionality - and printf is some like developer Esperanto. We
> significantly reduced complexity of printf function and we modified
> basic rules for usage in SQL, but some very typical rules - like format
> placeholders, we share - we don't introduce own rules there.

Yes, as I already wrote to Dean (and forgot to cc the list), you are 
right, the behavior is correct. Thanks for the explanation!

Kind regards,

r.



-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2013-09-20 08:05 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-09-14 08:29 "format" function documentation fix rudolf <stu3.1@eq.cz>
2013-09-17 08:49 ` Dean Rasheed <dean.a.rasheed@gmail.com>
2013-09-17 09:00   ` rudolf <stu3.1@eq.cz>
2013-09-17 10:41     ` Dean Rasheed <dean.a.rasheed@gmail.com>
2013-09-18 19:46     ` Pavel Stehule <pavel.stehule@gmail.com>
2013-09-20 08:05       ` rudolf <stu3.1@eq.cz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox