Parameter null problem - SVN 3987, PostgreSQL
Posted: 02.06.2017, 13:45
Hi,
As far as I can tell, SVN version is not assigning parameters to queries. I have below code for reproducing problem. I have tested with protocol postgresql and postgresql-9. Databases PostgreSQL 9.4.10 (32bit) running on Raspberry Pi 3 and 9.6.2 (64bit) running on Windows 10 64bit:
I read below lines in my PostgreSQL log file:
I appreciate any help for a fast code fix on Zeos library, please.
Thanks & regards,
Ertan
As far as I can tell, SVN version is not assigning parameters to queries. I have below code for reproducing problem. I have tested with protocol postgresql and postgresql-9. Databases PostgreSQL 9.4.10 (32bit) running on Raspberry Pi 3 and 9.6.2 (64bit) running on Windows 10 64bit:
Code: Select all
ZQuery1.Close();
ZQuery1.SQL.Text := 'create table test(atext text)';
ZQuery1.ExecSQL();
ZQuery1.SQL.Text := 'update test set atext = :param';
ZQuery1.ParamByName('param').AsString := 'test';
ZQuery1.ExecSQL();
ZQuery1.SQL.Text := 'select test from test';
ZQuery1.Open();
ShowMessage('Expected: "test". Received: ' + ZQuery1.Fields[0].AsString);
ZQuery1.Close();
ZQuery1.SQL.Text := 'update test set atext = :param';
ZQuery1.Params[0].AsString := 'test2';
ZQuery1.ExecSQL();
ZQuery1.SQL.Text := 'select test from test';
ZQuery1.Open();
ShowMessage('Expected: "test2". Received: ' + ZQuery1.Fields[0].AsString);
ZQuery1.Close();
ZQuery1.SQL.Text := 'drop table test';
ZQuery1.ExecSQL();
Code: Select all
2017-06-02 15:32:49 +03 [1370-3] postgres@robox LOG: statement: create table test(atext text)
2017-06-02 15:32:49 +03 [1370-4] postgres@robox LOG: execute 2816004798222281496: update test set atext = $1
2017-06-02 15:32:49 +03 [1370-5] postgres@robox DETAIL: parameters: $1 = NULL
2017-06-02 15:32:49 +03 [1370-6] postgres@robox LOG: statement: DEALLOCATE "2816004798222281496";
2017-06-02 15:32:49 +03 [1370-7] postgres@robox LOG: execute 3241896892322281496: select test from test
2017-06-02 15:32:49 +03 [1370-8] postgres@robox LOG: statement: select pc.relname, pns.nspname, pa.attnum, pa.attname from pg_catalog.pg_class pc join pg_catalog.pg_namespace pns on pc.relnamespace = pns.oid join pg_catalog.pg_attribute pa on pa.attrelid = pc.oid where pc.oid = 16612 and pa.attnum > 0
2017-06-02 15:32:49 +03 [1370-9] postgres@robox LOG: execute 3895761347422281496: SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull,a.atttypmod,a.attlen,a.attnum,pg_get_expr(def.adbin, def.adrelid) as adsrc,dsc.description FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0 AND NOT a.attisdropped AND c.relname = E'test' ORDER BY nspname,relname,attnum
2017-06-02 15:32:49 +03 [1370-10] postgres@robox LOG: statement: SELECT oid, typname, typbasetype,typtype FROM pg_type WHERE (typtype = 'b' and oid < 10000) OR typtype = 'p' OR typtype = 'e' OR typbasetype<>0 ORDER BY oid
2017-06-02 15:32:49 +03 [1370-11] postgres@robox LOG: statement: DEALLOCATE "3895761347422281496";
2017-06-02 15:32:52 +03 [1370-12] postgres@robox LOG: statement: DEALLOCATE "3241896892322281496";
2017-06-02 15:32:52 +03 [1370-13] postgres@robox LOG: execute 2816004798522281496: update test set atext = $1
2017-06-02 15:32:52 +03 [1370-14] postgres@robox DETAIL: parameters: $1 = NULL
2017-06-02 15:32:52 +03 [1370-15] postgres@robox LOG: statement: DEALLOCATE "2816004798522281496";
2017-06-02 15:32:52 +03 [1370-16] postgres@robox LOG: execute 3241896892622281496: select test from test
2017-06-02 15:32:53 +03 [1370-17] postgres@robox LOG: statement: DEALLOCATE "3241896892622281496";
2017-06-02 15:32:53 +03 [1370-18] postgres@robox LOG: statement: drop table test
Thanks & regards,
Ertan