From 23131a52cdbb23b04a184eefe3383087d305df91 Mon Sep 17 00:00:00 2001 From: Sait Talha Nisanci Date: Wed, 25 Aug 2021 17:17:16 +0300 Subject: [PATCH] Fix style --- .circleci/config.yml | 2 +- .../deparser/deparse_statistics_stmts.c | 5 +++ .../distributed/deparser/ruleutils_14.c | 6 +-- .../distributed/planner/multi_explain.c | 3 +- .../planner/multi_router_planner.c | 43 +++++++++++-------- .../udfs/citus_prepare_pg_upgrade/10.2-1.sql | 6 +-- .../udfs/citus_prepare_pg_upgrade/latest.sql | 6 +-- src/backend/distributed/utils/listutils.c | 3 +- .../distributed/commands/utility_hook.h | 2 +- src/test/regress/bin/normalize.sed | 2 +- src/test/regress/expected/multi_extension.out | 2 +- .../expected/upgrade_list_citus_objects.out | 2 +- .../expected/upgrade_list_citus_objects_0.out | 2 +- src/test/regress/sql/data_types.sql | 2 +- src/test/regress/sql/partition_wise_join.sql | 2 +- src/test/regress/sql/pg13.sql | 2 +- .../sql/propagate_extension_commands.sql | 6 +-- 17 files changed, 56 insertions(+), 40 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8af0eea8a..cbf965d32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -447,7 +447,7 @@ workflows: - build: name: build-14 pg_major: 14 - image_tag: '14beta3-dev202108191715' + image_tag: '14beta3-dev202108191715' - check-style - check-sql-snapshots diff --git a/src/backend/distributed/deparser/deparse_statistics_stmts.c b/src/backend/distributed/deparser/deparse_statistics_stmts.c index 049b0d5a3..a40150c6e 100644 --- a/src/backend/distributed/deparser/deparse_statistics_stmts.c +++ b/src/backend/distributed/deparser/deparse_statistics_stmts.c @@ -233,6 +233,7 @@ AppendStatTypes(StringInfo buf, CreateStatsStmt *stmt) appendStringInfoString(buf, ")"); } + #if PG_VERSION_NUM >= PG_VERSION_14 static void AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt) @@ -251,6 +252,8 @@ AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt) } } } + + #else static void AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt) @@ -277,6 +280,8 @@ AppendColumnNames(StringInfo buf, CreateStatsStmt *stmt) } } } + + #endif static void diff --git a/src/backend/distributed/deparser/ruleutils_14.c b/src/backend/distributed/deparser/ruleutils_14.c index 7d8213155..aa1fffe94 100644 --- a/src/backend/distributed/deparser/ruleutils_14.c +++ b/src/backend/distributed/deparser/ruleutils_14.c @@ -2060,7 +2060,7 @@ get_with_clause(Query *query, deparse_context *context) if (PRETTY_INDENT(context)) appendContextKeyword(context, "", 0, 0, 0); appendStringInfoChar(buf, ')'); - + if (cte->search_clause) { bool first = true; @@ -2100,7 +2100,7 @@ get_with_clause(Query *query, deparse_context *context) } appendStringInfo(buf, " SET %s", quote_identifier(cte->cycle_clause->cycle_mark_column)); - + { Const *cmv = castNode(Const, cte->cycle_clause->cycle_mark_value); Const *cmd = castNode(Const, cte->cycle_clause->cycle_mark_default); @@ -7771,7 +7771,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) appendStringInfoString(buf, quote_identifier(colname)); } appendStringInfoChar(buf, ')'); - + if (j->join_using_alias) appendStringInfo(buf, " AS %s", quote_identifier(j->join_using_alias->aliasname)); diff --git a/src/backend/distributed/planner/multi_explain.c b/src/backend/distributed/planner/multi_explain.c index a3bd6b0aa..7fdb6d8e7 100644 --- a/src/backend/distributed/planner/multi_explain.c +++ b/src/backend/distributed/planner/multi_explain.c @@ -286,9 +286,10 @@ ExplainSubPlans(DistributedPlan *distributedPlan, ExplainState *es) PlannedStmt *plan = subPlan->plan; IntoClause *into = NULL; ParamListInfo params = NULL; + /* * With PG14, we need to provide a string here, - * for now we put an empty string, which is valid according to postgres. + * for now we put an empty string, which is valid according to postgres. */ char *queryString = pstrdup(""); instr_time planduration; diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index 1d8361360..30713c2e7 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -643,22 +643,27 @@ ModifyPartialQuerySupported(Query *queryTree, bool multiShardQuery, } else { - if (commandType == CMD_UPDATE) { + if (commandType == CMD_UPDATE) + { /* - * For + * For */ - RangeTblEntry* resultRTE = ExtractResultRelationRTE(queryTree); + RangeTblEntry *resultRTE = ExtractResultRelationRTE(queryTree); + /* * FirstLowInvalidHeapAttributeNumber is added as an offset to rte->updatedCols. * So we substract that to get the column no for an updated column that matches * resultRTE->updatedcols. */ - int updatedColNoWithOffset = partitionColumn->varattno - FirstLowInvalidHeapAttributeNumber; - if (bms_is_member(updatedColNoWithOffset, resultRTE->updatedCols)) { + int updatedColNoWithOffset = partitionColumn->varattno - + FirstLowInvalidHeapAttributeNumber; + if (bms_is_member(updatedColNoWithOffset, resultRTE->updatedCols)) + { targetEntryPartitionColumn = true; } - - }else if (targetEntry->resno == partitionColumn->varattno) { + } + else if (targetEntry->resno == partitionColumn->varattno) + { targetEntryPartitionColumn = true; } } @@ -679,8 +684,8 @@ ModifyPartialQuerySupported(Query *queryTree, bool multiShardQuery, NULL, NULL); } - //TODO:: targetEntry->resno is wrong here, we SHOULD think about - //TargetEntryChangesValue for update case based on 86dc90056dfdbd9d1b891718d2e5614e3e432f35. + /*TODO:: targetEntry->resno is wrong here, we SHOULD think about */ + /*TargetEntryChangesValue for update case based on 86dc90056dfdbd9d1b891718d2e5614e3e432f35. */ if (commandType == CMD_UPDATE && targetEntryPartitionColumn && TargetEntryChangesValue(targetEntry, partitionColumn, queryTree->jointree)) @@ -1137,15 +1142,19 @@ ErrorIfOnConflictNotSupported(Query *queryTree) bool setTargetEntryPartitionColumn = false; - if (partitionColumn) { - RangeTblEntry* resultRTE = ExtractResultRelationRTE(queryTree); + if (partitionColumn) + { + RangeTblEntry *resultRTE = ExtractResultRelationRTE(queryTree); + /* - * FirstLowInvalidHeapAttributeNumber is added as an offset to rte->updatedCols. - * So we substract that to get the column no for an updated column that matches - * resultRTE->updatedcols. - */ - int updatedColNoWithOffset = partitionColumn->varattno - FirstLowInvalidHeapAttributeNumber; - if (bms_is_member(updatedColNoWithOffset, resultRTE->updatedCols)) { + * FirstLowInvalidHeapAttributeNumber is added as an offset to rte->updatedCols. + * So we substract that to get the column no for an updated column that matches + * resultRTE->updatedcols. + */ + int updatedColNoWithOffset = partitionColumn->varattno - + FirstLowInvalidHeapAttributeNumber; + if (bms_is_member(updatedColNoWithOffset, resultRTE->updatedCols)) + { setTargetEntryPartitionColumn = true; } } diff --git a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/10.2-1.sql b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/10.2-1.sql index 8b5e13bc0..48a54289f 100644 --- a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/10.2-1.sql +++ b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/10.2-1.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_prepare_pg_upgrade() AS $cppu$ BEGIN - DELETE FROM pg_depend WHERE - objid IN (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') AND + DELETE FROM pg_depend WHERE + objid IN (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') AND refobjid IN (select oid from pg_extension where extname = 'citus'); /* * We are dropping the aggregates because postgres 14 changed @@ -14,7 +14,7 @@ BEGIN * upgrading to pg14, spegifically when running pg_restore on * array_cat_agg we would get an error. So we drop the aggregate * and create the right one on citus_finish_pg_upgrade. - */ + */ DROP AGGREGATE IF EXISTS array_cat_agg(anyarray); DROP AGGREGATE IF EXISTS array_cat_agg(anycompatiblearray); -- diff --git a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql index 8b5e13bc0..48a54289f 100644 --- a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_prepare_pg_upgrade() AS $cppu$ BEGIN - DELETE FROM pg_depend WHERE - objid IN (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') AND + DELETE FROM pg_depend WHERE + objid IN (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') AND refobjid IN (select oid from pg_extension where extname = 'citus'); /* * We are dropping the aggregates because postgres 14 changed @@ -14,7 +14,7 @@ BEGIN * upgrading to pg14, spegifically when running pg_restore on * array_cat_agg we would get an error. So we drop the aggregate * and create the right one on citus_finish_pg_upgrade. - */ + */ DROP AGGREGATE IF EXISTS array_cat_agg(anyarray); DROP AGGREGATE IF EXISTS array_cat_agg(anycompatiblearray); -- diff --git a/src/backend/distributed/utils/listutils.c b/src/backend/distributed/utils/listutils.c index 53bfcdd2b..232837c23 100644 --- a/src/backend/distributed/utils/listutils.c +++ b/src/backend/distributed/utils/listutils.c @@ -140,7 +140,8 @@ ListToHashSet(List *itemList, Size keySize, bool isStringList) flags |= HASH_BLOBS; } #if PG_VERSION_NUM >= PG_VERSION_14 - else { + else + { flags |= HASH_STRINGS; } #endif diff --git a/src/include/distributed/commands/utility_hook.h b/src/include/distributed/commands/utility_hook.h index 22f8a8cf1..7845fb051 100644 --- a/src/include/distributed/commands/utility_hook.h +++ b/src/include/distributed/commands/utility_hook.h @@ -63,7 +63,7 @@ typedef struct DDLJob } DDLJob; -extern void multi_ProcessUtility(PlannedStmt *pstmt, const char *queryString, +extern void multi_ProcessUtility(PlannedStmt * pstmt, const char *queryString, #if PG_VERSION_NUM >= PG_VERSION_14 bool readOnlyTree, #endif diff --git a/src/test/regress/bin/normalize.sed b/src/test/regress/bin/normalize.sed index da49d573f..b9e1a5ad5 100644 --- a/src/test/regress/bin/normalize.sed +++ b/src/test/regress/bin/normalize.sed @@ -241,4 +241,4 @@ s/ERROR: ROLLBACK is not allowed in an SQL function/ERROR: ROLLBACK is not all /Parent-Relationship/d s/function array_cat_agg\(anyarray\) anyarray/function array_cat_agg\(anycompatiblearray\) anycompatiblearray/g s/TRIM\(BOTH FROM value\)/btrim\(value\)/g -s/function array_cat_agg\(anycompatiblearray\)/function array_cat_agg\(anyarray\)/g \ No newline at end of file +s/function array_cat_agg\(anycompatiblearray\)/function array_cat_agg\(anyarray\)/g diff --git a/src/test/regress/expected/multi_extension.out b/src/test/regress/expected/multi_extension.out index 3e8249bc7..48737aa91 100644 --- a/src/test/regress/expected/multi_extension.out +++ b/src/test/regress/expected/multi_extension.out @@ -139,7 +139,7 @@ SELECT * FROM multi_extension.print_extension_changes(); | function alter_role_if_exists(text,text) boolean | function any_value(anyelement) anyelement | function any_value_agg(anyelement,anyelement) anyelement - | function array_cat_agg(anycompatiblearray) anycompatiblearray + | function array_cat_agg(anyarray) anycompatiblearray | function assign_distributed_transaction_id(integer,bigint,timestamp with time zone) void | function authinfo_valid(text) boolean | function broadcast_intermediate_result(text,text) bigint diff --git a/src/test/regress/expected/upgrade_list_citus_objects.out b/src/test/regress/expected/upgrade_list_citus_objects.out index 03a48fb73..6ee6a3084 100644 --- a/src/test/regress/expected/upgrade_list_citus_objects.out +++ b/src/test/regress/expected/upgrade_list_citus_objects.out @@ -26,7 +26,7 @@ ORDER BY 1; function alter_table_set_access_method(regclass,text) function any_value(anyelement) function any_value_agg(anyelement,anyelement) - function array_cat_agg(anycompatiblearray) + function array_cat_agg(anyarray) function assign_distributed_transaction_id(integer,bigint,timestamp with time zone) function authinfo_valid(text) function broadcast_intermediate_result(text,text) diff --git a/src/test/regress/expected/upgrade_list_citus_objects_0.out b/src/test/regress/expected/upgrade_list_citus_objects_0.out index fc2db7cd7..045b538f2 100644 --- a/src/test/regress/expected/upgrade_list_citus_objects_0.out +++ b/src/test/regress/expected/upgrade_list_citus_objects_0.out @@ -23,7 +23,7 @@ ORDER BY 1; function alter_table_set_access_method(regclass,text) function any_value(anyelement) function any_value_agg(anyelement,anyelement) - function array_cat_agg(anycompatiblearray) + function array_cat_agg(anyarray) function assign_distributed_transaction_id(integer,bigint,timestamp with time zone) function authinfo_valid(text) function broadcast_intermediate_result(text,text) diff --git a/src/test/regress/sql/data_types.sql b/src/test/regress/sql/data_types.sql index 5f9651567..ce286feca 100644 --- a/src/test/regress/sql/data_types.sql +++ b/src/test/regress/sql/data_types.sql @@ -101,7 +101,7 @@ FROM -- DISTINCT w/wout distribution key -- there seems to be an issue with SELECT DISTINCT ROW with PG14 -- so we add an alternative output that gives an error, this should --- be removed after the issue is fixed on PG14. +-- be removed after the issue is fixed on PG14. SELECT DISTINCT(col1, col2, col3, col4, col5, col6, col70, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17, col18, col19, col20, col21, col22, col23, col24, col25, col26, col27, col28, col29, col32, col33, col34, col35, col36, col37, col38) FROM data_types_table diff --git a/src/test/regress/sql/partition_wise_join.sql b/src/test/regress/sql/partition_wise_join.sql index 0e91240e3..2b0610ec3 100644 --- a/src/test/regress/sql/partition_wise_join.sql +++ b/src/test/regress/sql/partition_wise_join.sql @@ -60,4 +60,4 @@ SELECT success FROM run_command_on_workers('select pg_reload_conf()'); RESET enable_partitionwise_join; -DROP SCHEMA partition_wise_join CASCADE; \ No newline at end of file +DROP SCHEMA partition_wise_join CASCADE; diff --git a/src/test/regress/sql/pg13.sql b/src/test/regress/sql/pg13.sql index 00c94a605..4145acf77 100644 --- a/src/test/regress/sql/pg13.sql +++ b/src/test/regress/sql/pg13.sql @@ -114,7 +114,7 @@ INSERT INTO test_wal VALUES(3,33),(4,44),(5,55) RETURNING *; -- this test has different output for pg14 and here we mostly test that -- we don't get an error, hence we use explain_has_distributed_subplan. SELECT public.explain_has_distributed_subplan( -$$ +$$ EXPLAIN (ANALYZE TRUE, WAL TRUE, COSTS FALSE, SUMMARY FALSE, BUFFERS FALSE, TIMING FALSE) WITH cte_1 AS (INSERT INTO test_wal VALUES(6,66),(7,77),(8,88) RETURNING *) SELECT * FROM cte_1; diff --git a/src/test/regress/sql/propagate_extension_commands.sql b/src/test/regress/sql/propagate_extension_commands.sql index 0ba17e293..500dc00b8 100644 --- a/src/test/regress/sql/propagate_extension_commands.sql +++ b/src/test/regress/sql/propagate_extension_commands.sql @@ -98,7 +98,7 @@ CREATE EXTENSION seg; -- show that the extension is created on existing worker SELECT run_command_on_workers($$SELECT count(extnamespace) FROM pg_extension WHERE extname = 'seg'$$); -SELECT workers.result = pg_extension.extversion AS same_version +SELECT workers.result = pg_extension.extversion AS same_version FROM run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extname = 'seg'$$) workers, pg_extension WHERE extname = 'seg'; -- now create the reference table @@ -145,7 +145,7 @@ SELECT 1 from master_add_node('localhost', :worker_2_port); -- show that the extension is created on both existing and new node SELECT run_command_on_workers($$SELECT count(extnamespace) FROM pg_extension WHERE extname = 'seg'$$); -SELECT workers.result = pg_extension.extversion AS same_version +SELECT workers.result = pg_extension.extversion AS same_version FROM run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extname = 'seg'$$) workers, pg_extension WHERE extname = 'seg'; -- check for the unpackaged extension to be created correctly @@ -212,7 +212,7 @@ ROLLBACK; -- show that the CREATE EXTENSION command propagated even if the transaction -- block is rollbacked, that's a shortcoming of dependency creation logic -SELECT COUNT(DISTINCT workers.result) +SELECT COUNT(DISTINCT workers.result) FROM run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extname = 'seg'$$) workers; -- drop the schema and all the objects