mirror of https://github.com/citusdata/citus.git
Address feedback
parent
eeb25aca85
commit
aa3032cfdd
|
@ -143,8 +143,8 @@ RelationColumnList(Relation rel)
|
||||||
Index varno = 0;
|
Index varno = 0;
|
||||||
AttrNumber varattno = i + 1;
|
AttrNumber varattno = i + 1;
|
||||||
Oid vartype = tupdesc->attrs[i].atttypid;
|
Oid vartype = tupdesc->attrs[i].atttypid;
|
||||||
int32 vartypmod = 0;
|
int32 vartypmod = tupdesc->attrs[i].atttypmod;
|
||||||
Oid varcollid = 0;
|
Oid varcollid = tupdesc->attrs[i].attcollation;
|
||||||
Index varlevelsup = 0;
|
Index varlevelsup = 0;
|
||||||
Var *var;
|
Var *var;
|
||||||
|
|
||||||
|
@ -530,16 +530,14 @@ cstore_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
TableWriteState *writeState = NULL;
|
TableWriteState *writeState = NULL;
|
||||||
TableReadState *readState = NULL;
|
TableReadState *readState = NULL;
|
||||||
CStoreOptions *cstoreOptions = NULL;
|
CStoreOptions *cstoreOptions = NULL;
|
||||||
Datum *sourceValues = NULL;
|
Datum *values = NULL;
|
||||||
bool *sourceNulls = NULL;
|
bool *nulls = NULL;
|
||||||
Datum *targetValues = NULL;
|
|
||||||
bool *targetNulls = NULL;
|
|
||||||
TupleDesc sourceDesc = RelationGetDescr(OldHeap);
|
TupleDesc sourceDesc = RelationGetDescr(OldHeap);
|
||||||
TupleDesc targetDesc = RelationGetDescr(NewHeap);
|
TupleDesc targetDesc = RelationGetDescr(NewHeap);
|
||||||
|
|
||||||
if (OldIndex != NULL || use_sort)
|
if (OldIndex != NULL || use_sort)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("cstore_am doesn't support indexes")));
|
ereport(ERROR, (errmsg(CSTORE_TABLEAM_NAME " doesn't support indexes")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -559,34 +557,18 @@ cstore_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
|
|
||||||
readState = CStoreBeginRead(OldHeap, sourceDesc, RelationColumnList(OldHeap), NULL);
|
readState = CStoreBeginRead(OldHeap, sourceDesc, RelationColumnList(OldHeap), NULL);
|
||||||
|
|
||||||
sourceValues = palloc0(sourceDesc->natts * sizeof(Datum));
|
values = palloc0(sourceDesc->natts * sizeof(Datum));
|
||||||
sourceNulls = palloc0(sourceDesc->natts * sizeof(bool));
|
nulls = palloc0(sourceDesc->natts * sizeof(bool));
|
||||||
|
|
||||||
targetValues = palloc0(targetDesc->natts * sizeof(Datum));
|
|
||||||
targetNulls = palloc0(targetDesc->natts * sizeof(bool));
|
|
||||||
|
|
||||||
*num_tuples = 0;
|
*num_tuples = 0;
|
||||||
|
|
||||||
while (CStoreReadNextRow(readState, sourceValues, sourceNulls))
|
while (CStoreReadNextRow(readState, values, nulls))
|
||||||
{
|
{
|
||||||
memset(targetNulls, true, targetDesc->natts * sizeof(bool));
|
CStoreWriteRow(writeState, values, nulls);
|
||||||
|
|
||||||
for (int attrIndex = 0; attrIndex < sourceDesc->natts; attrIndex++)
|
|
||||||
{
|
|
||||||
FormData_pg_attribute *sourceAttr = TupleDescAttr(sourceDesc, attrIndex);
|
|
||||||
|
|
||||||
if (!sourceAttr->attisdropped)
|
|
||||||
{
|
|
||||||
targetNulls[attrIndex] = sourceNulls[attrIndex];
|
|
||||||
targetValues[attrIndex] = sourceValues[attrIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CStoreWriteRow(writeState, targetValues, targetNulls);
|
|
||||||
(*num_tuples)++;
|
(*num_tuples)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tups_vacuumed = *num_tuples;
|
*tups_vacuumed = 0;
|
||||||
|
|
||||||
CStoreEndWrite(writeState);
|
CStoreEndWrite(writeState);
|
||||||
CStoreEndRead(readState);
|
CStoreEndRead(readState);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SELECT count(*) AS columnar_table_count FROM cstore.cstore_tables \gset
|
SELECT count(*) AS columnar_table_count FROM cstore.cstore_data_files \gset
|
||||||
CREATE TABLE t(a int, b int) USING cstore_tableam;
|
CREATE TABLE t(a int, b int) USING cstore_tableam;
|
||||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||||
count
|
count
|
||||||
|
@ -89,7 +89,7 @@ SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cs
|
||||||
(6 rows)
|
(6 rows)
|
||||||
|
|
||||||
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
||||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_tables;
|
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
1
|
1
|
||||||
|
@ -97,7 +97,7 @@ SELECT count(*) - :columnar_table_count FROM cstore.cstore_tables;
|
||||||
|
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
-- Make sure we cleaned the metadata for t too
|
-- Make sure we cleaned the metadata for t too
|
||||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_tables;
|
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
0
|
0
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SELECT count(*) AS columnar_table_count FROM cstore.cstore_tables \gset
|
SELECT count(*) AS columnar_table_count FROM cstore.cstore_data_files \gset
|
||||||
|
|
||||||
CREATE TABLE t(a int, b int) USING cstore_tableam;
|
CREATE TABLE t(a int, b int) USING cstore_tableam;
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ VACUUM FULL t;
|
||||||
SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cstore.cstore_skipnodes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t' ORDER BY 1, 2, 3;
|
SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cstore.cstore_skipnodes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t' ORDER BY 1, 2, 3;
|
||||||
|
|
||||||
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
||||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_tables;
|
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||||
|
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
|
||||||
-- Make sure we cleaned the metadata for t too
|
-- Make sure we cleaned the metadata for t too
|
||||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_tables;
|
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||||
|
|
Loading…
Reference in New Issue