Postgresql tableoid column problem

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
jaromir
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 20.01.2009, 12:52

Postgresql tableoid column problem

Post 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
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: Postgresql tableoid column problem

Post 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
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Postgresql tableoid column problem

Post by miab3 »

Probably you can use ad hoc???:

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

and change ParamChar.

Michal
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: Postgresql tableoid column problem

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Postgresql tableoid column problem

Post by EgonHugeist »

Thank you, Jan.

Patch applied R3596 \testing-7.2 (SVN)

@jaromir

please test the fix and give us a reply..
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
jaromir
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 20.01.2009, 12:52

Re: Postgresql tableoid column problem

Post 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
Post Reply