summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2015-06-26 21:17:54 +0000
committerAlvaro Herrera2015-06-26 21:17:54 +0000
commit7d60b2af34842ae89b1abdd31fb5d303bd43c514 (patch)
tree73fd808ab5ec9c45bd4de98ec8cbf46bec812a90
parent402822246866e1094d35a617775a65b4be93d322 (diff)
Fix DDL command collection for TRANSFORM
Commit b488c580ae, which added the DDL command collection feature, neglected to update the code that commit cac76582053e had previously added two weeks earlier for the TRANSFORM feature. Reported by Michael Paquier.
-rw-r--r--src/backend/commands/functioncmds.c4
-rw-r--r--src/backend/tcop/utility.c2
-rw-r--r--src/include/commands/defrem.h2
-rw-r--r--src/test/modules/test_ddl_deparse/Makefile1
-rw-r--r--src/test/modules/test_ddl_deparse/expected/create_transform.out13
-rw-r--r--src/test/modules/test_ddl_deparse/sql/create_transform.sql14
6 files changed, 32 insertions, 4 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 4accf767bb..dbbb2d3f88 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1740,7 +1740,7 @@ check_transform_function(Form_pg_proc procstruct)
/*
* CREATE TRANSFORM
*/
-Oid
+ObjectAddress
CreateTransform(CreateTransformStmt *stmt)
{
Oid typeid;
@@ -1938,7 +1938,7 @@ CreateTransform(CreateTransformStmt *stmt)
heap_close(relation, RowExclusiveLock);
- return transformid;
+ return myself;
}
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 7db9f96fdf..0dabcc130e 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -1438,7 +1438,7 @@ ProcessUtilitySlow(Node *parsetree,
break;
case T_CreateTransformStmt:
- CreateTransform((CreateTransformStmt *) parsetree);
+ address = CreateTransform((CreateTransformStmt *) parsetree);
break;
case T_AlterOpFamilyStmt:
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index dcb6c082c5..9b81c16d82 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -51,7 +51,7 @@ extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType);
extern ObjectAddress AlterFunction(AlterFunctionStmt *stmt);
extern ObjectAddress CreateCast(CreateCastStmt *stmt);
extern void DropCastById(Oid castOid);
-extern Oid CreateTransform(CreateTransformStmt *stmt);
+extern ObjectAddress CreateTransform(CreateTransformStmt *stmt);
extern void DropTransformById(Oid transformOid);
extern void IsThereFunctionInNamespace(const char *proname, int pronargs,
oidvector *proargtypes, Oid nspOid);
diff --git a/src/test/modules/test_ddl_deparse/Makefile b/src/test/modules/test_ddl_deparse/Makefile
index 13b985a296..8ea6f39afd 100644
--- a/src/test/modules/test_ddl_deparse/Makefile
+++ b/src/test/modules/test_ddl_deparse/Makefile
@@ -15,6 +15,7 @@ REGRESS = test_ddl_deparse \
create_domain \
create_sequence_1 \
create_table \
+ create_transform \
alter_table \
create_view \
create_trigger \
diff --git a/src/test/modules/test_ddl_deparse/expected/create_transform.out b/src/test/modules/test_ddl_deparse/expected/create_transform.out
new file mode 100644
index 0000000000..0d1cc360f4
--- /dev/null
+++ b/src/test/modules/test_ddl_deparse/expected/create_transform.out
@@ -0,0 +1,13 @@
+--
+-- CREATE_TRANSFORM
+--
+-- Create a dummy transform
+-- The function FROM SQL should have internal as single argument as well
+-- as return type. The function TO SQL should have as single argument
+-- internal and as return argument the datatype of the transform done.
+-- pl/plpgsql does not authorize the use of internal as data type.
+CREATE TRANSFORM FOR int LANGUAGE SQL (
+ FROM SQL WITH FUNCTION varchar_transform(internal),
+ TO SQL WITH FUNCTION int4recv(internal));
+NOTICE: DDL test: type simple, tag CREATE TRANSFORM
+DROP TRANSFORM FOR int LANGUAGE SQL;
diff --git a/src/test/modules/test_ddl_deparse/sql/create_transform.sql b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
new file mode 100644
index 0000000000..096870233f
--- /dev/null
+++ b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
@@ -0,0 +1,14 @@
+--
+-- CREATE_TRANSFORM
+--
+
+-- Create a dummy transform
+-- The function FROM SQL should have internal as single argument as well
+-- as return type. The function TO SQL should have as single argument
+-- internal and as return argument the datatype of the transform done.
+-- pl/plpgsql does not authorize the use of internal as data type.
+CREATE TRANSFORM FOR int LANGUAGE SQL (
+ FROM SQL WITH FUNCTION varchar_transform(internal),
+ TO SQL WITH FUNCTION int4recv(internal));
+
+DROP TRANSFORM FOR int LANGUAGE SQL;