MCPcopy Create free account
hub / github.com/documentdb/documentdb / IntListGetPgIntArray

Function IntListGetPgIntArray

pg_documentdb_core/src/utils/list_utils.c:179–197  ·  view source on GitHub ↗

* IntListGetPgIntArray creates a Postgres array based on given list of integers. */

Source from the content-addressed store, hash-verified

177 * IntListGetPgIntArray creates a Postgres array based on given list of integers.
178 */
179ArrayType *
180IntListGetPgIntArray(const List *intList)
181{
182 int nelems = list_length(intList);
183 if (nelems == 0)
184 {
185 return construct_empty_array(INT4OID);
186 }
187
188 Datum *intDatumArray = palloc(sizeof(Datum) * nelems);
189 for (int i = 0; i < nelems; i++)
190 {
191 intDatumArray[i] = Int32GetDatum(list_nth_int(intList, i));
192 }
193
194 bool elmbyval = true;
195 return construct_array(intDatumArray, nelems, INT4OID, sizeof(int),
196 elmbyval, TYPALIGN_INT);
197}
198
199
200/*

Callers 3

CheckForIndexCmdToFinishFunction · 0.85
IndexIdListGetValidCountFunction · 0.85
MarkIndexesAsValidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected