Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I was trying to drop tables from empty postgres database and got this error message:
drush sql-drop
Do you really want to drop all tables? (y/n): y
psql:/tmp/drush_cA0NAj:1: ERROR: syntax error at end of input
LINE 1: DROP TABLE
^
Here the code from _drush_sql_drop():
if ($tables = drush_shell_exec_output()) {
...
}
else {
drush_log(dt('No tables to drop.'), 'ok');
}
In my case if ($tables = drush_shell_exec_output())
evaluates to TRUE because query result contains a header.
postgres=> select tablename from pg_tables where schemaname='public';
tablename
-----------
(0 rows)
Comment | File | Size | Author |
---|---|---|---|
#5 | drush-sql-drop-failed-on-1827096-5.patch | 5.4 KB | greg.1.anderson |
#1 | 0001-sql-dump-Avoid-bad-SQL-on-empty-database.patch | 1.43 KB | gaas |
Comments
Comment #1
gaas CreditAttribution: gaas commentedAttached a patch against the 7.x-5.x branch that fixes the issue.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedComment #3
jsabater CreditAttribution: jsabater commentedGreg, could you please include this patch or similar one that suits you in the next release of Drush? I am using PostgreSQL and I'd like to see that error removed.
Thanks.
Comment #4
greg.1.anderson CreditAttribution: greg.1.anderson commentedGood idea.
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis was already fixed in 8.x-6.x. Here is a backport for 7.x-5.x.
Comment #6
greg.1.anderson CreditAttribution: greg.1.anderson commentedComment #7
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis issue was marked
closed (won't fix)
because Drush has moved to Github.If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to
closed (duplicate)
.Please ask support questions on Drupal Answers.
Comment #8
timidri CreditAttribution: timidri commentedComment #9
helmo CreditAttribution: helmo commentedhttps://github.com/drush-ops/drush/issues/847