Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B86C7B5DCD8 for ; Wed, 26 Oct 2011 01:08:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 70605-04 for ; Wed, 26 Oct 2011 04:08:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 22400B5DC22 for ; Wed, 26 Oct 2011 01:08:01 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p9Q480dj087566 for ; Wed, 26 Oct 2011 04:08:00 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p9Q480jo087565; Wed, 26 Oct 2011 04:08:00 GMT (envelope-from www) Date: Wed, 26 Oct 2011 04:08:00 GMT Message-Id: <201110260408.p9Q480jo087565@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6271: psql -f reporting unexpected syntax errors on first command From: "Shannon" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201110/248 X-Sequence-Number: 31518 The following bug has been logged online: Bug reference: 6271 Logged by: Shannon Email address: shannon@arc.net.au PostgreSQL version: 8.4.9 Operating system: Gentoo Linux 64bit Description: psql -f reporting unexpected syntax errors on first command Details: Given the following 2 line SQL script in a file: --- test.sql --- SHOW client_encoding; SHOW client_encoding; ---------------- $ psql -ftest.sql -U postgres template1 psql:test.sql:1: ERROR: syntax error at or near "SHOW" LINE 1: SHOW client_encoding; ^ client_encoding ----------------- UTF8 (1 row) See what happened there? The first line is treated as a syntax error and the second line works which is insane because the two lines are identical! I've tried: * Adding empty lines and/or comments to the top of the file * Setting PGCLIENTENCODING in the shell to a variety of values including UTF8, SQL_ASCII and LATIN1 * Other commands What works: * Every line except the one with the first command * Piping a string into psql stdin * Using psql interactively Other factors: Could this be related to my locale? $ locale LANG=en_AU.utf8 LC_CTYPE="en_AU.utf8" LC_NUMERIC="en_AU.utf8" LC_TIME="en_AU.utf8" LC_COLLATE="en_AU.utf8" LC_MONETARY="en_AU.utf8" LC_MESSAGES="en_AU.utf8" LC_PAPER="en_AU.utf8" LC_NAME="en_AU.utf8" LC_ADDRESS="en_AU.utf8" LC_TELEPHONE="en_AU.utf8" LC_MEASUREMENT="en_AU.utf8" LC_IDENTIFICATION="en_AU.utf8" LC_ALL=