Skip to content

Commit

Permalink
Strip trailing whitespace and add final newline (citusdata#3186)
Browse files Browse the repository at this point in the history
This brings files in line with our editorconfig file
  • Loading branch information
serprex authored and JelteF committed Nov 21, 2019
1 parent 1d8dde2 commit c563e08
Show file tree
Hide file tree
Showing 274 changed files with 6,482 additions and 6,638 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
- run:
name: 'Check Style'
command: citus_indent --check
- run:
name: 'Fix whitespace'
command: ci/editorconfig.sh
- run:
name: 'Check if whitespace fixing changed anything, install editorconfig if it did'
command: git diff --exit-code
- run:
name: 'Remove useless declarations'
command: ci/remove_useless_declarations.sh
Expand Down
12 changes: 9 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

# Don't change test output files
[*.out]
# Don't change test output files, pngs or test data files
[*.{out,png,data}]
insert_final_newline = unset
trim_trailing_whitespace = unset

[*.sql]
# Don't change test/regress/output directory, this needs to be a separate rule
# for some reason
[/src/test/regress/output/**]
insert_final_newline = unset
trim_trailing_whitespace = unset

[*.sql,*.sh]
indent_style = space
indent_size = 4
tab_width = 4
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -658,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
16 changes: 16 additions & 0 deletions ci/editorconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -eu
for f in $(git ls-tree -r HEAD --name-only); do
if [ "$f" = "${f%.out}" ] &&
[ "$f" = "${f%.data}" ] &&
[ "$f" = "${f%.png}" ] &&
[ "$(dirname "$f")" != "src/test/regress/output" ]
then
# Trim trailing whitespace
sed -e 's/[[:space:]]*$//' -i "./$f"
# Add final newline if not there
if [ -n "$(tail -c1 "$f")" ]; then
echo >> "$f"
fi
fi
done
4 changes: 2 additions & 2 deletions src/backend/distributed/planner/planner_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If the input query is trivial (e.g., no joins, no subqueries/ctes, single table

Distributed planning (`CreateDistributedPlan`) tries several different methods to plan the query:


1. Fast-path router planner, proceed if the query prunes down to a single shard of a single table
2. Router planner, proceed if the query prunes down to a single set of co-located shards
3. Modification planning, proceed if the query is a DML command and all joins are co-located
Expand All @@ -15,7 +15,7 @@ Distributed planning (`CreateDistributedPlan`) tries several different methods t

## Fast-path router planner

By examining the query tree, if we can decide that the query hits only a single shard of a single table, we can skip calling `standard_planner()`. Later on the execution, we simply fetch the filter on the distribution key and do the pruning.
By examining the query tree, if we can decide that the query hits only a single shard of a single table, we can skip calling `standard_planner()`. Later on the execution, we simply fetch the filter on the distribution key and do the pruning.

As the name reveals, this can be considered as a sub-item of Router planner described below. The only difference is that fast-path planner doesn't rely on `standard_planner()` for collecting restriction information.

Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.0-1--7.0-2.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- citus--7.0-1--7.0-2.sql
-- citus--7.0-1--7.0-2.sql

-- redefine shard_name as STRICT
-- redefine shard_name as STRICT
CREATE OR REPLACE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint)
RETURNS text
LANGUAGE C STABLE STRICT
Expand Down
10 changes: 5 additions & 5 deletions src/backend/distributed/sql/citus--7.0-10--7.0-11.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus-7.0-10--7.0-11
-- citus-7.0-10--7.0-11

SET search_path = 'pg_catalog';

Expand All @@ -8,9 +8,9 @@ DECLARE
colocated_tables regclass[];
BEGIN
SELECT get_colocated_table_array(relation) INTO colocated_tables;
PERFORM
master_update_shard_statistics(shardid)

PERFORM
master_update_shard_statistics(shardid)
FROM
pg_dist_shard
WHERE
Expand All @@ -19,7 +19,7 @@ END;
$$ LANGUAGE 'plpgsql';
COMMENT ON FUNCTION master_update_table_statistics(regclass)
IS 'updates shard statistics of the given table and its colocated tables';

CREATE OR REPLACE FUNCTION get_colocated_shard_array(bigint)
RETURNS BIGINT[]
LANGUAGE C STRICT
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-11--7.0-12.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-11--7.0-12.sql
-- citus--7.0-11--7.0-12.sql

CREATE OR REPLACE FUNCTION pg_catalog.citus_create_restore_point(text)
RETURNS pg_lsn
Expand Down
10 changes: 5 additions & 5 deletions src/backend/distributed/sql/citus--7.0-12--7.0-13.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-12--7.0-13.sql
-- citus--7.0-12--7.0-13.sql

SET search_path = 'pg_catalog';

Expand All @@ -18,7 +18,7 @@ BEGIN
SELECT array_agg(object_identity) INTO sequence_names
FROM pg_event_trigger_dropped_objects()
WHERE object_type = 'sequence';

FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects() JOIN
pg_dist_partition ON (logicalrelid = objid)
WHERE object_type IN ('table', 'foreign table')
Expand All @@ -28,20 +28,20 @@ BEGIN

-- ensure all shards are dropped
PERFORM master_drop_all_shards(v_obj.objid, v_obj.schema_name, v_obj.object_name);

PERFORM master_drop_distributed_table_metadata(v_obj.objid, v_obj.schema_name, v_obj.object_name);
END LOOP;

IF cardinality(sequence_names) = 0 THEN
RETURN;
END IF;

PERFORM master_drop_sequences(sequence_names);
END;
$cdbdt$;

COMMENT ON FUNCTION citus_drop_trigger()
IS 'perform checks and actions at the end of DROP actions';

RESET search_path;

2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-13--7.0-14.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-13--7.0-14.sql
-- citus--7.0-13--7.0-14.sql

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-14--7.0-15.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-14--7.0-15
-- citus--7.0-14--7.0-15

DROP FUNCTION pg_catalog.dump_local_wait_edges(int4);

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-15--7.1-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-15--7.1-1
-- citus--7.0-15--7.1-1

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-2--7.0-3.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-2--7.0-3.sql
-- citus--7.0-2--7.0-3.sql

ALTER SEQUENCE pg_catalog.pg_dist_shard_placement_placementid_seq
RENAME TO pg_dist_placement_placementid_seq;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-3--7.0-4.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-3--7.0-4.sql
-- citus--7.0-3--7.0-4.sql

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-4--7.0-5.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-4--7.0-5.sql
-- citus--7.0-4--7.0-5.sql

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-5--7.0-6.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-5--7.0-6
-- citus--7.0-5--7.0-6

CREATE FUNCTION pg_catalog.dump_local_wait_edges(
IN source_node_id int4,
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.0-6--7.0-7.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-6--7.0-7
-- citus--7.0-6--7.0-7

CREATE FUNCTION citus.replace_isolation_tester_func()
RETURNS void AS $$
Expand Down Expand Up @@ -66,7 +66,7 @@ RETURNS int4[] AS $$
-- pg says we're not blocked locally; check whether we're blocked globally.
SELECT transaction_number INTO mLocalTransactionNum
FROM get_all_active_transactions() WHERE process_id = pBlockedPid;

SELECT array_agg(process_id) INTO mRemoteBlockingPids FROM (
WITH activeTransactions AS (
SELECT process_id, transaction_number FROM get_all_active_transactions()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-7--7.0-8.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.0-7--7.0-8.sql
-- citus--7.0-7--7.0-8.sql

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-8--7.0-9.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus-7.0-8--7.0-9
-- citus-7.0-8--7.0-9

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.0-9--7.0-10.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus-7.0-9--7.0-10
-- citus-7.0-9--7.0-10

SET search_path = 'pg_catalog';

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.1-1--7.1-2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.1-1--7.1-2
-- citus--7.1-1--7.1-2

CREATE OR REPLACE FUNCTION pg_catalog.citus_version()
RETURNS text
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.1-2--7.1-3.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.1-2--7.1-3
-- citus--7.1-2--7.1-3

CREATE TABLE citus.pg_dist_node_metadata(
metadata jsonb NOT NULL
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.1-3--7.1-4.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.1-3--7.1-4
-- citus--7.1-3--7.1-4

CREATE TYPE citus.shard_transfer_mode AS ENUM (
'auto',
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.1-4--7.2-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.1-4--7.2-1
-- citus--7.1-4--7.2-1

-- bump version to 7.2-1
-- bump version to 7.2-1

2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.2-1--7.2-2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.2-1--7.2-2
-- citus--7.2-1--7.2-2

CREATE TYPE citus.copy_format AS ENUM ('csv', 'binary', 'text');

Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.2-2--7.2-3.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.2-2--7.2-3
-- citus--7.2-2--7.2-3

DROP FUNCTION pg_catalog.read_intermediate_result(text,citus.copy_format);
DROP TYPE citus.copy_format;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.2-3--7.3-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.2-3--7.3-1
-- citus--7.2-3--7.3-1

-- bump version to 7.3-1
-- bump version to 7.3-1

2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.3-1--7.3-2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.3-1--7.3-2
-- citus--7.3-1--7.3-2

CREATE FUNCTION pg_catalog.citus_text_send_as_jsonb(text)
RETURNS bytea
Expand Down
10 changes: 5 additions & 5 deletions src/backend/distributed/sql/citus--7.3-2--7.3-3.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- citus--7.3-2--7.3-3
-- citus--7.3-2--7.3-3

-- Citus json aggregate helpers

CREATE FUNCTION pg_catalog.citus_jsonb_concatenate(state jsonb, val jsonb)
RETURNS jsonb
LANGUAGE SQL
AS $function$
SELECT CASE
SELECT CASE
WHEN val IS NULL THEN state
WHEN jsonb_typeof(state) = 'null' THEN val
ELSE state || val
Expand All @@ -24,7 +24,7 @@ CREATE FUNCTION pg_catalog.citus_json_concatenate(state json, val json)
RETURNS json
LANGUAGE SQL
AS $function$
SELECT CASE
SELECT CASE
WHEN val IS NULL THEN state
WHEN json_typeof(state) = 'null' THEN val
WHEN json_typeof(state) = 'object' THEN
Expand All @@ -33,7 +33,7 @@ AS $function$
UNION ALL
SELECT * FROM json_each(val)
) t)
ELSE
ELSE
(SELECT json_agg(a) FROM (
SELECT json_array_elements(state) AS a
UNION ALL
Expand All @@ -60,7 +60,7 @@ CREATE AGGREGATE pg_catalog.jsonb_cat_agg(jsonb) (
);
COMMENT ON AGGREGATE pg_catalog.jsonb_cat_agg(jsonb)
IS 'concatenate input jsonbs into a single jsonb';

CREATE AGGREGATE pg_catalog.json_cat_agg(json) (
SFUNC = citus_json_concatenate,
FINALFUNC = citus_json_concatenate_final,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.3-3--7.4-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.3-3--7.4-1
-- citus--7.3-3--7.4-1

DROP FUNCTION IF EXISTS master_expire_table_cache(regclass);
DROP FUNCTION IF EXISTS pg_catalog.worker_fetch_regular_table(text, bigint, text[], integer[]);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.4-1--7.4-2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.4-1--7.4-2
-- citus--7.4-1--7.4-2

CREATE OR REPLACE FUNCTION pg_catalog.citus_drop_trigger()
RETURNS event_trigger
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.4-2--7.4-3.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.4-2--7.4-3
-- citus--7.4-2--7.4-3
SET search_path = 'pg_catalog';

-- note that we're not dropping the older version of the function
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.4-3--7.5-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.4-3--7.5-1
-- citus--7.4-3--7.5-1

-- bump version to 7.5-1
-- bump version to 7.5-1

2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-1--7.5-2.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-1--7.5-2
-- citus--7.5-1--7.5-2
SET search_path = 'pg_catalog';

-- note that we're not dropping the older version of the function
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-2--7.5-3.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-2--7.5-3
-- citus--7.5-2--7.5-3
SET search_path = 'pg_catalog';

CREATE FUNCTION master_dist_authinfo_cache_invalidate()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-3--7.5-4.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-3--7.5-4
-- citus--7.5-3--7.5-4

CREATE FUNCTION pg_catalog.citus_query_stats(OUT queryid bigint,
OUT userid oid,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-4--7.5-5.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-4--7.5-5
-- citus--7.5-4--7.5-5
CREATE FUNCTION pg_catalog.citus_executor_name(executor_type int)
RETURNS TEXT
LANGUAGE plpgsql
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-5--7.5-6.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-5--7.5-6
-- citus--7.5-5--7.5-6

-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_catalog.citus_stat_statements_reset() FROM PUBLIC;
2 changes: 1 addition & 1 deletion src/backend/distributed/sql/citus--7.5-6--7.5-7.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-6--7.5-7
-- citus--7.5-6--7.5-7
SET search_path = 'pg_catalog';

CREATE FUNCTION pg_catalog.poolinfo_valid(text)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--7.5-7--8.0-1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- citus--7.5-7--8.0-1
-- citus--7.5-7--8.0-1

-- bump version to 8.0-1
-- bump version to 8.0-1

Loading

0 comments on commit c563e08

Please sign in to comment.