public inbox for [email protected]
help / color / mirror / Atom feedFinding error in long input file
12+ messages / 5 participants
[nested] [flat]
* Finding error in long input file
@ 2024-07-09 22:14 Rich Shepard <[email protected]>
2024-07-09 22:26 ` Re: Finding error in long input file Ray O'Donnell <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
0 siblings, 2 replies; 12+ messages in thread
From: Rich Shepard @ 2024-07-09 22:14 UTC (permalink / raw)
To: pgsql-general
I've a file with 488 rows to be input into a table. I run the script using
psql with the `\i' option.
After psql found a few missing commas I thought the script was clean. But,
psql returned this error:
bustrac=# \i scripts/insert-addrs.sql
psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
^ Am
I correct that some rows were inserted into the table before this error was
generated somewhere prior to the end of the file? If so, how do I determine
which rows were inserted and what is the recommended procedure to locate
just where that error is?
I've learned from experience that using the old coding approach of dividing
the file in half, then half again and again until the row with the error is
found produces multiple rows with different PKs. Not what I want to clean
up.
A clue stick will be much appreciated.
TIA,
Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
@ 2024-07-09 22:26 ` Ray O'Donnell <[email protected]>
2024-07-09 22:33 ` Re: Finding error in long input file Rich Shepard <[email protected]>
1 sibling, 1 reply; 12+ messages in thread
From: Ray O'Donnell @ 2024-07-09 22:26 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; pgsql-general
On 9 July 2024 23:14:33 Rich Shepard <[email protected]> wrote:
> I've a file with 488 rows to be input into a table. I run the script using
> psql with the `\i' option.
>
> After psql found a few missing commas I thought the script was clean. But,
> psql returned this error:
> bustrac=# \i scripts/insert-addrs.sql
> psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
> ^ Am
> I correct that some rows were inserted into the table before this error was
> generated somewhere prior to the end of the file? If so, how do I determine
> which rows were inserted and what is the recommended procedure to locate
> just where that error is?
Did you run the entire thing inside a transaction? If so, then it will have
been rolled back after the error, and no rows will have been inserted.
Ray.
>
> I've learned from experience that using the old coding approach of dividing
> the file in half, then half again and again until the row with the error is
> found produces multiple rows with different PKs. Not what I want to clean
> up.
>
> A clue stick will be much appreciated.
>
> TIA,
>
> Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:26 ` Re: Finding error in long input file Ray O'Donnell <[email protected]>
@ 2024-07-09 22:33 ` Rich Shepard <[email protected]>
0 siblings, 0 replies; 12+ messages in thread
From: Rich Shepard @ 2024-07-09 22:33 UTC (permalink / raw)
To: pgsql-general
On Tue, 9 Jul 2024, Ray O'Donnell wrote:
> Did you run the entire thing inside a transaction? If so, then it will have
> been rolled back after the error, and no rows will have been inserted.
Ray,
When I tried using transactions they froze the application. Probably because
I don't know to properly invoke them.
Thanks
Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
@ 2024-07-09 22:29 ` Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
1 sibling, 1 reply; 12+ messages in thread
From: Adrian Klaver @ 2024-07-09 22:29 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; pgsql-general
On 7/9/24 15:14, Rich Shepard wrote:
> I've a file with 488 rows to be input into a table. I run the script using
> psql with the `\i' option.
>
> After psql found a few missing commas I thought the script was clean. But,
> psql returned this error:
> bustrac=# \i scripts/insert-addrs.sql
> psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
>
> ^ Am
> I correct that some rows were inserted into the table before this error was
> generated somewhere prior to the end of the file? If so, how do I determine
> which rows were inserted and what is the recommended procedure to locate
> just where that error is?
>
> I've learned from experience that using the old coding approach of dividing
> the file in half, then half again and again until the row with the error is
> found produces multiple rows with different PKs. Not what I want to clean
> up.
>
> A clue stick will be much appreciated.
bustrac=#\e scripts/insert-addrs.sql 488
If that raises this error:
environment variable PSQL_EDITOR_LINENUMBER_ARG must be set to specify a
line number
then:
bustrac=#\e scripts/insert-addrs.sql
If the editor is vi then:
:488
>
> TIA,
>
> Rich
>
>
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
@ 2024-07-09 22:40 ` Rich Shepard <[email protected]>
2024-07-09 22:46 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
0 siblings, 2 replies; 12+ messages in thread
From: Rich Shepard @ 2024-07-09 22:40 UTC (permalink / raw)
To: pgsql-general
On Tue, 9 Jul 2024, Adrian Klaver wrote:
> bustrac=#\e scripts/insert-addrs.sql 488
> If that raises this error:
> environment variable PSQL_EDITOR_LINENUMBER_ARG must be set to specify a line
> number
Adrian,
It doesn't; it prints the contents of the file to the virtual terminal.
Using my default small editor, joe, I scrolled back through the file
displayed without seeing any error.
Should I run BEGIN: at the psql prompt prior to entering the insert command?
Would that tell me if any rows were entered and, if so, where that stopped?
TIA,
Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
@ 2024-07-09 22:46 ` Rich Shepard <[email protected]>
1 sibling, 0 replies; 12+ messages in thread
From: Rich Shepard @ 2024-07-09 22:46 UTC (permalink / raw)
To: pgsql-general
On Tue, 9 Jul 2024, Rich Shepard wrote:
> Should I run BEGIN: at the psql prompt prior to entering the insert
> command? Would that tell me if any rows were entered and, if so, where
> that stopped?
Began a transction, ran the script, checked the locations table for a couple
of rows to be inserted. They weren't. Issued the rollback; command.
How best should I proceed to isolate the source of the error at the end of
the file?
Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
@ 2024-07-09 22:52 ` Adrian Klaver <[email protected]>
2024-07-10 00:46 ` Re: Finding error in long input file Craig McIlwee <[email protected]>
2024-07-10 12:30 ` Re: Finding error in long input file Rich Shepard <[email protected]>
1 sibling, 2 replies; 12+ messages in thread
From: Adrian Klaver @ 2024-07-09 22:52 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; pgsql-general
On 7/9/24 15:40, Rich Shepard wrote:
> On Tue, 9 Jul 2024, Adrian Klaver wrote:
>
>> bustrac=#\e scripts/insert-addrs.sql 488
>> If that raises this error:
>> environment variable PSQL_EDITOR_LINENUMBER_ARG must be set to specify
>> a line number
>
> Adrian,
>
> It doesn't; it prints the contents of the file to the virtual terminal.
> Using my default small editor, joe, I scrolled back through the file
> displayed without seeing any error.
The error:
LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
is giving you the line number and the data:
a) Navigate to that line number using whatever method Joe has for that.
b) Search for '85250 Red House Rd'.
>
> Should I run BEGIN: at the psql prompt prior to entering the insert
> command?
> Would that tell me if any rows were entered and, if so, where that stopped?
>
> TIA,
>
> Rich
>
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
@ 2024-07-10 00:46 ` Craig McIlwee <[email protected]>
2024-07-10 04:58 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
1 sibling, 1 reply; 12+ messages in thread
From: Craig McIlwee @ 2024-07-10 00:46 UTC (permalink / raw)
To: Adrian Klaver <[email protected]>; +Cc: Rich Shepard <[email protected]>; pgsql-general
Full error message from earlier in the thread:
> psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
> ^
The error:
>
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
>
> is giving you the line number and the data:
> a) Navigate to that line number using whatever method Joe has for that.
> b) Search for '85250 Red House Rd'.
>
The input file is 488 lines (presumably, since Rich said the file should
insert 488 rows). It seems like too much of a coincidence that the last
character of the last line is really the error. My guess is that there is
an unmatched character, perhaps a parenthesis, that is throwing off the
parser because it doesn't expect the statement to terminate yet. Maybe
that unmatched char really is on the last line, but '85250 Red House Rd'
doesn't seem like the issue. I don't know anything about the joe editor,
but I'd hope that any decent editor with syntax highlighting would make it
apparent where things went awry.
Craig
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-10 00:46 ` Re: Finding error in long input file Craig McIlwee <[email protected]>
@ 2024-07-10 04:58 ` Adrian Klaver <[email protected]>
2024-07-10 06:57 ` Re: Finding error in long input file Alban Hertroys <[email protected]>
0 siblings, 1 reply; 12+ messages in thread
From: Adrian Klaver @ 2024-07-10 04:58 UTC (permalink / raw)
To: Craig McIlwee <[email protected]>; +Cc: Rich Shepard <[email protected]>; pgsql-general
On 7/9/24 17:46, Craig McIlwee wrote:
> Full error message from earlier in the thread:
>
> > psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
> > LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
> >
> ^
>
>
> The error:
>
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
>
> is giving you the line number and the data:
> a) Navigate to that line number using whatever method Joe has for that.
> b) Search for '85250 Red House Rd'.
>
>
>
> The input file is 488 lines (presumably, since Rich said the file should
> insert 488 rows). It seems like too much of a coincidence that the last
> character of the last line is really the error. My guess is that there
This assumes that there where only INSERT lines and that each INSERT was
only one line. I have bit by those assumptions before, hence my
suggestion to actually find line 488.
> is an unmatched character, perhaps a parenthesis, that is throwing off
> the parser because it doesn't expect the statement to terminate yet.
> Maybe that unmatched char really is on the last line, but '85250 Red
> House Rd' doesn't seem like the issue. I don't know anything about the
> joe editor, but I'd hope that any decent editor with syntax highlighting
> would make it apparent where things went awry.
>
> Craig
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-10 00:46 ` Re: Finding error in long input file Craig McIlwee <[email protected]>
2024-07-10 04:58 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
@ 2024-07-10 06:57 ` Alban Hertroys <[email protected]>
0 siblings, 0 replies; 12+ messages in thread
From: Alban Hertroys @ 2024-07-10 06:57 UTC (permalink / raw)
To: Adrian Klaver <[email protected]>; +Cc: Craig McIlwee <[email protected]>; Rich Shepard <[email protected]>; pgsql-general
> On 10 Jul 2024, at 06:58, Adrian Klaver <[email protected]> wrote:
>
> On 7/9/24 17:46, Craig McIlwee wrote:
>> Full error message from earlier in the thread:
>> > psql:scripts/insert-addrs.sql:488: ERROR: syntax error at or near ";"
>> > LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636');
>> > ^
>> The error:
>> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
>> is giving you the line number and the data:
>> a) Navigate to that line number using whatever method Joe has for that.
>> b) Search for '85250 Red House Rd'.
>> The input file is 488 lines (presumably, since Rich said the file should insert 488 rows). It seems like too much of a coincidence that the last character of the last line is really the error. My guess is that there
>
> This assumes that there where only INSERT lines and that each INSERT was only one line. I have bit by those assumptions before, hence my suggestion to actually find line 488.
>
>> is an unmatched character, perhaps a parenthesis, that is throwing off the parser because it doesn't expect the statement to terminate yet. Maybe that unmatched char really is on the last line, but '85250 Red House Rd' doesn't seem like the issue. I don't know anything about the joe editor, but I'd hope that any decent editor with syntax highlighting would make it apparent where things went awry.
>> Craig
>
Is this a single INSERT statement with multiple tuples after VALUES? Then perhaps an earlier line (my bet would be on line 487) accidentally ends with a semi-colon instead of a comma?
Something like this:
INSERT INTO table (col1, col2, ..., coln) VALUES
(..., ..., ),
(..., ..., ),
(..., ..., ); -- <-- This terminates the INSERT
(..., ..., ); -- <-- Now this line make no sense
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
@ 2024-07-10 12:30 ` Rich Shepard <[email protected]>
2024-07-10 15:05 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
1 sibling, 1 reply; 12+ messages in thread
From: Rich Shepard @ 2024-07-10 12:30 UTC (permalink / raw)
To: pgsql-general
On Tue, 9 Jul 2024, Adrian Klaver wrote:
> The error:
>
> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
>
> is giving you the line number and the data:
> a) Navigate to that line number using whatever method Joe has for that.
> b) Search for '85250 Red House Rd'.
Adrian,
With the semicolon at the end of the line it's the last line in the file.
That's why I asked for help in finding where, in all the lines above it, the
actual error is located.
FWIW, I use emacs, not vim.
I'll try inserting the data a few lines at a time, each in a transaction.
Thanks,
Rich
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Finding error in long input file
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:29 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:52 ` Re: Finding error in long input file Adrian Klaver <[email protected]>
2024-07-10 12:30 ` Re: Finding error in long input file Rich Shepard <[email protected]>
@ 2024-07-10 15:05 ` Adrian Klaver <[email protected]>
0 siblings, 0 replies; 12+ messages in thread
From: Adrian Klaver @ 2024-07-10 15:05 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; pgsql-general
On 7/10/24 05:30, Rich Shepard wrote:
> On Tue, 9 Jul 2024, Adrian Klaver wrote:
>
>> The error:
>>
>> LINE 488: ...2832,1,default,'85250 Red House Rd','Paisley','OR','97636')
>>
>> is giving you the line number and the data:
>> a) Navigate to that line number using whatever method Joe has for that.
>> b) Search for '85250 Red House Rd'.
>
> Adrian,
>
> With the semicolon at the end of the line it's the last line in the file.
True, I was fixated on the line number.
> That's why I asked for help in finding where, in all the lines above it,
> the
> actual error is located.
>
> FWIW, I use emacs, not vim.
>
> I'll try inserting the data a few lines at a time, each in a transaction.
If it where me I would make the data a CSV file and use \copy. That is
an all or none operation and you would get a error message showing you
where in the file the operation failed.
>
> Thanks,
>
> Rich
>
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2024-07-10 15:05 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-07-09 22:14 Finding error in long input file Rich Shepard <[email protected]>
2024-07-09 22:26 ` Ray O'Donnell <[email protected]>
2024-07-09 22:33 ` Rich Shepard <[email protected]>
2024-07-09 22:29 ` Adrian Klaver <[email protected]>
2024-07-09 22:40 ` Rich Shepard <[email protected]>
2024-07-09 22:46 ` Rich Shepard <[email protected]>
2024-07-09 22:52 ` Adrian Klaver <[email protected]>
2024-07-10 00:46 ` Craig McIlwee <[email protected]>
2024-07-10 04:58 ` Adrian Klaver <[email protected]>
2024-07-10 06:57 ` Alban Hertroys <[email protected]>
2024-07-10 12:30 ` Rich Shepard <[email protected]>
2024-07-10 15:05 ` Adrian Klaver <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox