clkao / plv8js-migrated

Automatically exported from code.google.com/p/plv8js
Other
0 stars 0 forks source link

off-by-one error in plv8.execute? #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It looks like this [1] change that allows varargs-style arguments to 
plv8.execute may have an off-by-one error?

Passing in an array still works as expected:

d7l4hfvukuffq4=# do 'plv8.elog(NOTICE, JSON.stringify(plv8.execute("select $1 
a, $2 b", [2,3])))' language plv8;
NOTICE:  [{"a":"2","b":"3"}]
DO

But passing in two separate arguments here gives an argument count mismatch 
error:

d7l4hfvukuffq4=# do 'plv8.elog(NOTICE, JSON.stringify(plv8.execute("select $1 
a, $2 b", 2,3)))' language plv8;
ERROR:  Error: parameter numbers mismatch: 2 != 3
DETAIL:  undefined() LINE 1: plv8.elog(NOTICE, 
JSON.stringify(plv8.execute("select $1 a, $2 b", 2,3)))

Passing in the requested number of arguments gives a really odd behavior:

d7l4hfvukuffq4=# do 'plv8.elog(NOTICE, JSON.stringify(plv8.execute("select $1 
a, $2 b", 2)))' language plv8;
NOTICE:  [{"a":null,"b":"2"}]
DO

Running plv8 1.4.2 on Postgres 9.3.4 on Ubuntu 12.04 64-bit.

[1]: 
http://code.google.com/p/plv8js/source/detail?r=5e428ab67663015c71b2b6783d039e18
5cfcdaea

Original issue reported on code.google.com by mac...@heroku.com on 25 Apr 2014 at 11:09

GoogleCodeExporter commented 9 years ago
My colleague Daniel has a spike at a patch here: 
https://github.com/fdr/plv8/commit/a91ca9fa4ca129a1f8786fcd6d36cf6d75ea3155

Original comment by mac...@heroku.com on 25 Apr 2014 at 11:19

GoogleCodeExporter commented 9 years ago
Thanks guys.  Applied the patch as is.  That's embarrassing :(

Original comment by umi.tan...@gmail.com on 7 May 2014 at 8:18

GoogleCodeExporter commented 9 years ago

Original comment by umi.tan...@gmail.com on 7 May 2014 at 8:18