Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9oqj-0008MU-PI for pgsql-general@arkaria.postgresql.org; Fri, 08 Jul 2022 14:20:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9oqi-0008TG-KG for pgsql-general@arkaria.postgresql.org; Fri, 08 Jul 2022 14:20:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9oqi-0008Np-9l for pgsql-general@lists.postgresql.org; Fri, 08 Jul 2022 14:20:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9oqg-0008Ei-7D for pgsql-general@postgresql.org; Fri, 08 Jul 2022 14:20:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 268EKnpD3308508; Fri, 8 Jul 2022 10:20:49 -0400 From: Tom Lane To: Ludwig Isaac Lim cc: "pgsql-general@postgresql.org" Subject: Re: Error when pasting function blocks into psql In-reply-to: <1797402460.2041897.1657110240951@mail.yahoo.com> References: <1797402460.2041897.1657110240951.ref@mail.yahoo.com> <1797402460.2041897.1657110240951@mail.yahoo.com> Comments: In-reply-to Ludwig Isaac Lim message dated "Wed, 06 Jul 2022 12:24:00 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3308505.1657290049.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 08 Jul 2022 10:20:49 -0400 Message-ID: <3308507.1657290049@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ludwig Isaac Lim writes: > Hello: > 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 s= tatements having multiple lines, similar to the ones below: > CREATE OR REPLACE PROCEDURE test()AS$$=C2=A0 =C2=A0 =C2=A0UPDATE=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0table1=C2= =A0 =C2=A0 =C2=A0 SET=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0field1 =3D ?; > =C2=A0 =C2=A0 =C2=A0 =C2=A0-- more SQL statements$$LANGUAGE SQL; > 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 w= hen I copy and paste it to an empty file in vim, and the run: > psql -f > Is there a way of prevent this kind of error when pasting directly into = psql? A gotcha I frequently run into is that if there are any literal tab characters in the text, pasting it into psql fails because the tabs invoke tab-completion, producing either no text or unwanted text. I don't know if that's an issue on Windows (does your psql build do tab completion?), but if so, the workaround is to disable tab completion by starting psql with the '-n' switch. Another fairly likely possibility is that your paste contains invisible characters that psql does not think are whitespace, like non-break space ( ). However, pasting into a file wouldn't make that problem go away, so the tab idea seems a shade more likely. regards, tom lane