Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete support for C++ integer types #954

Merged
merged 38 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7644240
Update core code for complete integer type support
zann1x Apr 5, 2022
53f6aba
Update MySQL backend for complete integer type support
zann1x Apr 5, 2022
f27f144
Update SQLite3 backend for complete integer type support
zann1x Apr 5, 2022
dd45b6d
Update PostgreSQL backend for complete integer type support
zann1x Apr 5, 2022
8fc34db
Update Oracle backend for complete integer type support
zann1x Apr 5, 2022
9d0d7c4
Update DB2 backend for complete integer type support
zann1x Apr 5, 2022
e0d0038
Update Firebird backend for complete integer type support
zann1x Apr 5, 2022
6aa6aa7
Update ODBC backend for complete integer type support
zann1x Apr 5, 2022
ca28449
Update soci-simple for complete integer type support
zann1x Apr 5, 2022
9e39f97
Update shared unit tests for complete integer type support
zann1x Apr 5, 2022
8544cab
Update unit tests of MySQL backend for complete integer type support
zann1x Apr 5, 2022
44a4365
Update unit tests of SQLite3 backend for complete integer type support
zann1x Apr 7, 2022
236966f
Update unit tests of PostgreSQL backend for complete integer type
zann1x Apr 5, 2022
0a8f450
Update unit tests of Oracle backend for complete integer type support
zann1x Apr 5, 2022
455a580
Update unit tests of DB2 backend for complete integer type support
zann1x May 8, 2022
b56224e
Update unit test of Firebird backend for complete integer type support
zann1x Apr 5, 2022
43ab82f
Update unit tests of ODBC backend for complete integer type support
zann1x May 8, 2022
71d9b87
Add *_int and *_long_long methods back to the soci-simple API
zann1x Jun 18, 2022
d4414a3
Update docs for complete integer type support
zann1x Jun 18, 2022
8dba000
Correct ODBC error message for unsigned types
zann1x Oct 5, 2022
3d16170
Replace stdint.h with cstdint
zann1x Sep 28, 2022
ff90687
Add back removed dt_* and x_* types
zann1x Oct 5, 2022
367c0c0
Revert unnecessary changes in unit tests
zann1x Oct 5, 2022
4e80322
Fix header include order
zann1x Nov 29, 2022
d95c716
Remove abbreviation in user-facing ODBC error message
zann1x Nov 29, 2022
a824ac8
Fix incorrect extraction of Postgres bool type
zann1x Nov 29, 2022
ede341c
Remove unnecessary type casts
zann1x Dec 31, 2022
60da2f0
Merge separate integer unit tests into one
zann1x Dec 31, 2022
4c36213
Remove unsigned type support checks in unit tests
zann1x Dec 31, 2022
88e2cb4
Fix uint64 vector unit tests
zann1x Jan 3, 2023
ea4ce9d
Simplify platform-specific data type defines
zann1x Dec 30, 2022
e8e4fc9
Fix MSSQL ODBC unit tests
zann1x Jan 4, 2023
4de379f
Fix Postgres unit test
zann1x Jan 8, 2023
1c3e069
Fix MySQL ODBC unit tests
zann1x Jan 15, 2023
ff7e29c
Handle potential overflow in mysql into-conversion
zann1x Aug 13, 2023
826fa77
Expose new db_type for dynamic type mapping
zann1x Aug 11, 2023
037a332
Add db_type description to docs
zann1x Oct 18, 2023
06b68c2
Forward create_column_type() to db_type overload
zann1x Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions docs/api/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@ All names are defined in either `soci` or `soci::details` namespace.
// data types, as seen by the user
enum data_type
{
dt_string, dt_date, dt_double, dt_integer, dt_long_long, dt_unsigned_long_long
dt_string,
dt_int8,
dt_uint8,
dt_int16,
dt_uint16,
dt_int32,
dt_integer = dt_int32,
dt_uint32,
dt_int64,
dt_long_long = dt_int64,
dt_uint64,
dt_unsigned_long_long = dt_uint64,
dt_double,
dt_date,
dt_blob,
dt_xml
};

// the enum type for indicator variables
Expand All @@ -32,15 +47,26 @@ enum exchange_type
{
x_char,
x_stdstring,
x_short,
x_integer,
x_long_long,
x_unsigned_long_long,
x_int8,
x_uint8,
x_int16,
x_short = x_int16,
x_uint16,
x_int32,
x_integer = x_int32,
x_uint32,
x_int64,
x_long_long = x_int64,
x_uint64,
x_unsigned_long_long = x_uint64,
x_double,
x_stdtm,
x_statement,
x_rowid,
x_blob
x_blob,

x_xmltype,
x_longstring
};

struct cstring_descriptor
Expand Down
74 changes: 73 additions & 1 deletion docs/api/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The following types are commonly used in the rest of the interface:

```cpp
// data types, as seen by the user
enum data_type { dt_string, dt_date, dt_double, dt_integer, dt_long_long, dt_unsigned_long_long };
enum data_type { dt_string, dt_date, dt_double, dt_int8, dt_uint8, dt_int16, dt_uint16, dt_int32, dt_uint32, dt_int64, dt_uint64 };

// the enum type for indicator variables
enum indicator { i_ok, i_null, i_truncated };
Expand Down Expand Up @@ -642,13 +642,29 @@ The functions above create and destroy the statement object. If the statement ca
int soci_into_string (statement_handle st);
int soci_into_int (statement_handle st);
int soci_into_long_long(statement_handle st);
int soci_into_int8 (statement_handle st);
int soci_into_uint8 (statement_handle st);
int soci_into_int16 (statement_handle st);
int soci_into_uint16 (statement_handle st);
int soci_into_int32 (statement_handle st);
int soci_into_uint32 (statement_handle st);
int soci_into_int64 (statement_handle st);
int soci_into_uint64 (statement_handle st);
int soci_into_double (statement_handle st);
int soci_into_date (statement_handle st);
int soci_into_blob (statement_handle st);

int soci_into_string_v (statement_handle st);
int soci_into_int_v (statement_handle st);
int soci_into_long_long_v(statement_handle st);
int soci_into_int8_v (statement_handle st);
int soci_into_uint8_v (statement_handle st);
int soci_into_int16_v (statement_handle st);
int soci_into_uint16_v (statement_handle st);
int soci_into_int32_v (statement_handle st);
int soci_into_uint32_v (statement_handle st);
int soci_into_int64_v (statement_handle st);
int soci_into_uint64_v (statement_handle st);
int soci_into_double_v (statement_handle st);
int soci_into_date_v (statement_handle st);
```
Expand All @@ -669,13 +685,29 @@ This function returns `1` if the into element at the given position has non-null
char const * soci_get_into_string (statement_handle st, int position);
int soci_get_into_int (statement_handle st, int position);
long long soci_get_into_long_long(statement_handle st, int position);
int8_t soci_get_into_int8 (statement_handle st, int position);
uint8_t soci_get_into_uint8 (statement_handle st, int position);
int16_t soci_get_into_int16 (statement_handle st, int position);
uint16_t soci_get_into_uint16 (statement_handle st, int position);
int32_t soci_get_into_int32 (statement_handle st, int position);
uint32_t soci_get_into_uint32 (statement_handle st, int position);
int64_t soci_get_into_int64 (statement_handle st, int position);
uint64_t soci_get_into_uint64 (statement_handle st, int position);
double soci_get_into_double (statement_handle st, int position);
char const * soci_get_into_date (statement_handle st, int position);
blob_handle soci_get_into_blob (statement_handle st, int position);

char const * soci_get_into_string_v (statement_handle st, int position, int index);
int soci_get_into_int_v (statement_handle st, int position, int index);
long long soci_get_into_long_long_v(statement_handle st, int position, int index);
int8_t soci_get_into_int8_v (statement_handle st, int position, int index);
uint8_t soci_get_into_uint8_v (statement_handle st, int position, int index);
int16_t soci_get_into_int16_v (statement_handle st, int position, int index);
uint16_t soci_get_into_uint16_v (statement_handle st, int position, int index);
int32_t soci_get_into_int32_v (statement_handle st, int position, int index);
uint32_t soci_get_into_uint32_v (statement_handle st, int position, int index);
int64_t soci_get_into_int64_v (statement_handle st, int position, int index);
uint64_t soci_get_into_uint64_v (statement_handle st, int position, int index);
double soci_get_into_double_v (statement_handle st, int position, int index);
char const * soci_get_into_date_v (statement_handle st, int position, int index);
```
Expand All @@ -688,13 +720,29 @@ The functions above allow to retrieve the current value of the given into elemen
void soci_use_string (statement_handle st, char const * name);
void soci_use_int (statement_handle st, char const * name);
void soci_use_long_long(statement_handle st, char const * name);
void soci_use_int8 (statement_handle st, char const * name);
void soci_use_uint8 (statement_handle st, char const * name);
void soci_use_int16 (statement_handle st, char const * name);
void soci_use_uint16 (statement_handle st, char const * name);
void soci_use_int32 (statement_handle st, char const * name);
void soci_use_uint32 (statement_handle st, char const * name);
void soci_use_int64 (statement_handle st, char const * name);
void soci_use_uint64 (statement_handle st, char const * name);
void soci_use_double (statement_handle st, char const * name);
void soci_use_date (statement_handle st, char const * name);
void soci_use_blob (statement_handle st, char const * name);

void soci_use_string_v (statement_handle st, char const * name);
void soci_use_int_v (statement_handle st, char const * name);
void soci_use_long_long_v(statement_handle st, char const * name);
void soci_use_int8_v (statement_handle st, char const * name);
void soci_use_uint8_v (statement_handle st, char const * name);
void soci_use_int16_v (statement_handle st, char const * name);
void soci_use_uint16_v (statement_handle st, char const * name);
void soci_use_int32_v (statement_handle st, char const * name);
void soci_use_uint32_v (statement_handle st, char const * name);
void soci_use_int64_v (statement_handle st, char const * name);
void soci_use_uint64_v (statement_handle st, char const * name);
void soci_use_double_v (statement_handle st, char const * name);
void soci_use_date_v (statement_handle st, char const * name);
```
Expand All @@ -718,6 +766,14 @@ These functions get and set the size of vector use elements (see comments for ve
void soci_set_use_string (statement_handle st, char const * name, char const * val);
void soci_set_use_int (statement_handle st, char const * name, int val);
void soci_set_use_long_long(statement_handle st, char const * name, long long val);
void soci_set_use_int8 (statement_handle st, char const * name, int8_t val);
void soci_set_use_uint8 (statement_handle st, char const * name, uint8_t val);
void soci_set_use_int16 (statement_handle st, char const * name, int16_t val);
void soci_set_use_uint16 (statement_handle st, char const * name, uint16_t val);
void soci_set_use_int32 (statement_handle st, char const * name, int32_t val);
void soci_set_use_uint32 (statement_handle st, char const * name, uint32_t val);
void soci_set_use_int64 (statement_handle st, char const * name, int64_t val);
void soci_set_use_uint64 (statement_handle st, char const * name, uint64_t val);
void soci_set_use_double (statement_handle st, char const * name, double val);
void soci_set_use_date (statement_handle st, char const * name, char const * val);
void soci_set_use_blob (statement_handle st, char const * name, blob_handle blob);
Expand All @@ -726,6 +782,14 @@ void soci_set_use_state_v (statement_handle st, char const * name, int index,
void soci_set_use_string_v (statement_handle st, char const * name, int index, char const * val);
void soci_set_use_int_v (statement_handle st, char const * name, int index, int val);
void soci_set_use_long_long_v(statement_handle st, char const * name, int index, long long val);
void soci_set_use_int8_v (statement_handle st, char const * name, int index, int8_t val);
void soci_set_use_uint8_v (statement_handle st, char const * name, int index, uint8_t val);
void soci_set_use_int16_v (statement_handle st, char const * name, int index, int16_t val);
void soci_set_use_uint16_v (statement_handle st, char const * name, int index, uint16_t val);
void soci_set_use_int32_v (statement_handle st, char const * name, int index, int32_t val);
void soci_set_use_uint32_v (statement_handle st, char const * name, int index, uint32_t val);
void soci_set_use_int64_v (statement_handle st, char const * name, int index, int64_t val);
void soci_set_use_uint64_v (statement_handle st, char const * name, int index, uint64_t val);
void soci_set_use_double_v (statement_handle st, char const * name, int index, double val);
void soci_set_use_date_v (statement_handle st, char const * name, int index, char const * val);
```
Expand All @@ -739,6 +803,14 @@ int soci_get_use_state (statement_handle st, char const * name);
char const * soci_get_use_string (statement_handle st, char const * name);
int soci_get_use_int (statement_handle st, char const * name);
long long soci_get_use_long_long(statement_handle st, char const * name);
int8_t soci_get_use_int8 (statement_handle st, char const * name);
uint8_t soci_get_use_uint8 (statement_handle st, char const * name);
int16_t soci_get_use_int16 (statement_handle st, char const * name);
uint16_t soci_get_use_uint16 (statement_handle st, char const * name);
int32_t soci_get_use_int32 (statement_handle st, char const * name);
uint32_t soci_get_use_uint32 (statement_handle st, char const * name);
int64_t soci_get_use_int64 (statement_handle st, char const * name);
uint64_t soci_get_use_uint64 (statement_handle st, char const * name);
double soci_get_use_double (statement_handle st, char const * name);
char const * soci_get_use_date (statement_handle st, char const * name);
blob_handle soci_get_use_blob (statement_handle st, char const * name);
Expand Down
18 changes: 10 additions & 8 deletions docs/backends/firebird.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ type is not known at compile time.
When calling `row::get<T>()`, the type you should pass as T depends upon the underlying database type.
For the Firebird backend, this type mapping is:

|Firebird Data Type|SOCI Data Type|`row::get<T>` specializations|
|--- |--- |--- |
|numeric, decimal (where scale > 0)|dt_double|double|
|numeric, decimal [^1] (where scale = 0)|dt_integer, dt_double|int, double|
|double precision, float|dt_double|double|
|smallint, integer|dt_integer|int|
|char, varchar|dt_string|std::string|
|date, time, timestamp|dt_date|std::tm|
| Firebird Data Type | SOCI Data Type | `row::get<T>` specializations |
| --------------------------------------- | --------------------------------------- | --------------------------------- |
| numeric, decimal (where scale > 0) | dt_double | double |
| numeric, decimal [^1] (where scale = 0) | dt_int16/dt_int32/dt_int64, dt_double | dt_int16/int32_t/dt_int64, double |
| double precision, float | dt_double | double |
| smallint | dt_int16 | int16_t |
| integer | dt_int32 | int32_t |
| bigint | dt_int64 | int64_t |
| char, varchar | dt_string | std::string |
| date, time, timestamp | dt_date | std::tm |

[^1] There is also 64bit integer type for larger values which is
currently not supported.
Expand Down
24 changes: 15 additions & 9 deletions docs/backends/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ The MySQL backend supports the use of the SOCI `row` class, which facilitates re
When calling `row::get<T>()`, the type you should pass as `T` depends upon the underlying database type.
For the MySQL backend, this type mapping is:

|MySQL Data Type|SOCI Data Type|`row::get<T>` specializations|
|--- |--- |--- |
|FLOAT, DOUBLE, DECIMAL and synonyms|dt_double|double|
|TINYINT, TINYINT UNSIGNED, SMALLINT, SMALLINT UNSIGNED, INT|dt_integer|int|
|INT UNSIGNED|dt_long_long|long long or unsigned|
|BIGINT|dt_long_long|long long|
|BIGINT UNSIGNED|dt_unsigned_long_long|unsigned long long|
|CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB, BLOB,LONGBLOB, TINYTEXT, MEDIUMTEXT, TEXT, LONGTEXT, ENUM|dt_string|std::string|
|TIMESTAMP (works only with MySQL >= 5.0), DATE, TIME, DATETIME|dt_date|std::tm|
| MySQL Data Type | SOCI Data Type | `row::get<T>` specializations |
| ----------------------------------------------------------------------------------------------------------------- | --------------------- | ----------------------------- |
| FLOAT, DOUBLE, DECIMAL and synonyms | dt_double | double |
| TINYINT | dt_int8 | int8_t |
| TINYINT UNSIGNED | dt_uint8 | uint8_t |
| SMALLINT | dt_int16 | int16_t |
| SMALLINT UNSIGNED | dt_uint16 | uint16_t |
| MEDIUMINT | dt_int32 | int32_t |
| MEDIUMINT UNSIGNED | dt_uint32 | uint32_t |
| INT | dt_int32 | int32_t |
| INT UNSIGNED | dt_uint32 | uint32_t |
| BIGINT | dt_int64 | int64_t |
| BIGINT UNSIGNED | dt_uint64 | uint64_t |
| CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB, BLOB,LONGBLOB, TINYTEXT, MEDIUMTEXT, TEXT, LONGTEXT, ENUM | dt_string | std::string |
| TIMESTAMP (works only with MySQL >= 5.0), DATE, TIME, DATETIME | dt_date | std::tm |

(See the [dynamic resultset binding](../types.md#dynamic-binding) documentation for general information
on using the `Row` class.)
Expand Down
16 changes: 10 additions & 6 deletions docs/backends/odbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ The ODBC backend supports the use of the SOCI `row` class, which facilitates ret
When calling `row::get<T>()`, the type you should pass as T depends upon the underlying database type.
For the ODBC backend, this type mapping is:

|ODBC Data Type|SOCI Data Type|`row::get<T>` specializations|
|--- |--- |--- |
|SQL_DOUBLE, SQL_DECIMAL, SQL_REAL, SQL_FLOAT, SQL_NUMERIC|dt_double|double|
|SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT|dt_integer|int|
|SQL_CHAR, SQL_VARCHAR|dt_string|std::string|
|SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP|dt_date|std::tm|
| ODBC Data Type | SOCI Data Type | `row::get<T>` specializations |
| --------------------------------------------------------- | -------------- | ----------------------------- |
| SQL_DOUBLE, SQL_DECIMAL, SQL_REAL, SQL_FLOAT, SQL_NUMERIC | dt_double | double |
| SQL_TINYINT | dt_int8 | int8_t |
| SQL_SMALLINT | dt_int16 | int16_t |
| SQL_INTEGER | dt_int32 | int32_t |
| SQL_BIGINT | dt_int64 | int64_t |
| SQL_CHAR, SQL_VARCHAR | dt_string | std::string |
| SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMP | dt_date | std::tm |

Not all ODBC drivers support all datatypes.
Columns having the attribute `unsigned` get mapped to their corresponding `dt_uint[n]` and `uint[n]_t` types.

(See the [dynamic resultset binding](../types.md#dynamic-binding) documentation for general information on using the `row` class.)

Expand Down
14 changes: 7 additions & 7 deletions docs/backends/oracle.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ The Oracle backend supports the use of the SOCI `row` class, which facilitates r

When calling `row::get<T>()`, the type you should pass as `T` depends upon the underlying database type. For the Oracle backend, this type mapping is:

|Oracle Data Type|SOCI Data Type|`row::get<T>` specializations|
|--- |--- |--- |
|number (where scale > 0)|dt_double|double|
|number(where scale = 0 and precision ≤ `std::numeric_limits<int>::digits10`)|dt_integer|int|
|number|dt_long_long|long long|
|char, varchar, varchar2|dt_string|std::string|
|date|dt_date|std::tm|
| Oracle Data Type | SOCI Data Type | `row::get<T>` specializations |
| --------------------------------------------------------------------------------- | -------------- | ----------------------------- |
| number (where scale > 0) | dt_double | double |
| number (where scale = 0 and precision ≤ `std::numeric_limits<int32_t>::digits10`) | dt_int32 | int32_t |
| number (where scale = 0) | dt_int64 | int64_t |
| char, varchar, varchar2 | dt_string | std::string |
| date | dt_date | std::tm |

(See the [dynamic resultset binding](../types.md#dynamic-binding) documentation for general information on using the `row` class.)

Expand Down
Loading