Changeset: 834bdaaddb5f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=834bdaaddb5f
Modified Files:
        sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:

Code deduplication (only two simple assignments), and code dedent.


diffs (75 lines):

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
@@ -468,45 +468,42 @@ SQLinit(Client c)
                        SQLnewcatalog = 1;
        }
        if (SQLnewcatalog > 0) {
-#ifdef HAVE_EMBEDDED
                SQLnewcatalog = 0;
                maybeupgrade = 0;
-               {
-                       size_t createdb_len = strlen(createdb_inline);
-                       buffer* createdb_buf;
-                       stream* createdb_stream;
-                       bstream* createdb_bstream;
-                       if ((createdb_buf = GDKmalloc(sizeof(buffer))) == NULL)
-                               throw(MAL, "createdb", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
-                       buffer_init(createdb_buf, createdb_inline, 
createdb_len);
-                       if ((createdb_stream = buffer_rastream(createdb_buf, 
"createdb.sql")) == NULL) {
-                               GDKfree(createdb_buf);
-                               throw(MAL, "createdb", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
-                       }
-                       if ((createdb_bstream = bstream_create(createdb_stream, 
createdb_len)) == NULL) {
-                               mnstr_destroy(createdb_stream);
-                               GDKfree(createdb_buf);
-                               throw(MAL, "createdb", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
-                       }
-                       if (bstream_next(createdb_bstream) >= 0)
-                               msg = SQLstatementIntern(c, 
&createdb_bstream->buf, "sql.init", TRUE, FALSE, NULL);
-                       else
-                               msg = createException(MAL, "createdb", 
SQLSTATE(42000) "Could not load inlined createdb script");
 
-                       bstream_destroy(createdb_bstream);
+#ifdef HAVE_EMBEDDED
+               size_t createdb_len = strlen(createdb_inline);
+               buffer* createdb_buf;
+               stream* createdb_stream;
+               bstream* createdb_bstream;
+               if ((createdb_buf = GDKmalloc(sizeof(buffer))) == NULL)
+                       throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
+               buffer_init(createdb_buf, createdb_inline, createdb_len);
+               if ((createdb_stream = buffer_rastream(createdb_buf, 
"createdb.sql")) == NULL) {
                        GDKfree(createdb_buf);
-                       if (m->sa)
-                               sa_destroy(m->sa);
-                       m->sa = NULL;
-                       m->sqs = NULL;
+                       throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
+               }
+               if ((createdb_bstream = bstream_create(createdb_stream, 
createdb_len)) == NULL) {
+                       mnstr_destroy(createdb_stream);
+                       GDKfree(createdb_buf);
+                       throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
                }
+               if (bstream_next(createdb_bstream) >= 0)
+                       msg = SQLstatementIntern(c, &createdb_bstream->buf, 
"sql.init", TRUE, FALSE, NULL);
+               else
+                       msg = createException(MAL, "createdb", SQLSTATE(42000) 
"Could not load inlined createdb script");
+
+               bstream_destroy(createdb_bstream);
+               GDKfree(createdb_buf);
+               if (m->sa)
+                       sa_destroy(m->sa);
+               m->sa = NULL;
+               m->sqs = NULL;
 
 #else
                char path[FILENAME_MAX];
                str fullname;
 
-               SQLnewcatalog = 0;
-               maybeupgrade = 0;
                snprintf(path, FILENAME_MAX, "createdb");
                slash_2_dir_sep(path);
                fullname = MSP_locate_sqlscript(path, 1);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to