From b322a3ae53dd66e4384bdafd58f6109c9912de03 Mon Sep 17 00:00:00 2001 From: liang_-123 Date: Tue, 9 Feb 2021 10:40:59 +0800 Subject: [PATCH 1/2] Revert "!604 openGauss support pg_stat_statements" This reverts commit c38e1ded17d6084b9915a25df19dcf17c9d5837e, reversing changes made to 9656124c8e8602f780e6fbdbb9262b6aadf56e9d. --- GNUmakefile.in | 2 - contrib/pg_stat_statements/Makefile | 3 -- .../pg_stat_statements/pg_stat_statements.cpp | 45 ++++++++----------- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index 4ae1aa687..fa55afe49 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -57,7 +57,6 @@ install: $(MAKE) -C contrib/hstore $@ $(MAKE) -C src/distribute/kernel/extension/packages $@ $(MAKE) -C contrib/pagehack $@ - $(MAKE) -C contrib/pg_stat_statements $@ $(MAKE) -C contrib/pg_xlogdump $@ $(MAKE) -C contrib/gsredistribute $@ $(MAKE) -C src/distribute/kernel/extension/dimsearch $@ @@ -71,7 +70,6 @@ install: $(MAKE) install_oracle_fdw $(MAKE) install_pldebugger $(MAKE) -C contrib/postgres_fdw $@ - $(MAKE) -C contrib/pg_stat_statements $@ $(MAKE) -C contrib/hstore $@ $(MAKE) -C src/distribute/kernel/extension/packages $@ $(MAKE) -C contrib/gsredistribute $@ diff --git a/contrib/pg_stat_statements/Makefile b/contrib/pg_stat_statements/Makefile index 6d4631d20..e8aed6121 100644 --- a/contrib/pg_stat_statements/Makefile +++ b/contrib/pg_stat_statements/Makefile @@ -17,6 +17,3 @@ top_builddir = ../.. include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif - -exclude_option=-fPIE -override CPPFLAGS := $(filter-out $(exclude_option),$(CPPFLAGS)) diff --git a/contrib/pg_stat_statements/pg_stat_statements.cpp b/contrib/pg_stat_statements/pg_stat_statements.cpp index 80b43e766..65a08224e 100755 --- a/contrib/pg_stat_statements/pg_stat_statements.cpp +++ b/contrib/pg_stat_statements/pg_stat_statements.cpp @@ -135,7 +135,7 @@ typedef struct pgssEntry { * Global shared state */ typedef struct pgssSharedState { - LWLock* lock; /* protects hashtable search/modification */ + LWLockId lock; /* protects hashtable search/modification */ int query_size; /* max query length in bytes */ double cur_median_usage; /* current median usage in hashtable */ } pgssSharedState; @@ -172,20 +172,20 @@ typedef struct pgssJumbleState { /*---- Local variables ----*/ /* Current nesting depth of ExecutorRun+ProcessUtility calls */ -static THR_LOCAL int nested_level = 0; +static int nested_level = 0; /* Saved hook values in case of unload */ -static THR_LOCAL shmem_startup_hook_type prev_shmem_startup_hook = NULL; -static THR_LOCAL post_parse_analyze_hook_type prev_post_parse_analyze_hook = NULL; -static THR_LOCAL ExecutorStart_hook_type prev_ExecutorStart = NULL; -static THR_LOCAL ExecutorRun_hook_type prev_ExecutorRun = NULL; -static THR_LOCAL ExecutorFinish_hook_type prev_ExecutorFinish = NULL; -static THR_LOCAL ExecutorEnd_hook_type prev_ExecutorEnd = NULL; -static THR_LOCAL ProcessUtility_hook_type prev_ProcessUtility = NULL; +static shmem_startup_hook_type prev_shmem_startup_hook = NULL; +static post_parse_analyze_hook_type prev_post_parse_analyze_hook = NULL; +static ExecutorStart_hook_type prev_ExecutorStart = NULL; +static ExecutorRun_hook_type prev_ExecutorRun = NULL; +static ExecutorFinish_hook_type prev_ExecutorFinish = NULL; +static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; +static ProcessUtility_hook_type prev_ProcessUtility = NULL; /* Links to shared memory state */ -static THR_LOCAL pgssSharedState* pgss = NULL; -static THR_LOCAL HTAB* pgss_hash = NULL; +static pgssSharedState* pgss = NULL; +static HTAB* pgss_hash = NULL; /*---- GUC variables ----*/ @@ -210,8 +210,8 @@ static bool pgss_save; /* whether to save stats across shutdown */ void _PG_init(void); void _PG_fini(void); -extern "C" Datum pg_stat_statements_reset(PG_FUNCTION_ARGS); -extern "C" Datum pg_stat_statements(PG_FUNCTION_ARGS); +Datum pg_stat_statements_reset(PG_FUNCTION_ARGS); +Datum pg_stat_statements(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(pg_stat_statements_reset); PG_FUNCTION_INFO_V1(pg_stat_statements); @@ -260,7 +260,7 @@ void _PG_init(void) * module isn't active. The functions must protect themselves against * being called then, however.) */ - if (!u_sess->misc_cxt.process_shared_preload_libraries_in_progress) + if (!process_shared_preload_libraries_in_progress) return; /* @@ -389,7 +389,7 @@ static void pgss_shmem_startup(void) if (!found) { /* First time through ... */ - pgss->lock = LWLockAssign(LWTRANCHE_BUFFER_CONTENT); + pgss->lock = LWLockAssign(); pgss->query_size = g_instance.attr.attr_common.pgstat_track_activity_query_size; pgss->cur_median_usage = ASSUMED_MEDIAN_INIT; } @@ -456,7 +456,7 @@ static void pgss_shmem_startup(void) buffer_size = temp.query_len + 1; } - if (fread(buffer, 1, temp.query_len, file) != (size_t)temp.query_len) + if (fread(buffer, 1, temp.query_len, file) != temp.query_len) goto error; buffer[temp.query_len] = '\0'; @@ -536,7 +536,7 @@ static void pgss_shmem_shutdown(int code, Datum arg) while ((entry = (pgssEntry*)hash_seq_search(&hash_seq)) != NULL) { int len = entry->query_len; - if (fwrite(entry, offsetof(pgssEntry, mutex), 1, file) != 1 || fwrite(entry->query, 1, len, file) != (size_t)len) + if (fwrite(entry, offsetof(pgssEntry, mutex), 1, file) != 1 || fwrite(entry->query, 1, len, file) != len) goto error; } @@ -748,8 +748,8 @@ static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamL BufferUsage bufusage_start, bufusage; uint32 queryId; - bufusage_start = *(u_sess->instr_cxt.pg_buffer_usage); - INSTR_TIME_SET_CURRENT(start); + bufusage_start = u_sess->instr_cxt.pg_buffer_usage->INSTR_TIME_SET_CURRENT(start); + nested_level++; PG_TRY(); { @@ -1661,12 +1661,6 @@ static void JumbleExpr(pgssJumbleState* jstate, Node* node) JumbleExpr(jstate, (Node*)lfirst(temp)); } break; - case T_IntList: - foreach(temp, (List *) node) - { - APP_JUMB(lfirst_int(temp)); - } - break; case T_SortGroupClause: { SortGroupClause* sgc = (SortGroupClause*)node; @@ -1680,7 +1674,6 @@ static void JumbleExpr(pgssJumbleState* jstate, Node* node) JumbleExpr(jstate, (Node*)gsnode->content); } - break; case T_WindowClause: { WindowClause* wc = (WindowClause*)node; From fcb9ffbce55c1fc3cf1c9300f9c4056b47bb4cc3 Mon Sep 17 00:00:00 2001 From: liang_-123 Date: Tue, 9 Feb 2021 10:41:31 +0800 Subject: [PATCH 2/2] Revert "!609 openGauss supports binary_float" This reverts commit d052061fdfe30c30029fbb560ae2c48aee335500, reversing changes made to c38e1ded17d6084b9915a25df19dcf17c9d5837e. --- src/common/backend/parser/gram.y | 8 +- .../interfaces/libpq/frontend_parser/gram.y | 8 +- src/include/parser/kwlist.h | 1 - src/test/regress/expected/hw_datatype.out | 79 ------------------- src/test/regress/expected/hw_datatype_2.out | 79 ------------------- src/test/regress/sql/hw_datatype.sql | 26 ------ src/test/regress/sql/hw_datatype_2.sql | 26 ------ 7 files changed, 2 insertions(+), 225 deletions(-) diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index edc8c86c3..230feb5e8 100755 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -704,7 +704,7 @@ static void parameter_check_execute_direct(const char* query); AGGREGATE ALGORITHM ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUDIT AUTHID AUTHORIZATION AUTOEXTEND AUTOMAPPED - BACKWARD BARRIER BEFORE BEGIN_NON_ANOYBLOCK BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_FLOAT BINARY_INTEGER BIT BLOB_P BOGUS + BACKWARD BARRIER BEFORE BEGIN_NON_ANOYBLOCK BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_INTEGER BIT BLOB_P BOGUS BOOLEAN_P BOTH BUCKETS BY BYTEAWITHOUTORDER BYTEAWITHOUTORDERWITHEQUAL CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P @@ -16901,11 +16901,6 @@ Numeric: INT_P $$ = SystemTypeName("float8"); $$->location = @1; } - | BINARY_FLOAT - { - $$ = SystemTypeName("float4"); - $$->location = @1; - } | BINARY_INTEGER { $$ = SystemTypeName("int4"); @@ -20449,7 +20444,6 @@ col_name_keyword: BETWEEN | BIGINT | BINARY_DOUBLE - | BINARY_FLOAT | BINARY_INTEGER | BIT | BOOLEAN_P diff --git a/src/common/interfaces/libpq/frontend_parser/gram.y b/src/common/interfaces/libpq/frontend_parser/gram.y index 6f50c9441..d86111b98 100644 --- a/src/common/interfaces/libpq/frontend_parser/gram.y +++ b/src/common/interfaces/libpq/frontend_parser/gram.y @@ -493,7 +493,7 @@ extern THR_LOCAL bool stmt_contains_operator_plus; AGGREGATE ALGORITHM ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APP ARRAY AS ASC ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUDIT AUDIT_POLICY AUTHID AUTHORIZATION AUTOEXTEND AUTOMAPPED - BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_FLOAT BINARY_INTEGER BIT BLOB_P BOGUS + BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BINARY_DOUBLE BINARY_INTEGER BIT BLOB_P BOGUS BOOLEAN_P BOTH BUCKETS BY BYTEAWITHOUTORDER BYTEAWITHOUTORDERWITHEQUAL CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P @@ -7517,11 +7517,6 @@ Numeric: INT_P $$ = SystemTypeName("float8"); $$->location = @1; } - | BINARY_FLOAT - { - $$ = SystemTypeName("float4"); - $$->location = @1; - } | BINARY_INTEGER { $$ = SystemTypeName("int4"); @@ -10908,7 +10903,6 @@ col_name_keyword: BETWEEN | BIGINT | BINARY_DOUBLE - | BINARY_FLOAT | BINARY_INTEGER | BIT | BOOLEAN_P diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index 250a552ef..c2821bc39 100755 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -70,7 +70,6 @@ PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD) PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD) PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("binary_double", BINARY_DOUBLE, COL_NAME_KEYWORD) -PG_KEYWORD("binary_float", BINARY_FLOAT, COL_NAME_KEYWORD) PG_KEYWORD("binary_integer", BINARY_INTEGER, COL_NAME_KEYWORD) PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD) PG_KEYWORD("blob", BLOB_P, UNRESERVED_KEYWORD) diff --git a/src/test/regress/expected/hw_datatype.out b/src/test/regress/expected/hw_datatype.out index dcf31d1bd..21ee5f395 100644 --- a/src/test/regress/expected/hw_datatype.out +++ b/src/test/regress/expected/hw_datatype.out @@ -236,85 +236,6 @@ SELECT * FROM test_type order by 1; 1e+308 (3 rows) -DROP TABLE test_type; -/* f.BINARY_FLOAT type */ -CREATE TABLE test_type( - my_float BINARY_FLOAT - ); -INSERT INTO test_type VALUES (' 0.0'); -INSERT INTO test_type VALUES ('1004.30 '); -INSERT INTO test_type VALUES (' -34.84 '); -INSERT INTO test_type VALUES ('1.2345678901234e+20'); -INSERT INTO test_type VALUES ('1.2345678901234e-20'); --- test for over and under flow -INSERT INTO test_type VALUES ('10e70'); -ERROR: value out of range: overflow -LINE 1: INSERT INTO test_type VALUES ('10e70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('-10e70'); -ERROR: value out of range: overflow -LINE 1: INSERT INTO test_type VALUES ('-10e70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('10e-70'); -ERROR: value out of range: underflow -LINE 1: INSERT INTO test_type VALUES ('10e-70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('-10e-70'); -ERROR: value out of range: underflow -LINE 1: INSERT INTO test_type VALUES ('-10e-70'); - ^ -CONTEXT: referenced column: my_float --- bad input -INSERT INTO test_type VALUES (''); -INSERT INTO test_type VALUES (' '); -ERROR: invalid input syntax for type real: " " -LINE 1: INSERT INTO test_type VALUES (' '); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('xyz'); -ERROR: invalid input syntax for type real: "xyz" -LINE 1: INSERT INTO test_type VALUES ('xyz'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5.0.0'); -ERROR: invalid input syntax for type real: "5.0.0" -LINE 1: INSERT INTO test_type VALUES ('5.0.0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5 . 0'); -ERROR: invalid input syntax for type real: "5 . 0" -LINE 1: INSERT INTO test_type VALUES ('5 . 0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5. 0'); -ERROR: invalid input syntax for type real: "5. 0" -LINE 1: INSERT INTO test_type VALUES ('5. 0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES (' - 3.0'); -ERROR: invalid input syntax for type real: " - 3.0" -LINE 1: INSERT INTO test_type VALUES (' - 3.0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('123 5'); -ERROR: invalid input syntax for type real: "123 5" -LINE 1: INSERT INTO test_type VALUES ('123 5'); - ^ -CONTEXT: referenced column: my_float -SELECT * FROM test_type order by 1; - my_float -------------- - -34.84 - 0 - 1.23457e-20 - 1004.3 - 1.23457e+20 - -(6 rows) - DROP TABLE test_type; /* g.Type BINARY_INTEGER */ CREATE TABLE test_type( diff --git a/src/test/regress/expected/hw_datatype_2.out b/src/test/regress/expected/hw_datatype_2.out index cdf054ea8..1df3c3bf4 100644 --- a/src/test/regress/expected/hw_datatype_2.out +++ b/src/test/regress/expected/hw_datatype_2.out @@ -674,85 +674,6 @@ SELECT * FROM test_type order by 1; 1e+308 (3 rows) -DROP TABLE test_type; -/* f.BINARY_FLOAT type */ -CREATE TABLE test_type( - my_float BINARY_FLOAT - ); -INSERT INTO test_type VALUES (' 0.0'); -INSERT INTO test_type VALUES ('1004.30 '); -INSERT INTO test_type VALUES (' -34.84 '); -INSERT INTO test_type VALUES ('1.2345678901234e+20'); -INSERT INTO test_type VALUES ('1.2345678901234e-20'); --- test for over and under flow -INSERT INTO test_type VALUES ('10e70'); -ERROR: value out of range: overflow -LINE 1: INSERT INTO test_type VALUES ('10e70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('-10e70'); -ERROR: value out of range: overflow -LINE 1: INSERT INTO test_type VALUES ('-10e70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('10e-70'); -ERROR: value out of range: underflow -LINE 1: INSERT INTO test_type VALUES ('10e-70'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('-10e-70'); -ERROR: value out of range: underflow -LINE 1: INSERT INTO test_type VALUES ('-10e-70'); - ^ -CONTEXT: referenced column: my_float --- bad input -INSERT INTO test_type VALUES (''); -INSERT INTO test_type VALUES (' '); -ERROR: invalid input syntax for type real: " " -LINE 1: INSERT INTO test_type VALUES (' '); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('xyz'); -ERROR: invalid input syntax for type real: "xyz" -LINE 1: INSERT INTO test_type VALUES ('xyz'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5.0.0'); -ERROR: invalid input syntax for type real: "5.0.0" -LINE 1: INSERT INTO test_type VALUES ('5.0.0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5 . 0'); -ERROR: invalid input syntax for type real: "5 . 0" -LINE 1: INSERT INTO test_type VALUES ('5 . 0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('5. 0'); -ERROR: invalid input syntax for type real: "5. 0" -LINE 1: INSERT INTO test_type VALUES ('5. 0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES (' - 3.0'); -ERROR: invalid input syntax for type real: " - 3.0" -LINE 1: INSERT INTO test_type VALUES (' - 3.0'); - ^ -CONTEXT: referenced column: my_float -INSERT INTO test_type VALUES ('123 5'); -ERROR: invalid input syntax for type real: "123 5" -LINE 1: INSERT INTO test_type VALUES ('123 5'); - ^ -CONTEXT: referenced column: my_float -SELECT * FROM test_type order by 1; - my_float -------------- - -34.84 - 0 - 1.23457e-20 - 1004.3 - 1.23457e+20 - -(6 rows) - DROP TABLE test_type; /* g.Type BINARY_INTEGER */ CREATE TABLE test_type( diff --git a/src/test/regress/sql/hw_datatype.sql b/src/test/regress/sql/hw_datatype.sql index 76da53965..bc4f770e0 100644 --- a/src/test/regress/sql/hw_datatype.sql +++ b/src/test/regress/sql/hw_datatype.sql @@ -127,32 +127,6 @@ INSERT INTO test_type VALUES(1E+309); SELECT * FROM test_type order by 1; DROP TABLE test_type; -/* f.BINARY_FLOAT type */ -CREATE TABLE test_type( - my_float BINARY_FLOAT - ); -INSERT INTO test_type VALUES (' 0.0'); -INSERT INTO test_type VALUES ('1004.30 '); -INSERT INTO test_type VALUES (' -34.84 '); -INSERT INTO test_type VALUES ('1.2345678901234e+20'); -INSERT INTO test_type VALUES ('1.2345678901234e-20'); --- test for over and under flow -INSERT INTO test_type VALUES ('10e70'); -INSERT INTO test_type VALUES ('-10e70'); -INSERT INTO test_type VALUES ('10e-70'); -INSERT INTO test_type VALUES ('-10e-70'); --- bad input -INSERT INTO test_type VALUES (''); -INSERT INTO test_type VALUES (' '); -INSERT INTO test_type VALUES ('xyz'); -INSERT INTO test_type VALUES ('5.0.0'); -INSERT INTO test_type VALUES ('5 . 0'); -INSERT INTO test_type VALUES ('5. 0'); -INSERT INTO test_type VALUES (' - 3.0'); -INSERT INTO test_type VALUES ('123 5'); -SELECT * FROM test_type order by 1; -DROP TABLE test_type; - /* g.Type BINARY_INTEGER */ CREATE TABLE test_type( my_double BINARY_INTEGER diff --git a/src/test/regress/sql/hw_datatype_2.sql b/src/test/regress/sql/hw_datatype_2.sql index e9fcba21a..de955ecb8 100644 --- a/src/test/regress/sql/hw_datatype_2.sql +++ b/src/test/regress/sql/hw_datatype_2.sql @@ -267,32 +267,6 @@ INSERT INTO test_type VALUES(1E+309); SELECT * FROM test_type order by 1; DROP TABLE test_type; -/* f.BINARY_FLOAT type */ -CREATE TABLE test_type( - my_float BINARY_FLOAT - ); -INSERT INTO test_type VALUES (' 0.0'); -INSERT INTO test_type VALUES ('1004.30 '); -INSERT INTO test_type VALUES (' -34.84 '); -INSERT INTO test_type VALUES ('1.2345678901234e+20'); -INSERT INTO test_type VALUES ('1.2345678901234e-20'); --- test for over and under flow -INSERT INTO test_type VALUES ('10e70'); -INSERT INTO test_type VALUES ('-10e70'); -INSERT INTO test_type VALUES ('10e-70'); -INSERT INTO test_type VALUES ('-10e-70'); --- bad input -INSERT INTO test_type VALUES (''); -INSERT INTO test_type VALUES (' '); -INSERT INTO test_type VALUES ('xyz'); -INSERT INTO test_type VALUES ('5.0.0'); -INSERT INTO test_type VALUES ('5 . 0'); -INSERT INTO test_type VALUES ('5. 0'); -INSERT INTO test_type VALUES (' - 3.0'); -INSERT INTO test_type VALUES ('123 5'); -SELECT * FROM test_type order by 1; -DROP TABLE test_type; - /* g.Type BINARY_INTEGER */ CREATE TABLE test_type( my_double BINARY_INTEGER