pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rick Parrish <ai5jt@unitrunker.net>
To: bugs <pgsql-bugs@lists.postgresql.org>
Subject: psql include text file with bom
Date: Sat, 25 Nov 2023 23:46:37 -0600
Message-ID: <81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net> (raw)

*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.

view thread (2+ messages)  latest in thread

Message-ID: <81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net>
Permalink:  ../81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net/
Also on:    postgresql.org/message-id/81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: ai5jt@unitrunker.net, pgsql-bugs@lists.postgresql.org
  Subject: Re: psql include text file with bom
  In-Reply-To: <81ca2b25-6b3a-499a-9a09-2dd21253c2cb@unitrunker.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox