create table test(col bytea);
insert into test values ('abc'::text::bytea);
select * from test;
shows
col
----------
\x616263
(1 row)
When read using LuaSQL, the value returned is the same string displayed: \x616263 rather than the string abc, even though Lua supports binary strings. This is highly inconvenient because it forces the application to decode the hexadecimal string, which has a high impact in performance (3x in my application).
I assume that a similar situation happens when writing data (which thankfully I don't need to use), but since it can only be done through a valid SQL statement, there's no way around that until prepared statements are available.
(Edited to make the example string longer and to match the output with the statement)
Lua also supports numbers and yet type(conn:execute('select 1'):fetch()) is string. I'd guess this was done for simplicity, since handling of specific types in return values in postgresql is not exactly easy.
For example:
shows
When read using LuaSQL, the value returned is the same string displayed:
\x616263
rather than the stringabc
, even though Lua supports binary strings. This is highly inconvenient because it forces the application to decode the hexadecimal string, which has a high impact in performance (3x in my application).I assume that a similar situation happens when writing data (which thankfully I don't need to use), but since it can only be done through a valid SQL statement, there's no way around that until prepared statements are available.
(Edited to make the example string longer and to match the output with the statement)