<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-07-09 23:52 GMT+02:00 Chirayu Chiripal <span dir="ltr"><<a href="mailto:chirayu.chiripal@gmail.com" target="_blank">chirayu.chiripal@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="h5"><div class="gmail_extra">
<div class="gmail_quote">On Thu, Jul 10, 2014 at 3:10 AM, Hugues Peccatte <span dir="ltr"><<a href="mailto:hugues.peccatte@gmail.com" target="_blank">hugues.peccatte@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>2014-07-09 19:37 GMT+02:00 Hugues Peccatte <span dir="ltr"><<a href="mailto:hugues.peccatte@gmail.com" target="_blank">hugues.peccatte@gmail.com</a>></span>:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
2014-07-09 17:34 GMT+02:00 Isaac Bennetch <span dir="ltr"><<a href="mailto:bennetch@gmail.com" target="_blank">bennetch@gmail.com</a>></span>:<div><div><div><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Hello,<br>
<br>
In the course of my testing the new input transformation feature, I've<br>
encountered some trouble that Chirayu is unable to reproduce. We've had<br>
a bit of discussion privately about it, but wanted to move discussion<br>
back to the mailing list.<br>
<br>
Note that running his branch[1] will change your pma__column_info table<br>
structure; so you may wish to back it up for testing purposes.<br>
<br>
The problem at the moment is the automatic table upgrade feature. What<br>
is supposed to happen is that, when logging in,<br>
PMA_checkRelationsParam() verifies that the correct table structure<br>
exists for pma__column_info. If it doesn't, it attempts to run<br>
./examples/upgrade_column_info_4_3_0+.sql (after substituting the<br>
correct database and table names if needed). This is all quite good.<br>
<br>
On my system, what happens, however, is that<br>
<br>
$GLOBALS['dbi']->tryMultiQuery($query, $GLOBALS['controllink'])<br>
<br>
doesn't work. It returns 1 (which I presume is just how print_r<br>
represents TRUE), but the query doesn't execute ($query in this case is<br>
essentially the contents of the .sql file; several SQL statements with<br>
semicolons and newline characters and a few comments). It works properly<br>
on Chirayu's system but silently fails on mine.<br>
<br>
I'm hoping to get additional testing on the "silent upgrade" feature<br>
(or, for that matter, thoughts about the problem). At this point, I'm<br>
the only one for whom it fails, which is quite interesting. To test,<br>
simply checkout the branch and open phpMyAdmin, then check your<br>
pma__column_info table; it should have two new columns at the end (input_*).<br>
<br>
Thanks!<br>
<br>
Some more detailed information if you really want to read on:<br>
<br>
Around line 610, instead of directly testing the result of the<br>
tryMultiQuery in the if statement, I assign it to a variable then<br>
print_r that variable and get a message about "Commands out of sync; you<br>
can't run this command now".<br>
<br>
$ipb_test = $GLOBALS['dbi']->tryMultiQuery($query,<br>
$GLOBALS['controllink'] );<br>
die("<pre>" . print_r($GLOBALS['controllink']) . "</pre>");<br>
if ($ipb_test !== false ) {<br>
return true;<br>
<br>
mysqli Object ( [affected_rows] => 0 [client_info] => 5.5.37<br>
[client_version] => 50537 [connect_errno] => 0 [connect_error] =><br>
[errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0<br>
[host_info] => Localhost via UNIX socket [info] => [insert_id] => 0<br>
[server_info] => 5.5.37-0+wheezy1 [server_version] => 50537 [stat] =><br>
Commands out of sync; you can't run this command now [sqlstate] => HY000<br>
[protocol_version] => 10 [thread_id] => 6069 [warning_count] => 0 )<br>
<br>
I'm not familiar enough with tryMultiQuery to know why [stat] contains<br>
this message.<br>
<br>
According to [2], it appears as if there is a problem with executing the<br>
code because either we haven't used mysql_free_result() or<br>
mysql_use_result() or mysql_store_result() since a previous query.<br>
<br>
We've looked at mysqli_multi_query()<br>
(<a href="http://www.php.net/manual/en/mysqli.multi-query.php" target="_blank">http://www.php.net/manual/en/mysqli.multi-query.php</a>), which<br>
is called by tryMultiQuery() depending on your DBI Extension (mine<br>
is mysqli). It says that it returns false when First statement is<br>
failed. See the return values section of it.<br>
<br>
Note that my mysqli object claims 0 rows were affected but also didn't<br>
return false. I expect that the 87 rows in my pma__column_info would<br>
have been affected by the first line (ALTER...).<br>
<br>
1 - <a href="https://github.com/D-storm/phpmyadmin/commits/FR-637" target="_blank">https://github.com/D-storm/phpmyadmin/commits/FR-637</a><br>
2 - <a href="https://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html" target="_blank">https://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html</a><br>
</blockquote></div></div></div></div></div><br></div><div><div><div class="gmail_extra">Hi,</div><div class="gmail_extra"><br></div><div class="gmail_extra">It seems that I found the same information while reading your email and doing some research on internet about mysqli_multi_query and its return.</div>
<div class="gmail_extra">So maybe we need to improve PMA_DBI_Mysqli::realMultiQuery to return the real error status.</div><div class="gmail_extra"><br></div><div class="gmail_extra">But first maybe, you can try something like this in this method (I didn't test it…):</div>
<div class="gmail_extra">if ($r = mysqli_multi_query($link, $query)) {</div><div class="gmail_extra"><div class="gmail_extra"> do {</div><div class="gmail_extra"> if ($result = mysqli_store_result($link)) {</div>
<div class="gmail_extra"> echo 'ok.<br />';</div><div class="gmail_extra"> mysqli_free_result($result);</div><div class="gmail_extra"> } else {</div><div class="gmail_extra"> $r = false;</div>
<div class="gmail_extra"> echo 'KO<br />'; //Do you know a way get the query here? I didn't find one…</div><div class="gmail_extra"> }</div><div class="gmail_extra"> } while (mysqli_next_result($link));</div>
<div class="gmail_extra">}</div><div class="gmail_extra">return $r;</div><div class="gmail_extra"><br></div><div class="gmail_extra">Then, you'll know the query which failed.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
We're waiting for your feedback. (I'll try… to try…)</div><span><font color="#888888"><div class="gmail_extra">Hugues.</div></font></span></div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Sorry, I just did some research and it can work. mysqli_store_result can''t be used with INSERT, UPDATE, DELETE, ALTER statement. But we may try to use mysqli_error to really if there is an error or not.<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'll try to do other tests with mysqli_error, maybe.</div><span><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">
Hugues.</div></font></span></div>
</blockquote></div><br><br clear="all"></div></div></div><div class="gmail_extra">Yeah, you are right. I tested it using this code,<br><br>mysqli_multi_query(<br> $GLOBALS['controllink'], $query<br>);<br>do {<br>
var_dump(mysqli_error($GLOBALS['controllink']));<br>
} while (mysqli_next_result($GLOBALS['controllink']));<br>var_dump(mysqli_error($GLOBALS['controllink']));<br><br></div><div class="gmail_extra">and for the last var_dump() I got the error which I intentionally did and for other queries which were executed successfully it returned an empty string.<br>
</div><div class=""><div class="gmail_extra"><br></div><div class="gmail_extra">-- <br><div dir="ltr">Regards,<br>Chirayu Chiripal<br>phpMyAdmin Intern - Google Summer of Code 2014<br><a href="https://chirayuchiripal.wordpress.com/" target="_blank">https://chirayuchiripal.wordpress.com/</a></div>
</div></div></div></blockquote></div><br></div><div class="gmail_extra">Oh thanks! I was about giving up!</div><div class="gmail_extra">So I defined the following method (and I think that should be in master) :</div><div class="gmail_extra">
<div class="gmail_extra"> public function realMultiQuery($link, $query)</div><div class="gmail_extra"> {</div><div class="gmail_extra"> if (false === mysqli_multi_query($link, $query)) {</div><div class="gmail_extra">
return false;</div><div class="gmail_extra"> }</div><div class="gmail_extra"><br></div><div class="gmail_extra"> while (mysqli_next_result($link));</div><div class="gmail_extra"><br></div><div class="gmail_extra">
return('' === mysqli_error($link));</div><div class="gmail_extra"> }</div><div class="gmail_extra"><br></div><div class="gmail_extra">And it seems to be ok.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
The only thing that I don't like is that the script is half executed but can't be reverted… But I'm not sure there is a way to manage it… There are some DB structure modifications and we can't revert this, so it would need to write a specific "undo" script. But even with this, how to automatically know if all the undo script has to be executed are only a part and which one ?</div>
<div class="gmail_extra">(If we know the number of queries, we might imagine, but not sure that would be a good solution…)</div><div class="gmail_extra"><br></div><div class="gmail_extra">Hugues.</div></div></div>