Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#10,672 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
postgresql, python
領域
database

調査の方向性

web/pgadmin/tools/import_export/templates/import_export/sql/*/cmd.sql にある Import/Export Data の SQL テンプレートから始め、選択したファイルパスが \copy コマンド用にどのように引用符で囲まれるかを追ってください。テンプレートがファイル名とサーバーによって解析されるオプション値をどのように区別しているか確認してください。バックスラッシュを含むパスがインポートとエクスポートの両方で機能し、余分な E ファイルが作成されなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
3.9k
フォーク
910
平均マージ
1日 15時間
マージ済み PR(30日)
39

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pgadmin-org/pgadmin4 のほかの issue

pgadmin-org/pgadmin4 の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。