#185 (in 2.6.0) Unbuffered query while exporting

closed-accepted
1
2004-09-27
2004-02-03
Anonymous
No

Rene Luria <operator@infomaniak.ch>
(in production on 2.5.5-pl1 since 9jan2004 and used by over 15'000
clients)

There is no nead to do a normal mysql query to export data.
The only use of having a normal query instead of an unbuffered
one is that it allows to have row count on result set... to decide
wether to add ";" or "," at the end of a line in case of extended
insert.

Here's my dirty patch
__BEGIN__
diff -Naur MySQLAdmin.orig/libraries/export/sql.php MySQLAdmin/
libraries/export/sql.php
--- MySQLAdmin.orig/libraries/export/sql.php Thu Dec 11 18:32:
42 2003
+++ MySQLAdmin/libraries/export/sql.php Tue Jan 20 17:19:
27 2004
@@ -385,14 +385,14 @@

$buffer = '';

- $result = PMA_mysql_query($sql_query) or
PMA_mysqlDie('', $sql_query, '', $error_url);
+ $field_types =
PMA_fieldTypes($db,$table,$use_backquotes);
+ $result = PMA_mysql_unbuffered_query($sql_query) or
PMA_mysqlDie('', $sql_query, '', $error_url);
if ($result != FALSE) {
$fields_cnt = mysql_num_fields($result);
- $rows_cnt = mysql_num_rows($result);
+// $rows_cnt = mysql_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
@@ -507,9 +507,23 @@
}
unset($values);

- if (!PMA_exportOutputHandler($insert_line .
((isset($GLOBALS['extended_ins']) && ($current_row < $rows_cnt))
? ',' : ';') . $crlf)) return FALSE;
+ if (isset($GLOBALS['extended_ins'])) {
+ if ($current_row > 1) {
+ $firstsep = ',' . $crlf;
+ } else {
+ $firstsep = '';
+ }
+ $secondsep = '';
+ } else {
+ $firstsep = '';
+ $secondsep = ';' . $crlf;
+ }
+ if (!PMA_exportOutputHandler( $firstsep . $insert_line .
$secondsep)) return FALSE;

} // end while
+ if (($current_row > 0) && isset($GLOBALS['extended_ins'])) {
+ if (!PMA_exportOutputHandler(';' . $crlf)) return FALSE;
+ }
} // end if ($result != FALSE)
mysql_free_result($result);

diff -Naur MySQLAdmin.orig/libraries/mysql_wrappers.lib.php
MySQLAdmin/libraries/mysql_wrappers.lib.php
--- MySQLAdmin.orig/libraries/mysql_wrappers.lib.php Wed Nov
26 23:52:23 2003
+++ MySQLAdmin/libraries/mysql_wrappers.lib.php Tue Jan 20 17:
02:14 2004
@@ -105,6 +105,18 @@
}
}

+function PMA_mysql_unbuffered_query($query, $link_identifier =
FALSE, $result_mode = FALSE) {
+ if ($link_identifier != FALSE) {
+ if ($result_mode != FALSE) {
+ return
mysql_unbuffered_query(PMA_convert_charset($query),
$link_identifier, $result_mode);
+ } else {
+ return
mysql_unbuffered_query(PMA_convert_charset($query),
$link_identifier);
+ }
+ } else {
+ return
mysql_unbuffered_query(PMA_convert_charset($query));
+ }
+}
+
// mysql_list_tables() is deprecated, also we got report about
weird results
// under some circumstances

__END__

Discussion

  • Olivier Mueller

    Olivier Mueller - 2004-02-04

    Logged In: YES
    user_id=15563

    PS: submitted by SF user 'herel'

     
  • Olivier Mueller

    Olivier Mueller - 2004-02-04
    • priority: 5 --> 7
     
  • Michal Čihař

    Michal Čihař - 2004-03-09
    • assigned_to: nobody --> nijel
     
  • Michal Čihař

    Michal Čihař - 2004-03-10
    • priority: 7 --> 1
    • summary: make unbuffered query while exporting --> (in 2.6.0) Unbuffered query while exporting
    • status: open --> open-accepted
     
  • Michal Čihař

    Michal Čihař - 2004-03-10

    Logged In: YES
    user_id=192186

    Thanks for idea. Unbuffered queries are now used for all
    exports using new dbi infrastructure.

     
  • Olivier Mueller

    Olivier Mueller - 2004-03-12

    Logged In: YES
    user_id=15563

    hi nijel,

    have you commited the patch yet? otherwise herel would have
    a new version corresponding to the current cvs.

    cheers,
    Olivier

     
  • Michal Čihař

    Michal Čihař - 2004-03-14

    Logged In: YES
    user_id=192186

    Yes, commited only in cvs HEAD (not in MAINT_2_5) as it uses
    new DBI interface.

     
  • Alexander M. Turek

    • status: open-accepted --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks