Document that "Q" is ignored by to_date and to_timestamp. Add C comment
authorBruce Momjian
Wed, 3 Mar 2010 22:28:42 +0000 (22:28 +0000)
committerBruce Momjian
Wed, 3 Mar 2010 22:28:42 +0000 (22:28 +0000)
about the behavior.

Document that quotes in to_date, to_timestamp, to_number skip input
characters.

doc/src/sgml/func.sgml
src/backend/utils/adt/formatting.c

index 689cd34e93be14ac47a46a784eb3397516566b8d..38350c1bd35a6deaa7513ab9b412d98dd25d36b7 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Functions and Operators
@@ -5089,7 +5089,7 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
        
        
         Q
-        quarter
+        quarter (ignored by to_date and to_timestamp)
        
        
         RM
@@ -5209,7 +5209,10 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
        even if it contains pattern key words.  For example, in
        '"Hello Year "YYYY', the YYYY
        will be replaced by the year data, but the single Y in Year
-       will not be.
+       will not be.  In to_date, to_number,
+       and to_timestamp, double-quoted strings skip the number of
+       input characters contained in the string, e.g. "XX"
+       skips two input characters.
       
      
 
index e7e82a1b14850d55048c9451ac2c849f54ec08dd..cc4f8137db0f4bc8b35472a7c9134c7e718f14c2 100644 (file)
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
  * 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
@@ -2671,10 +2671,12 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out)
                s += SKIP_THth(n->suffix);
                break;
            case DCH_Q:
-
                /*
-                * We ignore Q when converting to date because it is not
-                * normative.
+                * We ignore 'Q' when converting to date because it is
+                * 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
                 * isn't stored anywhere in 'out'.