Changeset: 5172a797fdaa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5172a797fdaa
Modified Files:
sql/backends/monet5/sql_result.c
sql/test/nested/Tests/fileloader.test.in
sql/test/nested/Tests/simple.test
Branch: nested
Log Message:
improved string composite/multiset parser
diffs (95 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
@@ -2194,14 +2194,23 @@ end:
}
#define skipspace(s) while(*s && isspace(*s)) s++;
+static char *
+FINDsep(char *s, char tsep, char rsep)
+{
+ for (; *s; s++) {
+ if (s[0] == tsep || s[0] == rsep) {
+ break;
+ }
+ }
+ return s;
+}
static str
VALUEparser(char **S, Column *cols, int elm, sql_subtype *t, char tsep, char
rsep)
{
/* handle literals */
char *s = *S;
- int skip = 0;
- char *ns = NULL;
+ char *ns = s;
if (t->type->localtype == TYPE_str) {
/* todo improve properly skip "" strings. */
if (*s != '"')
@@ -2212,13 +2221,10 @@ VALUEparser(char **S, Column *cols, int
ns++;
if (*ns != '"')
throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "missing
\" at end of string value");
- skip++;
- } else if (tsep) {
- ns = strchr(s, tsep);
+ *ns = 0;
+ ns++;
}
- if (!ns && rsep) {
- ns = strchr(s, rsep);
- }
+ ns = FINDsep(ns, tsep, rsep);
char sep = 0;
if (!ns)
throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "missing '%c' at
end of value", rsep?rsep:tsep);
@@ -2230,10 +2236,7 @@ VALUEparser(char **S, Column *cols, int
if (elm >= 0 && d && BUNappend(cols[elm].c, d, false) != GDK_SUCCEED)
throw(SQL, "SQLfrom_varchar", SQLSTATE(42000) "append failed");
*ns = sep;
- s = ns;
- if (skip)
- s++;
- *S = s;
+ *S = ns;
return NULL;
}
diff --git a/sql/test/nested/Tests/fileloader.test.in
b/sql/test/nested/Tests/fileloader.test.in
--- a/sql/test/nested/Tests/fileloader.test.in
+++ b/sql/test/nested/Tests/fileloader.test.in
@@ -15,9 +15,9 @@ select cast(t.json as event) from (selec
(1, "click")
(2, "scroll")
-query T
-select cast(cast(t.json as event) as json) from (select json from
r'$TSTSRCDIR/events.json') t
-----
+#query T
+#select cast(cast(t.json as event) as json) from (select json from
r'$TSTSRCDIR/events.json') t
+#----
statement ok
drop type event
diff --git a/sql/test/nested/Tests/simple.test
b/sql/test/nested/Tests/simple.test
--- a/sql/test/nested/Tests/simple.test
+++ b/sql/test/nested/Tests/simple.test
@@ -199,3 +199,17 @@ left
1
l1
2
+
+statement ok
+create table tpi( p pair[2], i integer)
+
+statement ok
+insert into tpi values (array [ ('left','right'), ('l2','r2') ], 1), (array [
('left','right'), ('l2','r2') ], 2), (array [ ('l3', 'r3') ], 3)
+
+statement ok
+insert into tpi values ('{("l4", "r4"), ("l42", "r42")}, 4'), ('{("l5",
"r5")}, 5)');
+
+query I
+select count(*) from tpi
+----
+5
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]