Re: csv format for psql - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: csv format for psql
Date
Msg-id CAKFQuwYE0prgsFxUDByG3xPKK3hA4BQuFqFr71ai2yif-kQYmQ@mail.gmail.com
Whole thread Raw
In response to Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
On Thu, Mar 29, 2018 at 7:30 AM, Daniel Verite <daniel@manitou-mail.org> wrote:
        David G. Johnston wrote:

> Unaligned format could grow its own fieldsep if it wanted to but it can
> also just use the default provided fieldsep var whose default value is
> pipe.  If it did grow one it would need to understand "not set" in order to
> preserve existing behavior.  We don't have that problem with csv.

fielsep is already owned by the unaligned format. No other format
uses fieldsep currently. Why would it needs to grow its own?
I don't quite see what you mean here.

​Its mostly a terminology concern... 
  ​

For csv, Fabien and Peter expressed the opinion that we shouldn't
create another fieldsep-like variable specifically for it, but instead
reuse fieldsep. That's what my latest patch does.

Now it turns out that sharing fieldsep comes with some problems.
​[...]​


Personally I think the benefit of sharing fieldsep is not worth these
problems, but I'm waiting for the discussion to continue with
more opinions.

Basically that because "fieldsep" lacks any kind of suffix it can be considered "unowned" versus "fieldsep_csv" which would be "owned" by the "csv" format.​  Given the problems I do want an "owned by csv" variable.  An owned version for unaligned would then be named "fieldsep_unaligned".  But we wouldn't want to rename fieldsep, we'd simply leave it in place as a generic fieldsep variable that formats can choose to use if they wish - with the limitations that come with sharing it with unaligned.  Decent odds that no other format would want to but we cannot remove it so we might as well better describe its place now that two formats care about field separation.

fieldsep is "shared" even though at present no one else is sharing it.  fieldsep_csv is not shared.  fieldsep_unaligned doesn't exist because unaligned uses the shared variable.  No one else uses fieldsep, shared or owned.

Saying the "fieldsep" is owned by unaligned mode would be technically correct, though there is no "mark" that makes is readily obvious.

Implementation wise "ownership" could mean that changing the delimiter can only occur while the format type matches.  But we could not do that for fieldsep since no such ordering currently is enforced.

David J.

pgsql-hackers by date:

Previous
From: Pierre Ducroquet
Date:
Subject: Re: JIT compiling with LLVM v12
Next
From: Rushabh Lathia
Date:
Subject: Re: Commit 4dba331cb3 broke ATTACH PARTITION behaviour.