Skip to content

Commit

Permalink
Merge pull request #1435 from citusdata/unlogged_tables
Browse files Browse the repository at this point in the history
Support unlogged tables
  • Loading branch information
marcocitus authored Jun 14, 2017
2 parents fdbfde4 + a6eb469 commit 5230914
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/backend/distributed/utils/citus_ruleutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,14 @@ pg_get_tableschemadef_string(Oid tableRelationId, bool includeSequenceDefaults)
initStringInfo(&buffer);
if (relationKind == RELKIND_RELATION)
{
appendStringInfo(&buffer, "CREATE TABLE %s (", relationName);
appendStringInfoString(&buffer, "CREATE ");

if (relation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
{
appendStringInfoString(&buffer, "UNLOGGED ");
}

appendStringInfo(&buffer, "TABLE %s (", relationName);
}
else
{
Expand Down
27 changes: 27 additions & 0 deletions src/test/regress/expected/multi_create_table.out
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,30 @@ SELECT create_distributed_table('orders_hash_part', 'o_orderkey');

(1 row)

CREATE UNLOGGED TABLE unlogged_table
(
key text,
value text
);
SELECT create_distributed_table('unlogged_table', 'key');
create_distributed_table
--------------------------

(1 row)

SELECT * FROM master_get_table_ddl_events('unlogged_table');
master_get_table_ddl_events
--------------------------------------------------------------------
CREATE UNLOGGED TABLE public.unlogged_table (key text, value text)
(1 row)

\c - - - :worker_1_port
SELECT relpersistence FROM pg_class WHERE relname LIKE 'unlogged_table_%';
relpersistence
----------------
u
u
u
u
(4 rows)

11 changes: 11 additions & 0 deletions src/test/regress/sql/multi_create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,14 @@ SELECT create_distributed_table('lineitem_hash_part', 'l_orderkey');

CREATE TABLE orders_hash_part (like orders);
SELECT create_distributed_table('orders_hash_part', 'o_orderkey');

CREATE UNLOGGED TABLE unlogged_table
(
key text,
value text
);
SELECT create_distributed_table('unlogged_table', 'key');
SELECT * FROM master_get_table_ddl_events('unlogged_table');

\c - - - :worker_1_port
SELECT relpersistence FROM pg_class WHERE relname LIKE 'unlogged_table_%';

0 comments on commit 5230914

Please sign in to comment.