drush sql:query unintentionally "removes" original gzip files
Describe the bug
When using the drush sql:query command with gzips, the command can only be used once as the original gzip file gets decompressed into a different file name, which is undesired and undocumented behaviour.
To Reproduce
# Create gzipped import file
gzip test.sql
touch test.sql
# Ensure the gzipped file was created.
ls -al test.sql*
# Import the gzipped file.
drush sql:query --file="$PWD/test.sql.gz"
# The original gzipped file was decompressed into test.sql
ls -al test.sql*
Expected behavior I would expect my original gzip file to still exist following the import.
It should store the output of the original gzip decompression to a separate file, then use that for the import or pipe the output into the query.
Actual behavior The original gzip file is decompressed into a different file, as well as potentially using up valuable disk space as the original file is now decompressed.
Workaround
Able to work around it by piping to the drush sql:connect command instead:
gzip -cd test.sql.gz | $(drush sql:connect)
System Configuration
| Q | A |
|---|---|
| Drush version? | 14.x |
| Drupal version? | 11.x |
| PHP version | 8.x |
| OS? | Windows |
Additional information N/A