Import/Export Data fails for a file name containing a backslash, and creates a stray file named E
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 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 小时
- 30 天内合并 PR
- 39
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
pgadmin-org/pgadmin4#10658 ·
维护者通常 1 天内回复
-
Feature
难度 2/5 1-3 小时 新手友好度 78/100
pgadmin-org/pgadmin4#10426 · 3 条评论 · 1 个 reaction ·
维护者通常 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 个 reaction ·
-
bug triage
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复