syntax error for no apparent reason

Поиск
Список
Период
Сортировка
Искать

syntax error for no apparent reason

От:
Willy-Bas Loos <willybas@gmail.com>
Дата:
Вложения:
Hi,

I've encountered this before, psql gives me a syntax error for no clear reason. It's allways on the first character of a sql file.
I think that there must be some strange character code at the first position, maybe it is because i share a ntfs partition with the windows installation on my laptop and move files around.
I only editted this file with gedit, pgAdmin and vim on ubuntu lucid desktop.

Here's the error:

postgres=# \i db02-vulling.sql
psql:db02-vulling.sql:1: ERROR:  syntax error at or near "begin"
LINE 1: begin;
        ^
INSERT 0 10100
INSERT 0 101
INSERT 0 100
psql:db02-vulling.sql:12: WARNING:  there is no transaction in progress
COMMIT
postgres=#


The file is in the attachment, both gzipped and as-is.
I hope someone can reproduce this.
(the code itself makes no sense but that's not relevant here)

WBL
--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw

Re: [pgadmin-support] syntax error for no apparent reason

От:
Josh Berkus <josh@agliodbs.com>
Дата:

> I've encountered this before, psql gives me a syntax error for no clear
> reason. It's allways on the first character of a sql file.
> I think that there must be some strange character code at the first
> position, maybe it is because i share a ntfs partition with the windows
> installation on my laptop and move files around.

Yeah, this is caused by pgadmin adding a unicode marker at the first
position of the file.  If you uncheck "Read and Write Unicode UTF-8
Files" in the preferences, this issue should go away.


-- 
                                  -- Josh Berkus
                                     PostgreSQL Experts Inc.
                                     http://www.pgexperts.com

Re: [pgadmin-support] syntax error for no apparent reason

От:
Guillaume Lelarge <guillaume@lelarge.info>
Дата:
Le 04/12/2010 02:45, Josh Berkus a écrit :
> 
>> I've encountered this before, psql gives me a syntax error for no clear
>> reason. It's allways on the first character of a sql file.
>> I think that there must be some strange character code at the first
>> position, maybe it is because i share a ntfs partition with the windows
>> installation on my laptop and move files around.
> 
> Yeah, this is caused by pgadmin adding a unicode marker at the first
> position of the file.  If you uncheck "Read and Write Unicode UTF-8
> Files" in the preferences, this issue should go away.
> 

It goes away because the file is no longer in UTF-8, and that may not be
what the OP wants.

I have a patch ready to be commited that will handle this. But you will
need next pgAdmin's release.


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: syntax error for no apparent reason

От:
"Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Дата:
Willy-Bas Loos  wrote:
 
> I've encountered this before, psql gives me a syntax error for no
> clear reason. It's allways on the first character of a sql file.
 
> The file is in the attachment
 
hexdump says the first three bytes of that file are:
 
ef bb bf
 
http://en.wikipedia.org/wiki/Byte_order_mark
 
-Kevin
FAQ