SourceForge has been redesigned. Learn more.
Close

#698 (ok 3.4.10) copy table data missing SET SQL_MODE

closed-accepted
None
1
2012-02-14
2011-12-13
Glenn
No

For the same reason SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO' is included in export / import operations it needs to precede the INSERT INTO statement that copies table data. Here's a diff of my modification that solves the problem.

========================================
# diff -bu Table.class-orig.php Table.class.php
--- Table.class-orig.php 2011-12-01 11:21:14.000000000 -0600
+++ Table.class.php 2011-12-13 03:41:06.536499576 -0600
@@ -775,6 +775,10 @@

// Copy the data unless this is a VIEW
if (($what == 'data' || $what == 'dataonly') && ! PMA_Table::_isView($target_db,$target_table)) {
+ $sql_set_mode =
+ "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'";
+ PMA_DBI_query($sql_set_mode);
+ $GLOBALS['sql_query'] .= "\n\n" . $sql_set_mode . ';';
$sql_insert_data =
'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
PMA_DBI_query($sql_insert_data);

========================================

Not that it matters much in this case, here are relevant apps and versions:

Linux lindev2 3.1.0-1-686-pae #1 SMP Mon Nov 14 08:24:20 UTC 2011 i686 GNU/Linux
PHP extension: mysqli
PHP 5.3.8
MySQL sever 5.1.52
MySQL client 5.1.58
Apache/2.2.21 (Debian)

Discussion

  • Marc Delisle

    Marc Delisle - 2011-12-29
    • labels: 509096 -->
    • milestone: 2348504 -->
     
  • Marc Delisle

    Marc Delisle - 2011-12-29

    Moved to Patches.

     
  • Marc Delisle

    Marc Delisle - 2011-12-29
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2011-12-29
    • summary: copy table data missing SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO' --> (ok 3.4.10) copy table data missing SET SQL_MODE
    • priority: 5 --> 1
    • status: open --> open-accepted
     
  • Marc Delisle

    Marc Delisle - 2011-12-29

    Your patch was merged in the repository, thanks.

     
  • Marc Delisle

    Marc Delisle - 2012-02-14
    • status: open-accepted --> closed-accepted