Skip to content

Commit

Permalink
Fix typo in SOCI_POSTGRESQL_NOSINLGEROWMODE option/macro name
Browse files Browse the repository at this point in the history
How this has slipped through a few pair of reviewing eyes ;-)
Corrects changes added in #571 and #594
  • Loading branch information
mloskot committed Feb 22, 2018
1 parent 36030d0 commit 6bfa674
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions docs/backends/postgresql.md
Expand Up @@ -67,7 +67,7 @@ Note that in the single-row operation:

Also please note that single rows mode requires PostgreSQL 9 or later, both at
compile- and run-time. If you need to support earlier versions of PostgreSQL,
you can define `SOCI_POSTGRESQL_NOSINLGEROWMODE` when building the library to
you can define `SOCI_POSTGRESQL_NOSINGLEROWMODE` when building the library to
disable it.

Once you have created a `session` object as shown above, you can use it to access the database, for example:
Expand Down Expand Up @@ -168,4 +168,4 @@ To support older PostgreSQL versions, the following configuration macros are rec
* `SOCI_POSTGRESQL_NOBINDBYNAME` - switches off the query rewriting.
* `SOCI_POSTGRESQL_NOPARAMS` - disables support for parameterized queries (binding of use elements), automatically imposes also the `SOCI_POSTGRESQL_NOBINDBYNAME` macro. It is necessary for PostgreSQL 7.3.
* `SOCI_POSTGRESQL_NOPREPARE` - disables support for separate query preparation, which in this backend is significant only in terms of optimization. It is necessary for PostgreSQL 7.3 and 7.4.
* `SOCI_POSTGRESQL_NOSINLGEROWMODE` - disable single mode retrieving query results row-by-row. It is necessary for PostgreSQL prior to version 9.
* `SOCI_POSTGRESQL_NOSINGLEROWMODE` - disable single mode retrieving query results row-by-row. It is necessary for PostgreSQL prior to version 9.
10 changes: 5 additions & 5 deletions src/backends/postgresql/CMakeLists.txt
Expand Up @@ -11,7 +11,7 @@

include(CMakeDependentOption)

option(SOCI_POSTGRESQL_NOSINLGEROWMODE
option(SOCI_POSTGRESQL_NOSINGLEROWMODE
"Do not use single row mode. PostgreSQL <9 portability."
OFF)

Expand Down Expand Up @@ -40,11 +40,11 @@ if(SOCI_POSTGRESQL_NOPREPARE)
endif()

if (POSTGRESQL_VERSION VERSION_LESS "9.0.0")
set(SOCI_POSTGRESQL_NOSINLGEROWMODE ON CACHE BOOL "Use single row mode for PostgreSQL 9+" FORCE)
set(SOCI_POSTGRESQL_NOSINGLEROWMODE ON CACHE BOOL "Use single row mode for PostgreSQL 9+" FORCE)
endif()

if(SOCI_POSTGRESQL_NOSINLGEROWMODE)
add_definitions(-DSOCI_POSTGRESQL_NOSINLGEROWMODE=1)
if(SOCI_POSTGRESQL_NOSINGLEROWMODE)
add_definitions(-DSOCI_POSTGRESQL_NOSINGLEROWMODE=1)
endif()

soci_backend(PostgreSQL
Expand All @@ -56,4 +56,4 @@ soci_backend(PostgreSQL
boost_report_value(SOCI_POSTGRESQL_NOPARAMS)
boost_report_value(SOCI_POSTGRESQL_NOBINDBYNAME)
boost_report_value(SOCI_POSTGRESQL_NOPREPARE)
boost_report_value(SOCI_POSTGRESQL_NOSINLGEROWMODE)
boost_report_value(SOCI_POSTGRESQL_NOSINGLEROWMODE)
94 changes: 47 additions & 47 deletions src/backends/postgresql/statement.cpp
Expand Up @@ -66,12 +66,12 @@ postgresql_statement_backend::postgresql_statement_backend(
hasIntoElements_(false), hasVectorIntoElements_(false),
hasUseElements_(false), hasVectorUseElements_(false)
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode)
{
throw soci_error("Single row mode not supported in this version of the library");
}
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
}

postgresql_statement_backend::~postgresql_statement_backend()
Expand Down Expand Up @@ -225,7 +225,7 @@ void postgresql_statement_backend::prepare(std::string const & query,
// if it fails to prepare it we can't DEALLOCATE it.
std::string statementName = session_.get_next_statement_name();

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
// prepare for single-row retrieval
Expand All @@ -241,10 +241,10 @@ void postgresql_statement_backend::prepare(std::string const & query,
wait_until_operation_complete(session_);
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row query execution

postgresql_result result(session_,
PQprepare(session_.conn_, statementName.c_str(),
query_.c_str(), static_cast<int>(names_.size()), NULL));
Expand All @@ -263,12 +263,12 @@ void postgresql_statement_backend::prepare(std::string const & query,
statement_backend::exec_fetch_result
postgresql_statement_backend::execute(int number)
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_ && (number > 1))
{
throw soci_error("Bulk operations are not supported with single-row mode.");
}
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE

// If the statement was "just described", then we know that
// it was actually executed with all the use elements
Expand Down Expand Up @@ -367,7 +367,7 @@ postgresql_statement_backend::execute(int number)

#ifdef SOCI_POSTGRESQL_NOPREPARE

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQueryParams(
Expand All @@ -388,7 +388,7 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution
result_.reset(PQexecParams(session_.conn_, query_.c_str(),
Expand All @@ -400,7 +400,7 @@ postgresql_statement_backend::execute(int number)
{
// this query was separately prepared

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQueryPrepared(session_.conn_,
Expand All @@ -412,7 +412,7 @@ postgresql_statement_backend::execute(int number)
throw_soci_error(session_.conn_,
"Cannot execute prepared query in single-row mode");
}

result = PQsetSingleRowMode(session_.conn_);
if (result != 1)
{
Expand All @@ -421,10 +421,10 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

result_.reset(PQexecPrepared(session_.conn_,
statementName_.c_str(),
static_cast<int>(paramValues.size()),
Expand All @@ -436,7 +436,7 @@ postgresql_statement_backend::execute(int number)
// this query was not separately prepared and should
// be executed as a one-time query

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQueryParams(session_.conn_, query_.c_str(),
Expand All @@ -447,7 +447,7 @@ postgresql_statement_backend::execute(int number)
throw_soci_error(session_.conn_,
"cannot execute query in single-row mode");
}

result = PQsetSingleRowMode(session_.conn_);
if (result != 1)
{
Expand All @@ -456,10 +456,10 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

result_.reset(PQexecParams(session_.conn_, query_.c_str(),
static_cast<int>(paramValues.size()),
NULL, &paramValues[0], NULL, NULL, 0));
Expand Down Expand Up @@ -500,7 +500,7 @@ postgresql_statement_backend::execute(int number)

#ifdef SOCI_POSTGRESQL_NOPREPARE

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQuery(session_.conn_, query_.c_str());
Expand All @@ -518,18 +518,18 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

result_.reset(PQexec(session_.conn_, query_.c_str()));
}
#else
if (stType_ == st_repeatable_query)
{
// this query was separately prepared

#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQueryPrepared(session_.conn_,
Expand All @@ -539,7 +539,7 @@ postgresql_statement_backend::execute(int number)
throw_soci_error(session_.conn_,
"Cannot execute prepared query in single-row mode");
}

result = PQsetSingleRowMode(session_.conn_);
if (result != 1)
{
Expand All @@ -548,17 +548,17 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

result_.reset(PQexecPrepared(session_.conn_,
statementName_.c_str(), 0, NULL, NULL, NULL, 0));
}
}
else // stType_ == st_one_time_query
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
int result = PQsendQuery(session_.conn_, query_.c_str());
Expand All @@ -576,10 +576,10 @@ postgresql_statement_backend::execute(int number)
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

result_.reset(PQexec(session_.conn_, query_.c_str()));
}
}
Expand All @@ -589,7 +589,7 @@ postgresql_statement_backend::execute(int number)
}

bool process_result;
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
if (justDescribed_)
Expand All @@ -606,15 +606,15 @@ postgresql_statement_backend::execute(int number)
process_result = result_.check_for_data("Cannot execute query.");
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

process_result = result_.check_for_data("Cannot execute query.");
}

justDescribed_ = false;

if (process_result)
{
currentRow_ = 0;
Expand Down Expand Up @@ -648,12 +648,12 @@ postgresql_statement_backend::execute(int number)
statement_backend::exec_fetch_result
postgresql_statement_backend::fetch(int number)
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_ && (number > 1))
{
throw soci_error("Bulk operations are not supported with single-row mode.");
}
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE

// Note:
// In the multi-row mode this function does not actually fetch anything from anywhere
Expand All @@ -668,17 +668,17 @@ postgresql_statement_backend::fetch(int number)

if (currentRow_ >= numberOfRows_)
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
PGresult* res = PQgetResult(session_.conn_);
result_.reset(res);

if (res == NULL)
{
return ef_no_data;
}

currentRow_ = 0;
rowsToConsume_ = 0;

Expand All @@ -690,36 +690,36 @@ postgresql_statement_backend::fetch(int number)
else
{
rowsToConsume_ = 1;

return ef_success;
}
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

// all rows were already consumed

return ef_no_data;
}
}
else
{
if (currentRow_ + number > numberOfRows_)
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
rowsToConsume_ = 1;

return ef_success;
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
// default multi-row execution

rowsToConsume_ = numberOfRows_ - currentRow_;

// this simulates the behaviour of Oracle
Expand All @@ -730,17 +730,17 @@ postgresql_statement_backend::fetch(int number)
}
else
{
#ifndef SOCI_POSTGRESQL_NOSINLGEROWMODE
#ifndef SOCI_POSTGRESQL_NOSINGLEROWMODE
if (single_row_mode_)
{
rowsToConsume_ = 1;
}
else
#endif // !SOCI_POSTGRESQL_NOSINLGEROWMODE
#endif // !SOCI_POSTGRESQL_NOSINGLEROWMODE
{
rowsToConsume_ = number;
}

return ef_success;
}
}
Expand Down

0 comments on commit 6bfa674

Please sign in to comment.