MCPcopy Create free account
hub / github.com/apache/cloudberry / cast_value

Function cast_value

gpcontrib/orafce/dbms_sql.c:1536–1573  ·  view source on GitHub ↗

* Apply cast rules to a value */

Source from the content-addressed store, hash-verified

1534 * Apply cast rules to a value
1535 */
1536static Datum
1537cast_value(CastCacheData *ccast, Datum value, bool isnull)
1538{
1539 if (!isnull && !ccast->without_cast)
1540 {
1541 if (ccast->path == COERCION_PATH_FUNC)
1542 value = FunctionCall1(&ccast->finfo, value);
1543 else if (ccast->path == COERCION_PATH_RELABELTYPE)
1544 {
1545 /* do nothing */
1546 }
1547 else if (ccast->path == COERCION_PATH_COERCEVIAIO)
1548 {
1549 char *str;
1550
1551 str = OutputFunctionCall(&ccast->finfo_out, value);
1552 value = InputFunctionCall(&ccast->finfo_in,
1553 str,
1554 ccast->typIOParam,
1555 ccast->targettypmod);
1556 }
1557 else
1558 ereport(ERROR,
1559 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1560 errmsg("unsupported cast path yet %d", ccast->path)));
1561
1562 if (ccast->targettypmod != -1 && ccast->path_typmod == COERCION_PATH_FUNC)
1563 value = FunctionCall3(&ccast->finfo_typmod,
1564 value,
1565 Int32GetDatum(ccast->targettypmod),
1566 BoolGetDatum(true));
1567 }
1568
1569 if (ccast->targettypid != InvalidOid)
1570 domain_check(value, isnull, ccast->targettypid, NULL, NULL);
1571
1572 return value;
1573}
1574
1575/*
1576 * CALL statement is relatily slow in PLpgSQL - due repated parsing, planning.

Callers 1

column_valueFunction · 0.85

Calls 7

OutputFunctionCallFunction · 0.85
InputFunctionCallFunction · 0.85
Int32GetDatumFunction · 0.85
BoolGetDatumFunction · 0.85
domain_checkFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected