You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
drush sql:drop would not produce an error, and would successfully erase all tables in the database.
The SQL statement drush intends to create is like DROP TABLES `tablename1` `tablename2` `tablename3` `tablename4`;
Actual behavior
The SQL backend returns a syntax error to drush, and drush will terminate with an error.
The SQL statement with bad syntax drush actually creates is like:
DROP TABLES `tablename1
tablename2
tablename3
tablename4`;
Workarounds
Strangely, Oracle's MySQL 8.x mysql client-executable does work with drush 12.x with no problems. So simply install Oracle's MySQL on your Drupal webserver even though your SQL backend uses MariaDB? Clearly not an ideal solution.
I do not know why MySQL 8.x's client-executable's output has different line endings than MariaDB 10.11's output.
I may be so ignorant that MariaDB has a configuration setting to set its line-endings?
There is "binary-mode", which solves this drush sql:drop problem. BUT we think there may be compatibility problems setting binary-mode to true across other Drupal projects or Drupal Core functionality. No where in Drupal documentation does it say that SQL binary-mode must be enabled as a requirement?
Replacing PHP_EOL with "\n" in Drush\SqlMySql->listTables() makes drush work with MariaDB, but then it breaks when using Oracle's MySQL on Windows. This is clearly not the way to address the problem.
Additional information
The backend SQL server/service does not matter. For example, we reproduced the same error when the backend SQL is running Oracle's MySQL 5.7 instead of MariaDB 10.11.
In other words, we think what matters is only the client-executable that is used by drush.
Bypassing Drush, Symfony, and PHP, we verified that the output of mariadb's client-executable does use only \n line-endings while MySQL uses \r\n on Windows.
mysql -h DB_HOSTNAME_HERE -u DB_USER_HERE -p -e 'use `DB_SCHEMA_HERE`; show tables;' > output.txt
Thank you for any help on this!
The text was updated successfully, but these errors were encountered:
Describe the bug
drush sql:drop errors due to bad SQL syntax in a
DROP TABLE
query when using a MariaDB client-executable in a Microsoft Windows environment.Drush uses the constant
PHP_EOL
to create a list of table names from the SQL output ofSHOW TABLES
.PHP_EOL
in a Windows environment.PHP_EOL
is\r\n
on Windows, but the MariaDB client-executable's output is simply\n
for line endings.https://github.com/drush-ops/drush/blob/12.4.2/src/Sql/SqlMysql.php#L173
To Reproduce
Run drush sql:drop on a Windows computer where MariaDB 10.11's
mysql
client-executable is available in the PATH.Full log of the error, using drush's debug output drush sql:drop -vvv, is attached here:
drush-mariadb-sqldrop-error.log
Expected behavior
drush sql:drop would not produce an error, and would successfully erase all tables in the database.
The SQL statement drush intends to create is like
DROP TABLES `tablename1` `tablename2` `tablename3` `tablename4`;
Actual behavior
The SQL backend returns a syntax error to drush, and drush will terminate with an error.
The SQL statement with bad syntax drush actually creates is like:
Workarounds
Strangely, Oracle's MySQL 8.x
mysql
client-executable does work with drush 12.x with no problems. So simply install Oracle's MySQL on your Drupal webserver even though your SQL backend uses MariaDB? Clearly not an ideal solution.I may be so ignorant that MariaDB has a configuration setting to set its line-endings?
Replacing
PHP_EOL
with"\n"
inDrush\SqlMySql->listTables()
makes drush work with MariaDB, but then it breaks when using Oracle's MySQL on Windows. This is clearly not the way to address the problem.System Configuration
Additional information
The backend SQL server/service does not matter. For example, we reproduced the same error when the backend SQL is running Oracle's MySQL 5.7 instead of MariaDB 10.11.
Bypassing Drush, Symfony, and PHP, we verified that the output of mariadb's client-executable does use only
\n
line-endings while MySQL uses\r\n
on Windows.mysql -h DB_HOSTNAME_HERE -u DB_USER_HERE -p -e 'use `DB_SCHEMA_HERE`; show tables;' > output.txt
Thank you for any help on this!
The text was updated successfully, but these errors were encountered: