Changeset: 0ee3b795f7f0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0ee3b795f7f0 Modified Files: sql/backends/monet5/sql_scenario.c sql/include/sql_relation.h Branch: ustr Log Message:
Merge with default branch. diffs (truncated from 1279 to 300 lines): diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog file for devel # This file is updated with Maddlog +* Thu May 7 2026 Niels Nes <[email protected]> +- disallow casting /coercing from decimal to integers when the functions + work on bits (like xor, and, or, <<, >> etc) + * Thu May 7 2026 Sjoerd Mullender <[email protected]> - The version number has changed from three levels where the first level has always been 11 to two levels. The 11. has been dropped. 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 @@ -385,7 +385,7 @@ SQLexecPostLoginTriggers(Client c) c->curprg = curprg; ma_destroy(m->sa); m->sa = sa; - throw(SQL, "sql.SQLexecPostLoginTriggers", SQLSTATE(4200) "%s", "generating MAL failed"); + throw(SQL, "sql.SQLexecPostLoginTriggers", SQLSTATE(42000) "%s", "generating MAL failed"); } msg = SQLoptimizeQuery(c, c->curprg->def); @@ -668,7 +668,7 @@ SQLinit(Client c, const char *initpasswd } if ((opt_pipe = GDKgetenv("sql_optimizer")) && !isOptimizerPipe(opt_pipe)) - throw(SQL, "sql.init", SQLSTATE(42000) "invalid sql optimizer pipeline %s", opt_pipe); + throw(SQL, "sql.init", SQLSTATE(22023) "invalid sql optimizer pipeline '%s'", opt_pipe); MT_lock_set(&sql_contextLock); diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c --- a/sql/backends/monet5/sql_user.c +++ b/sql/backends/monet5/sql_user.c @@ -77,15 +77,15 @@ setUserPassword(mvc *m, oid rid, str val str hash = NULL; int res; if (is_oid_nil(rid)) { - (void) sql_error(m, 02, SQLSTATE(42000) "setUserPassword: invalid user"); + (void) sql_error(m, 02, SQLSTATE(22023) "setUserPassword: invalid user"); return LOG_ERR; } if (strNil(value)) { - (void) sql_error(m, 02, SQLSTATE(42000) "setUserPassword: password cannot be nil"); + (void) sql_error(m, 02, SQLSTATE(22004) "setUserPassword: password cannot be NULL"); return LOG_ERR; } if ((err = AUTHverifyPassword(value)) != MAL_SUCCEED) { - (void) sql_error(m, 02, SQLSTATE(42000) "setUserPassword: %s", getExceptionMessage(err)); + (void) sql_error(m, 02, SQLSTATE(28000) "setUserPassword: %s", getExceptionMessage(err)); return LOG_ERR; } allocator *ta = MT_thread_getallocator(); @@ -112,23 +112,23 @@ changeUserPassword(mvc *m, oid rid, str str hash = NULL; str passValue = NULL; if (is_oid_nil(rid)) { - (void) sql_error(m, 02, SQLSTATE(42000) "changeUserPassword: invalid user"); + (void) sql_error(m, 02, SQLSTATE(22023) "changeUserPassword: invalid user"); return LOG_ERR; } if (strNil(newpass)) { - (void) sql_error(m, 02, SQLSTATE(42000) "changeUserPassword: password cannot be nil"); + (void) sql_error(m, 02, SQLSTATE(22004) "changeUserPassword: password cannot be NULL"); return LOG_ERR; } if (oldpass) { // validate old password match if ((err = AUTHdecypherValue(m->sa, &hash, passValue=getUserPassword(m, rid))) != MAL_SUCCEED) { - (void) sql_error(m, 02, SQLSTATE(42000) "changeUserPassword: %s", getExceptionMessage(err)); + (void) sql_error(m, 02, SQLSTATE(28000) "changeUserPassword: %s", getExceptionMessage(err)); GDKfree(passValue); return LOG_ERR; } GDKfree(passValue); if (strcmp(oldpass, hash) != 0) { - (void) sql_error(m, 02, SQLSTATE(42000) "changeUserPassword: password mismatch"); + (void) sql_error(m, 02, SQLSTATE(28000) "changeUserPassword: password mismatch"); return LOG_ERR; } } @@ -166,7 +166,7 @@ monet5_drop_user(ptr _mvc, str user) rid = store->table_api.column_find_row(m->session->tr, users_name, user, NULL); if (!is_oid_nil(rid) && (log_res = store->table_api.table_delete(m->session->tr, users, rid)) != LOG_OK) { - (void) sql_error(m, 02, "DROP USER: failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); + (void) sql_error(m, 02, SQLSTATE(25000) "DROP USER: failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); return FALSE; } @@ -189,7 +189,7 @@ parse_schema_path_str(mvc *m, str schema size_t bp = 0; if (strNil(schema_path)) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema path cannot be NULL"); + throw(SQL, "sql.schema_path", SQLSTATE(22004) "A schema path cannot be NULL"); if (build) { while (l->t) /* if building, empty schema_path list */ @@ -198,6 +198,7 @@ parse_schema_path_str(mvc *m, str schema m->schema_path_has_tmp = false; } + /* SQLSTATE(0E000) = invalid schema name list specification */ for (size_t i = 0; schema_path[i]; i++) { char next = schema_path[i]; @@ -207,9 +208,9 @@ parse_schema_path_str(mvc *m, str schema i++; /* has to advance two positions */ } else if (status == inside_str) { if (bp == 0) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema name cannot be empty"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema name cannot be empty"); if (bp == 1023) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema has up to 1023 characters"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema has up to 1023 characters"); if (build) { char *val = NULL; @@ -236,24 +237,24 @@ parse_schema_path_str(mvc *m, str schema i++; /* has to advance two positions */ } else if (status == inside_str) { if (bp == 1023) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema has up to 1023 characters"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema has up to 1023 characters"); next_schema[bp++] = ','; /* used inside a schema name */ } else if (status == outside_str) { - throw(SQL, "sql.schema_path", SQLSTATE(42000) "The '\"' character is expected after the comma separator"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "The '\"' character is expected after the comma separator"); } } else if (status == inside_str) { if (bp == 1023) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema has up to 1023 characters"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema has up to 1023 characters"); if (bp == 0 && next == '%') - throw(SQL, "sql.schema_path", SQLSTATE(42000) "The character '%%' is not allowed as the first schema character"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "The character '%%' is not allowed as the first schema character"); next_schema[bp++] = next; } else { assert(status == outside_str); - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema in the path must be within '\"'"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema in the path must be within '\"'"); } } if (status == inside_str) - throw(SQL, "sql.schema_path", SQLSTATE(42000) "A schema path cannot end inside inside a schema name"); + throw(SQL, "sql.schema_path", SQLSTATE(0E000) "A schema path cannot end inside a schema name"); return MAL_SUCCEED; } @@ -267,8 +268,8 @@ monet5_create_user(ptr _mvc, str user, s sqlid user_id; sql_schema *s = find_sql_schema(m->session->tr, "sys"); sql_table *db_user_info = find_sql_table(m->session->tr, s, "db_user_info"), - *auths = find_sql_table(m->session->tr, s, "auths"), - *schemas_tbl = find_sql_table(m->session->tr, s, "schemas"); + *auths = find_sql_table(m->session->tr, s, "auths"), + *schemas_tbl = find_sql_table(m->session->tr, s, "schemas"); // Client c = MCgetClient(m->clientid); sqlstore *store = m->session->tr->store; int log_res = 0; @@ -281,7 +282,7 @@ monet5_create_user(ptr _mvc, str user, s throw(SQL,"sql.create_user",SQLSTATE(HY013) MAL_MALLOC_FAIL); case -2: case -3: - throw(SQL,"sql.create_user",SQLSTATE(42000) "Create user schema failed due to transaction conflict"); + throw(SQL,"sql.create_user",SQLSTATE(25000) "Create user schema failed due to transaction conflict"); default: break; } @@ -290,7 +291,7 @@ monet5_create_user(ptr _mvc, str user, s assert(schema_id); if (is_oid_nil(rid = store->table_api.column_find_row(m->session->tr, find_sql_column(schemas_tbl, "id"), &schema_id, NULL))) - throw(SQL,"sql.create_user",SQLSTATE(42000) "User schema not found"); + throw(SQL,"sql.create_user",SQLSTATE(22023) "User schema not found"); if (!schema_path) { schema_path = default_schema_path; @@ -303,13 +304,13 @@ monet5_create_user(ptr _mvc, str user, s if (!optimizer) optimizer = default_optimizer; if (!isOptimizerPipe(optimizer)) { - throw(MAL, "sql.create_user", SQLSTATE(42000) "Optimizer pipe '%s' unknown", optimizer); + throw(MAL, "sql.create_user", SQLSTATE(22023) "Optimizer pipe '%s' unknown", optimizer); } if (!enc) { if (!(pwd = mcrypt_BackendSum(passwd, strlen(passwd)))) { - throw(MAL, "sql.create_user", SQLSTATE(42000) "Crypt backend hash not found"); + throw(MAL, "sql.create_user", SQLSTATE(28000) "Crypt backend hash not found"); } } else { pwd = passwd; @@ -329,23 +330,23 @@ monet5_create_user(ptr _mvc, str user, s sqlid default_role_id = role_id > 0 ? role_id : user_id; if ((log_res = store->table_api.table_insert(m->session->tr, db_user_info, &user, &fullname, &schema_id, &schema_path, &max_memory, &max_workers, &optimizer, &default_role_id, &hash))) { ma_close(&ta_state); - throw(SQL, "sql.create_user", SQLSTATE(42000) "Create user failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); + throw(SQL, "sql.create_user", SQLSTATE(25000) "Create user failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); } // clean up ma_close(&ta_state); if ((log_res = store->table_api.table_insert(m->session->tr, auths, &user_id, &user, &grantorid))) { - throw(SQL, "sql.create_user", SQLSTATE(42000) "Create user failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); + throw(SQL, "sql.create_user", SQLSTATE(25000) "Create user failed%s", log_res == LOG_CONFLICT ? " due to conflict with another transaction" : ""); } if (new_schema) { // update schema authorization to be default_role_id switch (sql_trans_change_schema_authorization(m->session->tr, schema_id, default_role_id)) { case -1: - throw(SQL,"sql.create_user",SQLSTATE(HY013) MAL_MALLOC_FAIL); + throw(SQL, "sql.create_user", SQLSTATE(HY013) MAL_MALLOC_FAIL); case -2: case -3: - throw(SQL,"sql.create_user",SQLSTATE(42000) "Update schema authorization failed due to transaction conflict"); + throw(SQL, "sql.create_user", SQLSTATE(25000) "Update schema authorization failed due to transaction conflict"); default: break; } @@ -370,7 +371,7 @@ monet5_password_hash(mvc *m, const char msg = AUTHdecypherValue(m->sa, &hash, password); GDKfree(password); if (msg) { - (void) sql_error(m, 02, SQLSTATE(42000) "monet5_password_hash: %s", getExceptionMessage(msg)); + (void) sql_error(m, 02, SQLSTATE(28000) "monet5_password_hash: %s", getExceptionMessage(msg)); } } return hash; @@ -396,7 +397,7 @@ monet5_create_privileges(ptr _mvc, sql_s mvc_create_table(&t, m, s, "db_user_info", tt_table, 1, SQL_PERSIST, 0, -1, 0); mvc_create_column_(&col, m, t, "name", "varchar", 1024); mvc_create_column_(&col, m, t, "fullname", "varchar", 2048); - mvc_create_column_(&col, m, t, "default_schema", "int", 9); + mvc_create_column_(&col, m, t, "default_schema", "int", 32); mvc_create_column_(&col, m, t, "schema_path", "varchar", 0); mvc_create_column_(&col, m, t, "max_memory", "bigint", 64); mvc_create_column_(&col, m, t, "max_workers", "int", 32); @@ -473,8 +474,8 @@ monet5_alter_user(ptr _mvc, str user, st rid = store->table_api.column_find_row(m->session->tr, users_name, user, NULL); // user should be checked here since the way `ALTER USER ident ...` stmt is if (is_oid_nil(rid)) { - (void) sql_error(m, 02, "ALTER USER: local inconsistency, " - "your database is damaged, auth not found in SQL catalog"); + (void) sql_error(m, 02, SQLSTATE(42000) "ALTER USER: local inconsistency, " + "your database is damaged, db_user_info.name not found in SQL catalog"); return FALSE; } } @@ -486,14 +487,14 @@ monet5_alter_user(ptr _mvc, str user, st if (!enc) { pwd = mcrypt_BackendSum(passwd, strlen(passwd)); if (pwd == NULL) { - (void) sql_error(m, 02, SQLSTATE(42000) "ALTER USER: crypt backend hash not found"); + (void) sql_error(m, 02, SQLSTATE(28000) "ALTER USER: crypt backend hash not found"); return FALSE; } if (oldpasswd != NULL) { opwd = mcrypt_BackendSum(oldpasswd, strlen(oldpasswd)); if (opwd == NULL) { free(pwd); - (void) sql_error(m, 02, SQLSTATE(42000) "ALTER USER: crypt backend hash not found"); + (void) sql_error(m, 02, SQLSTATE(28000) "ALTER USER: crypt backend hash not found"); return FALSE; } } @@ -510,7 +511,7 @@ monet5_alter_user(ptr _mvc, str user, st free(pwd); free(opwd); } - (void) sql_error(m, 02, "ALTER USER: invalid user"); + (void) sql_error(m, 02, SQLSTATE(22023) "ALTER USER: invalid user"); return (FALSE); } if (strcmp(username, user) == 0) { @@ -519,7 +520,7 @@ monet5_alter_user(ptr _mvc, str user, st free(pwd); free(opwd); } - (void) sql_error(m, 02, "ALTER USER: " + (void) sql_error(m, 02, SQLSTATE(22023) "ALTER USER: " "use 'ALTER USER SET [ ENCRYPTED ] PASSWORD xxx " "USING OLD PASSWORD yyy' " "when changing your own password"); @@ -528,7 +529,7 @@ monet5_alter_user(ptr _mvc, str user, st GDKfree(username); // verify current user is MAL_ADMIN ? if ((err = AUTHrequireAdmin(c)) != MAL_SUCCEED) { - (void) sql_error(m, 02, "ALTER USER: %s", getExceptionMessage(err)); + (void) sql_error(m, 02, SQLSTATE(28000) "ALTER USER: %s", getExceptionMessage(err)); if (!enc) { free(pwd); free(opwd); _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
