Skip to content

Commit ea066f8

Browse files
committed
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.
1 parent 61d7511 commit ea066f8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/src/sgml/func.sgml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.506 2010/02/23 16:14:25 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.507 2010/03/03 22:28:42 momjian Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -5089,7 +5089,7 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
50895089
</row>
50905090
<row>
50915091
<entry><literal>Q</literal></entry>
5092-
<entry>quarter</entry>
5092+
<entry>quarter (ignored by <function>to_date</> and <function>to_timestamp</>)</entry>
50935093
</row>
50945094
<row>
50955095
<entry><literal>RM</literal></entry>
@@ -5209,7 +5209,10 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
52095209
even if it contains pattern key words. For example, in
52105210
<literal>'"Hello Year "YYYY'</literal>, the <literal>YYYY</literal>
52115211
will be replaced by the year data, but the single <literal>Y</literal> in <literal>Year</literal>
5212-
will not be.
5212+
will not be. In <function>to_date</>, <function>to_number</>,
5213+
and <function>to_timestamp</>, double-quoted strings skip the number of
5214+
input characters contained in the string, e.g. <literal>"XX"</>
5215+
skips two input characters.
52135216
</para>
52145217
</listitem>
52155218

src/backend/utils/adt/formatting.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.168 2010/02/26 02:01:08 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.169 2010/03/03 22:28:42 momjian Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2010, PostgreSQL Global Development Group
@@ -2671,10 +2671,12 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out)
26712671
s += SKIP_THth(n->suffix);
26722672
break;
26732673
case DCH_Q:
2674-
26752674
/*
2676-
* We ignore Q when converting to date because it is not
2677-
* normative.
2675+
* We ignore 'Q' when converting to date because it is
2676+
* unclear which date in the quarter to use, and some
2677+
* people specify both quarter and month, so if it was
2678+
* honored it might conflict with the supplied month.
2679+
* That is also why we don't throw an error.
26782680
*
26792681
* We still parse the source string for an integer, but it
26802682
* isn't stored anywhere in 'out'.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy