Changeset: b9c7118dc728 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b9c7118dc728
Branch: string_imprints
Log Message:
merged with default
diffs (208 lines):
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2525,7 +2525,7 @@ rel2bin_join(backend *be, sql_rel *rel,
(void) equality_only;
jexps = get_equi_joins_first(sql, jexps,
&equality_only);
/* generate a relational join (releqjoin) which does a
multi attribute (equi) join */
- for( en = jexps->h; en && !used_hash; en = en->next ) {
+ for( en = jexps->h; en ; en = en->next ) {
int join_idx = be->join_idx;
sql_exp *e = en->data;
stmt *s = NULL;
@@ -2545,15 +2545,14 @@ rel2bin_join(backend *be, sql_rel *rel,
list_append(lje, s->op1);
list_append(rje, s->op2);
list_append(exps, NULL);
- used_hash = 1; /* uses hash,
all jexps were consumed */
+ used_hash = 1;
} else {
/* hash lookup cannot be used,
clean leftover mal statements */
clean_mal_statements(be,
oldstop, oldvtop, oldvid);
}
}
- if (!s)
- s = exp_bin(be, e, left, right, NULL,
NULL, NULL, NULL, 0, 1, 0);
+ s = exp_bin(be, e, left, right, NULL, NULL,
NULL, NULL, 0, 1, 0);
if (!s) {
assert(sql->session->status == -10); /*
Stack overflow errors shouldn't terminate the server */
return NULL;
@@ -3623,10 +3622,10 @@ rel2bin_select(backend *be, sql_rel *rel
sql_idx *i = p->value;
int oldvtop = be->mb->vtop, oldstop = be->mb->stop,
oldvid = be->mb->vid;
- if ((sel = rel2bin_hash_lookup(be, rel, sub, NULL, i,
en)))
- goto done;
- /* hash lookup cannot be used, clean leftover mal
statements */
- clean_mal_statements(be, oldstop, oldvtop, oldvid);
+ if (!(sel = rel2bin_hash_lookup(be, rel, sub, NULL, i,
en))) {
+ /* hash lookup cannot be used, clean leftover
mal statements */
+ clean_mal_statements(be, oldstop, oldvtop,
oldvid);
+ }
}
}
for( en = rel->exps->h; en; en = en->next ) {
@@ -3653,7 +3652,6 @@ rel2bin_select(backend *be, sql_rel *rel
}
}
-done:
if (sub && sel) {
sub = stmt_list(be, sub->op4.lval); /* protect against
references */
sub->cand = sel;
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -805,25 +805,34 @@ readInt( char *r, int *pos)
}
static char *
-readAtomString( char *r, int *pos)
+readAtomString(mvc *sql, char *r, int *pos)
{
- char *st = NULL, *parsed;
+ char *res = NULL, *begin = NULL;
+ size_t nbytes = 0;
+ int firstpos = 0;
- assert(r[*pos] == '"');
+ assert(r[*pos] == '"'); /* skip first '"' */
(*pos)++;
- st = parsed = r+*pos;
- while (r[*pos] != '"') {
- if (r[*pos] == '\\' && (r[*pos + 1] == '"' || r[*pos + 1] ==
'\\')) {
- *parsed++ = r[*pos + 1];
+
+ firstpos = *pos;
+ begin = r + firstpos;
+ while (r[*pos] && r[*pos] != '"') { /* compute end of atom string */
+ if (r[*pos] == '\\')
(*pos)+=2;
- } else {
- *parsed++ = r[*pos];
+ else
(*pos)++;
- }
}
- *parsed = '\0';
+ if (!r[*pos])
+ return NULL;
+
+ nbytes = (size_t)(*pos - firstpos);
+ assert(r[*pos] == '"'); /* skip second '"' */
(*pos)++;
- return st;
+
+ res = sa_alloc(sql->sa, nbytes + 1); /* add null terminator */
+ if (GDKstrFromStr((unsigned char *) res, (unsigned char *) begin,
nbytes) < 0) /* also read non printable characters with GDKstrFromStr */
+ return NULL;
+ return res;
}
static sql_exp* exp_read(mvc *sql, sql_rel *lrel, sql_rel *rrel, list
*top_exps, char *r, int *pos, int grp);
@@ -956,7 +965,9 @@ parse_atom(mvc *sql, char *r, int *pos,
(*pos)+= (int) strlen("NULL");
return exp_atom(sql->sa, atom_general(sql->sa, tpe, NULL));
} else {
- char *st = readAtomString(r,pos);
+ char *st = readAtomString(sql, r, pos);
+ if (!st)
+ return sql_error(sql, -1, SQLSTATE(42000) "Invalid atom
string\n");
return exp_atom(sql->sa, atom_general(sql->sa, tpe, st));
}
}
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -2804,10 +2804,9 @@ bl_postversion(void *Store, void *Lg)
return GDK_FAIL;
}
/* the functions we need to change to FALSE */
- BAT *funcs = COLnew(0, TYPE_str, 2, TRANSIENT);
+ BAT *funcs = COLnew(0, TYPE_str, 1, TRANSIENT);
if (funcs == NULL ||
- BUNappend(funcs, "sqlrand", false) != GDK_SUCCEED ||
- BUNappend(funcs, "next_value", false) != GDK_SUCCEED) {
+ BUNappend(funcs, "sqlrand", false) != GDK_SUCCEED) {
bat_destroy(cands);
bat_destroy(func_se);
bat_destroy(func_func);
@@ -2815,7 +2814,7 @@ bl_postversion(void *Store, void *Lg)
return GDK_FAIL;
}
/* select * from sys.functions where schema_id = 2000 and func
in (...) */
- b = BATintersect(func_func, funcs, cands, NULL, false, false,
4);
+ b = BATintersect(func_func, funcs, cands, NULL, false, false,
1);
bat_destroy(funcs);
if (b == NULL) {
bat_destroy(cands);
@@ -2876,10 +2875,11 @@ bl_postversion(void *Store, void *Lg)
return GDK_FAIL;
}
/* the functions we need to change to TRUE */
- funcs = COLnew(0, TYPE_str, 4, TRANSIENT);
+ funcs = COLnew(0, TYPE_str, 5, TRANSIENT);
if (funcs == NULL ||
BUNappend(funcs, "copy_from", false) != GDK_SUCCEED ||
BUNappend(funcs, "importTable", false) != GDK_SUCCEED ||
+ BUNappend(funcs, "next_value", false) != GDK_SUCCEED ||
BUNappend(funcs, "update_schemas", false) !=
GDK_SUCCEED ||
BUNappend(funcs, "update_tables", false) !=
GDK_SUCCEED) {
bat_destroy(cands);
@@ -2889,7 +2889,7 @@ bl_postversion(void *Store, void *Lg)
return GDK_FAIL;
}
/* select * from sys.functions where schema_id = 2000 and func
in (...) */
- b = BATintersect(func_func, funcs, cands, NULL, false, false,
4);
+ b = BATintersect(func_func, funcs, cands, NULL, false, false,
7);
bat_destroy(funcs);
bat_destroy(cands);
bat_destroy(func_func);
diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py
b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
--- a/sql/test/SQLancer/Tests/sqlancer19.SQL.py
+++ b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
@@ -1,8 +1,13 @@
-import os
+import os, sys
from decimal import Decimal
from MonetDBtesting.sqltest import SQLTestCase
+try:
+ from MonetDBtesting import process
+except ImportError:
+ import process
+
port = os.environ['MAPIPORT']
db = os.environ['TSTDB']
@@ -331,6 +336,28 @@ with SQLTestCase() as cli:
("BW5z",),(".#OJruk",),("lU1覃Nlm",),(None,),("968786590",)])
cli.execute("ROLLBACK;")
+ cli.execute("DELETE FROM t3 where t3.c0 <> 1;") # Just one row in the
output
+ # This is SELECT r'd\VW' FROM t3;
+ INPUT =
b"\x53\x45\x4C\x45\x43\x54\x20\x72\x27\x64\x5C\x06\x56\x57\x27\x20\x46\x52\x4F\x4D\x20\x74\x33\x3B\x0A"
+ with process.client('sql', text=False, stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as c:
+ out, err = c.communicate(INPUT)
+ retcode = c.returncode
+
+ if retcode != 0:
+ sys.stderr.write("It should have succeeded, but got error %s" %
str(err))
+ if "[ \"d\\\\\\\\\\\\006VW\"\\t]" not in str(out):
+ sys.stderr.write("[ \"d\\\\\\\\\\\\006VW\"\\t] not in the output")
+ # This is SELECT r'd\VW' FROM rt3;
+ INPUT =
b"\x53\x45\x4C\x45\x43\x54\x20\x72\x27\x64\x5C\x06\x56\x57\x27\x20\x46\x52\x4F\x4D\x20\x72\x74\x33\x3B\x0A"
+ with process.client('sql', text=False, stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as c:
+ out, err = c.communicate(INPUT)
+ retcode = c.returncode
+
+ if retcode != 0:
+ sys.stderr.write("It should have succeeded, but got error %s" %
str(err))
+ if "[ \"d\\\\\\\\\\\\006VW\"\\t]" not in str(out):
+ sys.stderr.write("[ \"d\\\\\\\\\\\\006VW\"\\t] not in the output")
+
cli.execute("""
START TRANSACTION;
DROP TABLE rt1;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list