Changeset: 9dc14f9c1a37 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9dc14f9c1a37
Added Files:
sql/test/subquery/Tests/all.sql
sql/test/subquery/Tests/any.sql
sql/test/subquery/Tests/any_all.sql
sql/test/subquery/Tests/scalar.sql
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/mapiclient/mclient.c
clients/mapilib/mapi.c
monetdb5/mal/Tests/tst251.stable.out
monetdb5/modules/atoms/mtime.c
sql/backends/monet5/Tests/simpleSQL.malC
sql/backends/monet5/Tests/simpleSQL.stable.out
sql/backends/monet5/mal_backend.c
sql/backends/monet5/mal_backend.h
sql/backends/monet5/sql.mal
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_scenario.h
Branch: mtime
Log Message:
Merge with default branch.
diffs (truncated from 633 to 300 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -11665,7 +11665,6 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "grow", "pattern sql.grow(tid:bat[:oid], X_0:any_1):int ",
"mvc_grow_wrap;", "Resize the tid column of a declared table." ]
[ "sql", "importTable", "unsafe pattern sql.importTable(sname:str,
tname:str, onclient:int, fname:str...):bat[:any]... ",
"mvc_bin_import_table_wrap;", "Import a table from the files (fname)" ]
[ "sql", "include", "pattern sql.include(fname:str):void ",
"SQLinclude;", "Compile and execute a sql statements on the file" ]
-[ "sql", "init", "pattern sql.init():void ", "SQLinitEnvironment;",
"Initialize the environment for MAL" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, d:any_1, p:any_3,
o:any_4):any_1 ", "SQLlag;", "return the value in the previous 'l' row in
the partition or 'd' if non existent" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, d:bat[:any_1],
p:any_3, o:any_4):any_1 ", "SQLlag;", "return the value in the previous
'l' row in the partition or 'd' if non existent" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, p:any_3,
o:any_4):any_1 ", "SQLlag;", "return the value in the previous 'l' row
in the partition or NULL if non existent" ]
@@ -11742,8 +11741,6 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "single", "pattern sql.single(x:any_2):bat[:any_2] ",
"CMDBATsingle;", "" ]
[ "sql", "sql_environment", "inline function sql.sql_environment()
(name:bat[:str], value:bat[:str]);", "", "" ]
[ "sql", "sql_variables", "pattern sql.sql_variables():bat[:str]
", "sql_variables;", "return the table with session variables"
]
-[ "sql", "start", "pattern sql.start():void ", "SQLsession;",
"Switch to processing SQL statements" ]
-[ "sql", "start2", "pattern sql.start2():void ", "SQLsession2;",
"Switch to processing precompiled sql statements" ]
[ "sql", "storage", "pattern sql.storage() (schema:bat[:str],
table:bat[:str], column:bat[:str], type:bat[:str], mode:bat[:str],
location:bat[:str], count:bat[:lng], atomwidth:bat[:int], columnsize:bat[:lng],
heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit], imprints:bat[:lng],
sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit], orderidx:bat[:lng]) ",
"sql_storage;", "return a table with storage information " ]
[ "sql", "storage", "pattern sql.storage(sname:str)
(schema:bat[:str], table:bat[:str], column:bat[:str], type:bat[:str],
mode:bat[:str], location:bat[:str], count:bat[:lng], atomwidth:bat[:int],
columnsize:bat[:lng], heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit],
imprints:bat[:lng], sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit],
orderidx:bat[:lng]) ", "sql_storage;", "return a table with storage
information for a particular schema " ]
[ "sql", "storage", "pattern sql.storage(sname:str, tname:str)
(schema:bat[:str], table:bat[:str], column:bat[:str], type:bat[:str],
mode:bat[:str], location:bat[:str], count:bat[:lng], atomwidth:bat[:int],
columnsize:bat[:lng], heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit],
imprints:bat[:lng], sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit],
orderidx:bat[:lng]) ", "sql_storage;", "return a table with storage
information for a particular table" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -16079,7 +16079,6 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "grow", "pattern sql.grow(tid:bat[:oid], X_0:any_1):int ",
"mvc_grow_wrap;", "Resize the tid column of a declared table." ]
[ "sql", "importTable", "unsafe pattern sql.importTable(sname:str,
tname:str, onclient:int, fname:str...):bat[:any]... ",
"mvc_bin_import_table_wrap;", "Import a table from the files (fname)" ]
[ "sql", "include", "pattern sql.include(fname:str):void ",
"SQLinclude;", "Compile and execute a sql statements on the file" ]
-[ "sql", "init", "pattern sql.init():void ", "SQLinitEnvironment;",
"Initialize the environment for MAL" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, d:any_1, p:any_3,
o:any_4):any_1 ", "SQLlag;", "return the value in the previous 'l' row in
the partition or 'd' if non existent" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, d:bat[:any_1],
p:any_3, o:any_4):any_1 ", "SQLlag;", "return the value in the previous
'l' row in the partition or 'd' if non existent" ]
[ "sql", "lag", "pattern sql.lag(b:any_1, l:any_2, p:any_3,
o:any_4):any_1 ", "SQLlag;", "return the value in the previous 'l' row
in the partition or NULL if non existent" ]
@@ -16162,8 +16161,6 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "single", "pattern sql.single(x:any_2):bat[:any_2] ",
"CMDBATsingle;", "" ]
[ "sql", "sql_environment", "inline function sql.sql_environment()
(name:bat[:str], value:bat[:str]);", "", "" ]
[ "sql", "sql_variables", "pattern sql.sql_variables():bat[:str]
", "sql_variables;", "return the table with session variables"
]
-[ "sql", "start", "pattern sql.start():void ", "SQLsession;",
"Switch to processing SQL statements" ]
-[ "sql", "start2", "pattern sql.start2():void ", "SQLsession2;",
"Switch to processing precompiled sql statements" ]
[ "sql", "storage", "pattern sql.storage() (schema:bat[:str],
table:bat[:str], column:bat[:str], type:bat[:str], mode:bat[:str],
location:bat[:str], count:bat[:lng], atomwidth:bat[:int], columnsize:bat[:lng],
heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit], imprints:bat[:lng],
sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit], orderidx:bat[:lng]) ",
"sql_storage;", "return a table with storage information " ]
[ "sql", "storage", "pattern sql.storage(sname:str)
(schema:bat[:str], table:bat[:str], column:bat[:str], type:bat[:str],
mode:bat[:str], location:bat[:str], count:bat[:lng], atomwidth:bat[:int],
columnsize:bat[:lng], heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit],
imprints:bat[:lng], sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit],
orderidx:bat[:lng]) ", "sql_storage;", "return a table with storage
information for a particular schema " ]
[ "sql", "storage", "pattern sql.storage(sname:str, tname:str)
(schema:bat[:str], table:bat[:str], column:bat[:str], type:bat[:str],
mode:bat[:str], location:bat[:str], count:bat[:lng], atomwidth:bat[:int],
columnsize:bat[:lng], heap:bat[:lng], hashes:bat[:lng], phash:bat[:bit],
imprints:bat[:lng], sorted:bat[:bit], revsorted:bat[:bit], key:bat[:bit],
orderidx:bat[:lng]) ", "sql_storage;", "return a table with storage
information for a particular table" ]
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -27,6 +27,7 @@
#ifdef HAVE_STRINGS_H
#include <strings.h> /* strcasecmp */
#endif
+#include <sys/stat.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
@@ -3241,6 +3242,18 @@ usage(const char *prog, int xit)
/* hardwired defaults, only used if monet environment cannot be found */
#define defaultPort 50000
+static inline bool
+isfile(FILE *fp)
+{
+ struct stat stb;
+ if (fstat(fileno(fp), &stb) < 0 ||
+ (stb.st_mode & S_IFMT) != S_IFREG) {
+ fclose(fp);
+ return false;
+ }
+ return true;
+}
+
int
main(int argc, char **argv)
{
@@ -3559,7 +3572,8 @@ main(int argc, char **argv)
has_fileargs = optind != argc;
if (dbname == NULL && has_fileargs &&
- (fp = fopen(argv[optind], "r")) == NULL) {
+ ((fp = fopen(argv[optind], "r")) == NULL || !isfile(fp))) {
+ fp = NULL;
dbname = strdup(argv[optind]);
optind++;
has_fileargs = optind != argc;
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3649,7 +3649,7 @@ slice_row(const char *reply, char *null,
i = 0;
anchors = length == 0 ? NULL : malloc(length * sizeof(*anchors));
lens = length == 0 ? NULL : malloc(length * sizeof(*lens));
- do {
+ for (;;) {
if (i >= length) {
length = i + 1;
REALLOC(anchors, length);
@@ -3663,9 +3663,17 @@ slice_row(const char *reply, char *null,
}
lens[i] = len;
anchors[i++] = start;
- while (reply && *reply && isspace((unsigned char) *reply))
+ if (reply == NULL)
+ break;
+ while (*reply && isspace((unsigned char) *reply))
+ reply++;
+ if (*reply == ',') {
reply++;
- } while (reply && *reply && *reply != endchar);
+ while (*reply && isspace((unsigned char) *reply))
+ reply++;
+ } else if (*reply == 0 || *reply == endchar)
+ break;
+ }
*anchorsp = anchors;
*lensp = lens;
return i;
@@ -4774,8 +4782,6 @@ unquote(const char *msg, char **str, con
/* skip over trailing junk (presumably white space) */
while (*p && *p != ',' && *p != endchar)
p++;
- if (*p == ',')
- p++;
if (next)
*next = p;
*str = start;
@@ -4797,8 +4803,7 @@ unquote(const char *msg, char **str, con
;
if (s < msg || !isspace((unsigned char) *s)) /* gone one too
far */
s++;
- if (*p == ',' || *p == '\t') {
- /* there is more to come; skip over separator */
+ if (*p == '\t') {
p++;
}
len = s - msg;
diff --git a/monetdb5/mal/Tests/tst251.stable.out
b/monetdb5/mal/Tests/tst251.stable.out
--- a/monetdb5/mal/Tests/tst251.stable.out
+++ b/monetdb5/mal/Tests/tst251.stable.out
@@ -43,7 +43,7 @@ stdout of test 'tst251` in directory 'mo
[ 0, "hello" ]
[ 1, "brave" ]
[ 2, "world" ]
-[ 3 ]
+[ 3, "" ]
[ 4, nil ]
[ 5, "!" ]
diff --git a/sql/backends/monet5/Tests/simpleSQL.malC
b/sql/backends/monet5/Tests/simpleSQL.malC
--- a/sql/backends/monet5/Tests/simpleSQL.malC
+++ b/sql/backends/monet5/Tests/simpleSQL.malC
@@ -1,6 +1,5 @@
#execute simple SQL queries from MAL
function foo();
-sql.init();
sql.eval("select 1;",true);
sql.eval("create table simpleT(i integer);");
diff --git a/sql/backends/monet5/Tests/simpleSQL.stable.out
b/sql/backends/monet5/Tests/simpleSQL.stable.out
--- a/sql/backends/monet5/Tests/simpleSQL.stable.out
+++ b/sql/backends/monet5/Tests/simpleSQL.stable.out
@@ -25,7 +25,6 @@ stdout of test 'simpleSQL` in directory
# 13:03:24 >
function user.foo():void;
- sql.init();
sql.eval("select 1;", true);
sql.eval("create table simpleT(i integer);");
sql.eval("insert into simpleT values(123);");
diff --git a/sql/backends/monet5/mal_backend.c
b/sql/backends/monet5/mal_backend.c
--- a/sql/backends/monet5/mal_backend.c
+++ b/sql/backends/monet5/mal_backend.c
@@ -34,7 +34,6 @@ backend_create(mvc *m, Client c)
if( b== NULL)
return NULL;
- b->console = isAdministrator(c);
b->mvc = m;
b->client = c;
b->mvc_var = 0;
diff --git a/sql/backends/monet5/mal_backend.h
b/sql/backends/monet5/mal_backend.h
--- a/sql/backends/monet5/mal_backend.h
+++ b/sql/backends/monet5/mal_backend.h
@@ -36,7 +36,6 @@ typedef enum output_format {
* generated or not */
typedef struct backend {
- bool console;
char language; /* 'S' or 's' or 'X' */
char depth;
bool first_statement_generated;
diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -7,18 +7,6 @@
module batsql;
module sql;
-pattern start():void
-address SQLsession
-comment "Switch to processing SQL statements";
-
-pattern start2():void
-address SQLsession2
-comment "Switch to processing precompiled sql statements";
-
-pattern init():void
-address SQLinitEnvironment
-comment "Initialize the environment for MAL";
-
pattern shutdown(delay:bte, force:bit):str
address SQLshutdown_wrap;
pattern shutdown(delay:sht, force:bit):str
@@ -51,7 +39,6 @@ pattern abort()
address SQLabort
comment "Trigger the abort operation for a MAL block";
-
pattern eval(cmd:str):void
address SQLstatement
comment "Compile and execute a single sql statement";
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -83,52 +83,6 @@ monet5_freecode(int clientid, backend_co
#endif
}
-str
-SQLsession(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
- str msg = MAL_SUCCEED;
- const char *logmsg;
- int cnt=0;
-
- (void) mb;
- (void) stk;
- (void) pci;
- if (SQLinitialized == 0)// && (msg = SQLprelude(NULL)) != MAL_SUCCEED)
- return msg;
- msg = setScenario(cntxt, "sql");
- // Wait for any recovery process to be finished
- do {
- MT_sleep_ms(1000);
- logmsg = GDKgetenv("recovery");
- if( logmsg== NULL && ++cnt == 5)
- throw(SQL,"SQLinit", "#WARNING server not ready,
recovery in progress\n");
- } while (logmsg == NULL);
- return msg;
-}
-
-str
-SQLsession2(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
- str msg = MAL_SUCCEED;
- const char *logmsg;
- int cnt=0;
-
- (void) mb;
- (void) stk;
- (void) pci;
- if (SQLinitialized == 0)// && (msg = SQLprelude(NULL)) != MAL_SUCCEED)
- return msg;
- msg = setScenario(cntxt, "msql");
- // Wait for any recovery process to be finished
- do {
- MT_sleep_ms(1000);
- logmsg = GDKgetenv("recovery");
- if( logmsg== NULL && ++cnt == 5)
- throw(SQL,"SQLinit","#WARNING server not ready,
recovery in progress\n");
- } while (logmsg == NULL);
- return msg;
-}
-
static str SQLinit(Client c);
str
@@ -305,7 +259,7 @@ SQLprepareClient(Client c, int login)
mvc_destroy(m);
throw(SQL,"sql.initClient",SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
- if (isAdministrator(c) || strcmp(c->scenario, "msql") == 0)
/* console should return everything */
+ if (strcmp(c->scenario, "msql") == 0)
m->reply_size = -1;
be = (void *) backend_create(m, c);
if( be == NULL) {
@@ -323,7 +277,6 @@ SQLprepareClient(Client c, int login)
if (m->session->tr)
reset_functions(m->session->tr);
if (login) {
- /* pass through credentials of the user if not console */
schema = monet5_user_set_def_schema(m, c->user);
if (!schema) {
_DELETE(schema);
@@ -339,7 +292,6 @@ SQLprepareClient(Client c, int login)
c->state[MAL_SCENARIO_PARSER] = c;
c->state[MAL_SCENARIO_OPTIMIZE] = c;
c->sqlcontext = be;
-
return NULL;
}
@@ -728,24 +680,6 @@ SQLexitClient(Client c)
return MAL_SUCCEED;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list