Chinaunix首页 | 论坛 | 博客
  • 博客访问: 24427
  • 博文数量: 15
  • 博客积分: 26
  • 博客等级: 民兵
  • 技术积分: 155
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-21 11:21
文章分类

全部博文(15)

文章存档

2015年(10)

2014年(5)

我的朋友

分类: 数据库开发技术

2015-04-12 20:21:29

/*******************************************************************
 *                                                                 *
 *  sqlinf.cpp                                                     *
 *                                                                 *
 *  This file is a part of the eXtremeDB source code               *
 *  Copyright (c) 2001-2010 McObject LLC                           *
 *  All Rights Reserved                                            *
 *                                                                 *
 *******************************************************************/
#include

#include "mcosql.h"
#include "sqlcln.h"
#include "sqlsrv.h"

const int SERVER_PORT = 5501;
#include "sqlintf.h"
//#include "ph2db.h"

#ifdef DISK_DATABASE
#ifndef _WIN32
#include
#endif
#endif

using namespace McoSql;
#ifdef __cplusplus
extern "C" {
#endif
/* redefine default stack size if needed */
#undef DEFAULT_STACK_SIZE
#define DEFAULT_STACK_SIZE 64*1024

/*#ifndef MCO_PLATFORM_X64
    size_t const PAGE_SIZE = 128; // define eXtremeDB page size
#else
    size_t const PAGE_SIZE = 256;
#endif*/

McoMultithreadedSqlEngine engine;
McoSql::SqlServer * server=NULL;
char db_sname[100];


int start_sql(const char * dbname,int iCmd)
{
    McoSqlOpenParameters params;
 sprintf(db_sname,"%s",dbname);
    params.databaseName = db_sname;
    printf("sql dbname = %s\n", params.databaseName);
 params.flags = McoSqlOpenParameters::SET_SQL_ALLOCATOR;

 engine.open(params);
 if (iCmd)
 {
  engine.main("SQL>",stdin, stdout, stderr);
 }

    printf("start sql engine successful!\n");
   
    return 0;
}

int start_sqlsvr(int isMst)
{
 int iPort = SERVER_PORT + (isMst?0:1000);
 
 server = new SqlServer(&engine, iPort);

 server->start();
 return 0;
}

int stop_sql()
{
    engine.close();
    return 0;
};

int stop_sqlsvr()
{
 if (server)
 {
  server->stop();  
  delete server;
 }
 return 0;
};
#ifdef __cplusplus
}
#endif

阅读(546) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~