aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/utility.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-01-01 23:48:11 -0500
committerRobert Haas <rhaas@postgresql.org>2011-01-01 23:48:11 -0500
commit0d692a0dc9f0e532c67c577187fe5d7d323cb95b (patch)
tree5177be3794b8ffa768a3cd852221425bd2a74347 /src/backend/tcop/utility.c
parent6600d5e91c754789002ed794c18cb856c190f58f (diff)
downloadpostgresql-0d692a0dc9f0e532c67c577187fe5d7d323cb95b.tar.gz
postgresql-0d692a0dc9f0e532c67c577187fe5d7d323cb95b.zip
Basic foreign table support.
Foreign tables are a core component of SQL/MED. This commit does not provide a working SQL/MED infrastructure, because foreign tables cannot yet be queried. Support for foreign table scans will need to be added in a future patch. However, this patch creates the necessary system catalog structure, syntax support, and support for ancillary operations such as COMMENT and SECURITY LABEL. Shigeru Hanada, heavily revised by Robert Haas
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r--src/backend/tcop/utility.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index f4e41a17652..95000377704 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -220,6 +220,7 @@ check_xact_readonly(Node *parsetree)
case T_AlterUserMappingStmt:
case T_DropUserMappingStmt:
case T_AlterTableSpaceOptionsStmt:
+ case T_CreateForeignTableStmt:
case T_SecLabelStmt:
PreventCommandIfReadOnly(CreateCommandTag(parsetree));
break;
@@ -492,6 +493,7 @@ standard_ProcessUtility(Node *parsetree,
break;
case T_CreateStmt:
+ case T_CreateForeignTableStmt:
{
List *stmts;
ListCell *l;
@@ -540,6 +542,22 @@ standard_ProcessUtility(Node *parsetree,
AlterTableCreateToastTable(relOid, toast_options);
}
+ else if (IsA(stmt, CreateForeignTableStmt))
+ {
+ /* Create the table itself */
+ relOid = DefineRelation((CreateStmt *) stmt,
+ RELKIND_FOREIGN_TABLE,
+ InvalidOid);
+
+ /*
+ * Unless "IF NOT EXISTS" was specified and the
+ * relation already exists, create the pg_foreign_table
+ * entry.
+ */
+ if (relOid != InvalidOid)
+ CreateForeignTable((CreateForeignTableStmt *) stmt,
+ relOid);
+ }
else
{
/* Recurse for anything else */
@@ -618,6 +636,7 @@ standard_ProcessUtility(Node *parsetree,
case OBJECT_SEQUENCE:
case OBJECT_VIEW:
case OBJECT_INDEX:
+ case OBJECT_FOREIGN_TABLE:
RemoveRelations(stmt);
break;
@@ -1557,6 +1576,10 @@ CreateCommandTag(Node *parsetree)
tag = "DROP USER MAPPING";
break;
+ case T_CreateForeignTableStmt:
+ tag = "CREATE FOREIGN TABLE";
+ break;
+
case T_DropStmt:
switch (((DropStmt *) parsetree)->removeType)
{
@@ -1596,6 +1619,9 @@ CreateCommandTag(Node *parsetree)
case OBJECT_TSCONFIGURATION:
tag = "DROP TEXT SEARCH CONFIGURATION";
break;
+ case OBJECT_FOREIGN_TABLE:
+ tag = "DROP FOREIGN TABLE";
+ break;
default:
tag = "???";
}
@@ -1654,6 +1680,14 @@ CreateCommandTag(Node *parsetree)
tag = "ALTER SEQUENCE";
break;
case OBJECT_COLUMN:
+ {
+ RenameStmt *stmt = (RenameStmt *) parsetree;
+ if (stmt->relationType == OBJECT_FOREIGN_TABLE)
+ tag = "ALTER FOREIGN TABLE";
+ else
+ tag = "ALTER TABLE";
+ }
+ break;
case OBJECT_TABLE:
tag = "ALTER TABLE";
break;
@@ -1666,6 +1700,9 @@ CreateCommandTag(Node *parsetree)
case OBJECT_VIEW:
tag = "ALTER VIEW";
break;
+ case OBJECT_FOREIGN_TABLE:
+ tag = "ALTER FOREIGN TABLE";
+ break;
case OBJECT_TSPARSER:
tag = "ALTER TEXT SEARCH PARSER";
break;
@@ -1736,6 +1773,9 @@ CreateCommandTag(Node *parsetree)
case OBJECT_VIEW:
tag = "ALTER VIEW";
break;
+ case OBJECT_FOREIGN_TABLE:
+ tag = "ALTER FOREIGN TABLE";
+ break;
default:
tag = "???";
break;
@@ -1796,6 +1836,9 @@ CreateCommandTag(Node *parsetree)
case OBJECT_FOREIGN_SERVER:
tag = "ALTER SERVER";
break;
+ case OBJECT_FOREIGN_TABLE:
+ tag = "ALTER FOREIGN TABLE";
+ break;
default:
tag = "???";
break;
@@ -1820,6 +1863,9 @@ CreateCommandTag(Node *parsetree)
case OBJECT_VIEW:
tag = "ALTER VIEW";
break;
+ case OBJECT_FOREIGN_TABLE:
+ tag = "ALTER FOREIGN TABLE";
+ break;
default:
tag = "???";
break;
@@ -2316,6 +2362,7 @@ GetCommandLogLevel(Node *parsetree)
break;
case T_CreateStmt:
+ case T_CreateForeignTableStmt:
lev = LOGSTMT_DDL;
break;