Page 1 of 1

Postgresql tableoid column problem

Posted: 09.01.2015, 17:18
by jaromir
Hello,

Recently i upgrade from Delphi2010 to XE7. I used Zeos 6 before but now i had to switch to 7.1 stable release.
After upgrade i have problem with tableoid postgresql tables hidden column.

Simple example:

CREATE DATABASE test_zeos;
CREATE TABLE table_a ("int" integer, text text);

When i execute SQL in TZQuery:

SELECT tableoid, * FROM table_a;

There we have:

First chance exception at $00405C03. Exception class $C0000005 with message 'access violation at 0x00405c03: read of address 0x00000000'. Process Project1.exe (1984)

Of course: SELECT * FROM table_a; works OK.
It is possible to workaround something like this: SELECT my_new_procedure(tableoid), * FROM table_a;
but this is my last unhappy solution.

Tableoid is hidden column in every postgresql table, it is very important to me.

I checked the same bug under 2010 with 7.1 and the same bug with 7.2 from SVN on both my Delphi.

Any chance for help ?

Regards Jaromir

Re: Postgresql tableoid column problem

Posted: 10.01.2015, 11:40
by marsupilami
Hello Jaromir,

I can confirm this bug. It is a problem with the table info cache in the postgresql driver. I am working on a solution...
Best regards,

Jan

Re: Postgresql tableoid column problem

Posted: 10.01.2015, 16:11
by miab3
Probably you can use ad hoc???:

select tableoid::regclass::oid, * from table

and change ParamChar.

Michal

Re: Postgresql tableoid column problem

Posted: 11.01.2015, 08:48
by marsupilami
Hello :)

the problem is that there is a range check error in the table metadata caching code of the postgresql driver. System fields like oid and tableoid are stored with a negative index number in PostgreSQL whereas the cache in the driver only loads information of fields with positive indices and later on accesses them without checking if the index number is for the column is positive. The attached patch solves this problem by adding a check for negative numbers and resolving them statically. The static mapping is no problem because PostgreSQL also has static mappings for them in its source code.
With best regards,

Jan

Re: Postgresql tableoid column problem

Posted: 11.01.2015, 23:29
by EgonHugeist
Thank you, Jan.

Patch applied R3596 \testing-7.2 (SVN)

@jaromir

please test the fix and give us a reply..

Re: Postgresql tableoid column problem

Posted: 12.01.2015, 11:51
by jaromir
Jan !!
Thank You very much !

It looks like everything is ok. This patch is probably not for 7.1 but i did changes manually and my code passed few tests.
I'l be testing next few days - if something will be wrong i'll make a call :)

Thanks Jan again.

Regards Jaromir