Changeset: a2d1d853c33f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a2d1d853c33f
Modified Files:
        clients/ChangeLog.Oct2012
        clients/mapiclient/mclient.1
        clients/mapiclient/mclient.c
Branch: Oct2012
Log Message:

mclient: allow to use URIs to connect to a database

Since mclient itself reports the URI its connected to, and monetdb
discover lists URIs, it makes sense to also allow mclient to connect
using these URIs, as supported by mapilib for a while.


diffs (57 lines):

diff --git a/clients/ChangeLog.Oct2012 b/clients/ChangeLog.Oct2012
--- a/clients/ChangeLog.Oct2012
+++ b/clients/ChangeLog.Oct2012
@@ -1,6 +1,9 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Tue Sep  4 2012 Fabian Groffen <[email protected]>
+- mclient now accepts URIs as database to connect to.
+
 * Thu Jul 19 2012 Gijs Molenaar <[email protected]>
 - all strings returned by python2 are unicode, removed use_unicode option
 - python2 and 3 type convertion speed improvements
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -114,10 +114,12 @@ option is omitted, the default of
 is assumed.
 .TP
 \fB\-\-database=\fP\fIdatabase\fP (\fB\-d\fP \fIdatabase\fP)
-Specify the name of the database to connect to.  The \fB-d\fP can be
+Specify the name or URI of the database to connect to.  The \fB-d\fP can be
 omitted if an equally named file does not exist in the current
 directory.  As such, the first non-option argument will be interpreted
 as database to connect to if the argument does not exist as file.
+Valid URIs are as returned by
+.RB "`monetdb discover`, see " monetdb "(1), and look like " 
"mapi:monetdb://hostname:port/database" .
 .TP
 \fB\-\-host=\fP\fIhostname\fP (\fB\-h\fP \fIhostname\fP)
 Specify the name of the host on which the server runs (default:
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2595,7 +2595,7 @@ usage(const char *prog, int xit)
 #endif
        fprintf(stderr, " -p portnr   | --port=portnr      port to connect 
to\n");
        fprintf(stderr, " -u user     | --user=user        user id\n");
-       fprintf(stderr, " -d database | --database=database  database to 
connect to\n");
+       fprintf(stderr, " -d database | --database=database  database to 
connect to (may be URI)\n");
 
        fprintf(stderr, " -e          | --echo             echo the query\n");
 #ifdef HAVE_ICONV
@@ -3003,7 +3003,13 @@ main(int argc, char **argv)
                has_fileargs = optind != argc;
        }
 
-       mid = mapi_connect(host, port, user, passwd, language, dbname);
+       if (dbname != NULL && strncmp(dbname, "mapi:monetdb://", 15) == 0) {
+               mid = mapi_mapiuri(dbname, user, passwd, language);
+       } else {
+               mid = mapi_mapi(host, port, user, passwd, language, dbname);
+       }
+       if (mid && mapi_error(mid) == MOK)
+               mapi_reconnect(mid);    /* actually, initial connect */
 
        if (mid == NULL) {
                fprintf(stderr, "failed to allocate Mapi structure\n");
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to