Changeset: 0d192d651e4c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d192d651e4c Modified Files: ctest/tools/monetdbe/example2.c monetdb5/mal/mal.c monetdb5/mal/mal_authorize.c monetdb5/mal/mal_embedded.c sql/server/rel_schema.c tools/mserver/mserver5.c Branch: default Log Message:
allow create/drop/alter user in embedded mode, although not used fixed problem with have_hge in example2 added monetdbe_null(mdbe, type) returning a const NULL value (ptr) of the give type. moved AUTHinitTables inside the mal_init and malEmbedded diffs (153 lines): diff --git a/ctest/tools/monetdbe/example2.c b/ctest/tools/monetdbe/example2.c --- a/ctest/tools/monetdbe/example2.c +++ b/ctest/tools/monetdbe/example2.c @@ -19,9 +19,14 @@ main(void) char* err = NULL; monetdbe_database mdbe = NULL; monetdbe_result* result = NULL; +#ifdef HAVE_HGE + monetdbe_options opts = { .have_hge = 1 }; +#else + monetdbe_options opts = { }; +#endif // second argument is a string for the db directory or NULL for in-memory mode - if (monetdbe_open(&mdbe, NULL, NULL)) + if (monetdbe_open(&mdbe, NULL, &opts)) error("Failed to open database") if ((err = monetdbe_query(mdbe, "CREATE TABLE test (b bool, t tinyint, s smallint, x integer, l bigint, " #ifdef HAVE_HGE diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c --- a/monetdb5/mal/mal.c +++ b/monetdb5/mal/mal.c @@ -49,10 +49,19 @@ MT_Lock mal_oltpLock = MT_LOCK_INITI * Initialization of the MAL context */ -int mal_init(char *modules[], int embedded){ +int +mal_init(char *modules[], int embedded) +{ /* Any error encountered here terminates the process * with a message sent to stderr */ + str err; + + if ((err = AUTHinitTables(NULL)) != MAL_SUCCEED) { + freeException(err); + return -1; + } + if (!MCinit()) return -1; #ifndef NDEBUG @@ -64,7 +73,8 @@ int mal_init(char *modules[], int embedd initNamespace(); initParser(); initHeartbeat(); - str err = malBootstrap(modules, embedded); + + err = malBootstrap(modules, embedded); if (err != MAL_SUCCEED) { mal_client_reset(); #ifndef NDEBUG diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c --- a/monetdb5/mal/mal_authorize.c +++ b/monetdb5/mal/mal_authorize.c @@ -518,7 +518,11 @@ AUTHaddUser(oid *uid, Client cntxt, cons throw(MAL, "addUser", "user '%s' already exists", username); /* we assume the BATs are still aligned */ - rethrow("addUser", tmp, AUTHcypherValue(&hash, passwd)); + if (!GDKinmemory()) { + rethrow("addUser", tmp, AUTHcypherValue(&hash, passwd)); + } else { + hash = GDKstrdup("hash"); + } /* needs force, as SQL makes a view over user */ if (BUNappend(user, username, true) != GDK_SUCCEED || BUNappend(pass, hash, true) != GDK_SUCCEED) { diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c --- a/monetdb5/mal/mal_embedded.c +++ b/monetdb5/mal/mal_embedded.c @@ -48,6 +48,9 @@ malEmbeddedBoot(int workerlimit, int mem if( embeddedinitialized ) return MAL_SUCCEED; + if ((msg = AUTHinitTables(NULL)) != MAL_SUCCEED) + return msg; + if (!MCinit()) throw(MAL, "malEmbeddedBoot", "MAL debugger failed to start"); #ifndef NDEBUG diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c --- a/sql/server/rel_schema.c +++ b/sql/server/rel_schema.c @@ -2831,33 +2831,24 @@ rel_schemas(sql_query *query, symbol *s) case SQL_CREATE_USER: { dlist *l = s->data.lval; - if (GDKembedded()) - ret = sql_error(sql, 02, SQLSTATE(42S02) "CREATE USER: not supported in MonetDBe"); - else - ret = rel_create_user(sql->sa, l->h->data.sval, /* user name */ + ret = rel_create_user(sql->sa, l->h->data.sval, /* user name */ l->h->next->data.sval, /* password */ l->h->next->next->next->next->data.i_val == SQL_PW_ENCRYPTED, /* encrypted */ l->h->next->next->data.sval, /* fullname */ l->h->next->next->next->data.sval); /* dschema */ } break; case SQL_DROP_USER: - if (GDKembedded()) - ret = sql_error(sql, 02, SQLSTATE(42S02) "DROP USER: not supported in MonetDBe"); - else - ret = rel_schema2(sql->sa, ddl_drop_user, s->data.sval, NULL, 0); + ret = rel_schema2(sql->sa, ddl_drop_user, s->data.sval, NULL, 0); break; case SQL_ALTER_USER: { dlist *l = s->data.lval; dnode *a = l->h->next->data.lval->h; - if (GDKembedded()) - ret = sql_error(sql, 02, SQLSTATE(42S02) "ALTER USER: not supported in MonetDBe"); - else - ret = rel_alter_user(sql->sa, l->h->data.sval, /* user */ - a->data.sval, /* passwd */ - a->next->next->data.i_val == SQL_PW_ENCRYPTED, /* encrypted */ - a->next->data.sval, /* schema */ - a->next->next->next->data.sval /* old passwd */ + ret = rel_alter_user(sql->sa, l->h->data.sval, /* user */ + a->data.sval, /* passwd */ + a->next->next->data.i_val == SQL_PW_ENCRYPTED, /* encrypted */ + a->next->data.sval, /* schema */ + a->next->next->next->data.sval /* old passwd */ ); } break; case SQL_RENAME_USER: { diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -698,6 +698,7 @@ main(int argc, char **av) exit(1); } } +#if 0 /* make sure the authorisation BATs are loaded */ if ((err = AUTHinitTables(NULL)) != MAL_SUCCEED) { /* don't show this as a crash */ @@ -707,6 +708,7 @@ main(int argc, char **av) freeException(err); exit(1); } +#endif char *modules[16]; int mods = 0; @@ -739,6 +741,7 @@ main(int argc, char **av) modules[mods++] = "shp"; #endif modules[mods++] = 0; + if (mal_init(modules, 0)) { /* don't show this as a crash */ if (!GDKinmemory()) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list