From e690d8b79b91d4b6eaeef1af30a4d7db3c1c64a9 Mon Sep 17 00:00:00 2001 From: Hadi Moshayedi Date: Thu, 11 Feb 2021 16:47:12 -0800 Subject: [PATCH] Move stripe.chunk_count to last position --- src/backend/columnar/cstore_metadata_tables.c | 10 ++--- .../columnar/sql/columnar--9.5-1--10.0-1.sql | 2 +- src/test/regress/expected/am_create.out | 12 +++++- src/test/regress/expected/am_insert.out | 38 +++++++++---------- src/test/regress/sql/am_create.sql | 12 +++++- src/test/regress/sql/am_insert.sql | 4 +- 6 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/backend/columnar/cstore_metadata_tables.c b/src/backend/columnar/cstore_metadata_tables.c index 768b67fcc..e7acbed4a 100644 --- a/src/backend/columnar/cstore_metadata_tables.c +++ b/src/backend/columnar/cstore_metadata_tables.c @@ -139,9 +139,9 @@ typedef FormData_columnar_options *Form_columnar_options; #define Anum_columnar_stripe_file_offset 3 #define Anum_columnar_stripe_data_length 4 #define Anum_columnar_stripe_column_count 5 -#define Anum_columnar_stripe_chunk_count 6 -#define Anum_columnar_stripe_chunk_row_count 7 -#define Anum_columnar_stripe_row_count 8 +#define Anum_columnar_stripe_chunk_row_count 6 +#define Anum_columnar_stripe_row_count 7 +#define Anum_columnar_stripe_chunk_count 8 /* constants for columnar.chunk_group */ #define Natts_columnar_chunkgroup 4 @@ -633,9 +633,9 @@ InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe) Int64GetDatum(stripe->fileOffset), Int64GetDatum(stripe->dataLength), Int32GetDatum(stripe->columnCount), - Int32GetDatum(stripe->chunkCount), Int32GetDatum(stripe->chunkRowCount), - Int64GetDatum(stripe->rowCount) + Int64GetDatum(stripe->rowCount), + Int32GetDatum(stripe->chunkCount) }; Oid columnarStripesOid = ColumnarStripeRelationId(); diff --git a/src/backend/columnar/sql/columnar--9.5-1--10.0-1.sql b/src/backend/columnar/sql/columnar--9.5-1--10.0-1.sql index 37e03eb4e..aa932f013 100644 --- a/src/backend/columnar/sql/columnar--9.5-1--10.0-1.sql +++ b/src/backend/columnar/sql/columnar--9.5-1--10.0-1.sql @@ -21,9 +21,9 @@ CREATE TABLE stripe ( file_offset bigint NOT NULL, data_length bigint NOT NULL, column_count int NOT NULL, - chunk_count int NOT NULL, chunk_row_count int NOT NULL, row_count bigint NOT NULL, + chunk_group_count int NOT NULL, PRIMARY KEY (storage_id, stripe_num) ) WITH (user_catalog_table = true); diff --git a/src/test/regress/expected/am_create.out b/src/test/regress/expected/am_create.out index 9e56a39b4..1db635a8d 100644 --- a/src/test/regress/expected/am_create.out +++ b/src/test/regress/expected/am_create.out @@ -55,5 +55,15 @@ WITH a as ( ), c as ( (TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION (TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a) +), d as ( + SELECT storage_id, stripe_num, count(*) as chunk_group_count + FROM columnar.chunk_group + GROUP BY 1,2 +), e as ( + SELECT storage_id, stripe_num, chunk_group_count + FROM columnar.stripe +), f as ( + (TABLE d EXCEPT TABLE d) UNION (TABLE e EXCEPT TABLE d) ) -SELECT count(*) = 0 AS consistent FROM c; +SELECT (SELECT count(*) = 0 FROM c) AND + (SELECT count(*) = 0 FROM f) as consistent; diff --git a/src/test/regress/expected/am_insert.out b/src/test/regress/expected/am_insert.out index ae82a5470..2a02c8370 100644 --- a/src/test/regress/expected/am_insert.out +++ b/src/test/regress/expected/am_insert.out @@ -173,16 +173,16 @@ INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col SELECT * FROM zero_col_heap; -SELECT relname, stripe_num, row_count FROM columnar.stripe a, pg_class b +SELECT relname, stripe_num, chunk_group_count, row_count FROM columnar.stripe a, pg_class b WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' -ORDER BY 1,2,3; - relname | stripe_num | row_count +ORDER BY 1,2,3,4; + relname | stripe_num | chunk_group_count | row_count --------------------------------------------------------------------- - zero_col | 1 | 1 - zero_col | 2 | 1 - zero_col | 3 | 1 - zero_col | 4 | 1 - zero_col | 5 | 64 + zero_col | 1 | 1 | 1 + zero_col | 2 | 1 | 1 + zero_col | 3 | 1 | 1 + zero_col | 4 | 1 | 1 + zero_col | 5 | 7 | 64 (5 rows) SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b @@ -197,17 +197,17 @@ WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' ORDER BY 1,2,3,4; relname | stripe_num | chunk_group_num | row_count --------------------------------------------------------------------- - zero_col | 1 | 0 | 1 - zero_col | 2 | 0 | 1 - zero_col | 3 | 0 | 1 - zero_col | 4 | 0 | 1 - zero_col | 5 | 0 | 10 - zero_col | 5 | 1 | 10 - zero_col | 5 | 2 | 10 - zero_col | 5 | 3 | 10 - zero_col | 5 | 4 | 10 - zero_col | 5 | 5 | 10 - zero_col | 5 | 6 | 4 + zero_col | 1 | 0 | 1 + zero_col | 2 | 0 | 1 + zero_col | 3 | 0 | 1 + zero_col | 4 | 0 | 1 + zero_col | 5 | 0 | 10 + zero_col | 5 | 1 | 10 + zero_col | 5 | 2 | 10 + zero_col | 5 | 3 | 10 + zero_col | 5 | 4 | 10 + zero_col | 5 | 5 | 10 + zero_col | 5 | 6 | 4 (11 rows) DROP TABLE zero_col; diff --git a/src/test/regress/sql/am_create.sql b/src/test/regress/sql/am_create.sql index 6c394786f..6f606a87f 100644 --- a/src/test/regress/sql/am_create.sql +++ b/src/test/regress/sql/am_create.sql @@ -59,5 +59,15 @@ WITH a as ( ), c as ( (TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION (TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a) +), d as ( + SELECT storage_id, stripe_num, count(*) as chunk_group_count + FROM columnar.chunk_group + GROUP BY 1,2 +), e as ( + SELECT storage_id, stripe_num, chunk_group_count + FROM columnar.stripe +), f as ( + (TABLE d EXCEPT TABLE d) UNION (TABLE e EXCEPT TABLE d) ) -SELECT count(*) = 0 AS consistent FROM c; +SELECT (SELECT count(*) = 0 FROM c) AND + (SELECT count(*) = 0 FROM f) as consistent; diff --git a/src/test/regress/sql/am_insert.sql b/src/test/regress/sql/am_insert.sql index ce57feb34..e3f3a5230 100644 --- a/src/test/regress/sql/am_insert.sql +++ b/src/test/regress/sql/am_insert.sql @@ -128,9 +128,9 @@ INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col SELECT * FROM zero_col_heap; -SELECT relname, stripe_num, row_count FROM columnar.stripe a, pg_class b +SELECT relname, stripe_num, chunk_group_count, row_count FROM columnar.stripe a, pg_class b WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' -ORDER BY 1,2,3; +ORDER BY 1,2,3,4; SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col'