tests WIP

merge-cstore-pykello
Jeff Davis 2020-09-15 16:41:28 -07:00
parent f886fb33e5
commit a57b9004a4
26 changed files with 158 additions and 156 deletions

View File

@ -14,8 +14,8 @@ DATA = cstore_fdw--1.7.sql cstore_fdw--1.6--1.7.sql cstore_fdw--1.5--1.6.sql cs
cstore_fdw--1.3--1.4.sql cstore_fdw--1.2--1.3.sql cstore_fdw--1.1--1.2.sql \
cstore_fdw--1.0--1.1.sql cstore_fdw--1.7--1.8.sql
REGRESS = am_create am_load am_query am_analyze am_data_types am_functions \
am_block_filtering am_drop am_insert am_copyto am_alter am_truncate \
REGRESS = extension_create am_create am_load am_query am_analyze am_data_types am_functions \
am_block_filtering am_drop am_insert am_copyto am_alter am_truncate clean \
fdw_create fdw_load fdw_query fdw_analyze fdw_data_types fdw_functions \
fdw_block_filtering fdw_drop fdw_insert fdw_copyto fdw_alter fdw_truncate
EXTRA_CLEAN = cstore.pb-c.h cstore.pb-c.c data/*.cstore data/*.cstore.footer \

View File

@ -43,6 +43,7 @@ typedef struct CStoreScanDescData
typedef struct CStoreScanDescData *CStoreScanDesc;
static TableWriteState *CStoreWriteState = NULL;
static ExecutorEnd_hook_type PreviousExecutorEndHook = NULL;
static CStoreOptions *
CStoreGetDefaultOptions(void)
@ -71,7 +72,7 @@ cstore_init_write_state(Relation relation)
CStoreOptions *cstoreOptions = CStoreGetDefaultOptions();
TupleDesc tupdesc = RelationGetDescr(relation);
elog(NOTICE, "initializing write state for relation %d", relation->rd_id);
elog(LOG, "initializing write state for relation %d", relation->rd_id);
CStoreWriteState = CStoreBeginWrite(relation->rd_id,
cstoreOptions->compressionType,
cstoreOptions->stripeRowCount,
@ -87,7 +88,7 @@ cstore_free_write_state()
{
if (CStoreWriteState != NULL)
{
elog(NOTICE, "flushing write state for relation %d", CStoreWriteState->relation->rd_id);
elog(LOG, "flushing write state for relation %d", CStoreWriteState->relation->rd_id);
CStoreEndWrite(CStoreWriteState);
CStoreWriteState = NULL;
}
@ -495,6 +496,29 @@ cstore_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate,
elog(ERROR, "cstore_scan_sample_next_tuple not implemented");
}
static void
CStoreExecutorEnd(QueryDesc *queryDesc)
{
cstore_free_write_state();
if (PreviousExecutorEndHook)
PreviousExecutorEndHook(queryDesc);
else
standard_ExecutorEnd(queryDesc);
}
void
cstore_tableam_init()
{
PreviousExecutorEndHook = ExecutorEnd_hook;
ExecutorEnd_hook = CStoreExecutorEnd;
}
void
cstore_tableam_finish()
{
ExecutorEnd_hook = PreviousExecutorEndHook;
}
static const TableAmRoutine cstore_am_methods = {
.type = T_TableAmRoutine,

View File

@ -5,3 +5,5 @@
const TableAmRoutine *GetCstoreTableAmRoutine(void);
Datum cstore_tableam_handler(PG_FUNCTION_ARGS);
extern void cstore_free_write_state(void);
extern void cstore_tableam_init(void);
extern void cstore_tableam_finish(void);

10
expected/clean.out Normal file
View File

@ -0,0 +1,10 @@
DROP TABLE test_insert_command;
DROP TABLE collation_block_filtering_test;
DROP TABLE test_null_values;
DROP TABLE test_other_types;
DROP TABLE test_range_types;
DROP TABLE test_enum_and_composite_types;
DROP TYPE composite_type;
DROP TYPE enum_type;
DROP TABLE test_datetime_types;
DROP TABLE test_array_types;

View File

@ -0,0 +1,2 @@
-- Install cstore_fdw
CREATE EXTENSION cstore_fdw;

View File

@ -28,8 +28,8 @@ $$ LANGUAGE PLPGSQL;
-- Create and load data
CREATE FOREIGN TABLE test_block_filtering (a int)
SERVER cstore_server
CREATE TABLE test_block_filtering (a int)
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;
@ -58,8 +58,8 @@ SELECT filtered_row_count('SELECT count(*) FROM test_block_filtering WHERE a BET
-- Verify that we are fine with collations which use a different alphabet order
CREATE FOREIGN TABLE collation_block_filtering_test(A text collate "da_DK")
SERVER cstore_server;
CREATE TABLE collation_block_filtering_test(A text collate "da_DK")
USING cstore_tableam;
COPY collation_block_filtering_test FROM STDIN;
A
Å

View File

@ -1,9 +1,9 @@
--
-- Test copying data from cstore_fdw tables.
--
CREATE FOREIGN TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
CREATE TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server;
USING cstore_tableam;
-- load table data from file
COPY test_contestant FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
@ -14,4 +14,4 @@ COPY test_contestant TO STDOUT;
-- export using COPY (SELECT * FROM table) TO ...
COPY (select * from test_contestant) TO STDOUT;
DROP FOREIGN TABLE test_contestant CASCADE;
DROP TABLE test_contestant CASCADE;

View File

@ -1,42 +1,18 @@
--
-- Test the CREATE statements related to cstore_fdw.
-- Test the CREATE statements related to cstore.
--
-- Install cstore_fdw
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
-- Validator tests
CREATE FOREIGN TABLE test_validator_invalid_option ()
SERVER cstore_server
OPTIONS(bad_option_name '1'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_stripe_row_count ()
SERVER cstore_server
OPTIONS(stripe_row_count '0'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_block_row_count ()
SERVER cstore_server
OPTIONS(block_row_count '0'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_compression_type ()
SERVER cstore_server
OPTIONS(compression 'invalid_compression'); -- ERROR
-- Create uncompressed table
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server;
USING cstore_tableam;
-- Create compressed table with automatically determined file path
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
CREATE TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server
OPTIONS(compression 'pglz');
USING cstore_tableam;
-- Test that querying an empty table works
ANALYZE contestant;

View File

@ -10,8 +10,8 @@ SET intervalstyle TO 'POSTGRES_VERBOSE';
-- Test array types
CREATE FOREIGN TABLE test_array_types (int_array int[], bigint_array bigint[],
text_array text[]) SERVER cstore_server;
CREATE TABLE test_array_types (int_array int[], bigint_array bigint[],
text_array text[]) USING cstore_tableam;
COPY test_array_types FROM '@abs_srcdir@/data/array_types.csv' WITH CSV;
@ -19,9 +19,9 @@ SELECT * FROM test_array_types;
-- Test date/time types
CREATE FOREIGN TABLE test_datetime_types (timestamp timestamp,
CREATE TABLE test_datetime_types (timestamp timestamp,
timestamp_with_timezone timestamp with time zone, date date, time time,
interval interval) SERVER cstore_server;
interval interval) USING cstore_tableam;
COPY test_datetime_types FROM '@abs_srcdir@/data/datetime_types.csv' WITH CSV;
@ -32,8 +32,8 @@ SELECT * FROM test_datetime_types;
CREATE TYPE enum_type AS ENUM ('a', 'b', 'c');
CREATE TYPE composite_type AS (a int, b text);
CREATE FOREIGN TABLE test_enum_and_composite_types (enum enum_type,
composite composite_type) SERVER cstore_server;
CREATE TABLE test_enum_and_composite_types (enum enum_type,
composite composite_type) USING cstore_tableam;
COPY test_enum_and_composite_types FROM
'@abs_srcdir@/data/enum_and_composite_types.csv' WITH CSV;
@ -42,8 +42,8 @@ SELECT * FROM test_enum_and_composite_types;
-- Test range types
CREATE FOREIGN TABLE test_range_types (int4range int4range, int8range int8range,
numrange numrange, tsrange tsrange) SERVER cstore_server;
CREATE TABLE test_range_types (int4range int4range, int8range int8range,
numrange numrange, tsrange tsrange) USING cstore_tableam;
COPY test_range_types FROM '@abs_srcdir@/data/range_types.csv' WITH CSV;
@ -51,8 +51,8 @@ SELECT * FROM test_range_types;
-- Test other types
CREATE FOREIGN TABLE test_other_types (bool boolean, bytea bytea, money money,
inet inet, bitstring bit varying(5), uuid uuid, json json) SERVER cstore_server;
CREATE TABLE test_other_types (bool boolean, bytea bytea, money money,
inet inet, bitstring bit varying(5), uuid uuid, json json) USING cstore_tableam;
COPY test_other_types FROM '@abs_srcdir@/data/other_types.csv' WITH CSV;
@ -60,8 +60,8 @@ SELECT * FROM test_other_types;
-- Test null values
CREATE FOREIGN TABLE test_null_values (a int, b int[], c composite_type)
SERVER cstore_server;
CREATE TABLE test_null_values (a int, b int[], c composite_type)
USING cstore_tableam;
COPY test_null_values FROM '@abs_srcdir@/data/null_values.csv' WITH CSV;

View File

@ -23,8 +23,8 @@ COPY contestant_compressed FROM PROGRAM 'cat @abs_srcdir@/data/contestants.2.csv
WITH CSV;
-- Test column list
CREATE FOREIGN TABLE famous_constants (id int, name text, value real)
SERVER cstore_server;
CREATE TABLE famous_constants (id int, name text, value real)
USING cstore_tableam;
COPY famous_constants (value, name, id) FROM STDIN WITH CSV;
3.141,pi,1
2.718,e,2
@ -41,4 +41,4 @@ speed of light,2.997e8
SELECT * FROM famous_constants ORDER BY id, name;
DROP FOREIGN TABLE famous_constants;
DROP TABLE famous_constants;

View File

@ -2,10 +2,6 @@
-- Test the CREATE statements related to cstore_fdw.
--
-- Install cstore_fdw
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;

3
mod.c
View File

@ -16,6 +16,7 @@
#include "fmgr.h"
#include "mod.h"
#include "cstore_tableam.h"
#include "cstore_fdw.h"
PG_MODULE_MAGIC;
@ -23,6 +24,7 @@ PG_MODULE_MAGIC;
void
_PG_init(void)
{
cstore_tableam_init();
cstore_fdw_init();
}
@ -30,5 +32,6 @@ _PG_init(void)
void
_PG_fini(void)
{
cstore_tableam_finish();
cstore_fdw_finish();
}

View File

@ -1,8 +1,6 @@
--
-- 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
CREATE FOREIGN TABLE test_validator_invalid_option ()

View File

@ -2,7 +2,7 @@
-- Testing ALTER TABLE on cstore_fdw tables.
--
CREATE FOREIGN TABLE test_alter_table (a int, b int, c int) SERVER cstore_server;
CREATE TABLE test_alter_table (a int, b int, c int) USING cstore_tableam;
WITH sample_data AS (VALUES
(1, 2, 3),
@ -12,7 +12,7 @@ WITH sample_data AS (VALUES
INSERT INTO test_alter_table SELECT * FROM sample_data;
-- drop a column
ALTER FOREIGN TABLE test_alter_table DROP COLUMN a;
ALTER TABLE test_alter_table DROP COLUMN a;
-- test analyze
ANALYZE test_alter_table;
@ -28,29 +28,29 @@ INSERT INTO test_alter_table (SELECT 5, 8);
-- add a column with no defaults
ALTER FOREIGN TABLE test_alter_table ADD COLUMN d int;
ALTER TABLE test_alter_table ADD COLUMN d int;
SELECT * FROM test_alter_table;
INSERT INTO test_alter_table (SELECT 3, 5, 8);
SELECT * FROM test_alter_table;
-- add a fixed-length column with default value
ALTER FOREIGN TABLE test_alter_table ADD COLUMN e int default 3;
ALTER TABLE test_alter_table ADD COLUMN e int default 3;
SELECT * from test_alter_table;
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8);
SELECT * from test_alter_table;
-- add a variable-length column with default value
ALTER FOREIGN TABLE test_alter_table ADD COLUMN f text DEFAULT 'TEXT ME';
ALTER TABLE test_alter_table ADD COLUMN f text DEFAULT 'TEXT ME';
SELECT * from test_alter_table;
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8, 'ABCDEF');
SELECT * from test_alter_table;
-- drop couple of columns
ALTER FOREIGN TABLE test_alter_table DROP COLUMN c;
ALTER FOREIGN TABLE test_alter_table DROP COLUMN e;
ALTER TABLE test_alter_table DROP COLUMN c;
ALTER TABLE test_alter_table DROP COLUMN e;
ANALYZE test_alter_table;
SELECT * from test_alter_table;
SELECT count(*) from test_alter_table;
@ -58,28 +58,28 @@ SELECT count(t.*) from test_alter_table t;
-- unsupported default values
ALTER FOREIGN TABLE test_alter_table ADD COLUMN g boolean DEFAULT isfinite(current_date);
ALTER FOREIGN TABLE test_alter_table ADD COLUMN h DATE DEFAULT current_date;
ALTER TABLE test_alter_table ADD COLUMN g boolean DEFAULT isfinite(current_date);
ALTER TABLE test_alter_table ADD COLUMN h DATE DEFAULT current_date;
SELECT * FROM test_alter_table;
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN g DROP DEFAULT;
ALTER TABLE test_alter_table ALTER COLUMN g DROP DEFAULT;
SELECT * FROM test_alter_table;
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN h DROP DEFAULT;
ALTER TABLE test_alter_table ALTER COLUMN h DROP DEFAULT;
ANALYZE test_alter_table;
SELECT * FROM test_alter_table;
-- unsupported type change
ALTER FOREIGN TABLE test_alter_table ADD COLUMN i int;
ALTER FOREIGN TABLE test_alter_table ADD COLUMN j float;
ALTER FOREIGN TABLE test_alter_table ADD COLUMN k text;
ALTER TABLE test_alter_table ADD COLUMN i int;
ALTER TABLE test_alter_table ADD COLUMN j float;
ALTER TABLE test_alter_table ADD COLUMN k text;
-- this is valid type change
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN i TYPE float;
ALTER TABLE test_alter_table ALTER COLUMN i TYPE float;
-- this is not valid
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN j TYPE int;
ALTER TABLE test_alter_table ALTER COLUMN j TYPE int;
-- text / varchar conversion is valid both ways
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN k TYPE varchar(20);
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN k TYPE text;
ALTER TABLE test_alter_table ALTER COLUMN k TYPE varchar(20);
ALTER TABLE test_alter_table ALTER COLUMN k TYPE text;
DROP FOREIGN TABLE test_alter_table;
DROP TABLE test_alter_table;

View File

@ -28,8 +28,8 @@ $$ LANGUAGE PLPGSQL;
-- Create and load data
CREATE FOREIGN TABLE test_block_filtering (a int)
SERVER cstore_server
CREATE TABLE test_block_filtering (a int)
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;
@ -58,8 +58,8 @@ SELECT filtered_row_count('SELECT count(*) FROM test_block_filtering WHERE a BET
-- Verify that we are fine with collations which use a different alphabet order
CREATE FOREIGN TABLE collation_block_filtering_test(A text collate "da_DK")
SERVER cstore_server;
CREATE TABLE collation_block_filtering_test(A text collate "da_DK")
USING cstore_tableam;
COPY collation_block_filtering_test FROM STDIN;
A
Å

View File

@ -1,9 +1,9 @@
--
-- Test copying data from cstore_fdw tables.
--
CREATE FOREIGN TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
CREATE TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server;
USING cstore_tableam;
-- load table data from file
COPY test_contestant FROM '/Users/jefdavi/wd/cstore2/data/contestants.1.csv' WITH CSV;
@ -14,4 +14,4 @@ COPY test_contestant TO STDOUT;
-- export using COPY (SELECT * FROM table) TO ...
COPY (select * from test_contestant) TO STDOUT;
DROP FOREIGN TABLE test_contestant CASCADE;
DROP TABLE test_contestant CASCADE;

View File

@ -1,42 +1,18 @@
--
-- Test the CREATE statements related to cstore_fdw.
-- Test the CREATE statements related to cstore.
--
-- Install cstore_fdw
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
-- Validator tests
CREATE FOREIGN TABLE test_validator_invalid_option ()
SERVER cstore_server
OPTIONS(bad_option_name '1'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_stripe_row_count ()
SERVER cstore_server
OPTIONS(stripe_row_count '0'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_block_row_count ()
SERVER cstore_server
OPTIONS(block_row_count '0'); -- ERROR
CREATE FOREIGN TABLE test_validator_invalid_compression_type ()
SERVER cstore_server
OPTIONS(compression 'invalid_compression'); -- ERROR
-- Create uncompressed table
CREATE FOREIGN TABLE contestant (handle TEXT, birthdate DATE, rating INT,
CREATE TABLE contestant (handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server;
USING cstore_tableam;
-- Create compressed table with automatically determined file path
CREATE FOREIGN TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
CREATE TABLE contestant_compressed (handle TEXT, birthdate DATE, rating INT,
percentile FLOAT, country CHAR(3), achievements TEXT[])
SERVER cstore_server
OPTIONS(compression 'pglz');
USING cstore_tableam;
-- Test that querying an empty table works
ANALYZE contestant;

View File

@ -10,8 +10,8 @@ SET intervalstyle TO 'POSTGRES_VERBOSE';
-- Test array types
CREATE FOREIGN TABLE test_array_types (int_array int[], bigint_array bigint[],
text_array text[]) SERVER cstore_server;
CREATE TABLE test_array_types (int_array int[], bigint_array bigint[],
text_array text[]) USING cstore_tableam;
COPY test_array_types FROM '/Users/jefdavi/wd/cstore2/data/array_types.csv' WITH CSV;
@ -19,9 +19,9 @@ SELECT * FROM test_array_types;
-- Test date/time types
CREATE FOREIGN TABLE test_datetime_types (timestamp timestamp,
CREATE TABLE test_datetime_types (timestamp timestamp,
timestamp_with_timezone timestamp with time zone, date date, time time,
interval interval) SERVER cstore_server;
interval interval) USING cstore_tableam;
COPY test_datetime_types FROM '/Users/jefdavi/wd/cstore2/data/datetime_types.csv' WITH CSV;
@ -32,8 +32,8 @@ SELECT * FROM test_datetime_types;
CREATE TYPE enum_type AS ENUM ('a', 'b', 'c');
CREATE TYPE composite_type AS (a int, b text);
CREATE FOREIGN TABLE test_enum_and_composite_types (enum enum_type,
composite composite_type) SERVER cstore_server;
CREATE TABLE test_enum_and_composite_types (enum enum_type,
composite composite_type) USING cstore_tableam;
COPY test_enum_and_composite_types FROM
'/Users/jefdavi/wd/cstore2/data/enum_and_composite_types.csv' WITH CSV;
@ -42,8 +42,8 @@ SELECT * FROM test_enum_and_composite_types;
-- Test range types
CREATE FOREIGN TABLE test_range_types (int4range int4range, int8range int8range,
numrange numrange, tsrange tsrange) SERVER cstore_server;
CREATE TABLE test_range_types (int4range int4range, int8range int8range,
numrange numrange, tsrange tsrange) USING cstore_tableam;
COPY test_range_types FROM '/Users/jefdavi/wd/cstore2/data/range_types.csv' WITH CSV;
@ -51,8 +51,8 @@ SELECT * FROM test_range_types;
-- Test other types
CREATE FOREIGN TABLE test_other_types (bool boolean, bytea bytea, money money,
inet inet, bitstring bit varying(5), uuid uuid, json json) SERVER cstore_server;
CREATE TABLE test_other_types (bool boolean, bytea bytea, money money,
inet inet, bitstring bit varying(5), uuid uuid, json json) USING cstore_tableam;
COPY test_other_types FROM '/Users/jefdavi/wd/cstore2/data/other_types.csv' WITH CSV;
@ -60,8 +60,8 @@ SELECT * FROM test_other_types;
-- Test null values
CREATE FOREIGN TABLE test_null_values (a int, b int[], c composite_type)
SERVER cstore_server;
CREATE TABLE test_null_values (a int, b int[], c composite_type)
USING cstore_tableam;
COPY test_null_values FROM '/Users/jefdavi/wd/cstore2/data/null_values.csv' WITH CSV;

View File

@ -1,7 +1,7 @@
--
-- Tests the different DROP commands for cstore_fdw tables.
--
-- DROP FOREIGN TABL
-- DROP TABL
-- DROP SCHEMA
-- DROP EXTENSION
-- DROP DATABASE
@ -16,12 +16,12 @@
SELECT oid postgres_oid FROM pg_database WHERE datname = 'postgres' \gset
-- DROP cstore_fdw tables
DROP FOREIGN TABLE contestant;
DROP FOREIGN TABLE contestant_compressed;
DROP TABLE contestant;
DROP TABLE contestant_compressed;
-- Create a cstore_fdw table under a schema and drop it.
CREATE SCHEMA test_schema;
CREATE FOREIGN TABLE test_schema.test_table(data int) SERVER cstore_server;
CREATE TABLE test_schema.test_table(data int) USING cstore_tableam;
DROP SCHEMA test_schema CASCADE;
SELECT current_database() datname \gset
@ -29,19 +29,19 @@ SELECT current_database() datname \gset
CREATE DATABASE db_to_drop;
\c db_to_drop
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
CREATE USING cstore_tableam DATA WRAPPER cstore_fdw;
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
CREATE FOREIGN TABLE test_table(data int) SERVER cstore_server;
CREATE TABLE test_table(data int) USING cstore_tableam;
DROP EXTENSION cstore_fdw CASCADE;
-- test database drop
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
CREATE USING cstore_tableam DATA WRAPPER cstore_fdw;
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
CREATE FOREIGN TABLE test_table(data int) SERVER cstore_server;
CREATE TABLE test_table(data int) USING cstore_tableam;
\c :datname

View File

@ -2,8 +2,8 @@
-- Test utility functions for cstore_fdw tables.
--
CREATE FOREIGN TABLE empty_table (a int) SERVER cstore_server;
CREATE FOREIGN TABLE table_with_data (a int) SERVER cstore_server;
CREATE TABLE empty_table (a int) USING cstore_tableam;
CREATE TABLE table_with_data (a int) USING cstore_tableam;
CREATE TABLE non_cstore_table (a int);
COPY table_with_data FROM STDIN;
@ -15,6 +15,6 @@ COPY table_with_data FROM STDIN;
SELECT cstore_table_size('empty_table') < cstore_table_size('table_with_data');
SELECT cstore_table_size('non_cstore_table');
DROP FOREIGN TABLE empty_table;
DROP FOREIGN TABLE table_with_data;
DROP TABLE empty_table;
DROP TABLE table_with_data;
DROP TABLE non_cstore_table;

View File

@ -2,7 +2,7 @@
-- Testing insert on cstore_fdw tables.
--
CREATE FOREIGN TABLE test_insert_command (a int) SERVER cstore_server;
CREATE TABLE test_insert_command (a int) USING cstore_tableam;
-- test single row inserts fail
select count(*) from test_insert_command;
@ -37,8 +37,8 @@ CREATE TABLE test_long_text_hash AS
SELECT int_val, md5(text_val) AS hash
FROM test_long_text;
CREATE FOREIGN TABLE test_cstore_long_text(int_val int, text_val text)
SERVER cstore_server;
CREATE TABLE test_cstore_long_text(int_val int, text_val text)
USING cstore_tableam;
-- store long text in cstore table
INSERT INTO test_cstore_long_text SELECT * FROM test_long_text;
@ -53,4 +53,4 @@ FROM test_long_text_hash a, test_cstore_long_text c
WHERE a.int_val = c.int_val AND a.hash = md5(c.text_val);
DROP TABLE test_long_text_hash;
DROP FOREIGN TABLE test_cstore_long_text;
DROP TABLE test_cstore_long_text;

View File

@ -23,8 +23,8 @@ COPY contestant_compressed FROM PROGRAM 'cat /Users/jefdavi/wd/cstore2/data/cont
WITH CSV;
-- Test column list
CREATE FOREIGN TABLE famous_constants (id int, name text, value real)
SERVER cstore_server;
CREATE TABLE famous_constants (id int, name text, value real)
USING cstore_tableam;
COPY famous_constants (value, name, id) FROM STDIN WITH CSV;
3.141,pi,1
2.718,e,2
@ -41,4 +41,4 @@ speed of light,2.997e8
SELECT * FROM famous_constants ORDER BY id, name;
DROP FOREIGN TABLE famous_constants;
DROP TABLE famous_constants;

View File

@ -23,12 +23,12 @@ SELECT * FROM contestant_compressed ORDER BY handle;
SELECT to_json(v) FROM contestant v ORDER BY rating LIMIT 1;
-- Test variables used in expressions
CREATE FOREIGN TABLE union_first (a int, b int) SERVER cstore_server;
CREATE FOREIGN TABLE union_second (a int, b int) SERVER cstore_server;
CREATE TABLE union_first (a int, b int) USING cstore_tableam;
CREATE TABLE union_second (a int, b int) USING cstore_tableam;
INSERT INTO union_first SELECT a, a FROM generate_series(1, 5) a;
INSERT INTO union_second SELECT a, a FROM generate_series(11, 15) a;
(SELECT a*1, b FROM union_first) union all (SELECT a*1, b FROM union_second);
DROP FOREIGN TABLE union_first, union_second;
DROP TABLE union_first, union_second;

View File

@ -7,9 +7,9 @@ SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
-- CREATE a cstore_fdw table, fill with some data --
CREATE FOREIGN TABLE cstore_truncate_test (a int, b int) SERVER cstore_server;
CREATE FOREIGN TABLE cstore_truncate_test_second (a int, b int) SERVER cstore_server;
CREATE FOREIGN TABLE cstore_truncate_test_compressed (a int, b int) SERVER cstore_server OPTIONS (compression 'pglz');
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_compressed (a int, b int) USING cstore_tableam OPTIONS (compression 'pglz');
CREATE TABLE cstore_truncate_test_regular (a int, b int);
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
@ -70,13 +70,13 @@ SELECT cstore_truncate_test_regular_func();
SELECT cstore_truncate_test_regular_func();
DROP FUNCTION cstore_truncate_test_regular_func();
DROP FOREIGN TABLE cstore_truncate_test, cstore_truncate_test_second;
DROP TABLE cstore_truncate_test, cstore_truncate_test_second;
DROP TABLE cstore_truncate_test_regular;
DROP FOREIGN TABLE cstore_truncate_test_compressed;
DROP TABLE cstore_truncate_test_compressed;
-- test truncate with schema
CREATE SCHEMA truncate_schema;
CREATE FOREIGN TABLE truncate_schema.truncate_tbl (id int) SERVER cstore_server OPTIONS(compression 'pglz');
CREATE TABLE truncate_schema.truncate_tbl (id int) USING cstore_tableam OPTIONS(compression 'pglz');
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;

11
sql/clean.sql Normal file
View File

@ -0,0 +1,11 @@
DROP TABLE test_insert_command;
DROP TABLE collation_block_filtering_test;
DROP TABLE test_null_values;
DROP TABLE test_other_types;
DROP TABLE test_range_types;
DROP TABLE test_enum_and_composite_types;
DROP TYPE composite_type;
DROP TYPE enum_type;
DROP TABLE test_datetime_types;
DROP TABLE test_array_types;

4
sql/extension_create.sql Normal file
View File

@ -0,0 +1,4 @@
-- Install cstore_fdw
CREATE EXTENSION cstore_fdw;