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@gmx.net http://yi.org/peter-e/