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

Function dbms_sql_define_array

gpcontrib/orafce/dbms_sql.c:811–896  ·  view source on GitHub ↗

* CREATE PROCEDURE dbms_sql.define_array(c int, col int, value "anyarray", rowcount int, index1 int); */

Source from the content-addressed store, hash-verified

809 * CREATE PROCEDURE dbms_sql.define_array(c int, col int, value "anyarray", rowcount int, index1 int);
810 */
811Datum
812dbms_sql_define_array(PG_FUNCTION_ARGS)
813{
814 CursorData *c;
815 ColumnData *col;
816 Oid valtype;
817 Oid basetype;
818 int position;
819 int rowcount;
820 int index1;
821 Oid elementtype;
822 TYPCATEGORY category;
823 bool ispreferred;
824
825 c = get_cursor(fcinfo, true);
826
827 if (PG_ARGISNULL(1))
828 ereport(ERROR,
829 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
830 errmsg("column position (number) is NULL")));
831
832 position = PG_GETARG_INT32(1);
833 col = get_col(c, position, true);
834
835 valtype = get_fn_expr_argtype(fcinfo->flinfo, 2);
836 if (valtype == RECORDOID)
837 ereport(ERROR,
838 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
839 errmsg("cannot to define a column of record type")));
840
841 get_type_category_preferred(valtype, &category, &ispreferred);
842 if (category != TYPCATEGORY_ARRAY)
843 elog(ERROR, "defined value is not array");
844
845 col->typarrayoid = valtype;
846
847 basetype = getBaseType(valtype);
848 elementtype = get_element_type(basetype);
849
850 if (!OidIsValid(elementtype))
851 ereport(ERROR,
852 (errcode(ERRCODE_DATATYPE_MISMATCH),
853 errmsg("column is not a array")));
854
855 if (col->typoid != InvalidOid)
856 ereport(ERROR,
857 (errcode(ERRCODE_DUPLICATE_COLUMN),
858 errmsg("column is defined already")));
859
860 col->typoid = elementtype;
861
862 if (PG_ARGISNULL(3))
863 ereport(ERROR,
864 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
865 errmsg("cnt is NULL")));
866
867 rowcount = PG_GETARG_INT32(3);
868 if (rowcount <= 0)

Callers

nothing calls this directly

Calls 9

get_cursorFunction · 0.85
get_colFunction · 0.85
get_fn_expr_argtypeFunction · 0.85
getBaseTypeFunction · 0.85
get_element_typeFunction · 0.85
get_typlenbyvalFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected