diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index aa18064a9a509049a97751eef936b1de28d1b252..7eb91b8f5fabb18b1ea16f7bc24ad9014310bcef 100644 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -32097,6 +32097,8 @@ unreserved_keyword: | TIES | TIMESTAMP_FORMAT_P | TIME_FORMAT_P + | TIMEZONE_HOUR_P + | TIMEZONE_MINUTE_P | TRANSACTION | TRANSFORM | TRIGGER diff --git a/src/common/interfaces/libpq/frontend_parser/gram.y b/src/common/interfaces/libpq/frontend_parser/gram.y index 773a4c7f9e478a5054e83af1669bb993eea97f38..0273ec1b86618192ff393c4b566d4c9c8b35f896 100755 --- a/src/common/interfaces/libpq/frontend_parser/gram.y +++ b/src/common/interfaces/libpq/frontend_parser/gram.y @@ -12201,6 +12201,8 @@ unreserved_keyword: | TIES | TIME_FORMAT_P | TIMESTAMP_FORMAT_P + | TIMEZONE_HOUR_P + | TIMEZONE_MINUTE_P | TRANSACTION | TRANSFORM | TRIGGER diff --git a/src/test/regress/expected/hw_to_timestamp.out b/src/test/regress/expected/hw_to_timestamp.out index e837016fe2f9fbff95505bac81342e4196ea0e68..e866aebdaa12458f032f725901ffd0cc8f4ea613 100644 --- a/src/test/regress/expected/hw_to_timestamp.out +++ b/src/test/regress/expected/hw_to_timestamp.out @@ -1261,6 +1261,15 @@ ERROR: invalid input syntax for type interval: "invalid_timestamp" LINE 1: SELECT EXTRACT(TIMEZONE_ABBR FROM 'invalid_timestamp'); ^ CONTEXT: referenced column: timezone_extract +-- 测试TIMEZONE_XXX作为列名 +DROP TABLE IF EXISTS timezone_as_colname; +NOTICE: table "timezone_as_colname" does not exist, skipping +CREATE TABLE timezone_as_colname ( + timezone_hour text, + timezone_minute text, + timezone_region text, + timezone_abbr text +); SET TIMEZONE TO '-8:30'; SELECT EXTRACT(TIMEZONE_ABBR FROM TIMESTAMP WITH TIME ZONE '2024-09-02 10:30:00+320'); timezone_extract diff --git a/src/test/regress/sql/hw_to_timestamp.sql b/src/test/regress/sql/hw_to_timestamp.sql index 6d4f2865b6f12136c81a3c68f649d5d62c4f0f66..e96d6b35e95bef2664fefff3cf207a949740adcb 100644 --- a/src/test/regress/sql/hw_to_timestamp.sql +++ b/src/test/regress/sql/hw_to_timestamp.sql @@ -329,5 +329,14 @@ SELECT EXTRACT(TIMEZONE_MINUTE FROM 'invalid_timestamp'); SELECT EXTRACT(TIMEZONE_REGION FROM 'invalid_timestamp'); SELECT EXTRACT(TIMEZONE_ABBR FROM 'invalid_timestamp'); +-- 测试TIMEZONE_XXX作为列名 +DROP TABLE IF EXISTS timezone_as_colname; +CREATE TABLE timezone_as_colname ( + timezone_hour text, + timezone_minute text, + timezone_region text, + timezone_abbr text +); + SET TIMEZONE TO '-8:30'; SELECT EXTRACT(TIMEZONE_ABBR FROM TIMESTAMP WITH TIME ZONE '2024-09-02 10:30:00+320'); \ No newline at end of file