Re: libpq: PQfnumber overload for not null-terminated strings

Поиск
Список
Период
Сортировка
От Ivan Trofimov
Тема Re: libpq: PQfnumber overload for not null-terminated strings
Дата
Msg-id 0a5c227a-7dd5-6b8b-870b-c2867712659e@yandex.ru
обсуждение исходный текст
Ответ на Re: libpq: PQfnumber overload for not null-terminated strings  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: libpq: PQfnumber overload for not null-terminated strings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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?



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

Предыдущее
От: Jacob Champion
Дата:
Сообщение: Re: Refactor SASL exchange in preparation for OAuth Bearer
Следующее
От: Matthias van de Meent
Дата:
Сообщение: Re: Detoasting optionally to make Explain-Analyze less misleading