Re: Error when pasting function blocks into psql

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Error when pasting function blocks into psql
Date: 2022-07-08 11:25:30
Message-ID: CA+bJJbzqY97diohYyisQQQ9KnRM6N51pxnH32NvKQo7WUXVspQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Ludwig:

On Fri, 8 Jul 2022 at 12:37, Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com> wrote:
> I noticed that I'm getting errors when copy and pasting code for stored procedure from Windows directly into psql running in putty.
> To reproduce create a procedure that has multiple statements with each statements having multiple lines, similar to the ones below:
...
> Copy and paste from Windows editor (or IDE) to a psql running in a Putty. Chances are it will complain of syntax error. The error doesn't appear when I copy and paste it to an empty file in vim, and the run:
> psql -f <file name>
> Is there a way of prevent this kind of error when pasting directly into psql? I'm using the latest version of PostgreSQL (server and client. Version 14.4)

You omitted the OS version which is running psql/vim, I assume it is
some king of *ix, probably linux, and which kind of paste you are
using in putty, IIRC it has a couple.

Probably you are sending extra spaces or \015 or something like that
which vim filters for you on save. You can probably confirm these by
pasting your lines into "cat > file" ( remember EOF ing after paste,
enter+^D is the usual way ) and trying to feed that file to psql.

Not having used windows or vim in 20 years I can only think on one
thing to help you with these kind of problems. You'll probably have od
(octal dump) installed. Try pasting the code to 'od -tx1 -tc' which
will give you a nice dump from where you can see if your
IDE/EDITOR/putty is plain nasty tricks ( if you tried pasting into cat
you can cat that file and the one from vim ).

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sunil Thakur 2022-07-08 11:35:53 Re: CPU is 100% azure rds postgreSQL-11
Previous Message Christoph Moench-Tegeder 2022-07-08 11:24:30 Re: postgresql bug