hi all,
using the extension url_encode (not on pgxn) does not work in postgresql
9.3 (and 9.4). (i assume it works in earlier versions, but i have not
tested that.)
the testcase is the following.
create table t (id serial primary key, t1 text not null, t2 text);
insert into t (t1) values ('test');
update t set t2 = url_encode(t1);
it fails with
Error: invalid memory alloc request size 1452021511
for my untrained eye, the code [2] looks reasonable. it does use the
following idiom though.
static text *
encode(text *in_text, ...)
{
...
real_len = 0;
len = VARSIZE(in_text) - VARHDRSZ;
result = (text *) palloc(3 * len + VARHDRSZ);
write_ptr = VARDATA(result);
...
SET_VARSIZE(result, real_len + VARHDRSZ);
return result;
}
is that safe for "text" data type? how should it be replaced if not?
[1] https://github.com/okbob/url_encode
[2] https://github.com/okbob/url_encode/blob/master/src/url_encode.c
thank you in advance,
tobias florek