Changeset: 1a9996f224f8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1a9996f224f8 Modified Files: sql/backends/monet5/sql_upgrades.c Branch: pushdown Log Message:
Just return if something went wrong during upgrade. This just simplifies the code, it doesn't really do anything different. diffs (truncated from 334 to 300 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 @@ -3013,28 +3013,27 @@ SQLupgrades(Client c, mvc *m) sql_table *t; sql_column *col; bool systabfixed = false; - int res = 0; if (!prev_schema) { TRC_CRITICAL(SQL_PARSER, "Allocation failure while running SQL upgrades\n"); - res = -1; + return -1; } #ifdef HAVE_HGE - if (!res && have_hge) { + if (have_hge) { sql_find_subtype(&tp, "hugeint", 0, 0); if (!sql_bind_func(m->sa, s, "var_pop", &tp, NULL, F_AGGR)) { if ((err = sql_update_hugeint(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } } #endif f = sql_bind_func_(m->sa, s, "env", NULL, F_UNION); - if (!res && f && sql_privilege(m, ROLE_PUBLIC, f->func->base.id, PRIV_EXECUTE) != PRIV_EXECUTE) { + if (f && sql_privilege(m, ROLE_PUBLIC, f->func->base.id, PRIV_EXECUTE) != PRIV_EXECUTE) { sql_table *privs = find_sql_table(s, "privileges"); int pub = ROLE_PUBLIC, p = PRIV_EXECUTE, zero = 0; @@ -3045,15 +3044,15 @@ SQLupgrades(Client c, mvc *m) * exist any more at the "sys" schema (i.e., the first part of * the upgrade has been completed succesfully), then move on * to the second part */ - if (!res && find_sql_type(s, "point") != NULL) { + if (find_sql_type(s, "point") != NULL) { /* type sys.point exists: this is an old geom-enabled * database */ if ((err = sql_update_geom(c, m, 1, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } - } else if (!res && geomsqlfix_get() != NULL) { + } else if (geomsqlfix_get() != NULL) { /* the geom module is loaded... */ sql_find_subtype(&tp, "clob", 0, 0); if (!sql_bind_func(m->sa, s, "st_wkttosql", @@ -3062,67 +3061,67 @@ SQLupgrades(Client c, mvc *m) if ((err = sql_update_geom(c, m, 0, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } } - if (!res && mvc_bind_table(m, s, "function_languages") == NULL) { + if (mvc_bind_table(m, s, "function_languages") == NULL) { if ((err = sql_update_jul2017(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && (err = sql_update_jul2017_sp2(c)) != NULL) { + if ((err = sql_update_jul2017_sp2(c)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } - if (!res && (err = sql_update_jul2017_sp3(c, m, prev_schema, &systabfixed)) != NULL) { + if ((err = sql_update_jul2017_sp3(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } - if (!res && (t = mvc_bind_table(m, s, "geometry_columns")) != NULL && + if ((t = mvc_bind_table(m, s, "geometry_columns")) != NULL && (col = mvc_bind_column(m, t, "coord_dimension")) != NULL && strcmp(col->type.type->sqlname, "int") != 0) { if ((err = sql_update_mar2018_geom(c, t, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && mvc_bind_schema(m, "wlc") == NULL && + if (mvc_bind_schema(m, "wlc") == NULL && !sql_bind_func(m->sa, s, "master", NULL, NULL, F_PROC)) { if ((err = sql_update_mar2018(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } #ifdef HAVE_NETCDF if (mvc_bind_table(m, s, "netcdf_files") != NULL && (err = sql_update_mar2018_netcdf(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } #endif } - if (!res && sql_bind_func(m->sa, s, "dependencies_functions_os_triggers", NULL, NULL, F_UNION)) { + if (sql_bind_func(m->sa, s, "dependencies_functions_os_triggers", NULL, NULL, F_UNION)) { if ((err = sql_update_mar2018_sp1(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && mvc_bind_table(m, s, "ids") != NULL) { + if (mvc_bind_table(m, s, "ids") != NULL) { /* determine if sys.ids needs to be updated (only the version of Mar2018) */ char * qry = "select id from sys._tables where name = 'ids' and query like '% tmp.keys k join sys._tables% tmp.idxs i join sys._tables% tmp.triggers g join sys._tables% ';"; res_table *output = NULL; @@ -3130,7 +3129,7 @@ SQLupgrades(Client c, mvc *m) if (err) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } else { BAT *b = BATdescriptor(output->cols[0].b); if (b) { @@ -3139,7 +3138,8 @@ SQLupgrades(Client c, mvc *m) if ((err = sql_replace_Mar2018_ids_view(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + BBPunfix(b->batCacheid); + return -1; } } BBPunfix(b->batCacheid); @@ -3151,7 +3151,7 @@ SQLupgrades(Client c, mvc *m) /* temporarily use variable `err' to check existence of MAL * module gsl */ - if (!res && (((err = getName("gsl")) == NULL || getModule(err) == NULL))) { + if ((((err = getName("gsl")) == NULL || getModule(err) == NULL))) { /* no MAL module gsl, check for SQL function sys.chi2prob */ sql_find_subtype(&tp, "double", 0, 0); if (sql_bind_func(m->sa, s, "chi2prob", &tp, &tp, F_FUNC)) { @@ -3160,21 +3160,21 @@ SQLupgrades(Client c, mvc *m) if ((err = sql_update_gsl(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } } sql_find_subtype(&tp, "clob", 0, 0); - if (!res && sql_bind_func(m->sa, s, "group_concat", &tp, NULL, F_AGGR) == NULL) { + if (sql_bind_func(m->sa, s, "group_concat", &tp, NULL, F_AGGR) == NULL) { if ((err = sql_update_aug2018(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && sql_bind_func(m->sa, s, "dependencies_schemas_on_users", NULL, NULL, F_UNION) + if (sql_bind_func(m->sa, s, "dependencies_schemas_on_users", NULL, NULL, F_UNION) && sql_bind_func(m->sa, s, "dependencies_owners_on_schemas", NULL, NULL, F_UNION) && sql_bind_func(m->sa, s, "dependencies_tables_on_views", NULL, NULL, F_UNION) && sql_bind_func(m->sa, s, "dependencies_tables_on_indexes", NULL, NULL, F_UNION) @@ -3194,98 +3194,98 @@ SQLupgrades(Client c, mvc *m) if ((err = sql_drop_functions_dependencies_Xs_on_Ys(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && (err = sql_update_aug2018_sp2(c, prev_schema)) != NULL) { + if ((err = sql_update_aug2018_sp2(c, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } - if (!res && (t = mvc_bind_table(m, s, "systemfunctions")) != NULL && + if ((t = mvc_bind_table(m, s, "systemfunctions")) != NULL && t->type == tt_table) { if (!systabfixed && (err = sql_fix_system_tables(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } systabfixed = true; if ((err = sql_update_apr2019(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } /* when function storagemodel() exists and views tablestorage * and schemastorage don't, then upgrade storagemodel to match * 75_storagemodel.sql */ - if (!res && sql_bind_func(m->sa, s, "storagemodel", NULL, NULL, F_UNION) + if (sql_bind_func(m->sa, s, "storagemodel", NULL, NULL, F_UNION) && (t = mvc_bind_table(m, s, "tablestorage")) == NULL && (t = mvc_bind_table(m, s, "schemastorage")) == NULL ) { if ((err = sql_update_storagemodel(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } - if (!res && (err = sql_update_apr2019_sp1(c)) != NULL) { + if ((err = sql_update_apr2019_sp1(c)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } - if (!res && sql_bind_func(m->sa, s, "times", NULL, NULL, F_PROC)) { - if (!res && (err = sql_update_apr2019_sp2(c, m, prev_schema, &systabfixed)) != NULL) { + if (sql_bind_func(m->sa, s, "times", NULL, NULL, F_PROC)) { + if ((err = sql_update_apr2019_sp2(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } sql_find_subtype(&tp, "string", 0, 0); - if (!res && !sql_bind_func3(m->sa, s, "deltas", &tp, &tp, &tp, F_UNION)) { + if (!sql_bind_func3(m->sa, s, "deltas", &tp, &tp, &tp, F_UNION)) { if ((err = sql_update_nov2019_missing_dependencies(c, m)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } if (!systabfixed && (err = sql_fix_system_tables(c, m, prev_schema)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } systabfixed = true; if ((err = sql_update_nov2019(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } #ifdef HAVE_HGE - if (!res && have_hge) { + if (have_hge) { sql_find_subtype(&tp, "hugeint", 0, 0); if (!sql_bind_func(m->sa, s, "median_avg", &tp, NULL, F_AGGR)) { if ((err = sql_update_nov2019_sp1_hugeint(c, m, prev_schema, &systabfixed)) != NULL) { TRC_CRITICAL(SQL_PARSER, "%s\n", err); freeException(err); - res = -1; + return -1; } } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list