Skip to content

Commit

Permalink
Move DB2 maxBuffer out of public soci-db2.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mloskot committed Feb 24, 2013
1 parent 159dfce commit b634576
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
21 changes: 21 additions & 0 deletions src/backends/db2/common.h
@@ -0,0 +1,21 @@
//
// Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
// Copyright (C) 2011-2013 Denis Chapligin
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef SOCI_DB2_COMMON_H_INCLUDED
#define SOCI_DB2_COMMON_H_INCLUDED

#include <cstddef>

namespace soci { namespace details { namespace db2 {

const std::size_t cli_max_buffer = 1024 * 1024 * 1024; //CLI limit is about 3 GB, but 1GB should be enough

}}} // namespace soci::details::db2

#endif // SOCI_DB2_COMMON_H_INCLUDED
2 changes: 1 addition & 1 deletion src/backends/db2/soci-db2.h
Expand Up @@ -31,14 +31,14 @@
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>

#include <sqlcli1.h>

namespace soci
{

static const std::size_t maxBuffer = 1024 * 1024 * 1024; //CLI limit is about 3 GB, but 1GB should be enough
class db2_soci_error : public soci_error {
public:
db2_soci_error(std::string const & msg, SQLRETURN rc) : soci_error(msg),errorCode(rc) {};
Expand Down
5 changes: 3 additions & 2 deletions src/backends/db2/standard-into-type.cpp
Expand Up @@ -8,6 +8,7 @@

#define SOCI_DB2_SOURCE
#include "soci-db2.h"
#include "common.h"
#include <ctime>

using namespace soci;
Expand Down Expand Up @@ -37,7 +38,7 @@ void db2_standard_into_type_backend::define_by_pos(
// Patch: set to min between column size and 100MB (used ot be 32769)
// Column size for text data type can be too large for buffer allocation
size = statement_.column_size(this->position);
size = size > maxBuffer ? maxBuffer : size;
size = size > details::db2::cli_max_buffer ? details::db2::cli_max_buffer : size;
size++;
buf = new char[size];
data = buf;
Expand Down Expand Up @@ -133,7 +134,7 @@ void db2_standard_into_type_backend::post_fetch(
{
std::string *s = static_cast<std::string *>(data);
*s = buf;
if (s->size() >= (maxBuffer - 1))
if (s->size() >= (details::db2::cli_max_buffer - 1))
{
throw soci_error("Buffer size overflow; maybe got too large string");
}
Expand Down
3 changes: 2 additions & 1 deletion src/backends/db2/standard-use-type.cpp
Expand Up @@ -186,8 +186,9 @@ void db2_standard_use_type_backend::pre_use(indicator const *ind)
}
}

void db2_standard_use_type_backend::post_use(bool gotData, indicator *ind)
void db2_standard_use_type_backend::post_use(bool /*gotData*/, indicator* /*ind*/)
{

}

void db2_standard_use_type_backend::clean_up()
Expand Down

0 comments on commit b634576

Please sign in to comment.