Changeset: 7e28940c2713 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7e28940c2713 Modified Files: monetdb5/modules/mal/remote.c monetdb5/modules/mal/remote.h monetdb5/modules/mal/remote.mal Branch: remote_auth Log Message:
Add a new way to create remote table connections The new function, looks up the credentials for the table, and uses the old RMTconnect to create a new connection. TODOS: 1) we need to pass the full remote table URI, because this is part of the key that we need to look up the credentials (?) 2) We need to handle hashed passwords. diffs (76 lines): diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -262,6 +262,43 @@ str RMTconnect( return RMTconnectScen(ret, uri, user, passwd, &scen); } +str +RMTconnectURI(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ + char *remoteuser; + char *passwd; + char *uri; + char *tmp; + char *ret; + str msg; + ValPtr v; + + (void)mb; + + v = &stk->stk[pci->argv[0]]; + + uri = *getArgReference_str(stk, pci, 1); + if (uri == NULL || strcmp(uri, (str)str_nil) == 0) { + throw(ILLARG, "remote.connect", ILLEGAL_ARGUMENT ": URI is NULL or nil"); + } + + rethrow("remote.connect", tmp, AUTHgetRemoteTableCredentials(uri, cntxt, &remoteuser, &passwd)); + + msg = RMTconnect(&ret, &uri, &remoteuser, &passwd); + + GDKfree(remoteuser); + GDKfree(passwd); + + if (msg == MAL_SUCCEED) { + v = &stk->stk[pci->argv[0]]; + v->vtype = TYPE_str; + if((v->val.sval = GDKstrdup(ret)) == NULL) + throw(MAL, "remote.connect", SQLSTATE(HY001) MAL_MALLOC_FAIL); + } + + return msg; +} + /** * Disconnects a connection. The connection needs not to exist in the diff --git a/monetdb5/modules/mal/remote.h b/monetdb5/modules/mal/remote.h --- a/monetdb5/modules/mal/remote.h +++ b/monetdb5/modules/mal/remote.h @@ -51,6 +51,7 @@ mal_export str RMTepilogue(void *ret); mal_export str RMTresolve(bat *ret, str *pat); mal_export str RMTconnectScen( str *ret, str *ouri, str *user, str *passwd, str *scen); mal_export str RMTconnect( str *ret, str *uri, str *user, str *passwd); +mal_export str RMTconnectURI(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); mal_export str RMTdisconnect(void *ret, str *conn); mal_export str RMTget(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); @@ -66,4 +67,3 @@ mal_export str RMTisalive(int *ret, str mal_export str RMTregisterSupervisor(int *ret, str *sup_uuid, str *query_uuid); #endif /* HAVE_MAPI */ #endif /* _REMOTE_DEF */ - diff --git a/monetdb5/modules/mal/remote.mal b/monetdb5/modules/mal/remote.mal --- a/monetdb5/modules/mal/remote.mal +++ b/monetdb5/modules/mal/remote.mal @@ -24,6 +24,9 @@ comment "returns a newly created connect command connect(uri:str, user:str, passwd:str, scen:str):str address RMTconnectScen comment "returns a newly created connection for uri, using user name, password and scenario"; +pattern connect(uri:str):str +address RMTconnectURI +comment "return a newly created connection for uri. username and password should be in the vault" command disconnect(conn:str):void address RMTdisconnect _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list