From 68ef051f5cf16f82a5368067a40ffba3c340b0d3 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 25 Apr 2011 16:55:11 -0400 Subject: Refactor broken CREATE TABLE IF NOT EXISTS support. Per bug #5988, reported by Marko Tiikkaja, and further analyzed by Tom Lane, the previous coding was broken in several respects: even if the target table already existed, a subsequent CREATE TABLE IF NOT EXISTS might try to add additional constraints or sequences-for-serial specified in the new CREATE TABLE statement. In passing, this also fixes a minor information leak: it's no longer possible to figure out whether a schema to which you don't have CREATE access contains a sequence named like "x_y_seq" by attempting to create a table in that schema called "x" with a serial column called "y". Some more refactoring of this code in the future might be warranted, but that will need to wait for a later major release. --- src/include/catalog/heap.h | 3 +-- src/include/catalog/namespace.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/include/catalog') diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 463aff0358f..c95e91303b8 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -63,8 +63,7 @@ extern Oid heap_create_with_catalog(const char *relname, OnCommitAction oncommit, Datum reloptions, bool use_user_acl, - bool allow_system_table_mods, - bool if_not_exists); + bool allow_system_table_mods); extern void heap_drop_with_catalog(Oid relid); diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h index f59beee80dd..53600969ad7 100644 --- a/src/include/catalog/namespace.h +++ b/src/include/catalog/namespace.h @@ -49,6 +49,7 @@ typedef struct OverrideSearchPath extern Oid RangeVarGetRelid(const RangeVar *relation, bool failOK); extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation); +extern Oid RangeVarGetAndCheckCreationNamespace(const RangeVar *newRelation); extern Oid RelnameGetRelid(const char *relname); extern bool RelationIsVisible(Oid relid); -- cgit v1.2.3