Skip to content

Commit

Permalink
Build Firebird backend using patch from Sergei Nikulov
Browse files Browse the repository at this point in the history
  • Loading branch information
vnaydionov committed Feb 10, 2013
1 parent c18cf35 commit 60c9473
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 33 deletions.
9 changes: 9 additions & 0 deletions src/backends/firebird/CMakeLists.txt
@@ -0,0 +1,9 @@
soci_backend(Firebird
DEPENDS Firebird
HEADERS soci-firebird.h common.h
DESCRIPTION "SOCI backend for Firebird database engine"
AUTHORS "TBD"
MAINTAINERS "TBD")

add_subdirectory(test)

5 changes: 5 additions & 0 deletions src/backends/firebird/test/CMakeLists.txt
@@ -0,0 +1,5 @@
soci_backend_test(
BACKEND Firebird
SOURCE test-firebird.cpp
CONNSTR "dummy")

59 changes: 27 additions & 32 deletions src/backends/firebird/test/test-firebird.cpp
Expand Up @@ -14,6 +14,7 @@
#include <string>
#include <cassert>
#include <ctime>
#include <cstring>

using namespace soci;

Expand Down Expand Up @@ -86,6 +87,7 @@ void test2()
sql << "delete from test2";
}

#if 0
{
char msg[] = "Hello, Firebird!";
char buf1[100], buf2[100], buf3[100];
Expand All @@ -96,18 +98,7 @@ void test2()
sql << "insert into test2(p1, p2) values (?,?)", use(b1, 100), use(b1, 100);
sql << "select p1, p2 from test2", into(b2, 100), into(b3, 100);

assert(
buf2[0] == 'H' && buf3[0] == 'H' &&
buf2[1] == 'e' && buf3[1] == 'e' &&
buf2[2] == 'l' && buf3[2] == 'l' &&
buf2[3] == 'l' && buf3[3] == 'l' &&
buf2[4] == 'o' && buf3[4] == 'o' &&
buf2[5] == ',' && buf3[5] == ',' &&
buf2[6] == ' ' && buf3[6] == ' ' &&
buf2[7] == 'F' && buf3[7] == 'F' &&
buf2[8] == 'i' && buf3[8] == 'i' &&
buf2[9] == 'r' && buf3[9] == 'r' &&
buf2[10] == '\0' && buf3[10] == '\0');
assert(!std::strcmp(buf2, buf3) && !std::strcmp(buf2, "Hello, Fir"));

sql << "delete from test2";
}
Expand All @@ -121,18 +112,19 @@ void test2()
use(buf1), use(buf1);
sql << "select p1, p2 from test2", into(buf2), into(buf3);

assert(
buf2[0] == 'H' && buf3[0] == 'H' &&
buf2[1] == 'e' && buf3[1] == 'e' &&
buf2[2] == 'l' && buf3[2] == 'l' &&
buf2[3] == 'l' && buf3[3] == 'l' &&
buf2[4] == 'o' && buf3[4] == 'o' &&
buf2[5] == ',' && buf3[5] == ',' &&
buf2[6] == ' ' && buf3[6] == ' ' &&
buf2[7] == 'F' && buf3[7] == 'F' &&
buf2[8] == 'i' && buf3[8] == 'i' &&
buf2[9] == 'r' && buf3[9] == 'r' &&
buf2[10] == '\0' && buf3[10] == '\0');
assert(!std::strcmp(buf2, buf3) && !std::strcmp(buf2, "Hello, Fir"));

sql << "delete from test2";
}
#endif

{
std::string b1("Hello, Firebird!"), b2, b3;

sql << "insert into test2(p1, p2) values (?,?)", use(b1), use(b1);
sql << "select p1, p2 from test2", into(b2), into(b3);

assert(b2 == b3 && b2 == "Hello, Fir");

sql << "delete from test2";
}
Expand All @@ -144,7 +136,9 @@ void test2()
sql << "insert into test2(p1) values(\'" << msg << "\')";

char buf[20];
sql << "select p1 from test2", into(buf);
std::string buf_str;
sql << "select p1 from test2", into(buf_str);
std::strcpy(buf, buf_str.c_str());

assert(std::strncmp(buf, msg, 5) == 0);
assert(std::strncmp(buf+5, " ", 5) == 0);
Expand Down Expand Up @@ -322,7 +316,8 @@ void test5()
assert(ind == i_null);

char buf[4];
sql << "select \'Hello\' from rdb$database", into(buf, ind);
std::string buf_str;
sql << "select \'Hello\' from rdb$database", into(buf_str, ind);
assert(ind == i_truncated);

sql << "select 5 from rdb$database where 0 = 1", into(i, ind);
Expand Down Expand Up @@ -1069,9 +1064,9 @@ void test11()
// Support for soci Common Tests
//

struct table_creator_1 : public tests::table_creator_base
struct TableCreator1 : public tests::table_creator_base
{
table_creator_1(session & sql)
TableCreator1(session & sql)
: tests::table_creator_base(sql)
{
sql << "create table soci_test(id integer, val integer, c char, "
Expand All @@ -1082,9 +1077,9 @@ struct table_creator_1 : public tests::table_creator_base
}
};

struct table_creator_2 : public tests::table_creator_base
struct TableCreator2 : public tests::table_creator_base
{
table_creator_2(session & sql)
TableCreator2(session & sql)
: tests::table_creator_base(sql)
{
sql << "create table soci_test(\"num_float\" float, \"num_int\" integer, "
Expand All @@ -1094,9 +1089,9 @@ struct table_creator_2 : public tests::table_creator_base
}
};

struct table_creator_3 : public tests::table_creator_base
struct TableCreator3 : public tests::table_creator_base
{
table_creator_3(session & sql)
TableCreator3(session & sql)
: tests::table_creator_base(sql)
{
// CommonTest uses lower-case column names,
Expand Down
3 changes: 2 additions & 1 deletion src/cmake/SociDependencies.cmake
Expand Up @@ -24,7 +24,8 @@ set(SOCI_BACKENDS_DB_DEPENDENCIES
ODBC
Oracle
PostgreSQL
SQLite3)
SQLite3
Firebird)

set(SOCI_BACKENDS_ALL_DEPENDENCIES
Boost
Expand Down
6 changes: 6 additions & 0 deletions src/cmake/dependencies/Firebird.cmake
@@ -0,0 +1,6 @@
set(Firebird_FIND_QUIETLY TRUE)

find_package(Firebird)

boost_external_report(Firebird INCLUDE_DIR LIBRARIES VERSION)

35 changes: 35 additions & 0 deletions src/cmake/modules/FindFirebird.cmake
@@ -0,0 +1,35 @@
##############################################################
# Copyright (c) 2008 Daniel Pfeifer #
# #
# Distributed under the Boost Software License, Version 1.0. #
##############################################################

# This module defines
# FIREBIRD_INCLUDE_DIR - where to find ibase.h
# FIREBIRD_LIBRARIES - the libraries to link against to use FIREBIRD
# FIREBIRD_FOUND - true if FIREBIRD was found

cmake_minimum_required(VERSION 2.6)

find_path(FIREBIRD_INCLUDE_DIR ibase.h
/usr/include
$ENV{ProgramFiles}/Firebird/*/include
)

find_library(FIREBIRD_LIBRARIES
NAMES
fbclient
fbclient_ms
PATHS
/usr/lib
$ENV{ProgramFiles}/Firebird/*/lib
)

# fbembed ?

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Firebird
DEFAULT_MSG FIREBIRD_LIBRARIES FIREBIRD_INCLUDE_DIR)

mark_as_advanced(FIREBIRD_INCLUDE_DIR FIREBIRD_LIBRARIES)

0 comments on commit 60c9473

Please sign in to comment.