aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2008-10-31 08:39:22 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2008-10-31 08:39:22 +0000
commit092bc4965378840479e0250ae679e1d8e86577ee (patch)
tree12c24eea593d31739af864d8665553be6d33426c /src/backend/commands/functioncmds.c
parent34e37d58ed138bca3f7f0c799fdc1bb7bbc3d402 (diff)
downloadpostgresql-092bc4965378840479e0250ae679e1d8e86577ee.tar.gz
postgresql-092bc4965378840479e0250ae679e1d8e86577ee.zip
Add support for user-defined I/O conversion casts.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 12762b8aaab..80a57457ee5 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.99 2008/10/21 10:38:51 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.100 2008/10/31 08:39:20 heikki Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -1383,6 +1383,7 @@ CreateCast(CreateCastStmt *stmt)
Oid funcid;
int nargs;
char castcontext;
+ char castmethod;
Relation relation;
HeapTuple tuple;
Datum values[Natts_pg_cast];
@@ -1415,7 +1416,15 @@ CreateCast(CreateCastStmt *stmt)
format_type_be(sourcetypeid),
format_type_be(targettypeid))));
+ /* Detemine the cast method */
if (stmt->func != NULL)
+ castmethod = COERCION_METHOD_FUNCTION;
+ else if(stmt->inout)
+ castmethod = COERCION_METHOD_INOUT;
+ else
+ castmethod = COERCION_METHOD_BINARY;
+
+ if (castmethod == COERCION_METHOD_FUNCTION)
{
Form_pg_proc procstruct;
@@ -1476,6 +1485,12 @@ CreateCast(CreateCastStmt *stmt)
}
else
{
+ funcid = InvalidOid;
+ nargs = 0;
+ }
+
+ if (castmethod == COERCION_METHOD_BINARY)
+ {
int16 typ1len;
int16 typ2len;
bool typ1byval;
@@ -1483,10 +1498,6 @@ CreateCast(CreateCastStmt *stmt)
char typ1align;
char typ2align;
- /* indicates binary coercibility */
- funcid = InvalidOid;
- nargs = 0;
-
/*
* Must be superuser to create binary-compatible casts, since
* erroneous casts can easily crash the backend.
@@ -1562,6 +1573,7 @@ CreateCast(CreateCastStmt *stmt)
values[Anum_pg_cast_casttarget - 1] = ObjectIdGetDatum(targettypeid);
values[Anum_pg_cast_castfunc - 1] = ObjectIdGetDatum(funcid);
values[Anum_pg_cast_castcontext - 1] = CharGetDatum(castcontext);
+ values[Anum_pg_cast_castmethod - 1] = CharGetDatum(castmethod);
MemSet(nulls, ' ', Natts_pg_cast);