简体   繁体   English

PostgreSQL 14.5 pg_read_binary_file 无法打开文件进行读取:参数无效

[英]PostgreSQL 14.5 pg_read_binary_file could not open file for reading: Invalid argument

Yesterday I installed PostgreSQL 14.5 on a Windows 10 laptop.昨天我在 Windows 10 笔记本电脑上安装了 PostgreSQL 14.5。 I then ran an old script to load images into a table.然后我运行了一个旧脚本将图像加载到表中。 The script uses the pg_read_binary_file function.该脚本使用pg_read_binary_file function。 Some of the images are.jpg files and some are.png files.有些图像是.jpg 文件,有些是.png 文件。 Of the 34 files, only 5 were successfully processed (1.jpg and 4.png).在 34 个文件中,只有 5 个被成功处理(1.jpg 和 4.png)。 The other 29 failed with the following error:其他 29 个失败并出现以下错误:

[Exception, Error code 0, SQLState XX000] ERROR: could not open file " file absolute path " for reading: Invalid argument [异常,错误代码 0,SQLState XX000] 错误:无法打开文件“文件绝对路径”进行读取:无效参数

For instance, the following statement executes without errors例如,下面的语句执行没有错误

select pg_read_binary_file('C:\Users\Jorge\OneDrive\Documents\000\020-logos\adalid.png') as adalid_png;

... and the following statement fails ...并且以下语句失败

select pg_read_binary_file('C:\Users\Jorge\OneDrive\Documents\000\020-logos\oper.png') as oper_png;

... with the following error message ...带有以下错误消息

[Exception, Error code 0, SQLState XX000] ERROR: could not open file "C:/Users/Jorge/OneDrive/Documents/000/020-logos/oper.png" for reading: Invalid argument

So far, I have not been able to identify any difference in the files that could be the cause of the error.到目前为止,我无法确定可能导致错误的文件中的任何差异。 Also, I'm pretty sure the script works on earlier releases of version 14. Unfortunately I have not been able to find a website to download any of those earlier releases to test it again.此外,我很确定该脚本适用于版本 14 的早期版本。不幸的是,我无法找到一个网站来下载这些早期版本中的任何一个以再次对其进行测试。

Has anyone else found this problem, and its solution?有没有其他人发现这个问题及其解决方案?

I found the cause;我找到了原因; the command fails when the filename is not lowercase.当文件名不是小写时,命令失败。 So I solved the problem by renaming all the image files.所以我通过重命名所有图像文件解决了这个问题。

For example, it fails with a filename JRCG1.JPG but succeeds if the file is renamed jrcg1.jpg.例如,文件名 JRCG1.JPG 失败,但如果文件重命名为 jrcg1.jpg,则成功。

Isn't technology wonderful?科技不是很棒吗?

Please ignore my previous answer .请忽略我之前的回答 As you can see in it, there was no explanation for the failure of the last command (update pais).正如您在其中看到的,没有对最后一个命令(update pais)失败的解释。

Now I think the issue is somehow caused by OneDrive .现在我认为这个问题是由OneDrive引起的。 This laptop is new.这台笔记本电脑是新的。 When I logged in with my Microsoft account, the OneDrive directory was automatically created and updated.当我使用我的 Microsoft 帐户登录时,会自动创建和更新 OneDrive 目录。 Apparently this operation only updates the directory entries, leaving the contents of the files in the cloud until they are opened (or renamed).显然,此操作仅更新目录条目,将文件的内容保留在云中,直到它们被打开(或重命名)。 When I zipped the directory that contains all my images, a message from OneDrive appeared saying that it in that moment it will restore some files.当我压缩包含我所有图像的目录时,出现了来自 OneDrive 的一条消息,说它在那一刻将恢复一些文件。 After that, all the commands in my scripts work.之后,我的脚本中的所有命令都可以工作。 I even renamed (back to their original names) those files with hyphenated or uppercase names, and everything worked just fine.我什至将那些带有连字符或大写名称的文件重命名(恢复为原来的名称),一切正常。 My theory is that pg_read_binary_file gets the file entry from the directory, and so it doesn't give the "No such file or directory" message, but then it fails reading the contents;我的理论是pg_read_binary_file从目录中获取文件条目,因此它没有给出“没有这样的文件或目录”消息,但是它读取内容失败; giving the "Invalid argument" message instead.而是给出“无效参数”消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用pg_read_binary_file导入PostgreSQL 9.5 - import in postgresql 9.5 with pg_read_binary_file PostgreSQL 9.x-pg_read_binary_file并将文件插入bytea - PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea 如何授予非超级用户特权以执行函数pg_read_binary_file? - How to GRANT priveleges to non-superuser to execute function pg_read_binary_file? 无法打开版本文件 PG_VERSION postgresql pg 升级 - could not open version file PG_VERSION postgresql pg upgrade 使用不带 pg_read_file 的 PostgreSQL 读取二进制文件 - Read binary file with PostgreSQL without pg_read_file 无法连接到 PostgreSQL 13,无法打开文件« global/1262 »:无效参数 - Unable to connect to PostgreSQL 13, could not open file« global/1262 » : Invalid argument PostgreSQL 9:无法fsync文件“ base / 16386”:无效的参数 - PostgreSQL 9: could not fsync file “base/16386”: Invalid argument 在 Mac 上升级 PostgreSQL 时无法打开版本文件“postgresql@10/PG_VERSION”失败 - could not open version file "postgresql@10/PG_VERSION" Failure when upgrading PostgreSQL on Mac PG :: UndefinedFile at / ERROR:无法打开文件 - PG::UndefinedFile at / ERROR: could not open file ora2pg 无法打开扩展控制文件 PostgreSQL/11/share/extension/oracle_fdw.control - ora2pg could not open extension control file PostgreSQL/11/share/extension/oracle_fdw.control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM