From 83e90ae1a0507807514e73a939cbe0d4f6aebb2f Mon Sep 17 00:00:00 2001 From: Smita Kumari Date: Wed, 27 Aug 2014 18:47:21 +0530 Subject: [PATCH] bug fix #4487 Signed-off-by: Smita Kumari --- libraries/plugins/export/ExportSql.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index b4622020ac..8b136e023e 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1481,13 +1481,18 @@ class ExportSql extends ExportPlugin // that could be there starting with MySQL 5.0.24 // in Drizzle it's useless as it contains the value given at table // creation time - $schema_create = preg_replace( - '/AUTO_INCREMENT\s*=\s*([0-9])+/', - '', - $schema_create - ); - - $schema_create .= ($compat != 'MSSQL') ? $auto_increment : ''; + if (preg_match('/AUTO_INCREMENT\s*=\s*([0-9])+/', $schema_create)) { + if ($compat == 'MSSQL' || $auto_increment == '') { + $auto_increment = ' '; + } + $schema_create = preg_replace( + '/\sAUTO_INCREMENT\s*=\s*([0-9])+\s/', + $auto_increment, + $schema_create + ); + } else { + $schema_create .= ($compat != 'MSSQL') ? $auto_increment : ''; + } $GLOBALS['dbi']->freeResult($result); return $schema_create . ($add_semicolon ? ';' . $crlf : '');