Skip to content

[BUG] Cannot dump from a database which is accessed with a password containing a single-quote #1278

@roger-duthie-pivotal

Description

@roger-duthie-pivotal
  • Database type and version: PostgreSQL 14

Steps:

  1. Connect PostgreSQL database in the client, with a user which has a password containing a single-quote
  2. Right-click on the connected DB and selecting Dump Data & Structure

The psql command used "under the bonnet" fails because the password is enclosed by single-quotes.

export PGPASSWORD='PASSWORD'CONTAINING'SINGLE'QUOTES' && pg_dump -h 127.0.0.1 -w -p 5432 -U [USER_NAME] [DB_NAME] > [OUTPUT_FILE]

Perhaps this could be easily fixed by checking whether single-quotes or double-quotes are in the password and using the appropriate enclosing characters or using escape sequences?

For example:

export PGPASSWORD="PASSWORD'CONTAINING'SINGLE'QUOTES" && pg_dump -h 127.0.0.1 -w -p 5432 -U [USER_NAME] [DB_NAME] > [OUTPUT_FILE]

... would work for passwords with single-quotes and more generally, there are also double quotes:

export PGPASSWORD="PASSWORD'CONTAINING'SINGLE'QUOTES\"AND\"DOUBLE\"QUOTES" && pg_dump -h 127.0.0.1 -w -p 5432 -U [USER_NAME] [DB_NAME] > [OUTPUT_FILE]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions