Re: csv format for psql
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2018-08-28T18:54:02Z
Lists: pgsql-hackers
Bonjour Daniel, > Currently popt->topt.fieldSepCsv can't be NULL so I've simplified this > to just return pset_quoted_string(popt->topt.fieldSepCsv). Ok. >> While testing I found a small issue if "fieldsep_csv" is set to a strange >> value: >> >> \pset format_csv ',,' > > You meant \pset fieldsep_csv ',,' Indeed. > If you do that even SELECT 'foo', 'bar' comes out wrong because it looks > like a 3-field row: foo,,bar Yes and no. I asked for ",," as a separator, so probably I really want that and I'd be okay with the result. > If we want to prevent people to shoot themselves in the foot with that > sort of thing, I've added a couple tests: No double quote, no LF or > CR, single character (but multibyte allowed) for the separator. Ok, why not. Patch applies cleanly, compiles, "make check" ok. I tried "\pset fieldsep_csv '\0'" which could be seen as one character, but it does not want it. I'm okay with this behavior. I'd suggest to add a test about rejected fieldsep_csv values, which raises both errors. -- Fabien.
Commits
-
Add CSV table output mode in psql.
- aa2ba50c2c13 12.0 landed
-
Reorganize format options of psql in alphabetical order
- add9182e5908 12.0 landed
-
Complete TODO item:
- 862b20b38228 8.0.0 cited