Update of /cvsroot/monetdb/sql/src/backends/monet4
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27745

Modified Files:
        Makefile.ag 
Added Files:
        embeddedclient.c.in embeddedclient.h 
Removed Files:
        embeddedclient.mx.in 
Log Message:
.mx.in files do not play nicely with tar ball distribution, so avoid using them.

U Makefile.ag
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet4/Makefile.ag,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- Makefile.ag 10 Oct 2008 08:53:15 -0000      1.48
+++ Makefile.ag 13 Oct 2008 13:27:28 -0000      1.49
@@ -83,7 +83,7 @@
 }
 
 lib_embeddedsql = {
-       SOURCES = embeddedclient.mx.in
+       SOURCES = embeddedclient.c.in
        LIBS = libinitmodules STATIC_MODS @SHARED_LIBS@ lib_sql_server 
$(EXTRA_LIBS) \
                $(MONETDB_LIBS) -lbat -lmutils -lstream $(MONETDB4_LIBS) 
-lmonet $(CLIENTS_LIBS) -lMapi
 }
@@ -106,7 +106,7 @@
 headers_h = {
        HEADERS = h
        DIR = includedir/MonetDB4/sql
-       SOURCES = embeddedclient.mx.in
+       SOURCES = embeddedclient.h
 }
 
 EXTRA_DIST_DIR = Tests

--- NEW FILE: embeddedclient.c.in ---
/*
  The purpose of this Embedded MonetDB is to illustrate how the code
  base can be easily linked with a stand-alone application.  The
  current implementation uses a minimalistic approach, i.e.  using the
  Mapi prototol to communicate between application thread and the
  database kernel.
  This communication is not optimized for speed. 

  An area that has undergone some tweaking for performance improvement
  are the large number of lock calls needed in the GDK kernel to
  safely run multiple clients against the database.
  For direct linkage to an application we suggest to use the
  monet_embedded option, which allows just one mapi connection to be
  set up. This allows for removal of all lock calls in the
  kernel. This improves performance between 25-50%.
*/

#include <sql_config.h>
#include "embeddedclient.h"

#include "gdk.h"
#ifdef HAVE_PTHREAD_H
/* pthread.h on Windows includes config.h if HAVE_CONFIG_H is set */
#undef HAVE_CONFIG_H
#ifdef pid_t
#undef pid_t
#endif
#include <sched.h>
#include <pthread.h>
#endif

#include "monet.h"
#include "monet_options.h"
#include "initmodules.h"

static Client
Monet_init(opt **set, int setlen)
{
        /* determine Monet's kernel settings. */
        setlen = mo_add_option(set, setlen, opt_config, "gdk_embedded", "yes");
        if (!GDKinit(*set, setlen)) 
                return NULL;

        if (GDKgetenv_isyes("monet_daemon"))
                monet_daemon = 1;
        return monet_init();
}

static opt *embedded_set = NULL;
static int embedded_len = 0;

static void *
start_sql_server(void *arg)
{
        static int initialized = 0;
        stream *in, *out;
        char buf[128];

        if (!initialized) {
/*              monet_singlethreaded = 1; */
                if (embedded_set == NULL) {
                        int len = mo_builtin_settings(&embedded_set);
                        embedded_len = mo_system_config(&embedded_set, len);
                        embedded_len = mo_add_option(&embedded_set, 
embedded_len, opt_config, "monet_mod_path",
                                                     "@QXlibdir@@[EMAIL 
PROTECTED]@PATHSEP@@QXlibdir@@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@PATHSEP@@QXlibdir@@[EMAIL PROTECTED]@[EMAIL PROTECTED]");
                }
                Monet_init(&embedded_set, embedded_len);
                mo_free_options(embedded_set, embedded_len);
                static_module_init();
                THRnew(MT_getpid(), "Interpreter");
                initialized = 1;
        }

        in = ((stream **) arg)[0];
        out = ((stream **) arg)[1];
        free(arg);
        snprintf(buf, sizeof(buf), "client(Stream(\"" PTRFMT "\"), Stream(\"" 
PTRFMT "\"));", PTRFMTCAST in, PTRFMTCAST out);
        monet_exec("module(sql_server);");
        monet_exec(buf);
        return NULL;
}

Mapi
embedded_sql(opt *set, int len)
{
        Mapi mid;
        pthread_t sqlthread;
        stream **server;

        if (set) {
                embedded_set = set;
                embedded_len = len;
        }
        server = mapi_embedded_init(&mid,"sql");

        pthread_create(&sqlthread, NULL, start_sql_server, (void *) server);

        mapi_start_talking(mid);

        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", 
MONETDB4_PREFIX);
        len = mo_add_option(&embedded_set, len, opt_config, "config", 
MONETDB4_CONFFILE);
        len = mo_add_option(&embedded_set, embedded_len, opt_config, 
"monet_mod_path",
                            "@QXlibdir@@[EMAIL 
PROTECTED]@PATHSEP@@QXlibdir@@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@PATHSEP@@QXlibdir@@[EMAIL PROTECTED]@[EMAIL PROTECTED]");

        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;
}

--- embeddedclient.mx.in DELETED ---

--- NEW FILE: embeddedclient.h ---
#ifndef _EMBEDDEDCLIENT_H_
#define _EMBEDDEDCLIENT_H_

/* avoid using "#ifdef WIN32" so that this file does not need our config.h */
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__)
#ifndef LIBEMBEDDEDSQL
#define embeddedclient_export extern __declspec(dllimport)
#else
#define embeddedclient_export extern __declspec(dllexport)
#endif
#else
#define embeddedclient_export extern
#endif

#include <stdio.h>
#include <stream.h>
#include <mapilib/Mapi.h>
#include <monet_options.h>

#ifdef __cplusplus
extern "C" {
#endif

embeddedclient_export Mapi monetdb_sql(char *dbfarm, char *dbname);
embeddedclient_export Mapi embedded_sql(opt *set, int len);

#ifdef __cplusplus
}
#endif

#endif /* _EMBEDDEDCLIENT_H_ */


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to