Parameter null problem - SVN 3987, PostgreSQL

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

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:

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();
I read below lines in my PostgreSQL log file:

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
I appreciate any help for a fast code fix on Zeos library, please.

Thanks & regards,
Ertan
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

Using Raspberry Pi 3. OS is Jessie. Development Platform is Lazarus 1.8RC1

I believe I have tracked down to the exact location of the problem.

I have following text in my ZQuery1.SQL

Code: Select all

select * from sayimbaslik where id = :id
All below is at design time. I am using object inspector;
-Click Params (new windows pops: Editing ZQuery1.Params[0])
-Click 0 - id to set parameter "id" (Object Inspector changes into TParam properties)
- Click Value and type something.
1- When I hit Enter Value reverts back to "(Null)"
2- When I try to set a Parameter Value Type it simply reverts back to "Null" I cannot set it to something else.

I am not experienced component developer and I could not track down the problem in the source. I think it is somewhere in ZSqlProcessor.pas or ZSqlStrings.pas

I suspect ZSqlStrings.pas line 365:

Code: Select all

if not (Assigned(FParams) and Assigned(FStatements)) then exit; //Alexs
However, not sure about that at all.

I look forward to some help, please.

Thanks & regards,
Ertan


Edit:
No problem here: Windows 10 64bit Lazarus 1.6.4 (64bit) (SVN 54278) and Zeos 7.2.1-RC from branches/testing-7.2 (SVN 3987) Target is 64bit Executable
There is a problem here: Raspberry Pi 3, Jessie, Lazarus 1.6.4 (SVN 55188) and Zeos 7.2.1-RC from branches/testing-7.2 (SVN 3987)
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by miab3 »

It seems that this error only applies to Raspbian Linux(Debian Jessie - ARM-32) and PostgreSQL(9.4).
For MariaDB 10 or SQLite 3 or FirebirdSQL 2.5 there is no mistake on Raspberry Pi and Lazarus.
For Win32/64, Ubuntu-64 or Fedora-64 on x64 also no problem with PostgreSQL.

Michal
Last edited by miab3 on 05.06.2017, 08:50, edited 4 times in total.
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

Hi miab3,

If it is not too much to ask, would you test it with Raspbian Jessie, Lazarus (of your choice) and PostgreSQL 9.4.10 (or some 9.x version), please.

I have no Debian 64bit setup, yet. I am working on it. I will also make some tests with Lazarus on Debian 8.8 and Lazarus on FreeBSD 11.0-RELEASE

Thanks.

UPDATE:
My test on Raspberry pi 3, Jessie, Lazarus 1.6.4 (SVN 55188), using SQLdb components and my example code works as expected. Parameters are assigned as they should be. This makes me think problem is somewhere in Zeos.
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by miab3 »

I've been doing this on PostgreSQL 9.4 client and server.

Michal
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

I didn't understand clearly. Sorry for asking twice before hand. What I understand is that you have Raspberry Pi-Jessie and you also could reproduce the problem I described in my initial post?

If yes, I wonder how can I help to solve this.

Thank you.

Ertan
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by miab3 »

ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

My RPi says: Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

Update. Everything works on: Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux

Tested with Lazarus 1.6.4 64bit and Zeos 7.1.3 & Zeos 7.2-RC

Will do one more test with Lazarus 1.8RC1 on this Debian system and post results here.


Edit: Test with Lazarus 1.8.0RC2 64bit (SVN 55220) with Zeos 7.2.1-RC and there is no problem. Parameters do work.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by marsupilami »

Hello ertank,

I read all the thread and I am not sure if you have a problem right now or if it dissolved?
With best regards,

Jan
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by miab3 »

Hi Jan,

The problem is with Lazarus and PostgreSQL 9.4(client; Win32/64 server) on Raspbian(current) for Raspberry Pi3.

Michal
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

marsupilami wrote:Hello ertank,

I read all the thread and I am not sure if you have a problem right now or if it dissolved?
With best regards,

Jan
Hello Jan,

Problem still continues. Unfortunately, I couldn't resolve it. All tests are to be sure that there is no problem on platformsother than Raspberry Pi.

I do need Zeos 7.2.1-RC latest from SVN sources to work on Raspberry Pi 3. It is not working at the moment.

Thanks.
Ertan
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by marsupilami »

Hello Michal, hello Ertan,

so I got around to do some testing. This is my current environment:
  • Raspberry PI 3, Model B
  • Raspbian -> Debian GNU/Linux Jessie
  • FPC 2.6.4 from the repositories, Kernel: Linux raspberrypi 4.9.24-v7+ #993 SMP Wed Apr 26 18:01:23 BST 2017 armv7l GNU/Linux
  • Lazarus 1.6.4, compiled from source
  • Zeoslib 7.2 from SVN
  • PostgreSQL Client from the repositories (Version 9.4)
  • PostgreSQL Server on another Debian Jessie i386, Version 9.4
With a testtable I do get the same message saying all the parameter values are null. But before I get that exception, I do get an SIGILL exception during debugging. Wikipedia says this about SIGILL:
Wikipedia wrote:SIGILL
The SIGILL signal is sent to a process when it attempts to execute an illegal, malformed, unknown, or privileged instruction.
Do you both get that signal too? If you don't get that signal, does your configuration divert from my configuration?

With best regards,

Jan
ertank
Senior Boarder
Senior Boarder
Posts: 53
Joined: 02.06.2017, 12:00

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by ertank »

Hello Jan,

I am a newbie to Linux development. I couldn't understand receiving such a signal even if I am getting one. If you can direct me as to where I can check that SIGILL signal coming or not, I will gladly provide a feedback.

Just for the record, I cannot run my applications in debug mode. Do not know why is that. I get an exception from Lazarus if I try to do so. Maybe I am missing some libraries necessary for debugging.

Btw, my configuration is almost identical to yours.
* Raspberry PI 3, Model B
* Raspbian -> Debian GNU/Linux Jessie
* FPC 3.0.2 compiled from source, Kernel: Linux raspberrypi 4.9.24-v7+ #993 SMP Wed Apr 26 18:01:23 BST 2017 armv7l GNU/Linux
* Lazarus 1.8.0RC2 compiled from source
* Zeoslib 7.2 from SVN
* PostgreSQL Client from the repositories (Version 9.4.12)
* PostgreSQL Server same Debian Jessie i386, Version 9.4.12

Thanks.

Ertan


Edit: After checking, I confirm that I am getting SIGILL message whenever I try to debug run my current application which uses SQLdb components for now. However, there is no such signal received if I try to debug run a new empty form application.

Though, I am not sure that is the source of the problem as SQLdb seems to be able to assign parameters just fine with same signal being received.

Edit2: After some searching about the SIGILL it most likely is a problem with GDB and nothing else. Some relevant links:
https://forum.lazarus.freepascal.org/in ... ic=34658.0
http://wiki.freepascal.org/FPC_New_Feat ... MI_support
https://forum.lazarus.freepascal.org/in ... pic=6225.0
http://wiki.freepascal.org/FPC_New_Feat ... MI_support
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Parameter null problem - SVN 3987, PostgreSQL

Post by miab3 »

@marsupilami,

Disable the debugger or start outside of the IDE.

Michal
Post Reply