Changeset: 9519f89e3723 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9519f89e3723
Modified Files:
        sql/backends/monet5/sql_scenario.c
        sql/test/Tests/systemfunctions.stable.out
Branch: default
Log Message:

Provide update for new alpha function.
This also fixes bug 3056.


diffs (56 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
@@ -461,6 +461,25 @@ sql_update_apr2012_sp1(Client c)
        return err;             /* usually MAL_SUCCEED */
 }
 
+static str
+sql_update_jul2012(Client c)
+{
+       char *buf = GDKmalloc(2048), *err = NULL;
+       size_t bufsize = 2048, pos = 0;
+
+       /* new function sys.alpha */
+       pos += snprintf(buf+pos, bufsize-pos, "create function alpha(pdec 
double, pradius double) returns double external name sql.alpha;\n");
+
+       pos += snprintf(buf + pos, bufsize-pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name = 'alpha' and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_FUNC);
+
+       assert(pos < 2048);
+
+       printf("Running database upgrade commands:\n%s\n", buf);
+       err = SQLstatementIntern(c, &buf, "update", 1, 0);
+       GDKfree(buf);
+       return err;             /* usually MAL_SUCCEED */
+}
+
 str
 SQLinitClient(Client c)
 {
@@ -599,6 +618,13 @@ SQLinitClient(Client c)
                        if ((err = sql_update_apr2012_sp1(c)) != NULL)
                                fprintf(stderr, "!%s\n", err);
                }
+               /* if aggregate function sys.median(int) does not
+                * exist, we need to update */
+               sql_find_subtype(&tp, "double", 0, 0);
+               if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"), "alpha", 
&tp, &tp, F_FUNC )) {
+                       if ((err = sql_update_jul2012(c)) != NULL)
+                               fprintf(stderr, "!%s\n", err);
+               }
        }
        fflush(stdout);
        fflush(stderr);
diff --git a/sql/test/Tests/systemfunctions.stable.out 
b/sql/test/Tests/systemfunctions.stable.out
--- a/sql/test/Tests/systemfunctions.stable.out
+++ b/sql/test/Tests/systemfunctions.stable.out
@@ -58,6 +58,9 @@ Ready.
 [ "sys",       "Union",        2,      "geometry",     ""      ]
 [ "sys",       "abbrev",       0,      "clob", "create function \"abbrev\" (p 
inet) returns clob\n\texternal name inet.\"abbrev\";"    ]
 [ "sys",       "abbrev",       1,      "inet", ""      ]
+[ "sys",       "alpha",        0,      "double",       "create function 
alpha(pdec double, pradius double)\nreturns double external name sql.alpha;"   ]
+[ "sys",       "alpha",        1,      "double",       ""      ]
+[ "sys",       "alpha",        2,      "double",       ""      ]
 [ "sys",       "area", 0,      "double",       "-- ogc Spatial Analysis 
methods\n\ncreate function area(g geometry) returns float external name 
geom.\"Area\";"        ]
 [ "sys",       "area", 1,      "geometry",     ""      ]
 [ "sys",       "astext",       0,      "clob", "create function astext(g 
geometry) returns string external name geom.\"AsText\";"      ]
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to