Tidy up SQLite support into ripple_sqlite

This commit is contained in:
Vinnie Falco
2013-06-21 09:32:25 -07:00
parent bbaca7ebe9
commit cdc28c3fcf
11 changed files with 124 additions and 69 deletions

View File

@@ -83,10 +83,9 @@
#include <openssl/ripemd.h>
#include <openssl/sha.h>
// for SqliteDatabase.cpp
#include "src/cpp/database/sqlite3.h"
//------------------------------------------------------------------------------
#include "../modules/ripple_sqlite/ripple_sqlite.h" // for SqliteDatabase.cpp
// VFALCO TODO fix these warnings!
#ifdef _MSC_VER

View File

@@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
/** Add this to get the @ref ripple_sqlite module.
@file ripple_sqlite.cpp
@ingroup ripple_sqlite
*/
// This prevents sqlite.h from being included
//
#define RIPPLE_SQLITE_MODULE_INCLUDED 1
#include "ripple_sqlite.h"
#if BEAST_MSVC
#pragma warning (push)
#pragma warning (disable: 4100) /* unreferenced formal parameter */
#pragma warning (disable: 4127) /* conditional expression is constant */
#pragma warning (disable: 4232) /* nonstandard extension used: dllimport address */
#pragma warning (disable: 4244) /* conversion from 'int': possible loss of data */
#pragma warning (disable: 4701) /* potentially uninitialized variable */
#pragma warning (disable: 4706) /* assignment within conditional expression */
#endif
/* When compiled with SQLITE_THREADSAFE=1, SQLite operates in serialized mode.
In this mode, SQLite can be safely used by multiple threads with no restriction.
VFALCO NOTE This implies a global mutex!
NOTE Windows builds never had the threading model set. However, SQLite
defaults to Serialized (SQLITE_THREADSAFE == 1). Does Ripple need
Serialized mode? Because Ripple already uses a mutex with every
instance of the sqlite database session object.
*/
#define SQLITE_THREADSAFE 1
/* When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a
multithreaded program so long as no two threads attempt to use the
same database connection at the same time.
VFALCO NOTE This is the preferred threading model.
TODO Determine if Ripple can support this model.
*/
//#define SQLITE_THREADSAFE 2
// VFALCO TODO Move this into Beast
#define BEAST_PP_STR2_(x) #x
#define BEAST_PP_STR1_(x) BEAST_PP_STR2_(x)
#define BEAST_FILEANDLINE_ __FILE__ "("BEAST_PP_STR1_(__LINE__)"): warning:"
// VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens.
#if SQLITE_THREADSAFE != 2
#pragma message(BEAST_FILEANDLINE_"Possible performance issue, SQLITE_THREADSAFE != 2")
#endif
#include "sqlite/sqlite3.c"
#if BEAST_MSVC
#pragma warning (pop)
#endif

View File

@@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
/** Include this to get the @ref ripple_sqlite module.
@file ripple_sqlite.h
@ingroup ripple_sqlite
*/
/** Sqlite3 support.
This module brings in the Sqlite embedded database engine.
@defgroup ripple_sqlite
*/
#ifndef RIPPLE_SQLITE_RIPPLEHEADER
#define RIPPLE_SQLITE_RIPPLEHEADER
#include "beast/modules/beast_core/system/beast_TargetPlatform.h"
#if ! RIPPLE_SQLITE_MODULE_INCLUDED
#include "sqlite/sqlite3.h"
#endif
#endif