Re: multiline CSV fields

Поиск
Список
Период
Сортировка
От Patrick B Kelly
Тема Re: multiline CSV fields
Дата
Msg-id 2B41297B-3454-11D9-B14C-000A958A3956@patrickbkelly.org
обсуждение исходный текст
Ответ на Re: multiline CSV fields  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: multiline CSV fields  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
On Nov 11, 2004, at 6:16 PM, Tom Lane wrote:

> Patrick B Kelly <pbk@patrickbkelly.org> writes:
>> What about just coding a FSM into
>> backend/commands/copy.c:CopyReadLine() that does not process any 
>> flavor
>> of NL characters when it is inside of a data field?
>
> CopyReadLine has no business tracking that.  One reason why not is that
> it is dealing with data not yet converted out of the client's encoding,
> which makes matching to user-specified quote/escape characters
> difficult.
>
>             regards, tom lane
>
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>
>

I appreciate what you are saying about the encoding and you are, of 
course, right but CopyReadLine is already processing the NL characters 
and it is doing it without considering the context in which they 
appear. Unfortunately, the same character(s) are used for two different 
purposes in the files in question. Without considering whether they 
appear inside or outside of data fields, CopyReadline will mistake one 
for the other and cannot correctly do what it is already trying to do 
which is break the input file into lines.

My suggestion is to simply have CopyReadLine recognize these two states 
(in-field and out-of-field) and execute the current logic only while in 
the second state. It would not be too hard but as you mentioned it is 
non-trivial.


Patrick B. Kelly
------------------------------------------------------                              http://patrickbkelly.org



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: MAX/MIN optimization via rewrite (plus query rewrites generally)
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: multiline CSV fields