diff --git a/ChangeLog b/ChangeLog index aa1698951..bb17cb5ad 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ $Source$ 2004-03-10 Michal Cihar * export.php: Correctly report error when export fails. + * libraries/database_interface.lib.php, libraries/dbi/mysql.dbi.lib.php, + libraries/dbi/mysqli.dbi.lib.php: Support for unbuffered queries - + PMA_DBI_QUERY_UNBUFFERED and fix support of PMA_DBI_QUERY_STORE. + * libraries/export/*.php: Use unbuffered queries (patch #890075). 2004-03-09 Marc Delisle * libraries/common.lib.php, libraries/display*, lang/*: diff --git a/libraries/export/csv.php b/libraries/export/csv.php index a8f47d00c..a8c5c351f 100644 --- a/libraries/export/csv.php +++ b/libraries/export/csv.php @@ -113,7 +113,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { global $escaped; // Gets the data from the database - $result = PMA_DBI_query($sql_query); + $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $fields_cnt = PMA_DBI_num_fields($result); // If required, get fields name at the first line diff --git a/libraries/export/latex.php b/libraries/export/latex.php index 1f55aae8a..ba67cbf5c 100644 --- a/libraries/export/latex.php +++ b/libraries/export/latex.php @@ -118,7 +118,7 @@ function PMA_exportDBCreate($db) { * @access public */ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $error_url); + $result = PMA_mysql_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $columns_cnt = PMA_DBI_num_fields($result); for ($i = 0; $i < $columns_cnt; $i++) { diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 882712f0d..47d6c9284 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -402,19 +402,18 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) $buffer = ''; - $result = PMA_DBI_query($sql_query); + // get the real types of the table's fields (in an array) + // the key of the array is the backquoted field name + $field_types = PMA_fieldTypes($db,$table,$use_backquotes); + + // analyze the query to get the true column names, not the aliases + // (this fixes an undefined index, also if Complete inserts + // are used, we did not get the true column name in case of aliases) + $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query)); + + $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); if ($result != FALSE) { $fields_cnt = PMA_DBI_num_fields($result); - $rows_cnt = PMA_DBI_num_rows($result); - - // get the real types of the table's fields (in an array) - // the key of the array is the backquoted field name - $field_types = PMA_fieldTypes($db,$table,$use_backquotes); - - // analyze the query to get the true column names, not the aliases - // (this fixes an undefined index, also if Complete inserts - // are used, we did not get the true column name in case of aliases) - $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query)); // Checks whether the field is an integer or not for ($j = 0; $j < $fields_cnt; $j++) { @@ -474,6 +473,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) $search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required $replace = array('\0', '\n', '\r', '\Z'); $current_row = 0; + $separator = isset($GLOBALS['extended_ins']) ? ',' : ';'; while ($row = PMA_DBI_fetch_row($result)) { $current_row++; @@ -524,9 +524,10 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) } unset($values); - if (!PMA_exportOutputHandler($insert_line . ((isset($GLOBALS['extended_ins']) && ($current_row < $rows_cnt)) ? ',' : ';') . $crlf)) return FALSE; + if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) return FALSE; } // end while + if (!PMA_exportOutputHandler(';' . $crlf)) return FALSE; } // end if ($result != FALSE) PMA_DBI_free_result($result); diff --git a/libraries/export/xml.php b/libraries/export/xml.php index aafedf506..625fb070e 100644 --- a/libraries/export/xml.php +++ b/libraries/export/xml.php @@ -113,7 +113,7 @@ function PMA_exportDBCreate($db) { * @access public */ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { - $result = PMA_DBI_query($sql_query); + $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $columns_cnt = PMA_DBI_num_fields($result); for ($i = 0; $i < $columns_cnt; $i++) {