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)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gaas’s picture

Version: » 7.x-5.8
Status: Active » Needs review
FileSize
1.43 KB

Attached a patch against the 7.x-5.x branch that fixes the issue.

moshe weitzman’s picture

Assigned: Unassigned » greg.1.anderson
jsabater’s picture

Greg, 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.

greg.1.anderson’s picture

Issue tags: +Release blocker

Good idea.

greg.1.anderson’s picture

This was already fixed in 8.x-6.x. Here is a backport for 7.x-5.x.

greg.1.anderson’s picture

Assigned: greg.1.anderson » jonhattan
greg.1.anderson’s picture

Version: 7.x-5.8 » 8.x-6.x-dev
Status: Needs review » Closed (won't fix)
Issue tags: +Needs migration

This 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.

timidri’s picture

Issue summary: View changes
Status: Closed (won't fix) » Closed (duplicate)
helmo’s picture