Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18742/src/backends/monet5

Modified Files:
        Makefile.ag embeddedclient.mx prog.c sql_scenario.mx 
Added Files:
        monetdb5.py.i 
Log Message:
propagated changes of Wednesday Oct 17 2007 - Monday Oct 22 2007
from the SQL_2-20 branch to the development trunk


Index: sql_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_scenario.mx,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- sql_scenario.mx     13 Oct 2007 16:58:41 -0000      1.279
+++ sql_scenario.mx     22 Oct 2007 10:43:09 -0000      1.280
@@ -140,6 +140,7 @@
        Scenario s = getFreeScenario();
        if (!s)
                throw(MAL, "sql.start", "out of scenario slots");
+       sqlinit = GDKgetenv("sqlinit");
        s->name = "sql";
        s->language = "sql";
        s->initSystem = "SQLinit";
@@ -172,7 +173,6 @@
        s->optimizer = "MALoptimizer";
        /* s->tactics = .. */
        s->engine = "MALengine";
-       sqlinit = GDKgetenv("sqlinit");
        tmp = GDKgetenv("monet_welcome");
        if (tmp != NULL && strcmp(tmp, "yes") == 0)
                printf("# MonetDB/SQL module v" VERSION " loaded\n");
@@ -226,11 +226,9 @@
        if (debug_str) 
                SQLdebug = strtol(debug_str,NULL,10);
         SQLinitialized = TRUE;
-/*
-        if (MT_create_thread(&sqllogthread, (void (*)(void *)) mvc_logmanager, 
NULL) < 0) {
+        if (!GDKembedded && MT_create_thread(&sqllogthread, (void (*)(void *)) 
mvc_logmanager, NULL) < 0) {
                 throw(SQL, "SQLinit", "Starting log manager failed");
         }
-*/
        return MAL_SUCCEED;
 }
 

Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/Makefile.ag,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- Makefile.ag 12 Sep 2007 12:54:05 -0000      1.46
+++ Makefile.ag 22 Oct 2007 10:43:08 -0000      1.47
@@ -16,8 +16,14 @@
 
 man_MANS = monetdb.1 merovingian.1
 
+SWIGFLAGS = $(MONETDB_INCS) $(CLIENTS_INCS)
 INCLUDES = ../../include ../../common ../../storage ../../server \
-       $(MONETDB_INCS) $(CLIENTS_INCS) $(MONETDB5_INCS) 
+       $(MONETDB_INCS) $(CLIENTS_INCS) $(MONETDB5_INCS) $(PYTHON_INCS)
+
+# with gcc we could use these
+#X_CFLAGS = -Wno-unused-parameter -Wno-unused-function
+# but we certainly have to override the default X_CFLAGS:
+X_CFLAGS =
 
 EXTRA_DIST = $(man_MANS)
 
@@ -51,6 +57,30 @@
                $(CLIENTS_LIBS) $(MONETDB_LIBS) -lbat -lMapi -lmutils -lstream 
$(READLINE_LIBS) $(PTHREAD_LIBS)
 }
 
+headers_h = {
+       HEADERS = h
+       DIR = includedir
+       SOURCES = embeddedclient.mx
+}
+
+lib_monetdb5 = {
+       COND = HAVE_PYTHON_SWIG
+       PREFIX =
+       NAME = _monetdb5
+       SOURCES = monetdb5.py.i
+       LIBS = libembeddedsql5 ../../server/libsqlserver ../../storage/libstore 
../../storage/bat/libbatstore ../../common/libsqlcommon \
+               $(MONETDB5_MODS) -l_logger -l_bat5 -l_tablet $(MONETDB5_LIBS) 
-lmal \
+               $(CLIENTS_LIBS) $(MONETDB_LIBS) -lbat -lMapi -lmutils -lstream 
$(READLINE_LIBS) $(PTHREAD_LIBS)
+       DIR = $(prefix)/$(PYTHON_LIBDIR)
+}
+
+headers_py = {
+       COND = HAVE_PYTHON_SWIG
+       HEADERS = py
+       SOURCES = monetdb5.py.i
+       TARGETS = monetdb5.py
+       DIR = $(prefix)/$(PYTHON_LIBDIR)
+}
 
 headers_mal = {
        HEADERS = mal

Index: prog.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/prog.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- prog.c      7 Sep 2007 21:59:10 -0000       1.7
+++ prog.c      22 Oct 2007 10:43:09 -0000      1.8
@@ -20,6 +20,10 @@
 #include <monet_options.h>
 #include "embeddedclient.h"
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 /* stolen piece */
 #ifdef HAVE_FTIME
 #include <sys/timeb.h>
@@ -73,7 +77,7 @@
 int
 main(int argc, char **av)
 {
-       int curlen = 0, maxlen = BUFSIZ*8;
+       size_t curlen = 0, maxlen = BUFSIZ*8;
        char *prog = *av;
        opt *set = NULL;
        int setlen = 0, time = 0;
@@ -141,14 +145,14 @@
                                *tmp = '\0';
                                setlen = mo_add_option(&set, setlen, 
opt_cmdline, optarg, tmp + 1);
                        } else {
-                               fprintf(stderr, "!wrong format %s\n", optarg);
+                               fprintf(stderr, "!ERROR: wrong format %s\n", 
optarg);
                        }
                }
                        break;
                case '?':
                        usage(prog);
                default:
-                       fprintf(stderr, "!getopt returned character code 0%o 
??\n", c);
+                       fprintf(stderr, "!ERROR: getopt returned character code 
0%o ??\n", c);
                        usage(prog);
                }
        }
@@ -160,7 +164,7 @@
        /* now for each file given on the command line (or stdin) 
           read the query and execute it
         */
-       buf = GDKmalloc(maxlen);
+       buf = malloc(maxlen);
        if (buf == NULL) {
                fprintf(stderr, "Cannot allocate memory for query buffer\n");
                return -1;
@@ -170,13 +174,14 @@
        while (optind < argc || fp) {
                if (!fp && (fp=fopen(av[optind],"r")) == NULL){
                        fprintf(stderr,"could no open file %s\n", av[optind]);
+                       break;
                }
                while ((line = fgets(buf+curlen, 1024, fp)) != NULL) {
-                       int n = strlen(line);
+                       size_t n = strlen(line);
                        curlen += n;
                        if (curlen+1024 > maxlen) {
                                        maxlen += 8*BUFSIZ;
-                                       buf = GDKrealloc(buf, maxlen + 1);
+                                       buf = realloc(buf, maxlen + 1);
                                if (buf == NULL) {
                                        fprintf(stderr, "Cannot allocate memory 
for query buffer\n");
                                        return -1;
@@ -202,7 +207,7 @@
                if (time)
                        printf("Timer: %ld (usec)\n", gettime()-t0);
        }
-       GDKfree(buf);
+       free(buf);
        mapi_destroy(mid);
        return 0;
 }

--- NEW FILE: monetdb5.py.i ---
// The contents of this file are subject to the MonetDB Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is the MonetDB Database System.
//
// The Initial Developer of the Original Code is CWI.
// Portions created by CWI are Copyright (C) 1997-2007 CWI.
// All Rights Reserved.

%module monetdb5
%include "python/typemaps.i"
%include "exception.i"

%{
#ifdef HAVE_FSTAT
#undef HAVE_FSTAT
#endif
#include "mapilib/Mapi.h"

extern Mapi monetdb_sql(char *dbfarm, char *dbname);
%}

extern Mapi monetdb_sql(char *dbfarm, char *dbname);

%include "mapilib/Mapi.h"

Index: embeddedclient.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/embeddedclient.mx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- embeddedclient.mx   3 Oct 2007 14:05:48 -0000       1.12
+++ embeddedclient.mx   22 Oct 2007 10:43:08 -0000      1.13
@@ -54,6 +54,7 @@
 extern "C" {
 #endif
 
+embeddedclient_export Mapi monetdb_sql(char *dbfarm, char *dbname);
 embeddedclient_export Mapi embedded_sql(opt *set, int len);
 
 #ifdef __cplusplus
@@ -62,7 +63,7 @@
 
 #endif /* _EMBEDDEDCLIENT_H_ */
 @c
-#include "sql_config.h"
+#include <mal_config.h>
 #include "embeddedclient.h"
 
 #include "gdk.h"
@@ -228,3 +229,29 @@
 
        return mid;
 }
+
+Mapi
+monetdb_sql(char *dbfarm, char *dbname)
+{
+       Mapi mid;
+       pthread_t sqlthread;
+       stream **server;
+
+       int len = mo_builtin_settings(&embedded_set);
+
+       /* needed, to prevent the MonetDB config file to be used */  
+       len = mo_add_option(&embedded_set, len, opt_config, "prefix", 
MONETDBPREFIX);
+       len = mo_add_option(&embedded_set, len, opt_config, "config", 
MONETDBCONFIG);
+
+       embedded_len = mo_system_config(&embedded_set, len);
+       embedded_len = mo_add_option(&embedded_set, embedded_len, opt_cmdline, 
"gdk_dbfarm", dbfarm);
+       embedded_len = mo_add_option(&embedded_set, embedded_len, opt_cmdline, 
"gdk_dbname", dbname);
+
+       server = mapi_embedded_init(&mid,"sql");
+
+       pthread_create(&sqlthread, NULL, start_sql_server, (void *) server);
+
+       mapi_start_talking(mid);
+
+       return mid;
+}


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to