postgresql/src/backend/commands
Bruce Momjian a598385f3b Our code had:
if (c == '\\' && cstate->line_buf.len == 0)

The problem with that is the because of the input and _output_
buffering, cstate->line_buf.len could be zero even if we are not on the
first character of a line.  In fact, for a typical line, it is zero for
all characters on the line.  The proper solution is to introduce a
boolean, first_char_in_line, that we set as we enter the loop and clear
once we process a character.

I have restructured the line-reading code in copy.c by:

        o  merging the CSV/non-CSV functions into a single function
        o  used macros to centralize and clarify the buffering code
        o  updated comments
        o  renamed client_encoding_only to encoding_embeds_ascii
        o  added a high-bit test to the encoding_embeds_ascii test for
           performance
        o  in CSV mode, allow a backslash followed by a non-period to
           continue being processed as a data value

There should be no performance impact from this patch because it is
functionally equivalent.  If you apply the patch you will see copy.c is
much clearer in this area now and might suggest additional
optimizations.

I have also attached a 8.1-only patch to fix the CSV \. handling bug
with no code restructuring.
2005-12-27 18:10:48 +00:00
..
aggregatecmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
alter.c Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
analyze.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
async.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
cluster.c Tweak indexscan machinery to avoid taking an AccessShareLock on an index 2005-12-03 05:51:03 +00:00
comment.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
conversioncmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
copy.c Our code had: 2005-12-27 18:10:48 +00:00
dbcommands.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
define.c Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
explain.c Fix EXPLAIN and EXECUTE commands to pass portal parameters through to 2005-11-29 01:25:50 +00:00
functioncmds.c Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the 2005-11-21 12:49:33 +00:00
indexcmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
lockcmds.c Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Makefile Tablespaces. Alternate database locations are dead, long live tablespaces. 2004-06-18 06:14:31 +00:00
opclasscmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
operatorcmds.c Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the 2005-11-21 12:49:33 +00:00
portalcmds.c Rename the members of CommandDest enum so they don't collide with other uses of 2005-11-03 17:11:40 +00:00
prepare.c Defend against crash while processing Describe Statement or Describe Portal 2005-12-14 17:06:28 +00:00
proclang.c Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
schemacmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
sequence.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
tablecmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
tablespace.c Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
trigger.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
typecmds.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
user.c Allow CREATE/ALTER ROLE PASSWORD NULL to allow restoring the default state 2005-12-23 16:46:39 +00:00
vacuum.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
vacuumlazy.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
variable.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
view.c Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00