diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 7c229cc55..224abc7cc 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -133,7 +133,13 @@ master_create_distributed_table(PG_FUNCTION_ARGS) * sense of this table until we've committed, and we don't want multiple * backends manipulating this relation. */ - relation = relation_open(relationId, ExclusiveLock); + relation = try_relation_open(relationId, ExclusiveLock); + + if (relation == NULL) + { + ereport(ERROR, (errmsg("could not create distributed table: " + "relation does not exist"))); + } /* * We should do this check here since the codes in the following lines rely @@ -191,7 +197,13 @@ create_distributed_table(PG_FUNCTION_ARGS) * sense of this table until we've committed, and we don't want multiple * backends manipulating this relation. */ - relation = relation_open(relationId, ExclusiveLock); + relation = try_relation_open(relationId, ExclusiveLock); + + if (relation == NULL) + { + ereport(ERROR, (errmsg("could not create distributed table: " + "relation does not exist"))); + } /* * We should do this check here since the codes in the following lines rely diff --git a/src/test/regress/expected/isolation_drop_vs_all.out b/src/test/regress/expected/isolation_drop_vs_all.out index 4857572e1..66b09721b 100644 --- a/src/test/regress/expected/isolation_drop_vs_all.out +++ b/src/test/regress/expected/isolation_drop_vs_all.out @@ -213,7 +213,7 @@ step s1-drop: DROP TABLE drop_hash; step s2-distribute-table: SELECT create_distributed_table('drop_hash', 'id'); step s1-commit: COMMIT; step s2-distribute-table: <... completed> -error in steps s1-commit s2-distribute-table: ERROR: could not open relation with OID 23249 +error in steps s1-commit s2-distribute-table: ERROR: could not create distributed table: relation does not exist step s2-commit: COMMIT; step s1-select-count: SELECT COUNT(*) FROM drop_hash; ERROR: relation "drop_hash" does not exist diff --git a/src/test/regress/expected/isolation_drop_vs_all_0.out b/src/test/regress/expected/isolation_drop_vs_all_0.out index c2ff87489..66b09721b 100644 --- a/src/test/regress/expected/isolation_drop_vs_all_0.out +++ b/src/test/regress/expected/isolation_drop_vs_all_0.out @@ -213,7 +213,7 @@ step s1-drop: DROP TABLE drop_hash; step s2-distribute-table: SELECT create_distributed_table('drop_hash', 'id'); step s1-commit: COMMIT; step s2-distribute-table: <... completed> -error in steps s1-commit s2-distribute-table: ERROR: could not open relation with OID 22205 +error in steps s1-commit s2-distribute-table: ERROR: could not create distributed table: relation does not exist step s2-commit: COMMIT; step s1-select-count: SELECT COUNT(*) FROM drop_hash; ERROR: relation "drop_hash" does not exist