Changeset: b90e8e296a4b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b90e8e296a4b Modified Files: sql/backends/monet5/sql_result.c sql/test/nested/Tests/array.test Branch: nested Log Message:
improved parsing of strings diffs (57 lines): diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c --- a/sql/backends/monet5/sql_result.c +++ b/sql/backends/monet5/sql_result.c @@ -2147,7 +2147,22 @@ ARRAYparser(char *s, Column *cols, int n throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "missing ( at end of composite value"); } else { /* handle literals */ - char *ns = strchr(s, ','); + int skip = 0; + char *ns = NULL; + if (t->type->localtype == TYPE_str) { + /* todo improve properly skip "" strings. */ + if (*s != '"') + throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "missing \" at start of string value"); + s++; + ns = s; + while(*ns && *ns != '"') + ns++; + if (*ns != '"') + throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "missing \" at end of string value"); + skip++; + } else { + ns = strchr(s, ','); + } if (!ns) { ns = strchr(s, '}'); } @@ -2164,6 +2179,8 @@ ARRAYparser(char *s, Column *cols, int n elm++; *ns = sep; s = ns; + if (skip) + s++; } /* insert msid */ if (elm >= 0 && BUNappend(cols[elm].c, &id, false) != GDK_SUCCEED) diff --git a/sql/test/nested/Tests/array.test b/sql/test/nested/Tests/array.test --- a/sql/test/nested/Tests/array.test +++ b/sql/test/nested/Tests/array.test @@ -56,7 +56,7 @@ query T nosort select * from bar ---- {"left","right"} -{"l1","r2"} +{"l2","r2"} statement ok insert into bar values ('{"single"}'), ('{"a", "b", "c"}'), ('{"one", "two"}'); @@ -65,7 +65,7 @@ query T nosort select * from bar ---- {"left","right"} -{"l1","r2"} +{"l2","r2"} {"single"} {"a","b","c"} {"one","two"} _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org