Skip site navigation (1) Skip section navigation (2)

Re: Double newline bug with DBD::Pg: Where best to fix?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dan Lyke <danlyke(at)flutterby(dot)com>, <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Double newline bug with DBD::Pg: Where best to fix?
Date: 2001-02-28 17:11:06
Message-ID: Pine.LNX.4.30.0102281807470.775-100000@peter.localdomain (view raw or flat)
Thread:
Lists: pgsql-interfaces
Tom Lane writes:

> That's all fine IMHO.  But this isn't:
>
> regression=# select 'a string
> regression'#
> regression'# with a newline';
>         ?column?
> -------------------------
>  a string
> with a newline
> (1 row)

Well, *somebody* once figured that he could optimize away whitespace...
Not so.  Here's a patch that gets this case right:

Index: mainloop.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/mainloop.c,v
retrieving revision 1.35
diff -u -r1.35 mainloop.c
--- mainloop.c  2001/02/10 02:31:28     1.35
+++ mainloop.c  2001/02/28 16:57:31
@@ -249,7 +249,7 @@
                pset.lineno++;

                /* nothing left on line? then ignore */
-               if (line[0] == '\0')
+               if (line[0] == '\0' && !in_quote)
                {
                        free(line);
                        continue;
@@ -510,7 +510,7 @@


                /* Put the rest of the line in the query buffer. */
-               if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
+               if (in_quote || line[query_start + strspn(line + query_start, " \t\n\r")] != '\0')
                {
                        if (query_buf->len > 0)
                                appendPQExpBufferChar(query_buf, '\n');
===snip

Both of these whitespace-away-optimizing checks could probably be removed
completely, but I'm not sure whether there isn't some case that relies on
it.  I'm gonna stare at it for a few hours and then check it in.

-- 
Peter Eisentraut      peter_e(at)gmx(dot)net       http://yi.org/peter-e/


In response to

Responses

pgsql-interfaces by date

Next:From: Bruce MomjianDate: 2001-02-28 17:14:54
Subject: Re: libpq++: suggested patches for PgTransaction
Previous:From: J. T. VermeulenDate: 2001-02-28 12:55:00
Subject: libpq++: suggested patches for PgTransaction

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group