Re: Add header support to text format and matching feature
От
Julien Rouhaud
Тема
Re: Add header support to text format and matching feature
Дата
Msg-id
20220607154744.vvmitnqhyxrne5ms@jrouhaud
Ответ на
Re: Add header support to text format and matching feature (Peter Eisentraut)
Список
Дерево обсуждения
Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header David Steele <david@pgmasters.net>
Re: Allow COPY's 'text' format to output a header Michael Paquier <michael@paquier.xyz>
Re: Allow COPY's 'text' format to output a header Garick Hamlin <ghamlin@isc.upenn.edu>
Re: Allow COPY's 'text' format to output a header "David G. Johnston" <david.g.johnston@gmail.com>
Re: Allow COPY's 'text' format to output a header Isaac Morland <isaac.morland@gmail.com>
Re: Allow COPY's 'text' format to output a header Michael Paquier <michael@paquier.xyz>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Re: Allow COPY's 'text' format to output a header "Daniel Verite" <daniel@manitou-mail.org>
Re: Allow COPY's 'text' format to output a header Isaac Morland <isaac.morland@gmail.com>
Re: Allow COPY's 'text' format to output a header Tom Lane <tgl@sss.pgh.pa.us>
Re: Allow COPY's 'text' format to output a header Robert Haas <robertmhaas@gmail.com>
Re: Allow COPY's 'text' format to output a header "David G. Johnston" <david.g.johnston@gmail.com>
Re: Allow COPY's 'text' format to output a header "Daniel Verite" <daniel@manitou-mail.org>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header "Daniel Verite" <daniel@manitou-mail.org>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header "Daniel Verite" <daniel@manitou-mail.org>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Stephen Frost <sfrost@snowman.net>
Re: Allow COPY's 'text' format to output a header Simon Muller <samullers@gmail.com>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Michael Paquier <michael@paquier.xyz>
Re: Allow COPY's 'text' format to output a header Michael Paquier <michael@paquier.xyz>
[PATCH v1] Allow COPY "test" to output a header and add header matching mode to COPY FROM "Rémi Lapeyre" <remi.lapeyre@henki.fr>
[PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM "Rémi Lapeyre" <remi.lapeyre@henki.fr>
Re: [PATCH v1] Allow COPY "text" to output a header and add headermatching mode to COPY FROM Rémi Lapeyre <remi.lapeyre@henki.fr>
Re: [PATCH v1] Allow COPY "text" to output a header and add header matching mode to COPY FROM Daniel Gustafsson <daniel@yesql.se>
[PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: [PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM Daniel Gustafsson <daniel@yesql.se>
Re: [PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: [PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
[PATCH v3 1/2] Add header support to "COPY TO" text format Rémi Lapeyre <remi.lapeyre@lenstra.fr>
[PATCH v3 2/2] Add header matching mode to "COPY FROM" Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature Magnus Hagander <magnus@hagander.net>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature vignesh C <vignesh21@gmail.com>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature "Daniel Verite" <daniel@manitou-mail.org>
Re: Add header support to text format and matching feature vignesh C <vignesh21@gmail.com>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature Michael Paquier <michael@paquier.xyz>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature Michael Paquier <michael@paquier.xyz>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: Add header support to text format and matching feature "Daniel Verite" <daniel@manitou-mail.org>
Re: Add header support to text format and matching feature Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Re: [PATCH v1] Allow COPY "text" to output a header and add headermatching mode to COPY FROM Surafel Temesgen <surafel3000@gmail.com>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Re: Allow COPY's 'text' format to output a header Cynthia Shang <cynthia.shang@crunchydata.com>
Hi, On Wed, Mar 30, 2022 at 09:11:09AM +0200, Peter Eisentraut wrote: > > Committed, after some further refinements as discussed. While working on nearby code, I found some problems with this feature. First, probably nitpicking, the HEADER MATCH is allowed for COPY TO, is that expected? The documentation isn't really explicit about it, but there's nothing to match when exporting data it's a bit surprising. I'm not opposed to have HEADER MATCH means HEADER ON for COPY TO, as as-is one can easily reuse the commands history, but maybe it should be clearly documented? Then, apparently HEADER MATCH doesn't let you do sanity checks against a custom column list. This one looks like a clear oversight, as something like that should be entirely valid IMHO: CREATE TABLE tbl(col1 int, col2 int); COPY tbl (col2, col1) TO '/path/to/file' WITH (HEADER MATCH); COPY tbl (col2, col1) FROM '/path/to/file' WITH (HEADER MATCH); but right now it errors out with: ERROR: column name mismatch in header line field 1: got "col1", expected "col2" Note that the error message is bogus if you specify attributes in a different order from the relation, as the code is mixing access to the tuple desc and access to the raw fields with the same offset. This also means that it will actually fail to detect a mismatch in the provided column list and let you import data in the wrong position as long as the datatypes are compatible and the column header in the file are in the correct order. For instance: CREATE TABLE abc (a text, b text, c text); INSERT INTO abc SELECT 'a', 'b', 'c'; COPY abc TO '/path/to/file' WITH (HEADER MATCH); You can then import the data with any of those: COPY abc(c, b, a) TO '/path/to/file' WITH (HEADER MATCH); COPY abc(c, a, b) TO '/path/to/file' WITH (HEADER MATCH); [...] SELECT * FROM abc; Even worse, if you try to do a COPY ... FROM ... WITH (HEADER ON) on a table that has some dropped attribute(s). The current code will access random memory as there's no exact attnum / raw field mapping anymore. I can work on a fix if needed (with some additional regression test to cover those cases), but I'm still not sure that having a user provided column list is supposed to be accepted or not for the HEADER MATCH. In the meantime I will add an open item.
В списке pgsql-hackers по дате отправления
От: Robert Haas
Дата: