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

Function bind_array

gpcontrib/orafce/dbms_sql.c:590–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590static void
591bind_array(FunctionCallInfo fcinfo, int index1, int index2)
592{
593 CursorData *c;
594 VariableData *var;
595 char *varname, *varname_downcase;
596 Oid valtype;
597 Oid elementtype;
598
599 c = get_cursor(fcinfo, true);
600
601 if (PG_ARGISNULL(1))
602 ereport(ERROR,
603 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
604 errmsg("name of bind variable is NULL")));
605
606 varname = text_to_cstring(PG_GETARG_TEXT_P(1));
607 if (*varname == ':')
608 varname += 1;
609
610 varname_downcase = downcase_identifier(varname, (int) strlen(varname), false, true);
611 var = get_var(c, varname_downcase, -1, false);
612
613 valtype = get_fn_expr_argtype(fcinfo->flinfo, 2);
614 if (valtype == RECORDOID)
615 ereport(ERROR,
616 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
617 errmsg("cannot to bind a value of record type")));
618
619 valtype = getBaseType(valtype);
620 elementtype = get_element_type(valtype);
621
622 if (!OidIsValid(elementtype))
623 ereport(ERROR,
624 (errcode(ERRCODE_DATATYPE_MISMATCH),
625 errmsg("value is not a array")));
626
627 if (var->typoid != InvalidOid)
628 {
629 if (!var->typbyval && !var->isnull)
630 {
631 pfree(DatumGetPointer(var->value));
632 var->value = (Datum) 0;
633 }
634
635 var->isnull = true;
636 }
637
638 var->is_array = true;
639 var->typoid = valtype;
640 var->typelemid = elementtype;
641
642 get_typlenbyval(elementtype, &var->typelemlen, &var->typelembyval);
643
644 if (!PG_ARGISNULL(2))
645 {
646 MemoryContext oldcxt;
647

Callers 2

dbms_sql_bind_array_3Function · 0.85
dbms_sql_bind_array_5Function · 0.85

Calls 13

get_cursorFunction · 0.85
text_to_cstringFunction · 0.85
downcase_identifierFunction · 0.85
get_varFunction · 0.85
get_fn_expr_argtypeFunction · 0.85
getBaseTypeFunction · 0.85
get_element_typeFunction · 0.85
get_typlenbyvalFunction · 0.85
MemoryContextSwitchToFunction · 0.85
datumCopyFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected