NULL Bigint function param problem with postgres

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
eversun
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 28.01.2020, 09:31

NULL Bigint function param problem with postgres

Post by eversun »

Just updated 7.3/8.0 from SVN, has problem with bigint parameters when it's NULL
Postgres reports error: invalid input syntax for type bigint ""
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: NULL Bigint function param problem with postgres

Post by marsupilami »

I created a ticket for this on our bug tracker: https://sourceforge.net/p/zeoslib/tickets/479/.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: NULL Bigint function param problem with postgres

Post by EgonHugeist »

@eversun

please update again. According the report: My crystal ball doesn't tell me what your doing and what you are using for.
Thus please provide:

1: Compiler including version
2: Which postgres version?
3: The SQL or bette a little test-case.

Otherwise i'll close the ticket. With this informations i can't do anything, sorry.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: NULL Bigint function param problem with postgres

Post by marsupilami »

Hello eversun,

I tried to cteate a simple test for your bugreport:

Code: Select all

procedure TZTestCompPostgreSQLBugReport.TestSF479;
var
  Query: TZQuery;
begin
  Query := CreateQuery;
  try
    Query.SQL.Text := 'select cast(:param as bigint) as colname';
    Query.ParamByName('param').Value := Null; // Query.ParamByName('param').Clear also doesn't raise an error
    Query.Open;
    Check(VarIsNull(Query.Fields[0].Value), 'The returned Colulmn is expected to contain a null value...');
  finally
    FreeAndNil(Query);
  end;
end;
This code doesn't raise the error on my test environment: PostgreSQL 9.5, Delphi 2010, latest Version of Zeos 8.0 (not trunk).

Could you please try to create a small example that raises the error?

Best regards,

Jan
eversun
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 28.01.2020, 09:31

Re: NULL Bigint function param problem with postgres

Post by eversun »

My pardon, I just do not see email notification and thought this will be a long way.

1. Complier version is 10.1 (Berlin) update 2
2. Postgres version is 12.5, but got same problems with 11.1 too
3. Full code is a little bit complicated, as Zeos is deeply embedded with DWS (Delphi Web Script) components. So after I got this error and failed to find a fast solution, just returned to older 7.3 Zeos code I used before.

Now I had tried a "clean" test, like you offered, i.e. alone TZConnection + TZQuery: select * from XXX.YYYY(:id, null::uuid)
No error appeared !

Finally I had found the problem. I suppose it does exist, but is absolutely different type.
Actually I use the same TZQuery instance several times, i.e. set some SQL, open, close, set new SQL, etc.

First call is made with the SQL: select 1 from pg_catalog.pg_namespace where nspname = :schema
Is runs succesfully.
Then I change SQL to the one I reported, i.e. select * from XXX.YYYY(:id, null::uuid)
And I only do set id if one is needed, and do not apply id parameter value if no need for it. And the ParamByName('id') is kept WideString type and the value one set with the first SQL, while parameter name is changed

After I modified my code to select * from XXX.YYYY(:id::bigint, null::uuid) and make forced Param.Clear call, it started working, but this way is a bit non-standard.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 798
Joined: 18.11.2018, 17:37
Location: Hungary

Re: NULL Bigint function param problem with postgres

Post by aehimself »

Heh.

See this topic.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: NULL Bigint function param problem with postgres

Post by EgonHugeist »

That's definitelly related. So please update from SVN and report your findings, eversun.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
eversun
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 28.01.2020, 09:31

Re: NULL Bigint function param problem with postgres

Post by eversun »

Great, thanks, it's working !
Post Reply