Skip to content

Commit

Permalink
fix creating extension with global option appendonly=true (#19)
Browse files Browse the repository at this point in the history
All tables use primary keys. Unique index tables are created for primary keys.
Unique index tables can not be created for table with appendonly=true.
appendonly=false has been added for each table with primary key.
  • Loading branch information
red1452 authored Jun 5, 2023
1 parent eb6adf5 commit be945ba
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion control/ddl/diskquota--1.0--2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE diskquota.target (
primaryOid oid,
tablespaceOid oid, -- REFERENCES pg_tablespace.oid,
PRIMARY KEY (primaryOid, tablespaceOid, quotatype)
);
) WITH (appendonly=false);
-- TODO ALTER TABLE diskquota.target SET DEPENDS ON EXTENSION diskquota;

ALTER TABLE diskquota.table_size ADD COLUMN segid smallint DEFAULT -1; -- segid = coordinator means table size in cluster level
Expand Down
2 changes: 1 addition & 1 deletion control/ddl/diskquota--1.0.3--2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE diskquota.target (
primaryOid oid,
tablespaceOid oid, -- REFERENCES pg_tablespace.oid,
PRIMARY KEY (primaryOid, tablespaceOid, quotatype)
);
) WITH (appendonly=false);
-- TODO ALTER TABLE diskquota.target SET DEPENDS ON EXTENSION diskquota;

ALTER TABLE diskquota.table_size ADD COLUMN segid smallint DEFAULT -1; -- segid = coordinator means table size in cluster level
Expand Down
6 changes: 3 additions & 3 deletions control/ddl/diskquota--1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ CREATE TABLE diskquota.quota_config(
quotatype int,
quotalimitMB int8,
PRIMARY KEY(targetOid, quotatype)
);
) WITH (appendonly=false);

CREATE TABLE diskquota.table_size(
tableid oid,
size bigint,
PRIMARY KEY(tableid)
);
) WITH (appendonly=false);

CREATE TABLE diskquota.state(
state int,
PRIMARY KEY(state)
);
) WITH (appendonly=false);

-- only diskquota.quota_config is dump-able, other table can be generate on fly
SELECT pg_catalog.pg_extension_config_dump('diskquota.quota_config', '');
Expand Down
8 changes: 4 additions & 4 deletions control/ddl/diskquota--2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ CREATE TABLE diskquota.quota_config(
quotalimitMB int8,
segratio float4 DEFAULT 0,
PRIMARY KEY(targetOid, quotatype)
) DISTRIBUTED BY (targetOid, quotatype);
) WITH (appendonly=false) DISTRIBUTED BY (targetOid, quotatype);

CREATE TABLE diskquota.target (
rowId serial,
quotatype int, --REFERENCES disquota.quota_config.quotatype,
primaryOid oid,
tablespaceOid oid, --REFERENCES pg_tablespace.oid,
PRIMARY KEY (primaryOid, tablespaceOid, quotatype)
);
) WITH (appendonly=false);

CREATE TABLE diskquota.table_size(
tableid oid,
size bigint,
segid smallint,
PRIMARY KEY(tableid, segid)
) DISTRIBUTED BY (tableid, segid);
) WITH (appendonly=false) DISTRIBUTED BY (tableid, segid);

CREATE TABLE diskquota.state(
state int,
PRIMARY KEY(state)
) DISTRIBUTED BY (state);
) WITH (appendonly=false) DISTRIBUTED BY (state);

-- diskquota.quota_config AND diskquota.target is dump-able, other table can be generate on fly
SELECT pg_catalog.pg_extension_config_dump('diskquota.quota_config', '');
Expand Down
8 changes: 4 additions & 4 deletions control/ddl/diskquota--2.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ CREATE TABLE diskquota.quota_config(
quotalimitMB int8,
segratio float4 DEFAULT 0,
PRIMARY KEY(targetOid, quotatype)
) DISTRIBUTED BY (targetOid, quotatype);
) WITH (appendonly=false) DISTRIBUTED BY (targetOid, quotatype);

CREATE TABLE diskquota.target (
rowId serial,
quotatype int, --REFERENCES disquota.quota_config.quotatype,
primaryOid oid,
tablespaceOid oid, --REFERENCES pg_tablespace.oid,
PRIMARY KEY (primaryOid, tablespaceOid, quotatype)
);
) WITH (appendonly=false);

CREATE TABLE diskquota.table_size(
tableid oid,
size bigint,
segid smallint,
PRIMARY KEY(tableid, segid)
) DISTRIBUTED BY (tableid, segid);
) WITH (appendonly=false) DISTRIBUTED BY (tableid, segid);

CREATE TABLE diskquota.state(
state int,
PRIMARY KEY(state)
) DISTRIBUTED BY (state);
) WITH (appendonly=false) DISTRIBUTED BY (state);

-- diskquota.quota_config AND diskquota.target is dump-able, other table can be generate on fly
SELECT pg_catalog.pg_extension_config_dump('diskquota.quota_config', '');
Expand Down
8 changes: 4 additions & 4 deletions control/ddl/diskquota--2.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ CREATE TABLE diskquota.quota_config(
quotalimitMB int8,
segratio float4 DEFAULT 0,
PRIMARY KEY(targetOid, quotatype)
) DISTRIBUTED BY (targetOid, quotatype);
) WITH (appendonly=false) DISTRIBUTED BY (targetOid, quotatype);

CREATE TABLE diskquota.target (
rowId serial,
quotatype int, --REFERENCES disquota.quota_config.quotatype,
primaryOid oid,
tablespaceOid oid, --REFERENCES pg_tablespace.oid,
PRIMARY KEY (primaryOid, tablespaceOid, quotatype)
);
) WITH (appendonly=false);

CREATE TABLE diskquota.table_size(
tableid oid,
size bigint,
segid smallint,
PRIMARY KEY(tableid, segid)
) DISTRIBUTED BY (tableid, segid);
) WITH (appendonly=false) DISTRIBUTED BY (tableid, segid);

CREATE TABLE diskquota.state(
state int,
PRIMARY KEY(state)
) DISTRIBUTED BY (state);
) WITH (appendonly=false) DISTRIBUTED BY (state);

-- diskquota.quota_config AND diskquota.target is dump-able, other table can be generate on fly
SELECT pg_catalog.pg_extension_config_dump('diskquota.quota_config', '');
Expand Down
13 changes: 13 additions & 0 deletions tests/isolation2/expected/test_create_extension.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
-- check that diskquota ignores global flag appendonly=true

SET gp_default_storage_options='appendonly=true';
SET

CREATE EXTENSION diskquota;
CREATE
DROP EXTENSION diskquota;
DROP

SET gp_default_storage_options='appendonly=false';
SET

CREATE EXTENSION diskquota;
CREATE

Expand Down
9 changes: 9 additions & 0 deletions tests/isolation2/sql/test_create_extension.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- check that diskquota ignores global flag appendonly=true

SET gp_default_storage_options='appendonly=true';

CREATE EXTENSION diskquota;
DROP EXTENSION diskquota;

SET gp_default_storage_options='appendonly=false';

CREATE EXTENSION diskquota;

SELECT diskquota.init_table_size_table();
Expand Down
5 changes: 5 additions & 0 deletions tests/regress/expected/test_create_extension.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-- check that diskquota ignores global flag appendonly=true
SET gp_default_storage_options='appendonly=true';
CREATE EXTENSION diskquota;
DROP EXTENSION diskquota;
SET gp_default_storage_options='appendonly=false';
CREATE EXTENSION diskquota;
SELECT diskquota.init_table_size_table();
init_table_size_table
Expand Down
9 changes: 9 additions & 0 deletions tests/regress/sql/test_create_extension.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- check that diskquota ignores global flag appendonly=true

SET gp_default_storage_options='appendonly=true';

CREATE EXTENSION diskquota;
DROP EXTENSION diskquota;

SET gp_default_storage_options='appendonly=false';

CREATE EXTENSION diskquota;

SELECT diskquota.init_table_size_table();
Expand Down

0 comments on commit be945ba

Please sign in to comment.