File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,11 @@ SELECT CAST ( 2 AS numeric ) + 4.0;
288
288
convert between data types and a second to apply the modifier.
289
289
</para>
290
290
291
+ <para>
292
+ A cast to or from a domain type currently has no effect. Casting
293
+ to or from a domain uses the casts associated with its underlying type.
294
+ </para>
295
+
291
296
</refsect1>
292
297
293
298
<refsect1 id="sql-createcast-notes">
Original file line number Diff line number Diff line change @@ -1517,6 +1517,17 @@ CreateCast(CreateCastStmt *stmt)
1517
1517
aclcheck_error (aclresult , ACL_KIND_TYPE ,
1518
1518
format_type_be (targettypeid ));
1519
1519
1520
+ /* Domains are allowed for historical reasons, but we warn */
1521
+ if (sourcetyptype == TYPTYPE_DOMAIN )
1522
+ ereport (WARNING ,
1523
+ (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
1524
+ errmsg ("cast will be ignored because the source data type is a domain" )));
1525
+
1526
+ else if (targettyptype == TYPTYPE_DOMAIN )
1527
+ ereport (WARNING ,
1528
+ (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
1529
+ errmsg ("cast will be ignored because the target data type is a domain" )));
1530
+
1520
1531
/* Detemine the cast method */
1521
1532
if (stmt -> func != NULL )
1522
1533
castmethod = COERCION_METHOD_FUNCTION ;
Original file line number Diff line number Diff line change @@ -571,6 +571,7 @@ CREATE DOMAIN testdomain2b AS testdomain1;
571
571
CREATE DOMAIN testdomain3b AS int;
572
572
CREATE FUNCTION castfunc(int) RETURNS testdomain3b AS $$ SELECT $1::testdomain3b $$ LANGUAGE SQL;
573
573
CREATE CAST (testdomain1 AS testdomain3b) WITH FUNCTION castfunc(int);
574
+ WARNING: cast will be ignored because the source data type is a domain
574
575
CREATE FUNCTION testfunc5b(a testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
575
576
CREATE FUNCTION testfunc6b(b int) RETURNS testdomain1 LANGUAGE SQL AS $$ SELECT $1::testdomain1 $$;
576
577
CREATE OPERATOR !! (PROCEDURE = testfunc5b, RIGHTARG = testdomain1);
You can’t perform that action at this time.
0 commit comments