Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-05

Bug in TSQLQuery.ApplyRecUpdate

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luiz Américo

While trying to use mysql through sqldb i found some problems trying to apply the updates using TSqlQuery.ApplyUpdates:

Database info:
TableName = mysql_bench
Table structure = CREATE TABLE `mysql_bench` (`AInt` int(11) default NULL,`AFloat` float(13,5) default NULL,`AStr` varchar(100) default NULL)TYPE=MyISAM;

1 - FTableName was storing the ; caracter if it's near to the tablename in sql query. For example Select * from ATable; -> FTablename = 'ATable;'

I fixed it with this

sqldb.pp:699 -> Move(PS^,FTableName[1],(P-PS-1));

but its buggy in the case there's no ; in the end

2- After fixing the table name i got the following:

Sql executed through TSQLQuery.ApplyRecUpdate = insert into mysql_bench (AInt,AFloat,AStr) values
(0,10,123456789,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa');

Gives this error (also when used with a mysql management tool)

An unhandled exception occurred at $0040F0DD :
EDatabaseError : : Error executing query: You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server version for the right s
yntax to use near '' at line 1

3- I noticed that could be the Float format so i added the following line in TSqlConnection.GetAsSQLText

sqldb.pp:299 -> ftFloat    : Str(Double(Field.AsFloat),Result);

Now the sql is
insert into mysql_bench (AInt,AFloat,AStr) values (0,1.012345678900000E+001,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa');

But still gives the same error. Although the same sql can be executed with a mysql management tool.

I hope this info can help resolve this bug

Luiz

Reply by email

Joost van der Sluis
to Luiz Américo
Luiz Américo wrote 15 lines
While trying to use mysql through sqldb i found some problems trying to apply the updates using TSqlQuery.ApplyUpdates: Database info: TableName = mysql_bench Table structure = CREATE TABLE `mysql_bench` (`AInt` int(11) default NULL,`AFloat` float(13,5) default NULL,`AStr` varchar(100) default NULL)TYPE=MyISAM; 1 - FTableName was storing the ; caracter if it's near to the tablename in sql query. For example Select * from ATable; -> FTablename = 'ATable;' I fixed it with this sqldb.pp:699 -> Move(PS^,FTableName[1],(P-PS-1));

I'm rewriting this whole parser. It was more a proof-of-concept. It'll get soon better.

Show quoted text 24 lines
2- After fixing the table name i got the following: Sql executed through TSQLQuery.ApplyRecUpdate = insert into mysql_bench (AInt,AFloat,AStr) values (0,10,123456789,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa'); Gives this error (also when used with a mysql management tool) An unhandled exception occurred at $0040F0DD : EDatabaseError : : Error executing query: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right s yntax to use near '' at line 1 3- I noticed that could be the Float format so i added the following line in TSqlConnection.GetAsSQLText sqldb.pp:299 -> ftFloat : Str(Double(Field.AsFloat),Result); Now the sql is insert into mysql_bench (AInt,AFloat,AStr) values (0,1.012345678900000E+001,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa');

I've never tested it with float's. And i'm pretty sure they won't work. I'll have a
Met vriendelijke groeten,

Joost van der Sluis
CNOC Informatiesystemen en Netwerken
http://www.cnoc.nl

Reply by email