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

Function dbms_sql_column_value_f

gpcontrib/orafce/dbms_sql.c:1773–1811  ·  view source on GitHub ↗

* CREATE FUNCTION dbms_sql.column_value(c int, pos int, value anyelement) RETURNS anyelement; * Note - CALL statement is slow from PLpgSQL block (against function execution). * This is reason why this routine is in function form too. */

Source from the content-addressed store, hash-verified

1771 * This is reason why this routine is in function form too.
1772 */
1773Datum
1774dbms_sql_column_value_f(PG_FUNCTION_ARGS)
1775{
1776 CursorData *c;
1777 Datum value;
1778 int pos;
1779 bool isnull;
1780 Oid targetTypeId;
1781 MemoryContext oldcxt;
1782
1783 if (SPI_connect() != SPI_OK_CONNECT)
1784 elog(ERROR, "SPI_connact failed");
1785
1786 c = get_cursor(fcinfo, true);
1787
1788 if (PG_ARGISNULL(1))
1789 ereport(ERROR,
1790 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
1791 errmsg("column position (number) is NULL")));
1792
1793 pos = PG_GETARG_INT32(1);
1794
1795 if (!c->executed)
1796 ereport(ERROR,
1797 (errcode(ERRCODE_INVALID_CURSOR_STATE),
1798 errmsg("cursor is not executed")));
1799
1800 oldcxt = MemoryContextSwitchTo(c->result_cxt);
1801
1802 targetTypeId = get_fn_expr_argtype(fcinfo->flinfo, 2);
1803
1804 value = column_value(c, pos, targetTypeId, &isnull, true);
1805
1806 SPI_finish();
1807
1808 MemoryContextSwitchTo(oldcxt);
1809
1810 PG_RETURN_DATUM(value);
1811}
1812
1813/******************************************************************
1814 * Simple parser - just for replacement of bind variables by

Callers

nothing calls this directly

Calls 8

SPI_connectFunction · 0.85
get_cursorFunction · 0.85
MemoryContextSwitchToFunction · 0.85
get_fn_expr_argtypeFunction · 0.85
column_valueFunction · 0.85
SPI_finishFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected