Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Import/Export Data fails for a file name containing a backslash, and creates a stray file named E

Aperta Adatta ai principianti
#10,672 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, python
Ambito
database

Direzione di ricerca

Inizia dai template SQL di Import/Export Data in web/pgadmin/tools/import_export/templates/import_export/sql/*/cmd.sql e segui come viene racchiuso tra virgolette il percorso del file selezionato per il comando \copy. Verifica come i template distinguono il nome del file dai valori delle opzioni analizzati dal server. Il lavoro è completato quando i percorsi contenenti barre rovesciate funzionano per l’importazione e l’esportazione senza creare un file E isolato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug

Describe the bug

Import/Export Data fails for any file whose path contains a backslash (\), and leaves behind an empty file named E in psql's working directory.

The file name is written into the \copy command with qtLiteral() (web/pgadmin/tools/import_export/templates/import_export/sql/*/cmd.sql). For a value containing a backslash, that produces an escape-string literal, E'...'. psql parses the file name of \copy itself, and its tokenizer doesn't recognise the E'...' form there. It takes the file name as just E, opens (and, for an export, creates or truncates) ./E, and sends the rest of the line to the server. The server then fails with a syntax error.

To Reproduce

  1. Create a file or directory whose name contains a backslash, e.g. /tmp/a\b.csv (possible on Linux and macOS).
  2. Right-click a table > Import/Export Data, choose Export, and select that file.
  3. Run the job.
  4. The job fails, and an empty file named E appears in psql's working directory.

The same happens with psql directly:

\copy (select 1) TO E'/tmp/a\\b.csv' WITH(FORMAT csv)

Expected behavior

The data is exported to (or imported from) the selected file, and no other file is created.

Error message

ERROR:  syntax error at or near "'/tmp/a\\b.csv'"

Desktop (please complete the following information):

  • OS: Linux, macOS
  • pgAdmin version: 9.18 (also current master)
  • Mode: Desktop and Server
  • Package type: any

Additional context

psql's \copy file-name token has no backslash escapes, so the file name should be written as a plain '...' literal with only embedded single quotes doubled, never as E'...'. The option values later in the command (DELIMITER, QUOTE, ESCAPE, NULL, ENCODING) are parsed by the server, where E'...' is valid, so they are not affected.

Lingua principale
Python
Stelle
3.9k
Fork
914
Merge medio
1g 15h
PR unite (30g)
39

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pgadmin-org/pgadmin4

Tutte le issue di pgadmin-org/pgadmin4

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.