aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-15 18:43:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-15 18:43:03 +0200
commit2ed52d1bc30a08ef791e2677fe559b4bdd249a68 (patch)
tree4081b7a1b19ea235d7465fef1bcb795cd055afaf
parent146cd9dc8796944391b919e7add8da9463eea20a (diff)
Implement SQLite incremental BLOB/TEXT I/O
-rw-r--r--odb/statement-processing.cxx29
-rw-r--r--odb/statement.hxx33
2 files changed, 36 insertions, 26 deletions
diff --git a/odb/statement-processing.cxx b/odb/statement-processing.cxx
index e6ad96b..f9936b0 100644
--- a/odb/statement-processing.cxx
+++ b/odb/statement-processing.cxx
@@ -26,12 +26,13 @@ namespace odb
}
void statement::
- process_insert (const char* s,
+ process_insert (string& r,
+ const char* s,
bind_type bind,
size_t bind_size,
size_t bind_skip,
char param_symbol,
- string& r)
+ char param_symbol2)
{
#ifndef LIBODB_DEBUG_STATEMENT_PROCESSING
assert (bind_size != 0); // Cannot be versioned.
@@ -109,7 +110,8 @@ namespace odb
// INSERT ... VALUES(1,?). We also cannot be empty if this value
// is present in the bind array.
//
- if (find (p, ve, param_symbol) == 0 ||
+ if ((find (p, ve, param_symbol) == 0 &&
+ (param_symbol2 == '\0' || find (p, ve, param_symbol2) == 0)) ||
bind_at (bi++, bind, bind_skip) != 0)
empty = false;
}
@@ -190,7 +192,8 @@ namespace odb
// See if the value contains the parameter symbol and, if so,
// whether it is present in the bind array.
//
- if (find (v, ve, param_symbol) != 0 &&
+ if ((find (v, ve, param_symbol) != 0 ||
+ (param_symbol2 != '\0' && find (v, ve, param_symbol2) != 0)) &&
bind_at (bi++, bind, bind_skip) == 0)
continue;
@@ -228,7 +231,8 @@ namespace odb
// See if the value contains the parameter symbol and, if so,
// whether it is present in the bind array.
//
- if (find (v, ve, param_symbol) != 0 &&
+ if ((find (v, ve, param_symbol) != 0 ||
+ (param_symbol2 != '\0' && find (v, ve, param_symbol2) != 0)) &&
bind_at (bi++, bind, bind_skip) == 0)
continue;
@@ -262,12 +266,13 @@ namespace odb
}
void statement::
- process_update (const char* s,
+ process_update (string& r,
+ const char* s,
bind_type bind,
size_t bind_size,
size_t bind_skip,
char param_symbol,
- string& r)
+ char param_symbol2)
{
bool fast (true); // Fast case (if all present).
for (size_t i (0); i != bind_size && fast; ++i)
@@ -318,7 +323,8 @@ namespace odb
// e.g., UPDATE ... SET ver=ver+1 ... We also cannot be empty if
// this expression is present in the bind array.
//
- if (find (p, pe, param_symbol) == 0 ||
+ if ((find (p, pe, param_symbol) == 0 &&
+ (param_symbol2 == '\0' || find (p, pe, param_symbol2) == 0)) ||
bind_at (bi++, bind, bind_skip) != 0)
empty = false;
}
@@ -370,7 +376,8 @@ namespace odb
// See if the value contains the parameter symbol and, if so,
// whether it is present in the bind array.
//
- if (find (p, pe, param_symbol) != 0 &&
+ if ((find (p, pe, param_symbol) != 0 ||
+ (param_symbol2 != '\0' && find (p, pe, param_symbol2) != 0)) &&
bind_at (bi++, bind, bind_skip) == 0)
continue;
@@ -400,7 +407,8 @@ namespace odb
}
void statement::
- process_select (const char* s,
+ process_select (string& r,
+ const char* s,
bind_type bind,
size_t bind_size,
size_t bind_skip,
@@ -411,7 +419,6 @@ namespace odb
#else
bool,
#endif
- string& r,
bool as)
{
bool empty (true); // Empty case (if none present).
diff --git a/odb/statement.hxx b/odb/statement.hxx
index 6ad458c..31f9cc9 100644
--- a/odb/statement.hxx
+++ b/odb/statement.hxx
@@ -55,12 +55,13 @@ namespace odb
// [; SELECT ...]
//
static void
- process_insert (const char* statement,
- const void* const* bind, // Array of bind buffer pointers.
- std::size_t bind_size, // Number of bind elements.
- std::size_t bind_skip, // Offset to the next bind.
- char param_symbol, // $, ?, :, etc.
- std::string& result);
+ process_insert (std::string& result,
+ const char* statement,
+ const void* const* bind, // Array of bind buffer pointers.
+ std::size_t bind_size, // Number of bind elements.
+ std::size_t bind_skip, // Offset to the next bind.
+ char param_symbol, // $, ?, :, etc.
+ char param_symbol2 = '\0');
// Expected statement structure:
//
@@ -72,31 +73,33 @@ namespace odb
// [WHERE ...]
//
static void
- process_update (const char* statement,
- const void* const* bind, // Array of bind buffer pointers.
- std::size_t bind_size, // Number of bind elements.
- std::size_t bind_skip, // Offset to the next bind.
- char param_symbol, // $, ?, :, etc.
- std::string& result);
+ process_update (std::string& result,
+ const char* statement,
+ const void* const* bind, // Array of bind buffer pointers.
+ std::size_t bind_size, // Number of bind elements.
+ std::size_t bind_skip, // Offset to the next bind.
+ char param_symbol, // $, ?, :, etc.
+ char param_symbol2 = '\0');
+
// Expected statement structure:
//
// SELECT\n
- // [schema.]table.a,\n
+ // [schema.]table.a [AS b],\n
// alias.b\n
// FROM [schema.]table[\n]
// [{A-Z }* JOIN [schema.]table [AS alias][ ON ...][\n]]*
// [WHERE ...]
//
static void
- process_select (const char* statement,
+ process_select (std::string& result,
+ const char* statement,
const void* const* bind, // Array of bind buffer pointers.
std::size_t bind_size, // Number of bind elements.
std::size_t bind_skip, // Offset to the next bind.
char quote_open, // Identifier opening quote.
char quote_close, // Identifier closing quote.
bool optimize, // Remove unused JOINs.
- std::string& result,
bool as = true); // JOINs use AS keyword.
};
}