File tree Expand file tree Collapse file tree 6 files changed +89
-1
lines changed Expand file tree Collapse file tree 6 files changed +89
-1
lines changed Original file line number Diff line number Diff line change @@ -1291,6 +1291,24 @@ process_altertable_start_table(Node *parsetree)
12911291 if (ht != NULL )
12921292 process_alter_column_type_start (ht , cmd );
12931293 break ;
1294+ #if PG10
1295+ case AT_AttachPartition :
1296+ {
1297+ RangeVar * relation ;
1298+ PartitionCmd * partstmt ;
1299+
1300+ partstmt = (PartitionCmd * ) cmd -> def ;
1301+ relation = partstmt -> name ;
1302+ Assert (NULL != relation );
1303+
1304+ if (InvalidOid != hypertable_relid (relation ))
1305+ {
1306+ ereport (ERROR ,
1307+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1308+ errmsg ("Hypertables do not support native postgres partitioning" )));
1309+ }
1310+ }
1311+ #endif
12941312 default :
12951313 break ;
12961314 }
Original file line number Diff line number Diff line change 1+ -- Should expect an error when creating a hypertable from a partition
2+ \set ON_ERROR_STOP 0
3+ CREATE TABLE partitioned_ht_create(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
4+ SELECT create_hypertable('partitioned_ht_create', 'time');
5+ ERROR: table public.partitioned_ht_create is already partitioned
6+ \set ON_ERROR_STOP 1
7+ -- Should expect an error when attaching a hypertable to a partition
8+ \set ON_ERROR_STOP 0
9+ CREATE TABLE partitioned_attachment_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
10+ CREATE TABLE attachment_hypertable(time timestamptz, temp float, device int);
11+ SELECT create_hypertable('attachment_hypertable', 'time');
12+ NOTICE: Adding NOT NULL constraint to time column time (NULL time values not allowed)
13+ create_hypertable
14+ -------------------
15+
16+ (1 row)
17+
18+ ALTER TABLE partitioned_attachment_vanilla ATTACH PARTITION attachment_hypertable FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
19+ ERROR: Hypertables do not support native postgres partitioning
20+ \set ON_ERROR_STOP 1
21+ -- Should not expect an error when attaching a normal table to a partition
22+ CREATE TABLE partitioned_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
23+ CREATE TABLE attachment_vanilla(time timestamptz, temp float, device int);
24+ ALTER TABLE partitioned_vanilla ATTACH PARTITION attachment_vanilla FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
Original file line number Diff line number Diff line change 1+ -- Should expect an error when creating a hypertable from a partition
2+ \set ON_ERROR_STOP 0
3+ CREATE TABLE partitioned_ht_create(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
4+ ERROR: syntax error at or near "PARTITION" at character 78
5+ SELECT create_hypertable('partitioned_ht_create', 'time');
6+ ERROR: relation "partitioned_ht_create" does not exist at character 26
7+ \set ON_ERROR_STOP 1
8+ -- Should expect an error when attaching a hypertable to a partition
9+ \set ON_ERROR_STOP 0
10+ CREATE TABLE partitioned_attachment_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
11+ ERROR: syntax error at or near "PARTITION" at character 87
12+ CREATE TABLE attachment_hypertable(time timestamptz, temp float, device int);
13+ SELECT create_hypertable('attachment_hypertable', 'time');
14+ NOTICE: Adding NOT NULL constraint to time column time (NULL time values not allowed)
15+ create_hypertable
16+ -------------------
17+
18+ (1 row)
19+
20+ ALTER TABLE partitioned_attachment_vanilla ATTACH PARTITION attachment_hypertable FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
21+ ERROR: syntax error at or near "ATTACH" at character 44
22+ \set ON_ERROR_STOP 1
23+ -- Should not expect an error when attaching a normal table to a partition
24+ CREATE TABLE partitioned_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
25+ ERROR: syntax error at or near "PARTITION" at character 76
Original file line number Diff line number Diff line change 11/parallel-9.6.sql
22/parallel-10.0.sql
3+ /partitioning-9.6.sql
4+ /partitioning-10.sql
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ set(TEST_FILES
4949 version .sql)
5050
5151set (TEST_TEMPLATES
52- parallel.sql.in)
52+ parallel.sql.in
53+ partitioning.sql.in)
5354
5455# Regression tests that vary with PostgreSQL version. Generated test
5556# files are put in the original source directory since all tests must
Original file line number Diff line number Diff line change 1+ -- Should expect an error when creating a hypertable from a partition
2+ \set ON_ERROR_STOP 0
3+ CREATE TABLE partitioned_ht_create(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
4+ SELECT create_hypertable('partitioned_ht_create', 'time');
5+ \set ON_ERROR_STOP 1
6+
7+ -- Should expect an error when attaching a hypertable to a partition
8+ \set ON_ERROR_STOP 0
9+ CREATE TABLE partitioned_attachment_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
10+ CREATE TABLE attachment_hypertable(time timestamptz, temp float, device int);
11+ SELECT create_hypertable('attachment_hypertable', 'time');
12+ ALTER TABLE partitioned_attachment_vanilla ATTACH PARTITION attachment_hypertable FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
13+ \set ON_ERROR_STOP 1
14+
15+ -- Should not expect an error when attaching a normal table to a partition
16+ CREATE TABLE partitioned_vanilla(time timestamptz, temp float, device int) PARTITION BY RANGE (time);
17+ CREATE TABLE attachment_vanilla(time timestamptz, temp float, device int);
18+ ALTER TABLE partitioned_vanilla ATTACH PARTITION attachment_vanilla FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
You can’t perform that action at this time.
0 commit comments