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

Function BuildTupleFromCStrings

src/backend/executor/execTuples.c:2151–2203  ·  view source on GitHub ↗

* BuildTupleFromCStrings - build a HeapTuple given user data in C string form. * values is an array of C strings, one for each attribute of the return tuple. * A NULL string pointer indicates we want to create a NULL field. */

Source from the content-addressed store, hash-verified

2149 * A NULL string pointer indicates we want to create a NULL field.
2150 */
2151HeapTuple
2152BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
2153{
2154 TupleDesc tupdesc = attinmeta->tupdesc;
2155 int natts = tupdesc->natts;
2156 Datum *dvalues;
2157 bool *nulls;
2158 int i;
2159 HeapTuple tuple;
2160
2161 dvalues = (Datum *) palloc(natts * sizeof(Datum));
2162 nulls = (bool *) palloc(natts * sizeof(bool));
2163
2164 /*
2165 * Call the "in" function for each non-dropped attribute, even for nulls,
2166 * to support domains.
2167 */
2168 for (i = 0; i < natts; i++)
2169 {
2170 if (!TupleDescAttr(tupdesc, i)->attisdropped)
2171 {
2172 /* Non-dropped attributes */
2173 dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
2174 values[i],
2175 attinmeta->attioparams[i],
2176 attinmeta->atttypmods[i]);
2177 if (values[i] != NULL)
2178 nulls[i] = false;
2179 else
2180 nulls[i] = true;
2181 }
2182 else
2183 {
2184 /* Handle dropped attributes by setting to NULL */
2185 dvalues[i] = (Datum) 0;
2186 nulls[i] = true;
2187 }
2188 }
2189
2190 /*
2191 * Form a tuple
2192 */
2193 tuple = heap_form_tuple(tupdesc, dvalues, nulls);
2194
2195 /*
2196 * Release locally palloc'd space. XXX would probably be good to pfree
2197 * values of pass-by-reference datums, as well.
2198 */
2199 pfree(dvalues);
2200 pfree(nulls);
2201
2202 return tuple;
2203}
2204
2205/*
2206 * HeapTupleHeaderGetDatum - convert a HeapTupleHeader pointer to a Datum.

Callers 15

bt_page_stats_internalFunction · 0.85
bt_metapFunction · 0.85
bm_metapFunction · 0.85
bm_print_lov_itemFunction · 0.85
bm_bitmap_page_headerFunction · 0.85
bm_print_content_wordFunction · 0.85
build_pgstattuple_typeFunction · 0.85
pgstatindex_implFunction · 0.85
crosstabFunction · 0.85
get_crosstab_tuplestoreFunction · 0.85
pgrowlocksFunction · 0.85

Calls 4

InputFunctionCallFunction · 0.85
heap_form_tupleFunction · 0.85
pallocFunction · 0.50
pfreeFunction · 0.50

Tested by 1

retcompositeFunction · 0.68