mirror of https://github.com/citusdata/citus.git
more fixes
parent
a57b9004a4
commit
18f6829621
|
@ -44,6 +44,7 @@ typedef struct CStoreScanDescData *CStoreScanDesc;
|
||||||
|
|
||||||
static TableWriteState *CStoreWriteState = NULL;
|
static TableWriteState *CStoreWriteState = NULL;
|
||||||
static ExecutorEnd_hook_type PreviousExecutorEndHook = NULL;
|
static ExecutorEnd_hook_type PreviousExecutorEndHook = NULL;
|
||||||
|
static MemoryContext CStoreContext = NULL;
|
||||||
|
|
||||||
static CStoreOptions *
|
static CStoreOptions *
|
||||||
CStoreGetDefaultOptions(void)
|
CStoreGetDefaultOptions(void)
|
||||||
|
@ -71,13 +72,22 @@ cstore_init_write_state(Relation relation)
|
||||||
{
|
{
|
||||||
CStoreOptions *cstoreOptions = CStoreGetDefaultOptions();
|
CStoreOptions *cstoreOptions = CStoreGetDefaultOptions();
|
||||||
TupleDesc tupdesc = RelationGetDescr(relation);
|
TupleDesc tupdesc = RelationGetDescr(relation);
|
||||||
|
MemoryContext oldContext;
|
||||||
|
|
||||||
|
if (CStoreContext == NULL)
|
||||||
|
{
|
||||||
|
CStoreContext = AllocSetContextCreate(TopMemoryContext, "cstore context",
|
||||||
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
|
}
|
||||||
|
|
||||||
elog(LOG, "initializing write state for relation %d", relation->rd_id);
|
elog(LOG, "initializing write state for relation %d", relation->rd_id);
|
||||||
|
oldContext = MemoryContextSwitchTo(CStoreContext);
|
||||||
CStoreWriteState = CStoreBeginWrite(relation->rd_id,
|
CStoreWriteState = CStoreBeginWrite(relation->rd_id,
|
||||||
cstoreOptions->compressionType,
|
cstoreOptions->compressionType,
|
||||||
cstoreOptions->stripeRowCount,
|
cstoreOptions->stripeRowCount,
|
||||||
cstoreOptions->blockRowCount,
|
cstoreOptions->blockRowCount,
|
||||||
tupdesc);
|
tupdesc);
|
||||||
|
MemoryContextSwitchTo(oldContext);
|
||||||
|
|
||||||
CStoreWriteState->relation = relation;
|
CStoreWriteState->relation = relation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,15 @@
|
||||||
--
|
--
|
||||||
-- Test the CREATE statements related to cstore_fdw.
|
-- Test the CREATE statements related to cstore_fdw.
|
||||||
--
|
--
|
||||||
-- Install cstore_fdw
|
|
||||||
CREATE EXTENSION cstore_fdw;
|
|
||||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
|
||||||
-- Validator tests
|
-- Validator tests
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_option ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(bad_option_name '1'); -- ERROR
|
|
||||||
ERROR: invalid option "bad_option_name"
|
|
||||||
HINT: Valid options in this context are: compression, stripe_row_count, block_row_count
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_stripe_row_count ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(stripe_row_count '0'); -- ERROR
|
|
||||||
ERROR: invalid stripe row count
|
|
||||||
HINT: Stripe row count must be an integer between 1000 and 10000000
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_block_row_count ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(block_row_count '0'); -- ERROR
|
|
||||||
ERROR: invalid block row count
|
|
||||||
HINT: Block row count must be an integer between 1000 and 100000
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_compression_type ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(compression 'invalid_compression'); -- ERROR
|
|
||||||
ERROR: invalid compression type
|
|
||||||
HINT: Valid options are: none, pglz
|
|
||||||
-- Create uncompressed table
|
-- Create uncompressed table
|
||||||
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
SERVER cstore_server;
|
USING cstore_tableam;
|
||||||
-- Create compressed table with automatically determined file path
|
-- Create compressed table with automatically determined file path
|
||||||
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
SERVER cstore_server
|
USING cstore_tableam
|
||||||
OPTIONS(compression 'pglz');
|
|
||||||
-- Test that querying an empty table works
|
-- Test that querying an empty table works
|
||||||
ANALYZE contestant;
|
ANALYZE contestant;
|
||||||
SELECT count(*) FROM contestant;
|
SELECT count(*) FROM contestant;
|
||||||
|
|
|
@ -29,8 +29,7 @@ $$ LANGUAGE PLPGSQL;
|
||||||
|
|
||||||
-- Create and load data
|
-- Create and load data
|
||||||
CREATE TABLE test_block_filtering (a int)
|
CREATE TABLE test_block_filtering (a int)
|
||||||
USING cstore_tableam
|
USING cstore_tableam;
|
||||||
OPTIONS(block_row_count '1000', stripe_row_count '2000');
|
|
||||||
|
|
||||||
COPY test_block_filtering FROM '@abs_srcdir@/data/block_filtering.csv' WITH CSV;
|
COPY test_block_filtering FROM '@abs_srcdir@/data/block_filtering.csv' WITH CSV;
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,15 @@
|
||||||
--
|
--
|
||||||
-- Test the CREATE statements related to cstore_fdw.
|
-- Test the CREATE statements related to cstore_fdw.
|
||||||
--
|
--
|
||||||
-- Install cstore_fdw
|
|
||||||
CREATE EXTENSION cstore_fdw;
|
|
||||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
|
||||||
-- Validator tests
|
-- Validator tests
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_option ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(bad_option_name '1'); -- ERROR
|
|
||||||
ERROR: invalid option "bad_option_name"
|
|
||||||
HINT: Valid options in this context are: compression, stripe_row_count, block_row_count
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_stripe_row_count ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(stripe_row_count '0'); -- ERROR
|
|
||||||
ERROR: invalid stripe row count
|
|
||||||
HINT: Stripe row count must be an integer between 1000 and 10000000
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_block_row_count ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(block_row_count '0'); -- ERROR
|
|
||||||
ERROR: invalid block row count
|
|
||||||
HINT: Block row count must be an integer between 1000 and 100000
|
|
||||||
CREATE FOREIGN TABLE test_validator_invalid_compression_type ()
|
|
||||||
SERVER cstore_server
|
|
||||||
OPTIONS(compression 'invalid_compression'); -- ERROR
|
|
||||||
ERROR: invalid compression type
|
|
||||||
HINT: Valid options are: none, pglz
|
|
||||||
-- Create uncompressed table
|
-- Create uncompressed table
|
||||||
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
SERVER cstore_server;
|
USING cstore_tableam;
|
||||||
-- Create compressed table with automatically determined file path
|
-- Create compressed table with automatically determined file path
|
||||||
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
|
||||||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||||
SERVER cstore_server
|
USING cstore_tableam
|
||||||
OPTIONS(compression 'pglz');
|
|
||||||
-- Test that querying an empty table works
|
-- Test that querying an empty table works
|
||||||
ANALYZE contestant;
|
ANALYZE contestant;
|
||||||
SELECT count(*) FROM contestant;
|
SELECT count(*) FROM contestant;
|
||||||
|
|
|
@ -29,8 +29,7 @@ $$ LANGUAGE PLPGSQL;
|
||||||
|
|
||||||
-- Create and load data
|
-- Create and load data
|
||||||
CREATE TABLE test_block_filtering (a int)
|
CREATE TABLE test_block_filtering (a int)
|
||||||
USING cstore_tableam
|
USING cstore_tableam;
|
||||||
OPTIONS(block_row_count '1000', stripe_row_count '2000');
|
|
||||||
|
|
||||||
COPY test_block_filtering FROM '/Users/jefdavi/wd/cstore2/data/block_filtering.csv' WITH CSV;
|
COPY test_block_filtering FROM '/Users/jefdavi/wd/cstore2/data/block_filtering.csv' WITH CSV;
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ COPY table_with_data FROM STDIN;
|
||||||
3
|
3
|
||||||
\.
|
\.
|
||||||
|
|
||||||
SELECT cstore_table_size('empty_table') < cstore_table_size('table_with_data');
|
SELECT pg_relation_size('empty_table') < cstore_table_size('table_with_data');
|
||||||
SELECT cstore_table_size('non_cstore_table');
|
SELECT pg_relation_size('non_cstore_table');
|
||||||
|
|
||||||
DROP TABLE empty_table;
|
DROP TABLE empty_table;
|
||||||
DROP TABLE table_with_data;
|
DROP TABLE table_with_data;
|
||||||
|
|
|
@ -9,7 +9,7 @@ SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
|
||||||
-- CREATE a cstore_fdw table, fill with some data --
|
-- CREATE a cstore_fdw table, fill with some data --
|
||||||
CREATE TABLE cstore_truncate_test (a int, b int) USING cstore_tableam;
|
CREATE TABLE cstore_truncate_test (a int, b int) USING cstore_tableam;
|
||||||
CREATE TABLE cstore_truncate_test_second (a int, b int) USING cstore_tableam;
|
CREATE TABLE cstore_truncate_test_second (a int, b int) USING cstore_tableam;
|
||||||
CREATE TABLE cstore_truncate_test_compressed (a int, b int) USING cstore_tableam OPTIONS (compression 'pglz');
|
CREATE TABLE cstore_truncate_test_compressed (a int, b int) USING cstore_tableam;
|
||||||
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
||||||
|
|
||||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||||
|
@ -30,7 +30,7 @@ SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||||
TRUNCATE TABLE cstore_truncate_test_compressed;
|
TRUNCATE TABLE cstore_truncate_test_compressed;
|
||||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||||
|
|
||||||
SELECT cstore_table_size('cstore_truncate_test_compressed');
|
SELECT pg_relation_size('cstore_truncate_test_compressed');
|
||||||
|
|
||||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||||
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
||||||
|
@ -76,7 +76,7 @@ DROP TABLE cstore_truncate_test_compressed;
|
||||||
|
|
||||||
-- test truncate with schema
|
-- test truncate with schema
|
||||||
CREATE SCHEMA truncate_schema;
|
CREATE SCHEMA truncate_schema;
|
||||||
CREATE TABLE truncate_schema.truncate_tbl (id int) USING cstore_tableam OPTIONS(compression 'pglz');
|
CREATE TABLE truncate_schema.truncate_tbl (id int) USING cstore_tableam;
|
||||||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
DROP TABLE test_block_filtering;
|
||||||
DROP TABLE test_insert_command;
|
DROP TABLE test_insert_command;
|
||||||
DROP TABLE collation_block_filtering_test;
|
DROP TABLE collation_block_filtering_test;
|
||||||
DROP TABLE test_null_values;
|
DROP TABLE test_null_values;
|
||||||
|
|
Loading…
Reference in New Issue