Changeset: 507bae38bf6d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=507bae38bf6d
Added Files:
        sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.sql
        
sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.stable.err
        
sql/test/BugTracker-2019/Tests/sequence-first-next-value.Bug-6743.stable.out
        sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.sql
        sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.stable.err
        sql/test/BugTracker-2019/Tests/sequences-defaults.Bug-6744.stable.out
        sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.sql
        sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.err
        sql/test/BugTracker-2019/Tests/sequences-types.Bug-6745.stable.out
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        common/utils/msabaoth.c
        common/utils/msabaoth.h
        gdk/gdk_select.c
        monetdb5/mal/mal.c
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/atoms/uuid.mal
        monetdb5/modules/atoms/xml.c
        monetdb5/modules/atoms/xml.h
        monetdb5/modules/atoms/xml.mal
        sql/backends/monet5/sql_cat.c
        sql/server/rel_sequence.c
        sql/server/sql_parser.y
        sql/server/sql_scan.c
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        
sql/test/BugTracker-2018/Tests/remote-table-where-is-null.Bug-6601.stable.out
        
sql/test/BugTracker-2018/Tests/remote-table-where-not-equal.Bug-6621.stable.out
        sql/test/BugTracker-2019/Tests/All
        sql/test/wlcr/Tests/wlc01.py
        sql/test/wlcr/Tests/wlc01.stable.out
        sql/test/wlcr/Tests/wlc100.py
        sql/test/wlcr/Tests/wlc100.stable.out
        sql/test/wlcr/Tests/wlc20.py
        sql/test/wlcr/Tests/wlc20.stable.out
        sql/test/wlcr/Tests/wlc21.py
        sql/test/wlcr/Tests/wlc21.stable.out
        sql/test/wlcr/Tests/wlc30.py
        sql/test/wlcr/Tests/wlc30.stable.out
        sql/test/wlcr/Tests/wlc40.py
        sql/test/wlcr/Tests/wlc40.stable.out
        sql/test/wlcr/Tests/wlc50.py
        sql/test/wlcr/Tests/wlc50.stable.out
        sql/test/wlcr/Tests/wlc70.py
        sql/test/wlcr/Tests/wlc70.stable.out
Branch: candidate-exceptions
Log Message:

Merge with default branch.


diffs (truncated from 2060 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
@@ -11983,6 +11983,7 @@ stdout of test 'MAL-signatures` in direc
 [ "uuid",      "#read",        "command uuid.#read():void ",   "UUIDread;",    
""      ]
 [ "uuid",      "#tostr",       "command uuid.#tostr():void ",  
"UUIDtoString;",        ""      ]
 [ "uuid",      "#write",       "command uuid.#write():void ",  "UUIDwrite;",   
""      ]
+[ "uuid",      "epilogue",     "command uuid.epilogue():void ",        
"UUIDepilogue;",        "release the resources held by the uuid module" ]
 [ "uuid",      "isaUUID",      "command uuid.isaUUID(u:str):bit ",     
"UUIDisaUUID;", "Test a string for a UUID format"       ]
 [ "uuid",      "new",  "unsafe command uuid.new():uuid ",      
"UUIDgenerateUuid;",    "Generate a new uuid"   ]
 [ "uuid",      "new",  "unsafe command uuid.new(d:int):uuid ", 
"UUIDgenerateUuidInt;", "Generate a new uuid (dummy version for side effect 
free multiplex loop)"       ]
@@ -12154,6 +12155,7 @@ stdout of test 'MAL-signatures` in direc
 [ "xml",       "document",     "command xml.document(val:str):xml ",   
"XMLdocument;", "Check the value for compliance as XML document"        ]
 [ "xml",       "element",      "command xml.element(name:str, ns:xml, 
attr:xml, s:xml):xml ",  "XMLelement;",  "The basic building block for XML 
elements are namespaces, attributes and a sequence of xml elements. The name 
space and the attributes may be left unspecified(=nil:bat)."     ]
 [ "xml",       "element",      "command xml.element(name:str, s:xml):xml ",    
"XMLelementSmall;",     "The basic building block for XML elements are 
namespaces, attributes and a sequence of xml elements. The name space and the 
attributes may be left unspecified(=nil:bat)."     ]
+[ "xml",       "epilogue",     "command xml.epilogue():void ", "XMLepilogue;", 
"release the resources held by the xml module"  ]
 [ "xml",       "forest",       "pattern xml.forest(val:xml...):xml ",  
"XMLforest;",   "Construct an element list"     ]
 [ "xml",       "isdocument",   "command xml.isdocument(val:str):bit ", 
"XMLisdocument;",       "Validate the string as a document"     ]
 [ "xml",       "parse",        "command xml.parse(doccont:str, val:str, 
option:str):xml ",     "XMLparse;",    "Parse the XML document or element 
string values "      ]
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
@@ -16411,6 +16411,7 @@ stdout of test 'MAL-signatures` in direc
 [ "uuid",      "#read",        "command uuid.#read():void ",   "UUIDread;",    
""      ]
 [ "uuid",      "#tostr",       "command uuid.#tostr():void ",  
"UUIDtoString;",        ""      ]
 [ "uuid",      "#write",       "command uuid.#write():void ",  "UUIDwrite;",   
""      ]
+[ "uuid",      "epilogue",     "command uuid.epilogue():void ",        
"UUIDepilogue;",        "release the resources held by the uuid module" ]
 [ "uuid",      "isaUUID",      "command uuid.isaUUID(u:str):bit ",     
"UUIDisaUUID;", "Test a string for a UUID format"       ]
 [ "uuid",      "new",  "unsafe command uuid.new():uuid ",      
"UUIDgenerateUuid;",    "Generate a new uuid"   ]
 [ "uuid",      "new",  "unsafe command uuid.new(d:int):uuid ", 
"UUIDgenerateUuidInt;", "Generate a new uuid (dummy version for side effect 
free multiplex loop)"       ]
@@ -16582,6 +16583,7 @@ stdout of test 'MAL-signatures` in direc
 [ "xml",       "document",     "command xml.document(val:str):xml ",   
"XMLdocument;", "Check the value for compliance as XML document"        ]
 [ "xml",       "element",      "command xml.element(name:str, ns:xml, 
attr:xml, s:xml):xml ",  "XMLelement;",  "The basic building block for XML 
elements are namespaces, attributes and a sequence of xml elements. The name 
space and the attributes may be left unspecified(=nil:bat)."     ]
 [ "xml",       "element",      "command xml.element(name:str, s:xml):xml ",    
"XMLelementSmall;",     "The basic building block for XML elements are 
namespaces, attributes and a sequence of xml elements. The name space and the 
attributes may be left unspecified(=nil:bat)."     ]
+[ "xml",       "epilogue",     "command xml.epilogue():void ", "XMLepilogue;", 
"release the resources held by the xml module"  ]
 [ "xml",       "forest",       "pattern xml.forest(val:xml...):xml ",  
"XMLforest;",   "Construct an element list"     ]
 [ "xml",       "isdocument",   "command xml.isdocument(val:str):bit ", 
"XMLisdocument;",       "Validate the string as a document"     ]
 [ "xml",       "parse",        "command xml.parse(doccont:str, val:str, 
option:str):xml ",     "XMLparse;",    "Parse the XML document or element 
string values "      ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1888,6 +1888,7 @@ str URLnew4(url *u, str *protocol, str *
 str URLnoop(url *u, url *val);
 ssize_t URLtoString(str *s, size_t *len, const char *src, bool external);
 int UUIDcompare(const uuid *l, const uuid *r);
+str UUIDepilogue(void *ret);
 str UUIDequal(bit *retval, uuid **l, uuid **r);
 ssize_t UUIDfromString(const char *svalue, size_t *len, uuid **retval, bool 
external);
 str UUIDgenerateUuid(uuid **retval);
@@ -1934,6 +1935,7 @@ str XMLcontent(xml *x, str *s);
 str XMLdocument(xml *x, str *s);
 str XMLelement(xml *ret, str *name, xml *nspace, xml *attr, xml *val);
 str XMLelementSmall(xml *ret, str *name, xml *val);
+str XMLepilogue(void *ret);
 str XMLforest(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 ssize_t XMLfromString(const char *src, size_t *len, xml *x, bool external);
 str XMLisdocument(bit *x, str *s);
@@ -2374,6 +2376,7 @@ void moveInstruction(MalBlkPtr mb, int p
 void msab_dbfarminit(const char *dbfarm);
 void msab_dbpathinit(const char *dbpath);
 char *msab_deserialise(sabdb **ret, char *sabdb);
+void msab_exit(void);
 void msab_freeStatus(sabdb **ret);
 char *msab_getDBfarm(char **ret);
 char *msab_getDBname(char **ret);
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -119,6 +119,23 @@ msab_isuuid(const char *restrict s)
        return hyphens == 4;
 }
 
+void
+msab_exit(void)
+{
+       if (_sabaoth_internal_dbfarm != NULL) {
+               free(_sabaoth_internal_dbfarm);
+               _sabaoth_internal_dbfarm = NULL;
+       }
+       if (_sabaoth_internal_dbname != NULL) {
+               free(_sabaoth_internal_dbname);
+               _sabaoth_internal_dbname = NULL;
+       }
+       if (_sabaoth_internal_uuid != NULL) {
+               free(_sabaoth_internal_uuid);
+               _sabaoth_internal_uuid = NULL;
+       }
+}
+
 /**
  * Initialises this Sabaoth instance to use the given dbfarm and dbname.
  * dbname may be NULL to indicate that there is no active database.  The
diff --git a/common/utils/msabaoth.h b/common/utils/msabaoth.h
--- a/common/utils/msabaoth.h
+++ b/common/utils/msabaoth.h
@@ -79,5 +79,6 @@ msab_export void msab_freeStatus(sabdb**
 msab_export char *msab_getUplogInfo(sabuplog *ret, const sabdb *db);
 msab_export char *msab_serialise(char **ret, const sabdb *db);
 msab_export char *msab_deserialise(sabdb **ret, char *sabdb);
+msab_export void msab_exit(void);
 
 #endif
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -268,6 +268,7 @@ hashselect(BAT *b, struct canditer *rest
                        mask = ~innermask;                              \
                        innermask = ~tmp;                               \
                }                                                       \
+               /* if there are nils, we may need to check bin 0 */     \
                if (!b->tnonil)                                         \
                        innermask = IMPSunsetBit(B, innermask, 0);      \
                                                                        \
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -129,6 +129,7 @@ void mserver_reset(void)
        monet_memory = 0;
        memset((char*)monet_characteristics,0, sizeof(monet_characteristics));
        mal_namespace_reset();
+       msab_exit();
        /* No need to clean up the namespace, it will simply be extended
         * upon restart mal_namespace_reset(); */
        GDKreset(0);    // terminate all other threads
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -51,6 +51,7 @@ typedef union {
 } uuid;
 
 mal_export str UUIDprelude(void *ret);
+mal_export str UUIDepilogue(void *ret);
 mal_export int UUIDcompare(const uuid *l, const uuid *r);
 mal_export ssize_t UUIDfromString(const char *svalue, size_t *len, uuid 
**retval, bool external);
 mal_export BUN UUIDhash(const void *u);
@@ -67,16 +68,30 @@ mal_export str UUIDisaUUID(bit *retval, 
 mal_export str UUIDequal(bit *retval, uuid **l, uuid **r);
 
 static uuid uuid_nil;                  /* automatically initialized as zeros */
+static uuid *uuid_session = NULL;      /* automatically set during system 
restart */
 
 str
 UUIDprelude(void *ret)
 {
+       if (uuid_session)
+               return MAL_SUCCEED;
        (void) ret;
        assert(UUID_SIZE == 16);
        (void) malAtomSize(sizeof(uuid), "uuid");
        return MAL_SUCCEED;
 }
 
+str
+UUIDepilogue(void *ret)
+{
+       (void) ret;
+       if (uuid_session) {
+               GDKfree(uuid_session);
+               uuid_session = NULL;
+       }
+       return MAL_SUCCEED;
+}
+
 #define is_uuid_nil(x) (memcmp((x)->u, uuid_nil.u, UUID_SIZE) == 0)
 
 /**
diff --git a/monetdb5/modules/atoms/uuid.mal b/monetdb5/modules/atoms/uuid.mal
--- a/monetdb5/modules/atoms/uuid.mal
+++ b/monetdb5/modules/atoms/uuid.mal
@@ -13,6 +13,10 @@ command write() address UUIDwrite;
 command prelude():void address UUIDprelude;
 uuid.prelude();
 
+command epilogue():void
+address UUIDepilogue
+comment "release the resources held by the uuid module";
+
 # unsafe is to prevent optimizers to reuse common expressions
 unsafe command new() :uuid
 address UUIDgenerateUuid
diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c
--- a/monetdb5/modules/atoms/xml.c
+++ b/monetdb5/modules/atoms/xml.c
@@ -633,6 +633,14 @@ XMLprelude(void *ret)
        return MAL_SUCCEED;
 }
 
+str
+XMLepilogue(void *ret)
+{
+       (void) ret;
+       xmlCleanupParser();
+       return MAL_SUCCEED;
+}
+
 ssize_t
 XMLfromString(const char *src, size_t *len, xml *x, bool external)
 {
diff --git a/monetdb5/modules/atoms/xml.h b/monetdb5/modules/atoms/xml.h
--- a/monetdb5/modules/atoms/xml.h
+++ b/monetdb5/modules/atoms/xml.h
@@ -48,5 +48,6 @@ mal_export size_t XMLquotestring(const c
 mal_export size_t XMLunquotestring(const char **p, char q, char *buf);
 
 mal_export str XMLprelude(void *ret);
+mal_export str XMLepilogue(void *ret);
 
 #endif /* XML_H */
diff --git a/monetdb5/modules/atoms/xml.mal b/monetdb5/modules/atoms/xml.mal
--- a/monetdb5/modules/atoms/xml.mal
+++ b/monetdb5/modules/atoms/xml.mal
@@ -79,6 +79,10 @@ address XMLprelude;
 
 xml.prelude();
 
+command epilogue():void
+address XMLepilogue
+comment "release the resources held by the xml module";
+
 module calc;
 command xml(src:str):xml address XMLstr2xml;
 command xml(src:xml):xml address XMLxml2xml;
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -894,7 +894,9 @@ alter_table(Client cntxt, mvc *sql, char
        for (; n; n = n->next) {
                /* propagate alter table .. add column */
                sql_column *c = n->data;
-               mvc_copy_column(sql, nt, c);
+
+               if (mvc_copy_column(sql, nt, c) == NULL)
+                       throw(SQL,"sql.alter_table", SQLSTATE(40002) "ALTER 
TABLE: Failed to create column %s.%s", c->t->base.name, c->base.name);
        }
        if (t->idxs.set) {
                /* alter drop index */
@@ -929,7 +931,8 @@ alter_table(Client cntxt, mvc *sql, char
                                if (r != GDK_SUCCEED)
                                        throw(SQL, "sql.alter_table", 
GDK_EXCEPTION);
                        }
-                       mvc_copy_idx(sql, nt, i);
+                       if (mvc_copy_idx(sql, nt, i) == NULL)
+                               throw(SQL,"sql.alter_table", SQLSTATE(40002) 
"ALTER TABLE: Failed to create index %s.%s", i->t->base.name, i->base.name);
                }
        }
        if (t->keys.set) {
diff --git a/sql/server/rel_sequence.c b/sql/server/rel_sequence.c
--- a/sql/server/rel_sequence.c
+++ b/sql/server/rel_sequence.c
@@ -106,7 +106,7 @@ rel_create_seq(
        if (is_lng_nil(start)) start = 1;
        if (is_lng_nil(inc)) inc = 1;
        if (is_lng_nil(min)) min = 0;
-       if (cycle && is_lng_nil(max)) cycle = 0;
+       if (cycle && (!is_lng_nil(max) && max < 0)) cycle = 0;
        if (is_lng_nil(max)) max = 0;
        if (is_lng_nil(cache)) cache = 1;
 
@@ -139,70 +139,84 @@ list_create_seq(
        bit bedropped)
 {
        dnode *n;
-       sql_subtype* t = NULL;
+       sql_subtype *t = NULL;
        lng start = lng_nil, inc = lng_nil, min = lng_nil, max = lng_nil, cache 
= lng_nil;
        unsigned int used = 0;
        bit cycle = 0;
 
-       /* check if no option is given twice */
-       for (n = options->h; n; n = n->next) {
-               symbol *s = n->data.sym;
+       if (options) {
+               /* check if no option is given twice */
+               for (n = options->h; n; n = n->next) {
+                       symbol *s = n->data.sym;
+
+                       switch(s->token) {
+                       case SQL_TYPE: {
+                               bool found = false;
+                               const char *valid_types[4] = {"tinyint", 
"smallint", "int", "bigint"};
+                               size_t number_valid_types = sizeof(valid_types) 
/ sizeof(valid_types[0]);
 
-               switch(s->token) {
-               case SQL_TYPE:
-                       if ((used&(1<<SEQ_TYPE)))
-                               return sql_error(sql, 02, SQLSTATE(3F000) 
"CREATE SEQUENCE: AS type found should be used as most once");
-                       used |= (1<<SEQ_TYPE);
-                       t = &s->data.lval->h->data.typeval;
-                       break;
-               case SQL_START:
-                       if ((used&(1<<SEQ_START)))
-                               return sql_error(sql, 02, SQLSTATE(3F000) 
"CREATE SEQUENCE: START value should be passed as most once");
-                       used |= (1<<SEQ_START);
-                       if (is_lng_nil(s->data.l_val))
-                               return sql_error(sql, 02, SQLSTATE(42000) 
"CREATE SEQUENCE: START must not be null");
-                       start = s->data.l_val;
-                       break;
-               case SQL_INC:
-                       if ((used&(1<<SEQ_INC)))
-                               return sql_error(sql, 02, SQLSTATE(3F000) 
"CREATE SEQUENCE: INCREMENT value should be passed as most once");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to