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

Function array_set_slice

src/backend/utils/adt/arrayfuncs.c:2820–3145  ·  view source on GitHub ↗

* array_set_slice : * This routine sets the value of a range of array locations (specified * by upper and lower subscript values) to new values passed as * another array. * * This handles both ordinary varlena arrays and fixed-length arrays. * * Inputs: * arraydatum: the initial array object (mustn't be NULL) * nSubscripts: number of subscripts supplied (must be same for upper/lo

Source from the content-addressed store, hash-verified

2818 * rather than returning a NULL or empty array as the fetch operations do.
2819 */
2820Datum
2821array_set_slice(Datum arraydatum,
2822 int nSubscripts,
2823 int *upperIndx,
2824 int *lowerIndx,
2825 bool *upperProvided,
2826 bool *lowerProvided,
2827 Datum srcArrayDatum,
2828 bool isNull,
2829 int arraytyplen,
2830 int elmlen,
2831 bool elmbyval,
2832 char elmalign)
2833{
2834 ArrayType *array;
2835 ArrayType *srcArray;
2836 ArrayType *newarray;
2837 int i,
2838 ndim,
2839 dim[MAXDIM],
2840 lb[MAXDIM],
2841 span[MAXDIM];
2842 bool newhasnulls;
2843 int nitems,
2844 nsrcitems,
2845 olddatasize,
2846 newsize,
2847 olditemsize,
2848 newitemsize,
2849 overheadlen,
2850 oldoverheadlen,
2851 addedbefore,
2852 addedafter,
2853 lenbefore,
2854 lenafter,
2855 itemsbefore,
2856 itemsafter,
2857 nolditems;
2858
2859 /* Currently, assignment from a NULL source array is a no-op */
2860 if (isNull)
2861 return arraydatum;
2862
2863 if (arraytyplen > 0)
2864 {
2865 /*
2866 * fixed-length arrays -- not got round to doing this...
2867 */
2868 ereport(ERROR,
2869 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2870 errmsg("updates on slices of fixed-length arrays not implemented")));
2871 }
2872
2873 /* detoast arrays if necessary */
2874 array = DatumGetArrayTypeP(arraydatum);
2875 srcArray = DatumGetArrayTypeP(srcArrayDatum);
2876
2877 /* note: we assume srcArray contains no toasted elements */

Callers 1

Calls 15

deconstruct_arrayFunction · 0.85
ArrayGetNItemsFunction · 0.85
construct_md_arrayFunction · 0.85
pg_sub_s32_overflowFunction · 0.85
pg_add_s32_overflowFunction · 0.85
ArrayCheckBoundsFunction · 0.85
mda_get_rangeFunction · 0.85
array_nelems_sizeFunction · 0.85
array_slice_sizeFunction · 0.85
array_insert_sliceFunction · 0.85
array_bitmap_copyFunction · 0.85
errcodeFunction · 0.50

Tested by

no test coverage detected