Closed bjne closed 6 years ago
fromstring uses conversion from string to a value, not from bytes. Just compare the output
do $$ print(fromstring('bytea', "\x01\x00\x01")) $$ language pllua;
do $$ print(fromstring('bytea', "\\001\\000\\001")) $$ language pllua;
I suppose this will work as you expected:
create table test_bytea(id serial, data bytea);
create function insert_bytea() returns void as $$
local p = server.prepare([[
INSERT INTO test_bytea (data) values($1)
]], {'bytea'})
p:execute{fromstring('bytea', "\\001\\001\\001")}
p:execute{fromstring('bytea', "\\000\\000\\000")}
p:execute{fromstring('bytea', "\\001\\000\\001")}
$$ language pllua;
select insert_bytea();
select id,length(data) from test_bytea;
select * from test_bytea;
I made a pull request for it.
On Nov 18, 2017 11:12, "Eugene Sergeev" notifications@github.com wrote:
fromstring uses conversion from string to a value, not from bytes. Just compare output
do $$ print(fromstring('bytea', "\x01\x00\x01")) $$ language pllua; do $$ print(fromstring('bytea', "\001\000\001")) $$ language pllua;
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pllua/pllua/issues/58#issuecomment-345432330, or mute the thread https://github.com/notifications/unsubscribe-auth/ABU9uoAPj3R_5XGZ1s8QqvJRdvrUHdRtks5s3q1-gaJpZM4QfsS2 .
nonthing to fix, it is how postgres inner function work and correct string for bytes [01 00 01] is "\001\000\001" (not \x01\x00\x01)
given the following test:
expected:
actual: