Re: Finding error in long input file

From: Hans Schou <hans(dot)schou(at)gmail(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding error in long input file
Date: 2024-07-10 13:01:13
Message-ID: CAApBw36wX-00eWZDe3bEmYx0DjEdJ-xVGv=Hs4YpM13f51U-Sg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 <rshepard(at)appl-ecosys(dot)com>
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

--
π•³π–†π–“π–˜ π•Ύπ–ˆπ–π–”π–š
☏ ➁➁ βž…βžƒ βž‡β“ͺ ➁β“ͺ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hans Schou 2024-07-10 13:03:39 Re: Finding error in long input file
Previous Message David G. Johnston 2024-07-10 12:59:29 Re: Finding error in long input file