Changeset: 7dbe169d84b0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7dbe169d84b0 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 sql/backends/monet5/sql.mal sql/backends/monet5/sql_user.c Branch: Mar2018 Log Message:
Implemented bulk version of sql.password. diffs (82 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -8262,6 +8262,7 @@ Ready. [ "batsql", "diff", "pattern batsql.diff(b:bat[:any_1]):bat[:bit] ", "SQLdiff;", "return true if cur != prev row" ] [ "batsql", "diff", "pattern batsql.diff(p:bat[:bit], b:bat[:any_1]):bat[:bit] ", "SQLdiff;", "return true if cur != prev row" ] [ "batsql", "next_value", "pattern batsql.next_value(sname:bat[:str], sequence:str):bat[:lng] ", "mvc_bat_next_value;", "return the next value of the sequence" ] +[ "batsql", "password", "pattern batsql.password(user:bat[:str]):bat[:str] ", "db_password_wrap;", "Return password hash of user" ] [ "batsql", "rank", "pattern batsql.rank(b:bat[:any_1], p:any_2, o:any_3):bat[:int] ", "SQLrank;", "return the ranked groups" ] [ "batsql", "round", "command batsql.round(v:bat[:bte], d:int, s:int, r:bte):bat[:bte] ", "bte_bat_round_wrap;", "round off the decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)" ] [ "batsql", "round", "command batsql.round(v:bat[:dbl], r:bte):bat[:dbl] ", "dbl_bat_round_wrap;", "round off the floating point v to r digits behind the dot (if r < 0, before the dot)" ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -11831,6 +11831,7 @@ Ready. [ "batsql", "diff", "pattern batsql.diff(b:bat[:any_1]):bat[:bit] ", "SQLdiff;", "return true if cur != prev row" ] [ "batsql", "diff", "pattern batsql.diff(p:bat[:bit], b:bat[:any_1]):bat[:bit] ", "SQLdiff;", "return true if cur != prev row" ] [ "batsql", "next_value", "pattern batsql.next_value(sname:bat[:str], sequence:str):bat[:lng] ", "mvc_bat_next_value;", "return the next value of the sequence" ] +[ "batsql", "password", "pattern batsql.password(user:bat[:str]):bat[:str] ", "db_password_wrap;", "Return password hash of user" ] [ "batsql", "rank", "pattern batsql.rank(b:bat[:any_1], p:any_2, o:any_3):bat[:int] ", "SQLrank;", "return the ranked groups" ] [ "batsql", "round", "command batsql.round(v:bat[:bte], d:int, s:int, r:bte):bat[:bte] ", "bte_bat_round_wrap;", "round off the decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)" ] [ "batsql", "round", "command batsql.round(v:bat[:dbl], r:bte):bat[:dbl] ", "dbl_bat_round_wrap;", "round off the floating point v to r digits behind the dot (if r < 0, before the dot)" ] diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal --- a/sql/backends/monet5/sql.mal +++ b/sql/backends/monet5/sql.mal @@ -369,6 +369,10 @@ pattern password(user:str) :str address db_password_wrap comment "Return password hash of user"; +pattern batsql.password(user:bat[:str]) :bat[:str] +address db_password_wrap +comment "Return password hash of user"; + pattern dump_cache()(query:bat[:str],count:bat[:int]) address dump_cache comment "dump the content of the query cache"; 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 @@ -159,9 +159,41 @@ db_users_wrap(Client cntxt, MalBlkPtr mb str db_password_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { + (void) mb; + + if (stk->stk[pci->argv[0]].vtype == TYPE_bat) { + BAT *b = BATdescriptor(*getArgReference_bat(stk, pci, 1)); + if (b == NULL) + throw(SQL, "sql.password", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); + BAT *bn = COLnew(b->hseqbase, TYPE_str, BATcount(b), TRANSIENT); + if (bn == NULL) { + BBPunfix(b->batCacheid); + throw(SQL, "sql.password", SQLSTATE(HY001) MAL_MALLOC_FAIL); + } + BATiter bi = bat_iterator(b); + BUN p, q; + BATloop(b, p, q) { + char *hash, *msg; + msg = AUTHgetPasswordHash(&hash, cntxt, BUNtvar(bi, p)); + if (msg != MAL_SUCCEED) { + BBPunfix(b->batCacheid); + BBPreclaim(bn); + return msg; + } + if (BUNappend(bn, hash, FALSE) != GDK_SUCCEED) { + BBPunfix(b->batCacheid); + BBPreclaim(bn); + throw(SQL, "sql.password", SQLSTATE(HY001) MAL_MALLOC_FAIL); + } + GDKfree(hash); + } + BBPunfix(b->batCacheid); + BBPkeepref(bn->batCacheid); + *getArgReference_bat(stk, pci, 0) = bn->batCacheid; + return MAL_SUCCEED; + } str *hash = getArgReference_str(stk, pci, 0); str *user = getArgReference_str(stk, pci, 1); - (void) mb; return AUTHgetPasswordHash(hash, cntxt, *user); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list