Debugging SQL queries

From: Anastasios Hatzis <ahatzis(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Debugging SQL queries
Date: 2006-05-11 08:16:41
Message-ID: 4462F2E9.6020108@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers pgsql-general


I have sometimes very long queries, for example in setup-purposed sql
file where plenty of tables of a new database are created in a single
transaction. 600 lines of code or more is common. Sometimes, while
developing, an error may appear after submitting such a query for
testing purposes via pgAdmin III query dialog. pgAdmin III displays the
PostgreSQL error, like shown below (example)

syntax error at or near "1" at character 2641

According my current PostgreSQL configuration error message looks
similar in the log files:

2006-05-11 09:51:55 ERROR: syntax error at or near "1" at character
2641

My problem is that I don't know where the given character number is
inside the query/file. I can search in my code editors (e.g. those of
Eclipse IDE) for line number + character number in given line number...
but I can not search for an overall character number. Counting all
characters from 1 to 2641 or any other character number would be really
frustrating in such big queries and it wouldn't be satisfying for me to
split the sql file into multiple smaller queries. How can I configure
PostgreSQL to get line number + character number in that line in the
error statements, or which other solution may help?

Development version is PostgreSQL 8.1.3 on Windows XP Pro.

Many thanks!

Anastasios

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Douglas McNaught 2006-05-11 10:28:49 Re: Debugging SQL queries
Previous Message Dave Page 2006-05-11 07:38:19 Re: i18n online documentation

Browse pgsql-general by date

  From Date Subject
Next Message Volkan YAZICI 2006-05-11 08:25:30 Re: intarray internals
Previous Message Martijn van Oosterhout 2006-05-11 07:32:57 Re: compiling postgres on solaris and DBD::Pg