Commit ea066f87 authored by Bruce Momjian's avatar Bruce Momjian

Document that "Q" is ignored by to_date and to_timestamp. Add C comment

about the behavior.

Document that quotes in to_date, to_timestamp, to_number skip input
characters.
parent 61d75116
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.506 2010/02/23 16:14:25 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.507 2010/03/03 22:28:42 momjian Exp $ -->
<chapter id="functions"> <chapter id="functions">
<title>Functions and Operators</title> <title>Functions and Operators</title>
...@@ -5089,7 +5089,7 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); ...@@ -5089,7 +5089,7 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
</row> </row>
<row> <row>
<entry><literal>Q</literal></entry> <entry><literal>Q</literal></entry>
<entry>quarter</entry> <entry>quarter (ignored by <function>to_date</> and <function>to_timestamp</>)</entry>
</row> </row>
<row> <row>
<entry><literal>RM</literal></entry> <entry><literal>RM</literal></entry>
...@@ -5209,7 +5209,10 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); ...@@ -5209,7 +5209,10 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
even if it contains pattern key words. For example, in even if it contains pattern key words. For example, in
<literal>'"Hello Year "YYYY'</literal>, the <literal>YYYY</literal> <literal>'"Hello Year "YYYY'</literal>, the <literal>YYYY</literal>
will be replaced by the year data, but the single <literal>Y</literal> in <literal>Year</literal> will be replaced by the year data, but the single <literal>Y</literal> in <literal>Year</literal>
will not be. will not be. In <function>to_date</>, <function>to_number</>,
and <function>to_timestamp</>, double-quoted strings skip the number of
input characters contained in the string, e.g. <literal>"XX"</>
skips two input characters.
</para> </para>
</listitem> </listitem>
......
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.168 2010/02/26 02:01:08 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.169 2010/03/03 22:28:42 momjian Exp $
* *
* *
* Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group
...@@ -2671,10 +2671,12 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) ...@@ -2671,10 +2671,12 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out)
s += SKIP_THth(n->suffix); s += SKIP_THth(n->suffix);
break; break;
case DCH_Q: case DCH_Q:
/* /*
* We ignore Q when converting to date because it is not * We ignore 'Q' when converting to date because it is
* normative. * unclear which date in the quarter to use, and some
* people specify both quarter and month, so if it was
* honored it might conflict with the supplied month.
* That is also why we don't throw an error.
* *
* We still parse the source string for an integer, but it * We still parse the source string for an integer, but it
* isn't stored anywhere in 'out'. * isn't stored anywhere in 'out'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment