@@ -900,7 +900,13 @@ private function listValues($tableName)
900900 $ onlyOnce = true ;
901901 $ lineSize = 0 ;
902902
903+ // colStmt is used to form a query to obtain row values
903904 $ colStmt = $ this ->getColumnStmt ($ tableName );
905+ // colNames is used to get the name of the columns when using complete-insert
906+ if ($ this ->dumpSettings ['complete-insert ' ]) {
907+ $ colNames = $ this ->getColumnNames ($ tableName );
908+ }
909+
904910 $ stmt = "SELECT " .implode (", " , $ colStmt )." FROM ` $ tableName` " ;
905911
906912 if ($ this ->dumpSettings ['where ' ]) {
@@ -918,7 +924,7 @@ private function listValues($tableName)
918924 if ($ this ->dumpSettings ['complete-insert ' ]) {
919925 $ lineSize += $ this ->compressManager ->write (
920926 "INSERT $ ignore INTO ` $ tableName` ( " .
921- implode (", " , $ colStmt ).
927+ implode (", " , $ colNames ).
922928 ") VALUES ( " .implode (", " , $ vals ).") "
923929 );
924930 } else {
@@ -1035,7 +1041,7 @@ function endListValues($tableName)
10351041 }
10361042
10371043 /**
1038- * Build SQL List of all columns on current table
1044+ * Build SQL List of all columns on current table which will be used for selecting
10391045 *
10401046 * @param string $tableName Name of table to get columns
10411047 *
@@ -1059,6 +1065,27 @@ function getColumnStmt($tableName)
10591065
10601066 return $ colStmt ;
10611067 }
1068+
1069+ /**
1070+ * Build SQL List of all columns on current table which will be used for inserting
1071+ *
1072+ * @param string $tableName Name of table to get columns
1073+ *
1074+ * @return string SQL sentence with columns
1075+ */
1076+ function getColumnNames ($ tableName )
1077+ {
1078+ $ colNames = array ();
1079+ foreach ($ this ->tableColumnTypes [$ tableName ] as $ colName => $ colType ) {
1080+ if ($ colType ['is_virtual ' ]) {
1081+ $ this ->dumpSettings ['complete-insert ' ] = true ;
1082+ continue ;
1083+ } else {
1084+ $ colNames [] = "` $ {colName}` " ;
1085+ }
1086+ }
1087+ return $ colNames ;
1088+ }
10621089}
10631090
10641091/**
0 commit comments