Import/Export Data fails for a file name containing a backslash, and creates a stray file named E
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
web/pgadmin/tools/import_export/templates/import_export/sql/*/cmd.sql にある Import/Export Data の SQL テンプレートから始め、選択したファイルパスが \copy コマンド用にどのように引用符で囲まれるかを追ってください。テンプレートがファイル名とサーバーによって解析されるオプション値をどのように区別しているか確認してください。バックスラッシュを含むパスがインポートとエクスポートの両方で機能し、余分な E ファイルが作成されなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- Create a file or directory whose name contains a backslash, e.g.
/tmp/a\b.csv(possible on Linux and macOS). - Right-click a table > Import/Export Data, choose Export, and select that file.
- Run the job.
- The job fails, and an empty file named
Eappears 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
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pgadmin-org/pgadmin4 のほかの issue
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pgadmin-org/pgadmin4#10673 ·
メンテナーはふだん 1 日以内に返信
-
Helm chart: allow setting ingressClassName on the Ingress対応中かも @commarla が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
pgadmin-org/pgadmin4#10658 ·
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pgadmin-org/pgadmin4#10426 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pgadmin-org/pgadmin4#10272 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
Housekeeping
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pgadmin-org/pgadmin4#10157 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
pgadmin-org/pgadmin4 の issue をすべて見る
似ている issue
-
link-rot
難易度 1/5 1時間未満 初心者へのやさしさ 67/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
developmentseed/titiler-cmr#265 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Insecure Brotli version <1.2.1対応中かも @jamescw19 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
stac-utils/stac-fastapi-pgstac#438 · リアクション 1 件 ·
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信