public inbox for [email protected]
help / color / mirror / Atom feedRe: Finding error in long input file
9+ messages / 3 participants
[nested] [flat]
* Re: Finding error in long input file
@ 2024-07-10 12:52 Rich Shepard <[email protected]>
0 siblings, 2 replies; 9+ messages in thread
From: Rich Shepard @ 2024-07-10 12:52 UTC (permalink / raw)
To: pgsql-general
On Tue, 9 Jul 2024, Craig McIlwee wrote:
> 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, et al.,
I use emacs for scripts and coding, joe's only for small jobs.
I added a line to the file so the bottom line is now 489. The attached image
shows that line is the only one terminated with a semicolon rather than a
comma.
psql would tell me if there was no closing parenthesis on a line, if the
terminating comma was missing, or other similar error, and would tell me the
number of the line or following line. Having the error marked at the end of
the file does not tell _me_ just where the error actually is.
Partial screenshot attached.
Thanks all,
Rich
Attachments:
[image/png] postgres-insert-issue.png (23.4K, 2-postgres-insert-issue.png)
download | view image
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 12:59 David G. Johnston <[email protected]>
parent: Rich Shepard <[email protected]>
1 sibling, 2 replies; 9+ messages in thread
From: David G. Johnston @ 2024-07-10 12:59 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; +Cc: pgsql-general
On Wednesday, July 10, 2024, Rich Shepard <[email protected]> wrote:
>
> Partial screenshot attached.
And what are the first few lines of the file? Use text, not screenshots.
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 13:01 Hans Schou <[email protected]>
parent: Rich Shepard <[email protected]>
1 sibling, 1 reply; 9+ messages in thread
From: Hans Schou @ 2024-07-10 13:01 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; +Cc: pgsql-general
If the file has these line breaks you show, then can make it to multiple
'INSERT INTO' instead.
Search for lines starting with parentese begin '(' and replace it with the
correct INSERT and last comma to semi-colon:
cat i.sql | sed -e 's/^(/INSERT INTO foo VALUES(/' -e 's/,$/;/'
Does the file come from mysqldump? Then try option --extended-insert=FALSE
On Wed, Jul 10, 2024 at 2:53β―PM Rich Shepard <[email protected]>
wrote:
> On Tue, 9 Jul 2024, Craig McIlwee wrote:
>
> > 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, et al.,
>
> I use emacs for scripts and coding, joe's only for small jobs.
>
> I added a line to the file so the bottom line is now 489. The attached
> image
> shows that line is the only one terminated with a semicolon rather than a
> comma.
>
> psql would tell me if there was no closing parenthesis on a line, if the
> terminating comma was missing, or other similar error, and would tell me
> the
> number of the line or following line. Having the error marked at the end of
> the file does not tell _me_ just where the error actually is.
>
> Partial screenshot attached.
>
> Thanks all,
>
> Rich
--
π³πππ πΎππππ
β ββ β
β ββͺ ββͺ
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 13:03 Hans Schou <[email protected]>
parent: David G. Johnston <[email protected]>
1 sibling, 0 replies; 9+ messages in thread
From: Hans Schou @ 2024-07-10 13:03 UTC (permalink / raw)
To: [email protected]
On Wed, Jul 10, 2024 at 2:59β―PM David G. Johnston <
[email protected]> wrote:
>
> And what are the first few lines of the file? Use text, not screenshots.
>
Yes the line with 'INSERT'
grep -ni 'INSERT INTO' scripts/insert-addrs.sql
--
π³πππ πΎππππ
β ββ β
β ββͺ ββͺ
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 13:32 Rich Shepard <[email protected]>
parent: David G. Johnston <[email protected]>
1 sibling, 1 reply; 9+ messages in thread
From: Rich Shepard @ 2024-07-10 13:32 UTC (permalink / raw)
To: pgsql-general
On Wed, 10 Jul 2024, David G. Johnston wrote:
> And what are the first few lines of the file? Use text, not screenshots.
David,
insert into locations (company_nbr,loc_nbr,loc_name,addr1,city,state_code,postcode) values
(2564,1,default,'4250 Hopkins Rd','Ontario','OR','97914'),
(2565,1,default,'10695 Meridian Rd','Mount Angel','OR','97362'),
(2566,1,default,'6963 Keene Rd NE','Gervais ','OR','97026'),
(2567,1,default,'31250 S Bond Rd','Hubbard','OR','97032'),
Rich
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 13:33 Rich Shepard <[email protected]>
parent: Hans Schou <[email protected]>
0 siblings, 0 replies; 9+ messages in thread
From: Rich Shepard @ 2024-07-10 13:33 UTC (permalink / raw)
To: pgsql-general
On Wed, 10 Jul 2024, Hans Schou wrote:
> If the file has these line breaks you show, then can make it to multiple
> 'INSERT INTO' instead.
Hans,
I thought of that, but forgot it. This makes more sense than dividing the
file in small chunks.
Thanks,
Rich
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 15:11 David G. Johnston <[email protected]>
parent: Rich Shepard <[email protected]>
0 siblings, 1 reply; 9+ messages in thread
From: David G. Johnston @ 2024-07-10 15:11 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; +Cc: pgsql-general
On Wednesday, July 10, 2024, Rich Shepard <[email protected]> wrote:
> On Wed, 10 Jul 2024, David G. Johnston wrote:
>
> And what are the first few lines of the file? Use text, not screenshots.
>>
>
> David,
>
> insert into locations (company_nbr,loc_nbr,loc_name,
> addr1,city,state_code,postcode) values
> (2564,1,default,'4250 Hopkins Rd','Ontario','OR','97914'),
> (2565,1,default,'10695 Meridian Rd','Mount Angel','OR','97362'),
> (2566,1,default,'6963 Keene Rd NE','Gervais ','OR','97026'),
> (2567,1,default,'31250 S Bond Rd','Hubbard','OR','97032'),
>
My first easy look for this setup is for any single quotes not adjacent to
either a comma or a parenthesis. Syntax highlighting should ideally have
caught this but Iβd look anyway.
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 15:26 Rich Shepard <[email protected]>
parent: David G. Johnston <[email protected]>
0 siblings, 1 reply; 9+ messages in thread
From: Rich Shepard @ 2024-07-10 15:26 UTC (permalink / raw)
To: pgsql-general
On Wed, 10 Jul 2024, David G. Johnston wrote:
> My first easy look for this setup is for any single quotes not adjacent to
> either a comma or a parenthesis. Syntax highlighting should ideally have
> caught this but Iβd look anyway.
David,
I found an error on line 21 that I missed seeing every time I slowly scanned
the file: missing the terminal `);'. A common situation when I look at the
file so many times.
Rich
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Finding error in long input file
@ 2024-07-10 17:06 Rich Shepard <[email protected]>
parent: Rich Shepard <[email protected]>
0 siblings, 0 replies; 9+ messages in thread
From: Rich Shepard @ 2024-07-10 17:06 UTC (permalink / raw)
To: pgsql-general
On Wed, 10 Jul 2024, Rob Sargent wrote:
> I'm an emacs user too. Do you have show-paren enabled? This would show
> that your file was ill-formed. M-p and M-n go previous/next matching
> parentheses of all types.
Rob,
No, I haven't enabled show-paren.
Thanks for the tip,
Rich
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2024-07-10 17:06 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-07-10 12:52 Re: Finding error in long input file Rich Shepard <[email protected]>
2024-07-10 12:59 ` David G. Johnston <[email protected]>
2024-07-10 13:03 ` Hans Schou <[email protected]>
2024-07-10 13:32 ` Rich Shepard <[email protected]>
2024-07-10 15:11 ` David G. Johnston <[email protected]>
2024-07-10 15:26 ` Rich Shepard <[email protected]>
2024-07-10 17:06 ` Rich Shepard <[email protected]>
2024-07-10 13:01 ` Hans Schou <[email protected]>
2024-07-10 13:33 ` Rich Shepard <[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