Overflow error deleting a record
Moderators: gto, EgonHugeist
-
- Fresh Boarder
- Posts: 12
- Joined: 09.03.2009, 21:36
Overflow error deleting a record
Hi,
Using Delphi7-MySQL 5 ... I have this:
CREATE TABLE `banco` (
`banco_id` bigint(20) NOT NULL auto_increment,
`ban_numero` smallint(6) NOT NULL,
`ban_nombre` varchar(80) NOT NULL,
PRIMARY KEY (`banco_id`),
UNIQUE KEY `ban_unq_numero` (`ban_numero`),
UNIQUE KEY `ban_unq_nombre` (`ban_nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=689349199046620195 DEFAULT CHARSET=latin1;
I have a ZQuery component connected to a DataSetProvider and then a ClientDataSet
When deleting a record I get:
"Overflow while converting variant of type (Int64) into type (Integer)"
The code I used to delete the record is:
DataSource.DataSet.Delete;
if TClientDataSet( DataSource.DataSet ).ApplyUpdates(0) > 0 then
TClientDataSet( DataSource.DataSet ).CancelUpdates;
On a previous version of the program, I connected the DataSource directly to the TZQuery and I didn't have this problem. I added Provider and ClientDataSet since I need functioanlity of these...
I suppose this problem is related to the PK field "banco_id", being bigInt? what internally would be treating it as Integer data type?
Thank you,
Using Delphi7-MySQL 5 ... I have this:
CREATE TABLE `banco` (
`banco_id` bigint(20) NOT NULL auto_increment,
`ban_numero` smallint(6) NOT NULL,
`ban_nombre` varchar(80) NOT NULL,
PRIMARY KEY (`banco_id`),
UNIQUE KEY `ban_unq_numero` (`ban_numero`),
UNIQUE KEY `ban_unq_nombre` (`ban_nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=689349199046620195 DEFAULT CHARSET=latin1;
I have a ZQuery component connected to a DataSetProvider and then a ClientDataSet
When deleting a record I get:
"Overflow while converting variant of type (Int64) into type (Integer)"
The code I used to delete the record is:
DataSource.DataSet.Delete;
if TClientDataSet( DataSource.DataSet ).ApplyUpdates(0) > 0 then
TClientDataSet( DataSource.DataSet ).CancelUpdates;
On a previous version of the program, I connected the DataSource directly to the TZQuery and I didn't have this problem. I added Provider and ClientDataSet since I need functioanlity of these...
I suppose this problem is related to the PK field "banco_id", being bigInt? what internally would be treating it as Integer data type?
Thank you,
-
- Fresh Boarder
- Posts: 12
- Joined: 09.03.2009, 21:36
Debugging a bit deeper, I found that:
In ZAbstractDataSet.pas, there is this block of code, starting at line 677:
for I := 0 to Length(FieldRefs) - 1 do
begin
SrcField := Delta.FieldByName(TField(FieldRefs).FieldName);
if SrcField <> nil then
begin
if (SrcField.DataType = ftLargeInt)
and not VarIsNull(SrcField.OldValue) then
Temp := Integer(SrcField.OldValue)
else Temp := SrcField.OldValue;
end else
Temp := Null;
end;
On the marked line, the db table's id field its being tryed to be converted into an Integer (32 bits), when it is required a 64 bit number...
Is it a bug?
In ZAbstractDataSet.pas, there is this block of code, starting at line 677:
for I := 0 to Length(FieldRefs) - 1 do
begin
SrcField := Delta.FieldByName(TField(FieldRefs).FieldName);
if SrcField <> nil then
begin
if (SrcField.DataType = ftLargeInt)
and not VarIsNull(SrcField.OldValue) then
Temp := Integer(SrcField.OldValue)
else Temp := SrcField.OldValue;
end else
Temp := Null;
end;
On the marked line, the db table's id field its being tryed to be converted into an Integer (32 bits), when it is required a 64 bit number...
Is it a bug?
-
- Fresh Boarder
- Posts: 12
- Joined: 09.03.2009, 21:36
-
- Fresh Boarder
- Posts: 12
- Joined: 09.03.2009, 21:36
File ZAbstractRODataSet.pas, Line 3024:
Changed from
Statement.SetInt(I + 1, ParamValue.AsInteger);
To
Statement.SetLong(I + 1, StrToInt64(ParamValue.AsString));
File ZAbstractDataSet.pas, Line 688:
Changed from
Temp := Integer(SrcField.OldValue)
To
Temp:= string(SrcField.OldValue);
Regards,
Guillermo
Changed from
Statement.SetInt(I + 1, ParamValue.AsInteger);
To
Statement.SetLong(I + 1, StrToInt64(ParamValue.AsString));
File ZAbstractDataSet.pas, Line 688:
Changed from
Temp := Integer(SrcField.OldValue)
To
Temp:= string(SrcField.OldValue);
Regards,
Guillermo
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Didn't break the test suite. So I commit to SVN Testing branch (Rev. 608). Before this is backported to the 6.6-patches branch I want some more people to give feedback on this topic.
This patch impacts all people using bigints as key fields, I think. I suppose most people don't run into problems as long as the key stays withing the Integer range?
Mark
This patch impacts all people using bigints as key fields, I think. I suppose most people don't run into problems as long as the key stays withing the Integer range?
Mark
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Got some stupid idea. Seems like Variants can be Int64 values as well in D7. (When quick scanning the variants units)
Wouldn't it be better we just remove the
part from the code? At least in the Zeoslib 7.X version, 6.6 should in theory be able to compile on D5, where Variant support was still primitive, I believe.
Can you do me a favour and try this with your test program/data?
Mark
Wouldn't it be better we just remove the
if (SrcField.DataType = ftLargeInt)
and not VarIsNull(SrcField.OldValue) then
Temp := Integer(SrcField.OldValue)
else
part from the code? At least in the Zeoslib 7.X version, 6.6 should in theory be able to compile on D5, where Variant support was still primitive, I believe.
Can you do me a favour and try this with your test program/data?
Mark
-
- Fresh Boarder
- Posts: 12
- Joined: 09.03.2009, 21:36