From bcb162976f7bad994130d8ae693c586b83399fe6 Mon Sep 17 00:00:00 2001 From: Hadi Moshayedi Date: Mon, 1 Feb 2021 16:20:53 -0800 Subject: [PATCH] Fix #4608 --- src/backend/columnar/cstore_tableam.c | 2 +- .../expected/columnar_citus_integration.out | 26 +++++++++++++++++++ .../sql/columnar_citus_integration.sql | 10 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/backend/columnar/cstore_tableam.c b/src/backend/columnar/cstore_tableam.c index 4a5b3026f..7dd143277 100644 --- a/src/backend/columnar/cstore_tableam.c +++ b/src/backend/columnar/cstore_tableam.c @@ -164,7 +164,7 @@ columnar_beginscan(Relation relation, Snapshot snapshot, parallel_scan, flags, attr_needed, NULL); - pfree(attr_needed); + bms_free(attr_needed); return scandesc; } diff --git a/src/test/regress/expected/columnar_citus_integration.out b/src/test/regress/expected/columnar_citus_integration.out index 4b912467e..f80448b83 100644 --- a/src/test/regress/expected/columnar_citus_integration.out +++ b/src/test/regress/expected/columnar_citus_integration.out @@ -1067,5 +1067,31 @@ SELECT 1 FROM master_remove_node('localhost', :master_port); 1 (1 row) +-- verify reference table with no columns can be created +-- https://github.com/citusdata/citus/issues/4608 +CREATE TABLE zero_col() USING columnar; +SELECT create_reference_table('zero_col'); + create_reference_table +--------------------------------------------------------------------- + +(1 row) + +select result from run_command_on_placements('zero_col', 'select count(*) from %s'); + result +--------------------------------------------------------------------- + 0 + 0 +(2 rows) + +-- add a column so we can ad some data +ALTER TABLE zero_col ADD COLUMN a int; +INSERT INTO zero_col SELECT i FROM generate_series(1, 10) i; +select result from run_command_on_placements('zero_col', 'select count(*) from %s'); + result +--------------------------------------------------------------------- + 10 + 10 +(2 rows) + SET client_min_messages TO WARNING; DROP SCHEMA columnar_citus_integration CASCADE; diff --git a/src/test/regress/sql/columnar_citus_integration.sql b/src/test/regress/sql/columnar_citus_integration.sql index 57a8ccd26..21e3c7f57 100644 --- a/src/test/regress/sql/columnar_citus_integration.sql +++ b/src/test/regress/sql/columnar_citus_integration.sql @@ -403,5 +403,15 @@ SELECT compression FROM columnar.options WHERE regclass = 'table_option_citus_lo DROP TABLE table_option_citus_local, table_option_citus_local_2; SELECT 1 FROM master_remove_node('localhost', :master_port); +-- verify reference table with no columns can be created +-- https://github.com/citusdata/citus/issues/4608 +CREATE TABLE zero_col() USING columnar; +SELECT create_reference_table('zero_col'); +select result from run_command_on_placements('zero_col', 'select count(*) from %s'); +-- add a column so we can ad some data +ALTER TABLE zero_col ADD COLUMN a int; +INSERT INTO zero_col SELECT i FROM generate_series(1, 10) i; +select result from run_command_on_placements('zero_col', 'select count(*) from %s'); + SET client_min_messages TO WARNING; DROP SCHEMA columnar_citus_integration CASCADE;