summaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorTom Lane2005-06-09 21:52:07 +0000
committerTom Lane2005-06-09 21:52:07 +0000
commit1e42499ccddf68651a5d7af8640d1dcc9b961780 (patch)
treee737990c8806866fa55ca9cd64cb063076bd0979 /src/backend/commands/variable.c
parentcd03fed686999fbf3b43841dfbe279bfa238b488 (diff)
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.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index ff100afdc0..c579ce03b5 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -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);