Changeset: 48379cf064ff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/48379cf064ff
Branch: default
Log Message:
merged
diffs (108 lines):
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/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