mirror of https://github.com/citusdata/citus.git
Fix write path for zero column tables
parent
c8d61a31e2
commit
be90c20457
|
@ -447,7 +447,7 @@ FlushStripe(TableWriteState *writeState)
|
|||
uint32 lastChunkIndex = stripeBuffers->rowCount / chunkRowCount;
|
||||
uint32 lastChunkRowCount = stripeBuffers->rowCount % chunkRowCount;
|
||||
uint64 stripeSize = 0;
|
||||
uint64 stripeRowCount = 0;
|
||||
uint64 stripeRowCount = stripeBuffers->rowCount;
|
||||
|
||||
elog(DEBUG1, "Flushing Stripe of size %d", stripeBuffers->rowCount);
|
||||
|
||||
|
@ -500,12 +500,6 @@ FlushStripe(TableWriteState *writeState)
|
|||
}
|
||||
}
|
||||
|
||||
for (chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++)
|
||||
{
|
||||
stripeRowCount +=
|
||||
stripeSkipList->chunkSkipNodeArray[0][chunkIndex].rowCount;
|
||||
}
|
||||
|
||||
stripeMetadata = ReserveStripe(relation, stripeSize,
|
||||
stripeRowCount, columnCount, chunkCount,
|
||||
chunkRowCount);
|
||||
|
|
|
@ -149,3 +149,65 @@ SELECT * FROM chunk_group_consistency;
|
|||
|
||||
DROP TABLE test_toast_row;
|
||||
DROP TABLE test_toast_columnar;
|
||||
-- Verify metadata for zero column tables.
|
||||
-- We support writing into zero column tables, but not reading from them.
|
||||
-- We test that metadata makes sense so we can fix the read path in future.
|
||||
CREATE TABLE zero_col() USING columnar;
|
||||
SELECT alter_columnar_table_set('zero_col', chunk_group_row_limit => 10);
|
||||
alter_columnar_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
CREATE TABLE zero_col_heap();
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
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_heap SELECT * FROM zero_col_heap;
|
||||
INSERT INTO zero_col SELECT * FROM zero_col_heap;
|
||||
SELECT relname, stripeid, row_count FROM columnar.stripe a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3;
|
||||
relname | stripeid | row_count
|
||||
---------------------------------------------------------------------
|
||||
zero_col | 1 | 1
|
||||
zero_col | 2 | 1
|
||||
zero_col | 3 | 1
|
||||
zero_col | 4 | 1
|
||||
zero_col | 5 | 64
|
||||
(5 rows)
|
||||
|
||||
SELECT relname, stripeid, value_count FROM columnar.chunk a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3;
|
||||
relname | stripeid | value_count
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT relname, stripeid, chunkid, row_count FROM columnar.chunk_group a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3,4;
|
||||
relname | stripeid | chunkid | 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
|
||||
(11 rows)
|
||||
|
||||
DROP TABLE zero_col;
|
||||
|
|
|
@ -103,3 +103,41 @@ SELECT * FROM chunk_group_consistency;
|
|||
|
||||
DROP TABLE test_toast_row;
|
||||
DROP TABLE test_toast_columnar;
|
||||
|
||||
-- Verify metadata for zero column tables.
|
||||
-- We support writing into zero column tables, but not reading from them.
|
||||
-- We test that metadata makes sense so we can fix the read path in future.
|
||||
CREATE TABLE zero_col() USING columnar;
|
||||
SELECT alter_columnar_table_set('zero_col', chunk_group_row_limit => 10);
|
||||
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
INSERT INTO zero_col DEFAULT VALUES;
|
||||
|
||||
CREATE TABLE zero_col_heap();
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
INSERT INTO zero_col_heap DEFAULT VALUES;
|
||||
|
||||
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_heap SELECT * FROM zero_col_heap;
|
||||
|
||||
INSERT INTO zero_col SELECT * FROM zero_col_heap;
|
||||
|
||||
SELECT relname, stripeid, row_count FROM columnar.stripe a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3;
|
||||
|
||||
SELECT relname, stripeid, value_count FROM columnar.chunk a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3;
|
||||
|
||||
SELECT relname, stripeid, chunkid, row_count FROM columnar.chunk_group a, pg_class b
|
||||
WHERE columnar_relation_storageid(b.oid)=a.storageid AND relname = 'zero_col'
|
||||
ORDER BY 1,2,3,4;
|
||||
|
||||
DROP TABLE zero_col;
|
||||
|
|
Loading…
Reference in New Issue