&funcId);
if (pathtype != COERCION_PATH_NONE)
{
+ Oid baseTypeId;
+ int32 baseTypeMod;
+
+ baseTypeMod = targetTypeMod;
+ baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
+
if (pathtype != COERCION_PATH_RELABELTYPE)
{
/*
* and we need to extract the correct typmod to use from the
* domain's typtypmod.
*/
- Oid baseTypeId;
- int32 baseTypeMod;
-
- baseTypeMod = targetTypeMod;
- baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
-
result = build_coercion_expression(node, pathtype, funcId,
baseTypeId, baseTypeMod,
ccontext, cformat, location);
* that must be accounted for. If the destination is a domain
* then we won't need a RelabelType node.
*/
- result = coerce_to_domain(node, InvalidOid, -1, targetTypeId,
+ result = coerce_to_domain(node, baseTypeId, baseTypeMod,
+ targetTypeId,
ccontext, cformat, location,
false);
if (result == node)
* Create an expression tree to represent coercion to a domain type.
*
* 'arg': input expression
- * 'baseTypeId': base type of domain, if known (pass InvalidOid if caller
- * has not bothered to look this up)
- * 'baseTypeMod': base type typmod of domain, if known (pass -1 if caller
- * has not bothered to look this up)
+ * 'baseTypeId': base type of domain
+ * 'baseTypeMod': base type typmod of domain
* 'typeId': target type to coerce to
* 'ccontext': context indicator to control coercions
* 'cformat': coercion display format
{
CoerceToDomain *result;
- /* Get the base type if it hasn't been supplied */
- if (baseTypeId == InvalidOid)
- baseTypeId = getBaseTypeAndTypmod(typeId, &baseTypeMod);
+ /* We now require the caller to supply correct baseTypeId/baseTypeMod */
+ Assert(OidIsValid(baseTypeId));
/* If it isn't a domain, return the node as it was passed in */
if (baseTypeId == typeId)