diff --git a/src/Commands/sql/SqlCommands.php b/src/Commands/sql/SqlCommands.php index dc332bed8b..612459b011 100644 --- a/src/Commands/sql/SqlCommands.php +++ b/src/Commands/sql/SqlCommands.php @@ -137,12 +137,21 @@ public function drop($options = ['extra' => self::REQ]): void public function cli(InputInterface $input, $options = ['extra' => self::REQ]): void { $sql = SqlBase::create($options); - $process = $this->processManager()->shell($sql->connect(), null, $sql->getEnv()); + $sql_cmd = $sql->connect(); if (!Tty::isTtySupported()) { - $process->setInput($this->stdin()->getStream()); - } else { - $process->setTty((bool) $this->getConfig()->get('ssh.tty', $input->isInteractive())); + // Fast path for non-interactive mode (e.g. piped SQL dump). + // Use direct passthru to avoid PHP I/O buffering. + $env_str = ''; + foreach ($sql->getEnv() as $k => $v) { + $env_str .= "$k=" . escapeshellarg($v) . ' '; + } + + passthru($env_str . $sql_cmd); + return; } + // Interactive mode (TTY): use ProcessManager for better control. + $process = $this->processManager()->shell($sql_cmd, null, $sql->getEnv()); + $process->setTty((bool) $this->getConfig()->get('ssh.tty', $input->isInteractive())); $process->mustRun($process->showRealtime()); }