Skip to content

Commit

Permalink
Merge branch 'SOCI:master' into wstring_support
Browse files Browse the repository at this point in the history
  • Loading branch information
bold84 authored Apr 1, 2024
2 parents 5c4eb8f + 8a5ed87 commit 1aa9410
Show file tree
Hide file tree
Showing 13 changed files with 629 additions and 83 deletions.
30 changes: 11 additions & 19 deletions docs/backends/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ SOCI backend for accessing PostgreSQL database.

### Supported Versions

The SOCI PostgreSQL backend is supported for use with PostgreSQL >= 7.3, although versions older than 8.0 will suffer from limited feature support. See below for details.
The SOCI PostgreSQL backend is supported for use with PostgreSQL >= 9.0, although older versions may suffer from limited feature support. See below for details.

### Tested Platforms

|PostgreSQL|OS|Compiler|
|--- |--- |--- |
|9.6|Windows Server 2016|MSVC++ 14.1|
|9.4|Windows Server 2012 R2|MSVC++ 14.0|
|9.4|Windows Server 2012 R2|MSVC++ 12.0|
|9.4|Windows Server 2012 R2|MSVC++ 11.0|
|9.4|Windows Server 2012 R2|Mingw-w64/GCC 4.8|
|9.3|Ubuntu 12.04|g++ 4.6.3|
|9.0|Mac OS X 10.6.6|g++ 4.2|
|8.4|FreeBSD 8.2|g++ 4.1|
|8.4|Debian 6|g++ 4.3|
|8.4|RedHat 5|g++ 4.3|
|10.03|macOS High Sierra 10.13.5|AppleClang 9.1.0.9020039|
| 14|macOS 11.7|AppleClang 13|
| 14|Ubuntu 22.04|gcc 11.4|
| 13|Windows Server 2019|MSVS 2022|
| 12|Windows Server 2019|MSVS 2019|
| 11|Windows Server 2016|MSVS 2017|
| 10|Windows Server 2012 R2|MSVS 2015|
|9.4|Windows Server 2012 R2|Mingw-w64/GCC 8.1|

### Required Client Libraries

Expand Down Expand Up @@ -129,7 +125,9 @@ The PostgreSQL backend has full support for SOCI's [bulk operations](../binding.

### blob Data Type

The PostgreSQL backend supports working with data stored in columns of type Blob, via SOCI's [blob](../lobs.md) class with the exception that trimming is not supported.
The PostgreSQL backend supports working with data stored in columns of type Blob, via SOCI's [blob](../lobs.md) class.

Note that 64-bit offsets require PostgreSQL client library 9.3 or later.

### rowid Data Type

Expand Down Expand Up @@ -162,9 +160,3 @@ The PostgreSQL backend provides the following concrete classes for native API ac

The PostgreSQL backend supports working with data stored in columns of type UUID via simple string operations. All string representations of UUID supported by PostgreSQL are accepted on input, the backend will return the standard
format of UUID on output. See the test `test_uuid_column_type_support` for usage examples.

## Configuration options

To support older PostgreSQL versions, the following configuration macros are recognized:

* `SOCI_POSTGRESQL_NOSINLGEROWMODE` - disable single mode retrieving query results row-by-row. It is necessary for PostgreSQL prior to version 9.
26 changes: 12 additions & 14 deletions include/soci/oracle/soci-oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,8 @@ struct oracle_blob_backend : details::blob_backend

std::size_t get_len() override;

[[deprecated("Use read_from_start instead")]]
std::size_t read(std::size_t offset, void *buf, std::size_t toRead) override
{
// Offsets are 1-based in Oracle
return read_from_start(buf, toRead, offset - 1);
}

std::size_t read_from_start(void * buf, std::size_t toRead, std::size_t offset = 0) override;

[[deprecated("Use write_from_start instead")]]
std::size_t write(std::size_t offset, const void *buf, std::size_t toWrite) override
{
// Offsets are 1-based in Oracle
return write_from_start(buf, toWrite, offset - 1);
}

std::size_t write_from_start(const void * buf, std::size_t toWrite, std::size_t offset = 0) override;

std::size_t append(const void *buf, std::size_t toWrite) override;
Expand All @@ -300,6 +286,18 @@ struct oracle_blob_backend : details::blob_backend
void ensure_initialized();

private:
std::size_t do_deprecated_read(std::size_t offset, void *buf, std::size_t toRead) override
{
// Offsets are 1-based in Oracle
return read_from_start(buf, toRead, offset - 1);
}

std::size_t do_deprecated_write(std::size_t offset, const void *buf, std::size_t toWrite) override
{
// Offsets are 1-based in Oracle
return write_from_start(buf, toWrite, offset - 1);
}

oracle_session_backend &session_;

locator_t lobp_;
Expand Down
8 changes: 5 additions & 3 deletions include/soci/row.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SOCI_DECL row
template <typename T>
inline void add_holder(T* t, indicator* ind)
{
holders_.push_back(new details::type_holder<T>(t));
holders_.push_back(details::holder::make_holder(t));
indicators_.push_back(ind);
}

Expand All @@ -78,7 +78,8 @@ class SOCI_DECL row
typedef typename type_conversion<T>::base_type base_type;
static_assert(details::can_use_from_base<type_conversion<T>>(),
"Can't use row::get() with this type (not convertible/copy-assignable from base_type) - did you mean to use move_as?");
base_type const& baseVal = holders_.at(pos)->get<base_type>();
base_type const& baseVal =
holders_.at(pos)->get<base_type>(details::value_cast_tag{});

T ret;
type_conversion<T>::from_base(baseVal, *indicators_.at(pos), ret);
Expand All @@ -91,7 +92,8 @@ class SOCI_DECL row
typedef typename type_conversion<T>::base_type base_type;
static_assert(details::can_use_move_from_base<T, base_type>(),
"row::move_as() can only be called with types that can be instantiated from a base type rvalue reference");
base_type & baseVal = holders_.at(pos)->get<base_type>();
base_type & baseVal =
holders_.at(pos)->get<base_type>(details::value_reference_tag{});

T ret;
type_conversion<T>::move_from_base(baseVal, *indicators_.at(pos), ret);
Expand Down
17 changes: 11 additions & 6 deletions include/soci/soci-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,26 @@ class blob_backend

virtual std::size_t get_len() = 0;

[[deprecated("Use read_from_start instead")]]
virtual std::size_t read(std::size_t offset, void* buf, std::size_t toRead) { return read_from_start(buf, toRead, offset); }

virtual std::size_t read_from_start(void* buf, std::size_t toRead, std::size_t offset) = 0;

[[deprecated("Use write_from_start instead")]]
virtual std::size_t write(std::size_t offset, const void* buf, std::size_t toWrite) { return write_from_start(buf, toWrite, offset); }

virtual std::size_t write_from_start(const void* buf, std::size_t toWrite, std::size_t offset) = 0;

virtual std::size_t append(const void* buf, std::size_t toWrite) = 0;

virtual void trim(std::size_t newLen) = 0;

// Deprecated functions with backend-specific semantics preserved only for
// compatibility.
[[deprecated("Use read_from_start instead")]]
std::size_t read(std::size_t offset, void* buf, std::size_t toRead) { return do_deprecated_read(offset, buf, toRead); }

[[deprecated("Use write_from_start instead")]]
virtual std::size_t write(std::size_t offset, const void* buf, std::size_t toWrite) { return do_deprecated_write(offset, buf, toWrite); }

private:
virtual std::size_t do_deprecated_read(std::size_t offset, void* buf, std::size_t toRead) { return read_from_start(buf, toRead, offset); }
virtual std::size_t do_deprecated_write(std::size_t offset, const void* buf, std::size_t toWrite) { return write_from_start(buf, toWrite, offset); }

SOCI_NOT_COPYABLE(blob_backend)
};

Expand Down
Loading

0 comments on commit 1aa9410

Please sign in to comment.