Changeset: a312da20f272 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a312da20f272
Modified Files:
        sql/backends/monet5/sql_upgrades.c
Branch: clean-candidates
Log Message:

Added upgrade code


diffs (57 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2543,6 +2543,39 @@ bailout:
        return err;             /* usually MAL_SUCCEED */
 }
 
+static str
+sql_update_default(Client c, mvc *sql, const char *prev_schema, bool 
*systabfixed)
+{
+       size_t bufsize = 1024, pos = 0;
+       char *buf = NULL, *err = NULL;
+       res_table *output = NULL;
+       BAT *b = NULL;
+
+       if ((buf = GDKmalloc(bufsize)) == NULL)
+               throw(SQL, __func__, SQLSTATE(HY013) MAL_MALLOC_FAIL);
+
+       /* if there are 6 'lpad' functions of the same name in the catalog: ((1 
or 2 string inputs) * (char or varchar or clob)), then upgrade */
+       pos += snprintf(buf + pos, bufsize - pos,
+                                       "select id from sys.functions where 
name = 'lpad' and mod = 'str' and func = 'lpad' and system = true;\n");
+       assert(pos < bufsize);
+       if ((err = SQLstatementIntern(c, buf, "update", true, false, &output)))
+               goto bailout;
+       if ((b = BATdescriptor(output->cols[0].b))) {
+               if (BATcount(b) == 6) {
+                       if (!*systabfixed && (err = sql_fix_system_tables(c, 
sql, prev_schema)) != NULL)
+                               goto bailout;
+                       *systabfixed = true;
+               }
+       }
+bailout:
+       if (b)
+               BBPunfix(b->batCacheid);
+       if (output)
+               res_table_destroy(output);
+       GDKfree(buf);
+       return err;             /* usually MAL_SUCCEED */
+}
+
 int
 SQLupgrades(Client c, mvc *m)
 {
@@ -2796,6 +2829,13 @@ SQLupgrades(Client c, mvc *m)
                return -1;
        }
 
+       if ((err = sql_update_default(c, m, prev_schema, &systabfixed)) != 
NULL) {
+               TRC_CRITICAL(SQL_PARSER, "%s\n", err);
+               freeException(err);
+               GDKfree(prev_schema);
+               return -1;
+       }
+
        GDKfree(prev_schema);
        return 0;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to