postgresqlwindowscharacter-encodingfile-access

Postgres filenames with german umlaut


I would like to read some rtf files I received from an outside source into a table with Postgres. I am using the pg_stat_file() function to check whether or not the file exists and aim to read its content with pg_read_file(). If the filename contains an umlaut, the function fails.

SELECT pg_stat_file('C:\datafolder\ctköln.rtf', true);

ERROR:  could not open file "C:\datafolder\ctköln.rtf" for reading: No such file or directory 
SQL state: 58P01

Is there an option to read the file without changing its name? The underlying system is a Windows server.

The file contents will be eventually read into a table.


Solution

  • If your database encoding is UTF8 as it should be, you won't be able to read this file using an SQL command. So to read the file with pg_read_file(), you'd have to rename the file.