aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-06-24 13:20:25 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-06-24 13:20:25 +0200
commit019a58726d50f8f7ca1f16e474a90dfa71064bc9 (patch)
tree908555479891f65471df42c55307151a01fa1232
parent26db3d36d9787bb14419b66a4219fd9e1818556a (diff)
Correct native_bind lengths array initialization
-rw-r--r--odb/pgsql/statement.cxx56
1 files changed, 55 insertions, 1 deletions
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx
index b73f2dc..c5b4b95 100644
--- a/odb/pgsql/statement.cxx
+++ b/odb/pgsql/statement.cxx
@@ -85,7 +85,61 @@ namespace odb
else
{
n.formats[i] = 1;
- n.lengths[i] = static_cast<int> (*current_bind.size);
+
+ size_t l;
+
+ switch (current_bind.type)
+ {
+ case bind::boolean:
+ {
+ l = sizeof (bool);
+ break;
+ }
+ case bind::smallint:
+ {
+ l = sizeof (short);
+ break;
+ }
+ case bind::integer:
+ {
+ l = sizeof (int);
+ break;
+ }
+ case bind::bigint:
+ {
+ l = sizeof (long long);
+ break;
+ }
+ case bind::real:
+ {
+ l = sizeof (float);
+ break;
+ }
+ case bind::double_:
+ {
+ l = sizeof (double);
+ break;
+ }
+ case bind::uuid:
+ {
+ // UUID is a 16-byte sequence.
+ //
+ l = 16;
+ break;
+ }
+ case bind::text:
+ case bind::bytea:
+ case bind::bit:
+ case bind::varbit:
+ {
+ l = *current_bind.size;
+ break;
+ }
+ case bind::numeric:
+ assert (false);
+ }
+
+ n.lengths[i] = static_cast<int> (l);
}
}
}