From d4b2de9e265cbdc2176148214deffc044147fb2d Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Sat, 4 Oct 2025 23:58:12 +0500 Subject: [PATCH] Align DateStyle parsing with PostgreSQL Updated PgSQL_DateStyle_Util::parse_datestyle() to support prefix-based matching for known tokens (POSTGRES, EURO, NONEURO). This allows variants like "PostgreSQL", "European", to be recognized as valid inputs. --- lib/PgSQL_Session.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PgSQL_Session.cpp b/lib/PgSQL_Session.cpp index 4392a193a..f416a2820 100644 --- a/lib/PgSQL_Session.cpp +++ b/lib/PgSQL_Session.cpp @@ -6613,7 +6613,7 @@ PgSQL_DateStyle_t PgSQL_DateStyle_Util::parse_datestyle(std::string_view input) newDateStyle = DATESTYLE_FORMAT_SQL; have_style = true; } - else if (strcasecmp(tok, "POSTGRES") == 0) { + else if (strncasecmp(tok, "POSTGRES", sizeof("POSTGRES") - 1) == 0) { if (have_style && newDateStyle != DATESTYLE_FORMAT_POSTGRES) ok = false; /* conflicting styles */ newDateStyle = DATESTYLE_FORMAT_POSTGRES; @@ -6634,8 +6634,8 @@ PgSQL_DateStyle_t PgSQL_DateStyle_Util::parse_datestyle(std::string_view input) newDateOrder = DATESTYLE_ORDER_YMD; have_order = true; } - else if (strcasecmp(tok, "DMY") == 0 || - strcasecmp(tok, "EURO") == 0) { + else if (strcasecmp(tok, "DMY") == 0 || + strncasecmp(tok, "EURO", sizeof("EURO") - 1) == 0) { if (have_order && newDateOrder != DATESTYLE_ORDER_DMY) ok = false; /* conflicting orders */ newDateOrder = DATESTYLE_ORDER_DMY; @@ -6643,7 +6643,7 @@ PgSQL_DateStyle_t PgSQL_DateStyle_Util::parse_datestyle(std::string_view input) } else if (strcasecmp(tok, "MDY") == 0 || strcasecmp(tok, "US") == 0 || - strcasecmp(tok, "NONEURO") == 0) { + strncasecmp(tok, "NONEURO", sizeof("NONEURO") - 1) == 0) { if (have_order && newDateOrder != DATESTYLE_ORDER_MDY) ok = false; /* conflicting orders */ newDateOrder = DATESTYLE_ORDER_MDY;