Hacktoberfest 2026:维护者为十月标记出来的 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 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
39

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pgadmin-org/pgadmin4 的其他 Issue

查看 pgadmin-org/pgadmin4 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。