summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index f9aa968f098..b91ff7bb803 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1381,10 +1381,12 @@ parse_format(FormatNode *node, const char *str, const KeyWord *kw,
{
int chlen;
- if (flags & STD_FLAG)
+ if ((flags & STD_FLAG) && *str != '"')
{
/*
- * Standard mode, allow only following separators: "-./,':; "
+ * Standard mode, allow only following separators: "-./,':; ".
+ * However, we support double quotes even in standard mode
+ * (see below). This is our extension of standard mode.
*/
if (strchr("-./,':; ", *str) == NULL)
ereport(ERROR,
@@ -3346,7 +3348,19 @@ DCH_from_char(FormatNode *node, const char *in, TmFromChar *out,
}
else
{
- s += pg_mblen(s);
+ int chlen = pg_mblen(s);
+
+ /*
+ * Standard mode requires strict match of format characters.
+ */
+ if (std && n->type == NODE_TYPE_CHAR &&
+ strncmp(s, n->character, chlen) != 0)
+ RETURN_ERROR(ereport(ERROR,
+ (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
+ errmsg("unmatched format character \"%s\"",
+ n->character))));
+
+ s += chlen;
}
continue;
}