Re: [PATCHES] CopyReadLineText optimization

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] CopyReadLineText optimization
Date: 2008-03-27 18:28:54
Message-ID: 47EBE766.3070305@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Heikki Linnakangas wrote:
> 1. CopyReadLineText is all about finding the the next end of line;
> splitting to fields is done later. We therefore only care about quotes
> and escapes when they affect the end of line detection. In text mode, we
> only need to care about a backslash that precedes a LF/CR. Therefore,
> we could search for the next LF/CR character with memchr(), and check if
> the preceding character is a backslash (and if it is, check if there's
> yet another backslash behind it, and so forth until we hit a
> non-backslash character).

While looking into this, I realized that we also need to detect the
end-of-copy marker, backslash+period+EOL. In CSV mode, we only honor the
end-of-copy marker if it's on a line of it's own, as \. can occur in
data, but in text mode we accept it at any point.

Does anyone object to changing that so that we only accept \. on a line
of its own in text mode as well? That way we wouldn't need to care about
backslashes in CopyReadLineText. AFAIK our tools have always output the
\. like that, so this would only affect custom applications that use
COPY and the \. marker.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2008-03-27 18:34:05 pg_standby for 8.2 (with last restart point)
Previous Message Aidan Van Dyk 2008-03-27 17:55:03 Re: psql and named pipes

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2008-03-27 19:22:36 Re: Auto-explain patch
Previous Message Bruce Momjian 2008-03-27 18:07:07 Re: ipcclean is excepted by windows.