"format" function documentation fix

Started by rudolfover 12 years ago6 messagesdocs
Jump to latest
#1rudolf
stu3.1@eq.cz

(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.

Attachments:

patch.difftext/x-patch; name=patch.diffDownload+1-1
#2Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: rudolf (#1)
Re: "format" function documentation fix

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

#3rudolf
stu3.1@eq.cz
In reply to: Dean Rasheed (#2)
Re: "format" function documentation fix

(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

#4Dean Rasheed
dean.a.rasheed@gmail.com
In reply to: rudolf (#3)
Re: "format" function documentation fix

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

#5Pavel Stehule
pavel.stehule@gmail.com
In reply to: rudolf (#3)
Re: "format" function documentation fix

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&gt;
- "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

Show quoted text

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&lt;http://www.postgresql.org/mailpref/pgsql-docs&gt;

#6rudolf
stu3.1@eq.cz
In reply to: Pavel Stehule (#5)
Re: "format" function documentation fix

(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