aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-09 21:52:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-09 21:52:07 +0000
commit8714d9c56bdf86817d37375fa31ee0aa9de224bf (patch)
tree633a8fa5b51f6a9c2028d2d4d60ee1a49082fbce /src/backend/commands/variable.c
parent56b01dc9ff900a944cd970ea8d65fd3de2361441 (diff)
downloadpostgresql-8714d9c56bdf86817d37375fa31ee0aa9de224bf.tar.gz
postgresql-8714d9c56bdf86817d37375fa31ee0aa9de224bf.zip
Fix assign_datestyle() so that it doesn't misleadingly complain about
'conflicting datestyle specifications' for input that's actually only redundant, such as SET DATESTYLE = MDY, MDY. Per recent gripe.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 3388f314fe3..048a3e41562 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.107 2005/06/05 01:48:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.108 2005/06/09 21:52:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,9 +42,9 @@ assign_datestyle(const char *value, bool doit, GucSource source)
{
int newDateStyle = DateStyle;
int newDateOrder = DateOrder;
+ bool have_style = false;
+ bool have_order = false;
bool ok = true;
- int scnt = 0,
- ocnt = 0;
char *rawstring;
char *result;
List *elemlist;
@@ -74,44 +74,58 @@ assign_datestyle(const char *value, bool doit, GucSource source)
if (pg_strcasecmp(tok, "ISO") == 0)
{
+ if (have_style && newDateStyle != USE_ISO_DATES)
+ ok = false; /* conflicting styles */
newDateStyle = USE_ISO_DATES;
- scnt++;
+ have_style = true;
}
else if (pg_strcasecmp(tok, "SQL") == 0)
{
+ if (have_style && newDateStyle != USE_SQL_DATES)
+ ok = false; /* conflicting styles */
newDateStyle = USE_SQL_DATES;
- scnt++;
+ have_style = true;
}
else if (pg_strncasecmp(tok, "POSTGRES", 8) == 0)
{
+ if (have_style && newDateStyle != USE_POSTGRES_DATES)
+ ok = false; /* conflicting styles */
newDateStyle = USE_POSTGRES_DATES;
- scnt++;
+ have_style = true;
}
else if (pg_strcasecmp(tok, "GERMAN") == 0)
{
+ if (have_style && newDateStyle != USE_GERMAN_DATES)
+ ok = false; /* conflicting styles */
newDateStyle = USE_GERMAN_DATES;
- scnt++;
+ have_style = true;
/* GERMAN also sets DMY, unless explicitly overridden */
- if (ocnt == 0)
+ if (!have_order)
newDateOrder = DATEORDER_DMY;
}
else if (pg_strcasecmp(tok, "YMD") == 0)
{
+ if (have_order && newDateOrder != DATEORDER_YMD)
+ ok = false; /* conflicting orders */
newDateOrder = DATEORDER_YMD;
- ocnt++;
+ have_order = true;
}
else if (pg_strcasecmp(tok, "DMY") == 0 ||
pg_strncasecmp(tok, "EURO", 4) == 0)
{
+ if (have_order && newDateOrder != DATEORDER_DMY)
+ ok = false; /* conflicting orders */
newDateOrder = DATEORDER_DMY;
- ocnt++;
+ have_order = true;
}
else if (pg_strcasecmp(tok, "MDY") == 0 ||
pg_strcasecmp(tok, "US") == 0 ||
pg_strncasecmp(tok, "NONEURO", 7) == 0)
{
+ if (have_order && newDateOrder != DATEORDER_MDY)
+ ok = false; /* conflicting orders */
newDateOrder = DATEORDER_MDY;
- ocnt++;
+ have_order = true;
}
else if (pg_strcasecmp(tok, "DEFAULT") == 0)
{
@@ -128,9 +142,9 @@ assign_datestyle(const char *value, bool doit, GucSource source)
subval = assign_datestyle(GetConfigOptionResetString("datestyle"),
true, source);
- if (scnt == 0)
+ if (!have_style)
newDateStyle = DateStyle;
- if (ocnt == 0)
+ if (!have_order)
newDateOrder = DateOrder;
DateStyle = saveDateStyle;
DateOrder = saveDateOrder;
@@ -155,9 +169,6 @@ assign_datestyle(const char *value, bool doit, GucSource source)
}
}
- if (scnt > 1 || ocnt > 1)
- ok = false;
-
pfree(rawstring);
list_free(elemlist);