diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 22402b9af..e725dc0b0 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -50,6 +50,7 @@ static void RecordDistributedRelationDependencies(Oid distributedRelationId, static Oid SupportFunctionForColumn(Var *partitionColumn, Oid accessMethodId, int16 supportFunctionNumber); static bool LocalTableEmpty(Oid tableId); +static void ErrorIfTableHasOids(Relation relation); /* exports for SQL callable functions */ @@ -101,6 +102,7 @@ master_create_distributed_table(PG_FUNCTION_ARGS) distributedRelationName = RelationGetRelationName(distributedRelation); EnsureTableOwner(distributedRelationId); + ErrorIfTableHasOids(distributedRelation); /* open system catalog and insert new tuple */ pgDistPartition = heap_open(DistPartitionRelationId(), RowExclusiveLock); @@ -446,3 +448,18 @@ LocalTableEmpty(Oid tableId) return localTableEmpty; } + + +/* + * ErrorIfTableHasOids raises an ERROR if a to-be-distributed table + * has the WITH (OIDS) option set. + */ +static void +ErrorIfTableHasOids(Relation relation) +{ + if (relation->rd_att->tdhasoid) + { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH (OIDS) not supported on distributed tables"))); + } +} diff --git a/src/test/regress/expected/multi_create_shards.out b/src/test/regress/expected/multi_create_shards.out index cf3dfc3cd..bc7629380 100644 --- a/src/test/regress/expected/multi_create_shards.out +++ b/src/test/regress/expected/multi_create_shards.out @@ -40,6 +40,12 @@ CREATE TABLE table_to_distribute ( json_data json, test_type_data dummy_type ); +-- use the table WITH (OIDS) set +ALTER TABLE table_to_distribute SET WITH OIDS; +SELECT master_create_distributed_table('table_to_distribute', 'id', 'hash'); +ERROR: WITH (OIDS) not supported on distributed tables +-- revert WITH (OIDS) from above +ALTER TABLE table_to_distribute SET WITHOUT OIDS; -- use an index instead of table name SELECT master_create_distributed_table('table_to_distribute_pkey', 'id', 'hash'); ERROR: cannot distribute relation: table_to_distribute_pkey diff --git a/src/test/regress/sql/multi_create_shards.sql b/src/test/regress/sql/multi_create_shards.sql index c5e38fa63..b49f0c0f4 100644 --- a/src/test/regress/sql/multi_create_shards.sql +++ b/src/test/regress/sql/multi_create_shards.sql @@ -52,6 +52,13 @@ CREATE TABLE table_to_distribute ( test_type_data dummy_type ); +-- use the table WITH (OIDS) set +ALTER TABLE table_to_distribute SET WITH OIDS; +SELECT master_create_distributed_table('table_to_distribute', 'id', 'hash'); + +-- revert WITH (OIDS) from above +ALTER TABLE table_to_distribute SET WITHOUT OIDS; + -- use an index instead of table name SELECT master_create_distributed_table('table_to_distribute_pkey', 'id', 'hash');