From: | Ivan Trofimov <i(dot)trofimow(at)yandex(dot)ru> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: libpq: PQfnumber overload for not null-terminated strings |
Date: | 2024-02-26 19:12:30 |
Message-ID: | 0a5c227a-7dd5-6b8b-870b-c2867712659e@yandex.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thanks for the quick reply.
> If you need counted strings
> for PQfnumber, wouldn't you need them for every single other
> string-based API in libpq as well?
No, not really.
Thing is, out of all the functions listed in "34.3.2. Retrieving Query
Result Information" and "34.3.3. Retrieving Other Result Information"
PQfnumber is the only (well, technically also PQprint) one that takes a
string as an input.
As far as I know PQfnumber is the only portable way to implement "give
me the the value at this row with this 'column_name'", which is an
essential feature for any kind of client-side parsing.
Right now as a library writer in a higher-level language I'm forced to
either
* Sacrifice performance to ensure 'column_name' is null-terminated
(that's what some bindings in Rust do)
* Sacrifice interface quality by requiring a null-terminated string,
which is not necessary idiomatic (that's what we do)
* Sacrifice usability by requiring a user to guarantee that the
'string_view' provided is null-terminated (that's what libpqxx does, for
example)
I don't think it's _that_ big of a deal, but could it be QoL improvement
nice enough to be worth of a tiny addition into libpq interface?
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias van de Meent | 2024-02-26 19:30:56 | Re: Detoasting optionally to make Explain-Analyze less misleading |
Previous Message | Jacob Champion | 2024-02-26 18:56:39 | Re: Refactor SASL exchange in preparation for OAuth Bearer |