Best way to construct PostgreSQL ArrayType (_int4) from C int array

Поиск
Список
Период
Сортировка
От Adrian Schreyer
Тема Best way to construct PostgreSQL ArrayType (_int4) from C int array
Дата
Msg-id BANLkTim6L6NCgDP3cUvA4hZjPLpPU1ZLeA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Best way to construct PostgreSQL ArrayType (_int4) from C int array  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
At the moment I am using the following code to construct a PostgreSQL
array from a C array in my C extension but I am not so sure if this is
really the best solution:

const int *data = array.data(); // C array
Datum *d = (Datum *) palloc(sizeof(Datum) * size);

for (int i = 0; i < size; i++) d[i] = Int32GetDatum(data[i]);

ArrayType *a = construct_array(d, size, INT4OID, sizeof(int4), true, 'i');

Is this okay or is there a better solution (existing function in the
PostgreSQL source for example)?

Cheers,

Adrian

В списке pgsql-general по дате отправления:

Предыдущее
От: Toby Corkindale
Дата:
Сообщение: Re: tuning on ec2
Следующее
От: hirenlad
Дата:
Сообщение: Create Database automatacally after silent installation of postgresql. ?