As long as a command is not ended with a database delimiter, sql.php
kept appending the line without noticing the users. That is a bit
confusing since you might not even know what you are going to run when
entering the delimiter.
This patch alter the prompt to ' ->' until the command is finished.
That is more in line with how MySQL cli handles it.
Example:
$ php sql.php
> SELECT
-> *
-> from
-> job;
Query OK, 0 row(s) affected
// repeal command:
> SELECT * from job
Change-Id: Ic18b39d75d4db48d37d485e66f36d691e95934fb
}
$wholeLine = '';
- while ( ( $line = Maintenance::readconsole() ) !== false ) {
+ $newPrompt = '> ';
+ $prompt = $newPrompt;
+ while ( ( $line = Maintenance::readconsole( $prompt ) ) !== false ) {
+ if( !$line ) {
+ # User simply pressed return key
+ continue;
+ }
$done = $dbw->streamStatementEnd( $wholeLine, $line );
$wholeLine .= $line;
if ( !$done ) {
+ $wholeLine .= ' ';
+ $prompt = ' -> ';
continue;
}
if ( $useReadline ) {
try{
$res = $dbw->query( $wholeLine );
$this->sqlPrintResult( $res, $dbw );
+ $prompt = $newPrompt;
$wholeLine = '';
} catch (DBQueryError $e) {
$this->error( $e, true );