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

Function copy_byval_expanded_array

src/backend/utils/adt/array_expanded.c:184–227  ·  view source on GitHub ↗

* helper for expand_array(): copy pass-by-value Datum-array representation */

Source from the content-addressed store, hash-verified

182 * helper for expand_array(): copy pass-by-value Datum-array representation
183 */
184static void
185copy_byval_expanded_array(ExpandedArrayHeader *eah,
186 ExpandedArrayHeader *oldeah)
187{
188 MemoryContext objcxt = eah->hdr.eoh_context;
189 int ndims = oldeah->ndims;
190 int dvalueslen = oldeah->dvalueslen;
191
192 /* Copy array dimensionality information */
193 eah->ndims = ndims;
194 /* We can alloc both dimensionality arrays with one palloc */
195 eah->dims = (int *) MemoryContextAlloc(objcxt, ndims * 2 * sizeof(int));
196 eah->lbound = eah->dims + ndims;
197 /* .. but don't assume the source's arrays are contiguous */
198 memcpy(eah->dims, oldeah->dims, ndims * sizeof(int));
199 memcpy(eah->lbound, oldeah->lbound, ndims * sizeof(int));
200
201 /* Copy element-type data */
202 eah->element_type = oldeah->element_type;
203 eah->typlen = oldeah->typlen;
204 eah->typbyval = oldeah->typbyval;
205 eah->typalign = oldeah->typalign;
206
207 /* Copy the deconstructed representation */
208 eah->dvalues = (Datum *) MemoryContextAlloc(objcxt,
209 dvalueslen * sizeof(Datum));
210 memcpy(eah->dvalues, oldeah->dvalues, dvalueslen * sizeof(Datum));
211 if (oldeah->dnulls)
212 {
213 eah->dnulls = (bool *) MemoryContextAlloc(objcxt,
214 dvalueslen * sizeof(bool));
215 memcpy(eah->dnulls, oldeah->dnulls, dvalueslen * sizeof(bool));
216 }
217 else
218 eah->dnulls = NULL;
219 eah->dvalueslen = dvalueslen;
220 eah->nelems = oldeah->nelems;
221 eah->flat_size = oldeah->flat_size;
222
223 /* we don't make a flat representation */
224 eah->fvalue = NULL;
225 eah->fstartptr = NULL;
226 eah->fendptr = NULL;
227}
228
229/*
230 * get_flat_size method for expanded arrays

Callers 1

expand_arrayFunction · 0.85

Calls 1

MemoryContextAllocFunction · 0.85

Tested by

no test coverage detected