提交 07236a50 authored 作者: Thomas Mueller's avatar Thomas Mueller

CSVREAD did not process NULL correctly when using a whitespace field separator.

上级 cc29aa7f
......@@ -19,6 +19,7 @@ Change Log
<ul><li>Multi version concurrency (MVCC): when a row was updated or deleted, but this change was rolled back,
the row was not visible by other sessions if no index was used to access it. Fixed.
</li><li>Views with multiple joined tables (where one was an outer join) couldn't be used in some cases. Fixed.
</li><li>The CSVREAD method did not process NULL correctly when using a whitespace field separator.
</li><li>Fixed the Oracle mode: Oracle allows multiple rows with NULL in a unique index.
</li><li>Running out of memory could result in incomplete transactions or corrupted databases. Fixed.
</li><li>When using order by in a query that uses the same table multiple times, the order could
......
......@@ -345,12 +345,12 @@ public class Csv implements SimpleRowSource {
if (ch < 0 || ch == '\r' || ch == '\n') {
endOfLine = true;
break;
} else if (ch <= ' ') {
// ignore spaces
continue;
} else if (ch == fieldSeparatorRead) {
// null
break;
} else if (ch <= ' ') {
// ignore spaces
continue;
} else if (ch == fieldDelimiter) {
// delimited value
StringBuffer buff = new StringBuffer();
......@@ -388,10 +388,10 @@ public class Csv implements SimpleRowSource {
ch = readChar();
if (ch < 0) {
break;
} else if (ch == ' ' || ch == '\t') {
// ignore
} else if (ch == fieldSeparatorRead) {
break;
} else if (ch == ' ' || ch == '\t') {
// ignore
} else if (ch == '\r' || ch == '\n') {
pushBack(ch);
endOfLine = true;
......
......@@ -25,6 +25,7 @@ $$A new version of H2 is available for <a href="http://www.h2database.com">downl
</li></ul>
<b>Bugfixes:</b>
<ul><li>Running out of memory could result in incomplete transactions or corrupted databases. Fixed.
</li><li>CSVREAD did not process NULL correctly when using a whitespace field separator.
</li><li>Stopping a WebServer didn't always work. Fixed.
</li><li>Sometimes, order by in a query that uses the same table multiple times didn't work.
</li><li>A multi version concurrency (MVCC) problem has been fixed.
......
......@@ -33,6 +33,7 @@ import org.h2.util.StringUtils;
public class TestCsv extends TestBase {
public void test() throws Exception {
testSpaceSeparated();
testNull();
testRandomData();
testEmptyFieldDelimiter();
......@@ -42,6 +43,25 @@ public class TestCsv extends TestBase {
testRead();
testPipe();
}
private void testSpaceSeparated() throws Exception {
deleteDb("csv");
File f = new File(baseDir + "/testSpace.csv");
FileUtils.delete(f.getAbsolutePath());
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("create temporary table test (a int, b int, c int)");
stat.execute("insert into test values(1,2,3)");
stat.execute("insert into test values(4,null,5)");
stat.execute("call csvwrite('test.tsv','select * from test',null,' ')");
ResultSet rs1 = stat.executeQuery("select * from test");
assertResultSetOrdered(rs1, new String[][]{new String[]{"1", "2", "3"}, new String[]{"4", null, "5"}});
ResultSet rs2 = stat.executeQuery("select * from csvread('test.tsv',null,null,' ')");
assertResultSetOrdered(rs2, new String[][]{new String[]{"1", "2", "3"}, new String[]{"4", null, "5"}});
conn.close();
FileUtils.delete(f.getAbsolutePath());
}
/**
* Test custom NULL string.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论