TMyDump doTables=true set the auto_increment value

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

TMyDump doTables=true set the auto_increment value

Post by Thomas J. » Wed 17 Jan 2007 08:29

Hello support,
i have a problem with the TMyDump and Option doTables=true. Such a statement is generated by your component.
DROP TABLE IF EXISTS t_allekufen;
CREATE TABLE `t_allekufen` (
`k_id` int(11) NOT NULL auto_increment,
`k_dim1` int(11) default NULL,
`k_dim2` int(11) default NULL,
PRIMARY KEY (`k_id`)
) ENGINE=MyISAM AUTO_INCREMENT=67 DEFAULT CHARSET=latin1;
Why is the autoinc value set like 'AUTO_INCREMENT=67'?

If I want to create a new table the inc value should start by 0 and not by the value which is actual set for the specific table. Is this an option which I can change?

Actual a have to change in my script 53 tables! :cry:

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 17 Jan 2007 11:03

This is MySQL Server behaviour. TMyDump uses the SHOW CREATE TABLE command to get this script. TMyDump does not have such option. You should change this script manually.

Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

Post by Thomas J. » Wed 17 Jan 2007 11:56

Sorry, but this is not true. If I execute the command
SHOW CREATE TABLE `p_cratemaker`.`t_allekufen`;
I get
"Table","Create Table"
"t_allekufen","CREATE TABLE `t_allekufen` (
`k_id` int(11) NOT NULL auto_increment,
`k_dim1` int(11) default NULL,
`k_dim2` int(11) default NULL,
PRIMARY KEY (`k_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1"
And I cannot see anything regarding 'AUTO_INCREMENT=67'

I use the MySQL Server 5.0.22 and your component V 4.40.0.22 for C++Builder

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 17 Jan 2007 15:33

We could not reproduce the problem. There is no code in MyDAC for adding the AUTO_INCREMENT statement to the CREATE TABLE command. Probably there is a difference in your connections settings.
We executed the script from your first post to create test table and compared SQL statement generated by TMyDump with the one returned by executing SHOW CREATE TABLE via mysql.exe - AUTO_INCREMENT appears in both cases.
Probably adding "NO_TABLE_OPTIONS" to the sql_mode server variable will help you to solve the problem.

Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

Post by Thomas J. » Thu 18 Jan 2007 08:16

Ok you are right. The version of MySQLServer 5.0.22 creates a statement without auto_increment. The version 5.0.27 creates a statement with auto_increment.

And you are sure that no option exists to create a statement without auto_increment?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 18 Jan 2007 10:33

There is no such option in MyDAC. Probably there is a possibility to solve this problem with a MySQL Server setting(e.g. NO_TABLE_OPTIONS mentioned above). Another possible way to solve the problem is to write a procedure that scans SQL text, retrieved by a TMyDump object, and removes the "AUTO_INCREMENT=xx" entries.

Post Reply