Changeset: 7d671a94450f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7d671a94450f Modified Files: monetdb5/extras/rapi/rapi.c sql/backends/monet5/UDF/pyapi3/connection.h sql/backends/monet5/UDF/pyapi3/connection3.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_execute.h sql/backends/monet5/sql_import.h sql/backends/monet5/sql_scenario.c sql/backends/monet5/sql_upgrades.c sql/backends/monet5/vaults/fits/fits.c sql/backends/monet5/vaults/netcdf/netcdf.c sql/backends/monet5/vaults/shp/shp.c sql/backends/monet5/wlr.c tools/mserver/shutdowntest.c Branch: Oct2020 Log Message:
Cleanup interface of SQLstatementIntern. Arg two is now "const char *" instead of "char **". diffs (truncated from 641 to 300 lines): diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c --- a/monetdb5/extras/rapi/rapi.c +++ b/monetdb5/extras/rapi/rapi.c @@ -808,7 +808,7 @@ void * RAPIloopback(void *query) { res_table* output = NULL; char* querystr = (char*)CHAR(STRING_ELT(query, 0)); - char* err = SQLstatementIntern(rapiClient, &querystr, "name", 1, 0, &output); + char* err = SQLstatementIntern(rapiClient, querystr, "name", 1, 0, &output); if (err) { // there was an error return ScalarString(RSTR(err)); diff --git a/sql/backends/monet5/UDF/pyapi3/connection.h b/sql/backends/monet5/UDF/pyapi3/connection.h --- a/sql/backends/monet5/UDF/pyapi3/connection.h +++ b/sql/backends/monet5/UDF/pyapi3/connection.h @@ -48,7 +48,7 @@ PyObject *Py_Connection_Create(Client cn int query_sem); str _connection_init(void); -str _connection_query(Client cntxt, char *query, res_table **result); +str _connection_query(Client cntxt, const char *query, res_table **result); str _connection_create_table(Client cntxt, char *sname, char *tname, sql_emit_col *columns, size_t ncols); str _connection_append_to_table(Client cntxt, char *sname, char *tname, diff --git a/sql/backends/monet5/UDF/pyapi3/connection3.c b/sql/backends/monet5/UDF/pyapi3/connection3.c --- a/sql/backends/monet5/UDF/pyapi3/connection3.c +++ b/sql/backends/monet5/UDF/pyapi3/connection3.c @@ -116,10 +116,10 @@ void _connection_cleanup_result(void *ou SQLdestroyResult((res_table *)output); } -str _connection_query(Client cntxt, char *query, res_table **result) +str _connection_query(Client cntxt, const char *query, res_table **result) { str res = MAL_SUCCEED; - res = SQLstatementIntern(cntxt, &query, "name", 1, 0, result); + res = SQLstatementIntern(cntxt, query, "name", 1, 0, result); return res; } diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -311,7 +311,7 @@ SQLescapeString(str s) } str -SQLstatementIntern(Client c, str *expr, str nme, bit execute, bit output, res_table **result) +SQLstatementIntern(Client c, const char *expr, str nme, bit execute, bit output, res_table **result) { int status = 0, err = 0, oldvtop, oldstop = 1, inited = 0, ac, sizeframes, topframes; unsigned int label; @@ -324,10 +324,10 @@ SQLstatementIntern(Client c, str *expr, stream *buf = NULL; str msg = MAL_SUCCEED; backend *be = NULL, *sql = (backend *) c->sqlcontext; - size_t len = strlen(*expr); + size_t len = strlen(expr); #ifdef _SQL_COMPILE - mnstr_printf(c->fdout, "#SQLstatement:%s\n", *expr); + mnstr_printf(c->fdout, "#SQLstatement:%s\n", expr); #endif if (!sql) { inited = 1; @@ -389,7 +389,7 @@ SQLstatementIntern(Client c, str *expr, msg = createException(SQL,"sql.statement",SQLSTATE(HY013) MAL_MALLOC_FAIL); goto endofcompile; } - strncpy(n, *expr, len); + strncpy(n, expr, len); n[len] = '\n'; n[len + 1] = 0; len++; diff --git a/sql/backends/monet5/sql_execute.h b/sql/backends/monet5/sql_execute.h --- a/sql/backends/monet5/sql_execute.h +++ b/sql/backends/monet5/sql_execute.h @@ -10,7 +10,7 @@ #define _SQL_EXECUTE_H_ #include "sql.h" -sql5_export str SQLstatementIntern(Client c, str *expr, str nme, bit execute, bit output, res_table **result); +sql5_export str SQLstatementIntern(Client c, const char *expr, str nme, bit execute, bit output, res_table **result); sql5_export str SQLengineIntern(Client c, backend *be); sql5_export str RAstatement(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); sql5_export str RAstatement2(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/sql/backends/monet5/sql_import.h b/sql/backends/monet5/sql_import.h --- a/sql/backends/monet5/sql_import.h +++ b/sql/backends/monet5/sql_import.h @@ -9,8 +9,16 @@ #ifndef _SQL_IMPORT_H #define _SQL_IMPORT_H -#include "sql.h" +#ifdef WIN32 +#ifdef LIBSQL +#define sql_export extern __declspec(dllexport) +#else +#define sql_export extern __declspec(dllimport) +#endif +#else +#define sql_export extern +#endif -sql_export void sql_register(str name, unsigned char *code); +sql_export void sql_register(const char *name, const unsigned char *code); #endif /* _SQL_IMPORT_H */ 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 @@ -49,11 +49,11 @@ #define MAX_SQL_MODULES 128 static int sql_modules = 0; -static str sql_module_name[MAX_SQL_MODULES] = {0}; -static unsigned char *sql_module_code[MAX_SQL_MODULES] = {0}; +static const char *sql_module_name[MAX_SQL_MODULES] = {0}; +static const unsigned char *sql_module_code[MAX_SQL_MODULES] = {0}; void -sql_register(str name, unsigned char *code) +sql_register(const char *name, const unsigned char *code) { assert (sql_modules < MAX_SQL_MODULES); sql_module_name[sql_modules] = name; @@ -421,9 +421,9 @@ SQLinit(Client c) maybeupgrade = 0; for (int i = 0; i < sql_modules && !msg; i++) { - char *createdb_inline = (char*)sql_module_code[i]; + const char *createdb_inline = (const char*)sql_module_code[i]; - msg = SQLstatementIntern(c, &createdb_inline, "sql.init", TRUE, FALSE, NULL); + msg = SQLstatementIntern(c, createdb_inline, "sql.init", TRUE, FALSE, NULL); if (m->sa) sa_destroy(m->sa); m->sa = NULL; @@ -431,7 +431,7 @@ SQLinit(Client c) } /* 99_system.sql */ if (!msg) { - char *createdb_inline = " \ + const char *createdb_inline = " \ create trigger system_update_schemas after update on sys.schemas for each statement call sys_update_schemas(); \ create trigger system_update_tables after update on sys._tables for each statement call sys_update_tables(); \ update sys.functions set system = true; \ @@ -442,7 +442,7 @@ SQLinit(Client c) UPDATE sys.types SET schema_id = (SELECT id FROM sys.schemas WHERE name = 'sys') WHERE schema_id = 0 AND schema_id NOT IN (SELECT id from sys.schemas); \ UPDATE sys.functions SET schema_id = (SELECT id FROM sys.schemas WHERE name = 'sys') WHERE schema_id = 0 AND schema_id NOT IN (SELECT id from sys.schemas); \ "; - msg = SQLstatementIntern(c, &createdb_inline, "sql.init", TRUE, FALSE, NULL); + msg = SQLstatementIntern(c, createdb_inline, "sql.init", TRUE, FALSE, NULL); if (m->sa) sa_destroy(m->sa); m->sa = NULL; @@ -656,7 +656,7 @@ SQLstatement(Client cntxt, MalBlkPtr mb, if (pci->argc == 3) output = *getArgReference_bit(stk, pci, 2); - return SQLstatementIntern(cntxt, expr, "SQLstatement", TRUE, output, NULL); + return SQLstatementIntern(cntxt, *expr, "SQLstatement", TRUE, output, NULL); } str @@ -668,7 +668,7 @@ SQLcompile(Client cntxt, MalBlkPtr mb, M (void) mb; *ret = NULL; - if ((msg = SQLstatementIntern(cntxt, expr, "SQLcompile", FALSE, FALSE, NULL)) != MAL_SUCCEED) + if ((msg = SQLstatementIntern(cntxt, *expr, "SQLcompile", FALSE, FALSE, NULL)) != MAL_SUCCEED) return msg; if ((*ret = _STRDUP("SQLcompile")) == NULL) throw(SQL,"sql.compile",SQLSTATE(HY013) MAL_MALLOC_FAIL); @@ -688,7 +688,6 @@ SQLinclude(Client cntxt, MalBlkPtr mb, M bstream *bfd; str *name = getArgReference_str(stk, pci, 1); str msg = MAL_SUCCEED, fullname; - str *expr; mvc *m; size_t sz; @@ -714,8 +713,7 @@ SQLinclude(Client cntxt, MalBlkPtr mb, M throw(MAL, "sql.include", SQLSTATE(42000) "could not read %s\n", *name); } - expr = &bfd->buf; - msg = SQLstatementIntern(cntxt, expr, "sql.include", TRUE, FALSE, NULL); + msg = SQLstatementIntern(cntxt, bfd->buf, "sql.include", TRUE, FALSE, NULL); bstream_destroy(bfd); m = ((backend *) cntxt->sqlcontext)->mvc; if (m->sa) 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 @@ -144,7 +144,7 @@ sql_fix_system_tables(Client c, mvc *sql assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); GDKfree(buf); return err; /* usually MAL_SUCCEED */ } @@ -255,7 +255,7 @@ sql_update_hugeint(Client c, mvc *sql, c assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); GDKfree(buf); return err; /* usually MAL_SUCCEED */ } @@ -303,7 +303,7 @@ sql_update_geom(Client c, mvc *sql, int assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); GDKfree(buf); return err; /* usually MAL_SUCCEED */ } @@ -332,7 +332,7 @@ sql_update_remote_tables(Client c, mvc * assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "create function", true, false, NULL); + err = SQLstatementIntern(c, buf, "create function", true, false, NULL); if (err) goto bailout; @@ -344,7 +344,7 @@ sql_update_remote_tables(Client c, mvc * assert(pos < bufsize); - err = SQLstatementIntern(c, &buf, "get remote table names", true, false, &output); + err = SQLstatementIntern(c, buf, "get remote table names", true, false, &output); if (err) goto bailout; @@ -417,7 +417,7 @@ sql_update_aug2018(Client c, mvc *sql, c assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); if (err) goto bailout; err = sql_update_remote_tables(c, sql, prev_schema); @@ -441,7 +441,7 @@ sql_update_aug2018_sp2(Client c, const c /* required update for changeset 23e1231ada99 */ pos += snprintf(buf + pos, bufsize - pos, "select id from sys.functions where language <> 0 and not side_effect and type <> 4 and (type = 2 or (language <> 2 and id not in (select func_id from sys.args where inout = 1)));\n"); - err = SQLstatementIntern(c, &buf, "update", true, false, &output); + err = SQLstatementIntern(c, buf, "update", true, false, &output); if (err) { GDKfree(buf); return err; @@ -458,7 +458,7 @@ sql_update_aug2018_sp2(Client c, const c assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); } BBPunfix(b->batCacheid); } @@ -501,7 +501,7 @@ sql_drop_functions_dependencies_Xs_on_Ys assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); GDKfree(buf); return err; /* usually MAL_SUCCEED */ } @@ -588,7 +588,7 @@ sql_update_apr2019(Client c, mvc *sql, c assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); if (err == MAL_SUCCEED) { pos = snprintf(buf, bufsize, "set schema \"sys\";\n" "ALTER TABLE sys.keywords SET READ ONLY;\n"); @@ -596,7 +596,7 @@ sql_update_apr2019(Client c, mvc *sql, c pos += snprintf(buf + pos, bufsize - pos, "set schema \"%s\";\n", prev_schema); assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); } GDKfree(buf); @@ -913,7 +913,7 @@ sql_update_storagemodel(Client c, mvc *s assert(pos < bufsize); printf("Running database upgrade commands:\n%s\n", buf); - err = SQLstatementIntern(c, &buf, "update", true, false, NULL); + err = SQLstatementIntern(c, buf, "update", true, false, NULL); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list