pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq PQexecParams and arrays
6+ messages / 3 participants
[nested] [flat]
* libpq PQexecParams and arrays
@ 2006-06-06 12:25 Alexey Slynko <slynko@tronet.ru>
0 siblings, 0 replies; 6+ messages in thread
From: Alexey Slynko @ 2006-06-06 12:25 UTC (permalink / raw)
To: pgsql-interfaces
Hi,
I wish to call PQexecParams with array of uint32_t values.
I've tried to use example from src/test/examples/testlibpq3.c, but with
no effect - it's unusable for input array.
Have anyone an idea, how it can be done?
Thanks
^ permalink raw reply [nested|flat] 6+ messages in thread
* libpq PQexecParams and arrays
@ 2006-06-06 13:20 Alexey Slynko <slynko@tronet.ru>
2006-06-06 23:35 ` Re: libpq PQexecParams and arrays Keary Suska <hierophant@pcisys.net>
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Slynko @ 2006-06-06 13:20 UTC (permalink / raw)
To: pgsql-interfaces
Hi,
I wish to call PQexecParams with array of uint32_t values.
I've tried to use example from src/test/examples/testlibpq3.c, but with
no effect - it's unusable for input array.
Have anyone an idea, how it can be done?
Thanks
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq PQexecParams and arrays
2006-06-06 13:20 libpq PQexecParams and arrays Alexey Slynko <slynko@tronet.ru>
@ 2006-06-06 23:35 ` Keary Suska <hierophant@pcisys.net>
0 siblings, 0 replies; 6+ messages in thread
From: Keary Suska @ 2006-06-06 23:35 UTC (permalink / raw)
To: pgsql-interfaces
on 6/6/06 7:20 AM, slynko@tronet.ru purportedly said:
> I wish to call PQexecParams with array of uint32_t values.
> I've tried to use example from src/test/examples/testlibpq3.c, but with
> no effect - it's unusable for input array.
>
> Have anyone an idea, how it can be done?
Have you tried passing all parameters, including especially the appropriate
paramTypes and paramFormats parameters? I believe that doing this should
permit libpq to understand binary data.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq PQexecParams and arrays
@ 2006-06-07 16:05 Keary Suska <hierophant@pcisys.net>
2006-06-07 16:39 ` Re: libpq PQexecParams and arrays Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Keary Suska @ 2006-06-07 16:05 UTC (permalink / raw)
To: Alexey Slynko <slynko@tronet.ru>; +Cc: pgsql-interfaces
on 6/7/06 2:54 AM, slynko@tronet.ru purportedly said:
>>> I wish to call PQexecParams with array of uint32_t values.
>>> I've tried to use example from src/test/examples/testlibpq3.c, but with
>>> no effect - it's unusable for input array.
>>>
>>> Have anyone an idea, how it can be done?
>>
>> Have you tried passing all parameters, including especially the appropriate
>> paramTypes and paramFormats parameters?
> Of course
>
>> I believe that doing this should
>> permit libpq to understand binary data.
> No, it doesn't.
> I've found, that array parsed at the server side by array_recv function.
> Is there is a way to send an array of arbitrary type by libpq?
To make sure that I understand, do you mean passing a paramValues as an
array of uint32, or passing values to a *column* that is an array column? If
it's the latter (array column), I don't think libpq supports array columns
in this way.
If it is just a matter of passing binary numeric values, I thought it was
supported by libpq, but maybe not. The documentation is ambiguous in many
places, so it is possible that libpq's binary support is only for blobs and
not for other data types.
I have never tried passing binary data, as I tend to find it easier in my
applications to pass textual representations, so I can't say for sure.
You may have to "convert" your int array into an array of char.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq PQexecParams and arrays
2006-06-07 16:05 Re: libpq PQexecParams and arrays Keary Suska <hierophant@pcisys.net>
@ 2006-06-07 16:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-06-07 17:20 ` Re: libpq PQexecParams and arrays Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2006-06-07 16:39 UTC (permalink / raw)
To: Keary Suska <hierophant@pcisys.net>; +Cc: Alexey Slynko <slynko@tronet.ru>; pgsql-interfaces
Keary Suska <hierophant@pcisys.net> writes:
> To make sure that I understand, do you mean passing a paramValues as an
> array of uint32, or passing values to a *column* that is an array column? If
> it's the latter (array column), I don't think libpq supports array columns
> in this way.
If you're trying to pass a binary parameter value to an array column,
you have to create the correct struct representing an array datatype,
as expected by array_recv. This implies making the appropriate array
header and (for integer data) converting each value to big-endian byte
order. A plain C uint32[] array definitely hasn't got the header, and
on Intel platforms it's the wrong byte order too. There is not anything
built into libpq that will do the translation for you.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq PQexecParams and arrays
2006-06-07 16:05 Re: libpq PQexecParams and arrays Keary Suska <hierophant@pcisys.net>
2006-06-07 16:39 ` Re: libpq PQexecParams and arrays Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-06-07 17:20 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2006-06-07 17:20 UTC (permalink / raw)
To: Alexey Slynko <slynko@tronet.ru>; +Cc: pgsql-interfaces
Alexey Slynko <slynko@tronet.ru> writes:
> I don't think, that it's a good idea to construct it by hand, because
> array_recv is an internal backend function,
> and format can be changed at any time
No, the on-the-wire binary formats are intended to be stable. They're
rather poorly documented :-( but they aren't something we will change
lightly.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-06-07 17:20 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-06 12:25 libpq PQexecParams and arrays Alexey Slynko <slynko@tronet.ru>
2006-06-06 13:20 libpq PQexecParams and arrays Alexey Slynko <slynko@tronet.ru>
2006-06-06 23:35 ` Keary Suska <hierophant@pcisys.net>
2006-06-07 16:05 Re: libpq PQexecParams and arrays Keary Suska <hierophant@pcisys.net>
2006-06-07 16:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-06-07 17:20 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox