psql include text file with bom - Mailing list pgsql-bugs

From Rick Parrish
Subject psql include text file with bom
Date
Msg-id 81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net
Whole thread Raw
Responses Re: psql include text file with bom  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs

Summary:

psql "include" or "\i" command chokes on UTF8 text files prefixed with BOM.

Steps to reproduce:

  1. create a UTF8 file with three byte BOM 'EF BB BF'.
  2. include the file from psql via the "include" or \i command.

Example output for file named "test.sql" below:

redacted-# \i test.sql
psql:test.sql:1: ERROR:  syntax error at or near ""
LINE 1: 

Background

https://en.wikipedia.org/wiki/Byte_order_mark

Some text editors save text to a file prefixed by a BOM or byte marker. This includes Visual Studio, VSCode and others. I think it would be reasonable for the include command to skip over any BOM found in the first two or three bytes of a file.

pgsql-bugs by date:

Previous
From: Nikolay Shaplov
Date:
Subject: Re: BUG #18214: poly_contain (@>) hangs forever for input data with zeros and infinities
Next
From: Stephen Frost
Date:
Subject: Re: BUG #18210: libpq: PQputCopyData sometimes fails in non-blocking mode over GSSAPI encrypted connection