Changeset: 0559f7f640c7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0559f7f640c7
Modified Files:
        sql/backends/monet5/sql.c
Branch: Aug2018
Log Message:

Allocation check and fixed error message.


diffs (67 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -391,8 +391,10 @@ create_table_from_emit(Client cntxt, cha
 
        /* for some reason we don't have an allocator here, so make one */
        sql->sa = sa_create();
-       if(!sql->sa)
-               throw(SQL, "sql.catalog",SQLSTATE(HY001) MAL_MALLOC_FAIL);
+       if (!sql->sa) {
+               msg = sql_error(sql, 02, SQLSTATE(HY001) "CREATE TABLE: %s", 
MAL_MALLOC_FAIL);
+               goto cleanup;
+       }
 
        if (!sname)
                sname = "sys";
@@ -445,14 +447,16 @@ create_table_from_emit(Client cntxt, cha
                }
        }
 
-  cleanup:
-       sa_destroy(sql->sa);
-       sql->sa = NULL;
+cleanup:
+       if(sql->sa) {
+               sa_destroy(sql->sa);
+               sql->sa = NULL;
+       }
        return msg;
 }
 
 str 
-append_to_table_from_emit(Client cntxt, char *sname, char *tname, sql_emit_col 
*columns, size_t ncols) 
+append_to_table_from_emit(Client cntxt, char *sname, char *tname, sql_emit_col 
*columns, size_t ncols)
 {
        size_t i;
        sql_table *t;
@@ -467,8 +471,12 @@ append_to_table_from_emit(Client cntxt, 
 
        /* for some reason we don't have an allocator here, so make one */
        sql->sa = sa_create();
-
-       if (!sname) 
+       if (!sql->sa) {
+               msg = sql_error(sql, 02, SQLSTATE(HY001) "CREATE TABLE: %s", 
MAL_MALLOC_FAIL);
+               goto cleanup;
+       }
+
+       if (!sname)
                sname = "sys";
        if (!(s = mvc_bind_schema(sql, sname))) {
                msg = sql_error(sql, 02, "3F000!CREATE TABLE: no such schema 
'%s'", sname);
@@ -494,9 +502,11 @@ append_to_table_from_emit(Client cntxt, 
                }
        }
 
-  cleanup:
-       sa_destroy(sql->sa);
-       sql->sa = NULL;
+cleanup:
+       if(sql->sa) {
+               sa_destroy(sql->sa);
+               sql->sa = NULL;
+       }
        return msg;
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to