Bruce Momjian wrote: > Andrew Dunstan wrote: > > > > > > Bruce Momjian wrote: > > > > > The big problem is that \. is also a valid > > >CSV data value (though not a valid non-CSV data value). So, the > > >solution we came up with was to require \. to appear alone on a line in > > >CSV mode for it to be treated as end-of-copy. > > > > > > > According to the docs, that's the way to specify EOD in both text and > > CSV mode: > > > > End of data can be represented by a single line containing just > > backslash-period. > > Right, but in non-CSV mode, we allow \. at the end of any line because > it is unique so I kept that behavior. That is not documented however. > > > Your analysis regarding line_buf.len seems correct. > > > > We probably should have a regression test with \. in a CSV field. > > Agreed. My test for CSV was simple, just try loading: > > x\. > x\.b > \.c > > all should load literally, but they fail.
OK, original patch applied to HEAD and smaller version to 8.1.X, and regression test added, now attached. -- Bruce Momjian | http://candle.pha.pa.us firstname.lastname@example.org | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/test/regress/expected/copy2.out =================================================================== RCS file: /cvsroot/pgsql/src/test/regress/expected/copy2.out,v retrieving revision 1.22 diff -c -c -r1.22 copy2.out *** src/test/regress/expected/copy2.out 26 Jun 2005 03:04:18 -0000 1.22 --- src/test/regress/expected/copy2.out 27 Dec 2005 18:19:36 -0000 *************** *** 194,199 **** --- 194,202 ---- --test that we read consecutive LFs properly CREATE TEMP TABLE testnl (a int, b text, c int); COPY testnl FROM stdin CSV; + -- test end of copy marker + CREATE TEMP TABLE testeoc (a text); + COPY testeoc FROM stdin CSV; DROP TABLE x, y; DROP FUNCTION fn_x_before(); DROP FUNCTION fn_x_after(); Index: src/test/regress/sql/copy2.sql =================================================================== RCS file: /cvsroot/pgsql/src/test/regress/sql/copy2.sql,v retrieving revision 1.13 diff -c -c -r1.13 copy2.sql *** src/test/regress/sql/copy2.sql 26 Jun 2005 03:04:37 -0000 1.13 --- src/test/regress/sql/copy2.sql 27 Dec 2005 18:19:36 -0000 *************** *** 139,144 **** --- 139,153 ---- inside",2 \. + -- test end of copy marker + CREATE TEMP TABLE testeoc (a text); + + COPY testeoc FROM stdin CSV; + a\. + \.b + c\.d + \. + DROP TABLE x, y; DROP FUNCTION fn_x_before();
---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match