aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/oracle-types.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-10 16:23:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-10 16:28:29 +0200
commit0fb66e3e85ccb096cb625bf4664fdbbf3b8a29f9 (patch)
tree6ee6a9fce07ecc686afefd7aa8f83b5e57fd2a30 /odb/oracle/oracle-types.cxx
parentf5f1489bed3bddd424981bbe84898832fb0e7414 (diff)
Add descriptor management flags for TIMESTAMP and INTERVAL image types
For a query expression that has only by-value parameters, we guarantee that it can be used by multiple threads. However, the way we handle TIMESTAMP and INTERVAL types now requires the modification of the image during query execution. To resolve this, the datetime, interval_ym, and interval_ds image types now have flags that allow the query implementation to avoid the modification.
Diffstat (limited to 'odb/oracle/oracle-types.cxx')
-rw-r--r--odb/oracle/oracle-types.cxx197
1 files changed, 145 insertions, 52 deletions
diff --git a/odb/oracle/oracle-types.cxx b/odb/oracle/oracle-types.cxx
index fad085f..9de57cd 100644
--- a/odb/oracle/oracle-types.cxx
+++ b/odb/oracle/oracle-types.cxx
@@ -14,10 +14,64 @@ namespace odb
{
namespace oracle
{
+ //
+ // datetime
+ //
+
+ datetime::
+ ~datetime ()
+ {
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_TIMESTAMP);
+ }
+
+ datetime::
+ datetime (datetime& x)
+ : environment (x.environment),
+ error (x.error),
+ descriptor (x.descriptor),
+ flags (x.flags),
+ year_ (x.year_),
+ month_ (x.month_),
+ day_ (x.day_),
+ hour_ (x.hour_),
+ minute_ (x.minute_),
+ second_ (x.second_),
+ nanosecond_ (x.nanosecond_)
+ {
+ x.descriptor = 0;
+ }
+
+ datetime& datetime::
+ operator= (datetime& x)
+ {
+ if (this != &x)
+ {
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_TIMESTAMP);
+
+ environment = x.environment;
+ error = x.error;
+ descriptor = x.descriptor;
+ flags = x.flags;
+ year_ = x.year_;
+ month_ = x.month_;
+ day_ = x.day_;
+ hour_ = x.hour_;
+ minute_ = x.minute_;
+ second_ = x.second_;
+ nanosecond_ = x.nanosecond_;
+
+ x.descriptor = 0;
+ }
+
+ return *this;
+ }
+
void datetime::
get (sb2& y, ub1& m, ub1& d, ub1& h, ub1& minute, ub1& s, ub4& ns) const
{
- assert (descriptor.get () != 0);
+ assert (descriptor != 0);
sword r (OCIDateTimeGetDate (environment,
error,
@@ -44,7 +98,7 @@ namespace odb
void datetime::
set (sb2 y, ub1 m, ub1 d, ub1 h, ub1 minute, ub1 s, ub4 ns)
{
- if (descriptor.get () != 0)
+ if (descriptor != 0)
{
sword r (OCIDateTimeConstruct (environment,
error,
@@ -74,32 +128,54 @@ namespace odb
}
}
- void datetime::
- set ()
+ //
+ // interval_ym
+ //
+
+ interval_ym::
+ ~interval_ym ()
{
- assert (descriptor.get () != 0);
-
- sword r (OCIDateTimeConstruct (environment,
- error,
- descriptor,
- year_,
- month_,
- day_,
- hour_,
- minute_,
- second_,
- nanosecond_,
- 0,
- 0));
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_INTERVAL_YM);
+ }
- if (r != OCI_SUCCESS)
- translate_error (error, r);
+ interval_ym::
+ interval_ym (interval_ym& x)
+ : environment (x.environment),
+ error (x.error),
+ descriptor (x.descriptor),
+ flags (x.flags),
+ year_ (x.year_),
+ month_ (x.month_)
+ {
+ x.descriptor = 0;
+ }
+
+ interval_ym& interval_ym::
+ operator= (interval_ym& x)
+ {
+ if (this != &x)
+ {
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_INTERVAL_YM);
+
+ environment = x.environment;
+ error = x.error;
+ descriptor = x.descriptor;
+ flags = x.flags;
+ year_ = x.year_;
+ month_ = x.month_;
+
+ x.descriptor = 0;
+ }
+
+ return *this;
}
void interval_ym::
get (sb4& y, sb4& m) const
{
- assert (descriptor.get () != 0);
+ assert (descriptor != 0);
sword r (OCIIntervalGetYearMonth (environment,
error,
@@ -114,7 +190,7 @@ namespace odb
void interval_ym::
set (sb4 y, sb4 m)
{
- if (descriptor.get () != 0)
+ if (descriptor != 0)
{
sword r (OCIIntervalSetYearMonth (environment,
error,
@@ -132,25 +208,60 @@ namespace odb
}
}
- void interval_ym::
- set ()
+ //
+ // interval_ds
+ //
+
+ interval_ds::
+ ~interval_ds ()
{
- assert (descriptor.get () != 0);
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_INTERVAL_DS);
+ }
- sword r (OCIIntervalSetYearMonth (environment,
- error,
- year_,
- month_,
- descriptor));
+ interval_ds::
+ interval_ds (interval_ds& x)
+ : environment (x.environment),
+ error (x.error),
+ descriptor (x.descriptor),
+ flags (x.flags),
+ day_ (x.day_),
+ hour_ (x.hour_),
+ minute_ (x.minute_),
+ second_ (x.second_),
+ nanosecond_ (x.nanosecond_)
+ {
+ x.descriptor = 0;
+ }
- if (r != OCI_SUCCESS)
- translate_error (error, r);
+ interval_ds& interval_ds::
+ operator= (interval_ds& x)
+ {
+ if (this != &x)
+ {
+ if (descriptor != 0 && (flags & descriptor_free))
+ OCIDescriptorFree (descriptor, OCI_DTYPE_INTERVAL_DS);
+
+ environment = x.environment;
+ error = x.error;
+ descriptor = x.descriptor;
+ flags = x.flags;
+ day_ = x.day_;
+ hour_ = x.hour_;
+ minute_ = x.minute_;
+ second_ = x.second_;
+ nanosecond_ = x.nanosecond_;
+
+ x.descriptor = 0;
+ }
+
+ return *this;
}
void interval_ds::
get (sb4& d, sb4& h, sb4& m, sb4& s, sb4& ns) const
{
- assert (descriptor.get () != 0);
+ assert (descriptor != 0);
sword r (OCIIntervalGetDaySecond (environment,
error,
@@ -168,7 +279,7 @@ namespace odb
void interval_ds::
set (sb4 d, sb4 h, sb4 m, sb4 s, sb4 ns)
{
- if (descriptor.get () != 0)
+ if (descriptor != 0)
{
sword r (OCIIntervalSetDaySecond (environment,
error,
@@ -191,23 +302,5 @@ namespace odb
nanosecond_ = ns;
}
}
-
- void interval_ds::
- set ()
- {
- assert (descriptor.get () != 0);
-
- sword r (OCIIntervalSetDaySecond (environment,
- error,
- day_,
- hour_,
- minute_,
- second_,
- nanosecond_,
- descriptor));
-
- if (r != OCI_SUCCESS)
- translate_error (error, r);
- }
}
}