Thread: refint doesn't work well with BDE

refint doesn't work well with BDE

From
Zoltan Kovacs
Date:
Hi,

referential integrity seems to have a new behaviour in 7.0 versus 6.5.2
via the Borland Database Engine -> ODBC -> pgsql connection.

This error occurs when inserting into the foreign table an unreferenced value
or deleting from the primary table which is a referenced value (my opinion is
that none of the new refint errors can reach the BDE).

Details from ODBC log with 6.5.2:
-- cut here --
conn=53084280, query='BEGIN'
conn=53084280, query='DELETE FROM "table1" WHERE "id"=1001 AND "field1"=1015 AND "field2"=9 AND "field3"='207.1600.01'
AND"field4"='1''
 
ERROR from backend during send_query: 'ERROR:  table1_fd1: tuple referenced in table2'
conn=53084280, query='COMMIT'
STATEMENT ERROR: func=SC_execute, desc='', errnum=1, errmsg='Error while executing the query'
------------------------------------------------------------               hdbc=53084280, stmt=53098820, result=0
        manual_result=0, prepare=0, internal=0                bindings=0, bindings_allocated=0
parameters=54256992,parameters_allocated=5                statement_type=3, statement='DELETE FROM "table1" WHERE
"id"=?AND "field1"=? AND "field2"=? AND "field3"=? AND "field4"=?'                stmt_with_params='DELETE FROM
"table1"WHERE "id"=1001 AND "field1"=1015 AND "field2"=9 AND "field3"='207.1600.01' AND "field4"='1''
data_at_exec=-1,current_exec_param=-1, put_data=0                currTuple=-1, current_col=-1, lobj_fd=-1
maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1
cursor_name='SQL_CUR032A3944'               ----------------QResult Info -------------------------------
 
CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR:  table1_fd1: tuple referenced in table2'
------------------------------------------------------------          henv=54199504, conn=53084280, status=1,
num_stmts=16          sock=54199520, stmts=54199568, lobj_type=-999           ---------------- Socket Info
-------------------------------          socket=148, reverse=0, errornumber=0, errormsg='(NULL)'
buffer_in=53090620,buffer_out=53094720           buffer_filled_in=3, buffer_filled_out=0, buffer_read_in=2
 
-- cut here --

BDE stops after this.

Details from ODBC log with 7.0 (PSQLODBC.DLL has the only change which is
Thomas' one specially for the "list index" problem):

-- cut here --
conn=57606264, query='BEGIN'
conn=57606264, query='INSERT INTO "tmp" ("az" ,"hiv" )  VALUES (5, 2)'
ERROR from backend during clear: 'ERROR:  <unnamed> referential integrity violation - key referenced from tmp not found
intmp2
 
'
conn=57606264, query='COMMIT'
-- cut here --

BDE says nothing to this. BDE thinks that everything is all right, it changes
the table (inserts a row). After making a refresh, one can realize that no
changes were made, of course.


Could you please help?

Regards,
Zoltan


Re: refint doesn't work well with BDE

From
Kovacs Zoltan Sandor
Date:
On Wed, 5 Apr 2000, Jan Wieck wrote:
>     First of all, 6.5.* didn't had the FOREIGN KEY implementation
>     your 7.0 message is coming from. It's completely new stuff.
Yes, you're right, sorry. I used the contrib/spi/refint* stuff in 6.5.2.

>     Second, since an ERROR is correctly reported (violating a  RI
>     constraint  is an ERROR and I cannot see any extra \n there),
>     the bug seems to be in the ODBC or BDE part, not  looking  at
>     the  return  code  but  trying to interpret the textual error
>     message.
Checking the ODBC source, I found two places in interfaces/odbc/info.c
with check_foreign_key and check_primary_key functions. They are the
names of the refint check functions in the "contrib" solution in 6.5.*
These places are queries which should be changed a bit, I think. Are these
changes enough to make it work, Byron?

Thank you again.

Regards, Zoltan