Changeset: aad47eed5d12 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aad47eed5d12
Branch: groupjoin
Log Message:

merged with default


diffs (283 lines):

diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -673,9 +673,9 @@ SQLhelp sqlhelp2[] = {
         NULL},
        {"generated_column",
         NULL,
-        "AUTO_INCREMENT | GENERATED ALWAYS AS IDENTITY [ '(' [ AS data_type] [ 
START [WITH start]] [INCREMENT BY increment]\n"
-        "[MINVALUE minvalue | NO MINVALUE] [MAXVALUE maxvalue | NO MAXVALUE] 
[CACHE cachevalue] [[NO] CYCLE] ')' ] ",
-        "data_type",
+        "AUTO_INCREMENT | GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ '(' 
[ AS seq_int_datatype] [ START [WITH start]]\n"
+        " [INCREMENT BY increment] [MINVALUE minvalue | NO MINVALUE] [MAXVALUE 
maxvalue | NO MAXVALUE] [CACHE cachevalue] [[NO] CYCLE] ')' ]",
+        "seq_int_datatype",
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-types/serial-types/"},
        {"global_privileges",
         NULL,
diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -16,6 +16,12 @@
   Note: MonetDB does NOT support catalog qualifiers in object names, so all the
   _CATALOG columns in these information_schema views will allways contain NULL.
 
+* Mon Aug 21 2023 Niels Nes <niels....@monetdbsolutions.com>
+- Added support for generated column syntax:
+   GENERATED BY DEFAULT AS IDENTITY ...
+  This allows the user to override the default generated sequence value
+  during inserts.
+
 * Fri Jul 7 2023 Niels Nes <niels....@monetdbsolutions.com>
 - Added SQL support for: <result offset clause> and <fetch first clause>
   in  <query expression> ::=
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1540,7 +1540,7 @@ sqltypeinit( sql_allocator *sa)
        f->varres = 1;
 
        /* file_loader */
-       f = sql_create_union(sa, "file_loader", "", "", FALSE, SCALE_FIX, 0, 
TABLE, 1, STR);
+       f = sql_create_union(sa, "file_loader", "files", "", FALSE, SCALE_FIX, 
0, TABLE, 1, STR);
        f->varres = 1;
 
        /* sys_update_schemas, sys_update_tables */
diff --git a/sql/server/rel_file_loader.c b/sql/server/rel_file_loader.c
--- a/sql/server/rel_file_loader.c
+++ b/sql/server/rel_file_loader.c
@@ -1,3 +1,12 @@
+/*
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
+ */
 
 #include "monetdb_config.h"
 #include "rel_file_loader.h"
@@ -8,7 +17,7 @@ static file_loader_t file_loaders[NR_FIL
 void
 fl_exit(void)
 {
-       for (int i = 0; i<NR_FILE_LOADERS; i++) {
+       for (int i = 0; i < NR_FILE_LOADERS; i++) {
                if (file_loaders[i].name)
                        GDKfree(file_loaders[i].name);
        }
@@ -18,10 +27,9 @@ void
 fl_unregister(char *name)
 {
        file_loader_t *fl = fl_find(name);
-
        if (fl) {
-                       GDKfree(fl->name);
-                       fl->name = NULL;
+               GDKfree(fl->name);
+               fl->name = NULL;
        }
 }
 
@@ -29,13 +37,13 @@ int
 fl_register(char *name, fl_add_types_fptr add_types, fl_load_fptr load)
 {
        file_loader_t *fl = fl_find(name);
-
        if (fl) {
                printf("re-registering %s\n", name);
                GDKfree(fl->name);
                fl->name = NULL;
        }
-       for (int i = 0; i<NR_FILE_LOADERS; i++) {
+
+       for (int i = 0; i < NR_FILE_LOADERS; i++) {
                if (file_loaders[i].name == NULL) {
                        file_loaders[i].name = GDKstrdup(name);
                        file_loaders[i].add_types = add_types;
@@ -43,7 +51,9 @@ fl_register(char *name, fl_add_types_fpt
                        return 0;
                }
        }
-       return -1;
+
+       /* all file_loaders array locations are occupied */
+       return -1;      /* could not register file_loader */
 }
 
 file_loader_t*
@@ -51,7 +61,7 @@ fl_find(char *name)
 {
        if (!name)
                return NULL;
-       for (int i = 0; i<NR_FILE_LOADERS; i++) {
+       for (int i = 0; i < NR_FILE_LOADERS; i++) {
                if (file_loaders[i].name && strcmp(file_loaders[i].name, name) 
== 0)
                        return file_loaders+i;
        }
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -529,12 +529,16 @@ file_loader_add_table_column_types(mvc *
        sql_exp *file = exps->h->data;
        if (!exp_is_atom(file))
                return "Filename missing";
+
        atom *a = file->l;
        if (a->data.vtype != TYPE_str || !a->data.val.sval)
                return "Filename missing";
+
        char *filename = a->data.val.sval;
+       if (strcmp(filename, "") == 0)
+               return "Filename missing";
+
        char *ext = strrchr(filename, '.'), *ep = ext;
-
        if (ext) {
                ext=ext+1;
                ext = mkLower(sa_strdup(sql->sa, ext));
@@ -563,7 +567,7 @@ file_loader_add_table_column_types(mvc *
        sql_subtype *st = sql_bind_localtype("str");
        sql_exp *ext_exp = exp_atom(sql->sa, atom_string(sql->sa, st, ext));
        if (!ext_exp)
-                       return sql_error(sql, 02, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+               return sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL);
        append(exps, ext_exp);
        return NULL;
 }
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -1906,6 +1906,7 @@ column_def:
                }
  |  column serial_or_bigserial
                { /* SERIAL = INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY 
*/
+                 /* BIGSERIAL = BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY 
KEY */
                        /* handle multi-statements by wrapping them in a list */
                        sql_subtype it;
                        dlist* stmts;
diff --git a/sql/test/emptydb/Tests/check.stable.out 
b/sql/test/emptydb/Tests/check.stable.out
--- a/sql/test/emptydb/Tests/check.stable.out
+++ b/sql/test/emptydb/Tests/check.stable.out
@@ -1754,7 +1754,7 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions",     "sys",  "evalalgebra",  "SYSTEM",       "create 
procedure sys.evalalgebra(ra_stmt string, opt bool) external name 
sql.\"evalAlgebra\";",        "sql",  "MAL",  "Procedure",    true,   false,  
false,  true,   NULL,   "ra_stmt",      "clob", 0,      0,      "in",   "opt",  
"boolean",      1,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "double",       53,     0,      "out",  "arg_1",        
"double",       53,     0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "real", 24,     0,      "out",  "arg_1",        "real", 24,     
0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL    ]
-[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     "",     
"Internal C",   "Function returning a table",   false,  true,   false,  true,   
NULL,   "res_0",        "table",        0,      0,      "out",  "arg_1",        
"clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL    ]
+[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     
"files",        "Internal C",   "Function returning a table",   false,  true,   
false,  true,   NULL,   "res_0",        "table",        0,      0,      "out",  
"arg_1",        "clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "first_value",  "SYSTEM",       "first_value",  
"sql",  "Internal C",   "Analytic function",    false,  false,  false,  true,   
NULL,   "res_0",        "any",  0,      0,      "out",  "arg_1",        "any",  
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsattach",   "SYSTEM",       "create 
procedure fitsattach(fname string) external name fits.attach;", "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "fname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsload",     "SYSTEM",       "create 
procedure fitsload(tname string) external name fits.load;",     "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "tname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit 
b/sql/test/emptydb/Tests/check.stable.out.32bit
--- a/sql/test/emptydb/Tests/check.stable.out.32bit
+++ b/sql/test/emptydb/Tests/check.stable.out.32bit
@@ -1739,7 +1739,7 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions",     "sys",  "evalalgebra",  "SYSTEM",       "create 
procedure sys.evalalgebra(ra_stmt string, opt bool) external name 
sql.\"evalAlgebra\";",        "sql",  "MAL",  "Procedure",    true,   false,  
false,  true,   NULL,   "ra_stmt",      "clob", 0,      0,      "in",   "opt",  
"boolean",      1,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "double",       53,     0,      "out",  "arg_1",        
"double",       53,     0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "real", 24,     0,      "out",  "arg_1",        "real", 24,     
0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL    ]
-[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     "",     
"Internal C",   "Function returning a table",   false,  true,   false,  true,   
NULL,   "res_0",        "table",        0,      0,      "out",  "arg_1",        
"clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL    ]
+[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     
"files",        "Internal C",   "Function returning a table",   false,  true,   
false,  true,   NULL,   "res_0",        "table",        0,      0,      "out",  
"arg_1",        "clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "first_value",  "SYSTEM",       "first_value",  
"sql",  "Internal C",   "Analytic function",    false,  false,  false,  true,   
NULL,   "res_0",        "any",  0,      0,      "out",  "arg_1",        "any",  
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsattach",   "SYSTEM",       "create 
procedure fitsattach(fname string) external name fits.attach;", "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "fname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsload",     "SYSTEM",       "create 
procedure fitsload(tname string) external name fits.load;",     "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "tname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -1771,7 +1771,7 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions",     "sys",  "evalalgebra",  "SYSTEM",       "create 
procedure sys.evalalgebra(ra_stmt string, opt bool) external name 
sql.\"evalAlgebra\";",        "sql",  "MAL",  "Procedure",    true,   false,  
false,  true,   NULL,   "ra_stmt",      "clob", 0,      0,      "in",   "opt",  
"boolean",      1,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "double",       53,     0,      "out",  "arg_1",        
"double",       53,     0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "exp",  "SYSTEM",       "exp",  "mmath",        
"Internal C",   "Scalar function",      false,  false,  false,  false,  NULL,   
"res_0",        "real", 24,     0,      "out",  "arg_1",        "real", 24,     
0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL    ]
-[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     "",     
"Internal C",   "Function returning a table",   false,  true,   false,  true,   
NULL,   "res_0",        "table",        0,      0,      "out",  "arg_1",        
"clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL    ]
+[ "sys.functions",     "sys",  "file_loader",  "SYSTEM",       "",     
"files",        "Internal C",   "Function returning a table",   false,  true,   
false,  true,   NULL,   "res_0",        "table",        0,      0,      "out",  
"arg_1",        "clob", 0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "first_value",  "SYSTEM",       "first_value",  
"sql",  "Internal C",   "Analytic function",    false,  false,  false,  true,   
NULL,   "res_0",        "any",  0,      0,      "out",  "arg_1",        "any",  
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsattach",   "SYSTEM",       "create 
procedure fitsattach(fname string) external name fits.attach;", "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "fname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
 [ "sys.functions",     "sys",  "fitsload",     "SYSTEM",       "create 
procedure fitsload(tname string) external name fits.load;",     "fits", "MAL",  
"Procedure",    true,   false,  false,  true,   NULL,   "tname",        "clob", 
0,      0,      "in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL    ]
diff --git a/sql/test/file_loader/Tests/All b/sql/test/file_loader/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/All
@@ -0,0 +1,1 @@
+file_loader_function
diff --git a/sql/test/file_loader/Tests/file_loader_function.test 
b/sql/test/file_loader/Tests/file_loader_function.test
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/file_loader_function.test
@@ -0,0 +1,16 @@
+query TT rowsort
+select name, mod from sys.functions where mod is null or mod = '';
+----
+
+statement error 42000!Table expression without table name
+select * from file_loader('');
+
+statement error 42000!Table expression without table name
+select * from file_loader('filenotfound');
+
+statement error server crash
+select * from sys.file_loader('');
+
+statement error server crash
+select * from sys.file_loader('filenotfound');
+
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -219,6 +219,7 @@ validate_database_handle_noerror(monetdb
 {
        if (!monetdbe_embedded_initialized || !MCvalid(mdbe->c))
                return 0;
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        clear_error(mdbe);
        return 1;
@@ -953,7 +954,8 @@ monetdbe_close(monetdbe_database dbhdl)
        int err = 0;
        int registered_thread = mdbe->registered_thread;
 
-       MT_thread_set_qry_ctx(&mdbe->c->qryctx);
+       if (mdbe->c)
+               MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        MT_lock_set(&embedded_lock);
        if (mdbe->mid)
                err = monetdbe_close_remote(mdbe);
@@ -1561,6 +1563,7 @@ monetdbe_query(monetdbe_database dbhdl, 
                return NULL;
        monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
 
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        if (mdbe->mid) {
                mdbe->msg = monetdbe_query_remote(mdbe, query, result, 
affected_rows, NULL);
@@ -1581,6 +1584,7 @@ monetdbe_prepare(monetdbe_database dbhdl
 
        int prepare_id = 0;
 
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        if (!stmt) {
                set_error(mdbe, createException(MAL, 
"monetdbe.monetdbe_prepare", "Parameter stmt is NULL"));
@@ -1709,6 +1713,7 @@ monetdbe_execute(monetdbe_statement *stm
        cq *q = stmt_internal->q;
        Symbol s = NULL;
 
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        if ((mdbe->msg = SQLtrans(m)) != MAL_SUCCEED)
                return mdbe->msg;
@@ -1752,6 +1757,7 @@ monetdbe_cleanup_statement(monetdbe_data
 
        assert(!stmt_internal->mdbe || mdbe == stmt_internal->mdbe);
 
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        for (size_t i = 0; i < stmt_internal->res.nparam + 1; i++) {
                ValPtr data = &stmt_internal->data[i];
@@ -1774,6 +1780,7 @@ monetdbe_cleanup_result(monetdbe_databas
        monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
        monetdbe_result_internal* res = (monetdbe_result_internal *) result;
 
+       assert(mdbe->c);
        MT_thread_set_qry_ctx(&mdbe->c->qryctx);
        if (!result) {
                set_error(mdbe, createException(MAL, 
"monetdbe.monetdbe_cleanup_result_internal", "Parameter result is NULL"));
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to