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

Function get_col

gpcontrib/orafce/dbms_sql.c:707–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707static ColumnData *
708get_col(CursorData *c, int position, bool append)
709{
710 ListCell *lc;
711
712 foreach(lc, c->columns)
713 {
714 ColumnData *col = (ColumnData *) lfirst(lc);
715
716 if (col->position == position)
717 return col;
718 }
719
720 if (append)
721 {
722 ColumnData *ncol;
723 MemoryContext oldcxt;
724
725 oldcxt = MemoryContextSwitchTo(c->cursor_cxt);
726 ncol = palloc0(sizeof(ColumnData));
727
728 ncol->position = position;
729 if (c->max_colpos < position)
730 c->max_colpos = position;
731
732 c->columns = lappend(c->columns, ncol);
733
734 MemoryContextSwitchTo(oldcxt);
735
736 return ncol;
737 }
738 else
739 ereport(ERROR,
740 (errcode(ERRCODE_UNDEFINED_COLUMN),
741 errmsg("column no %d is not defined", position)));
742
743 /* be msvc quite */
744 return NULL;
745}
746
747/*
748 * CREATE PROCEDURE dbms_sql.define_column(c int, col int, value "any", column_size int DEFAULT -1);

Callers 3

dbms_sql_define_columnFunction · 0.85
dbms_sql_define_arrayFunction · 0.85
executeFunction · 0.85

Calls 6

MemoryContextSwitchToFunction · 0.85
lappendFunction · 0.85
foreachFunction · 0.50
palloc0Function · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected