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 all 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
43 changes: 37 additions & 6 deletions docs/api/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ enum data_type
dt_string, dt_date, dt_double, dt_integer, dt_long_long, dt_unsigned_long_long
};

// data types, as seen by the user
enum db_type
{
db_string,
db_int8,
db_uint8,
db_int16,
db_uint16,
db_int32,
db_uint32,
db_int64,
db_uint64,
db_double,
db_date,
db_blob,
db_xml
};

// the enum type for indicator variables
enum indicator { i_ok, i_null, i_truncated };

Expand All @@ -32,15 +50,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 All @@ -60,8 +89,9 @@ public:
};
```

The `data_type` enumeration type defines all types that form the core type support for SOCI.
The `data_type` and `db_type` enumeration type defines all types that form the core type support for SOCI.
The enum itself can be used by clients when dealing with dynamic rowset description.
`data_type` is deprecated in favor of `db_type`, so users are encouraged to use the latter.

The `indicator` enumeration type defines all recognized *states* of data.
The `i_truncated` state is provided for the case where the string is retrieved from the database
Expand Down Expand Up @@ -191,6 +221,7 @@ public:

virtual int prepare_for_describe() = 0;
virtual void describe_column(int colNum, data_type& dtype,
db_type& dbtype,
std::string& column_name) = 0;

virtual standard_into_type_backend* make_into_type_backend() = 0;
Expand Down
84 changes: 81 additions & 3 deletions docs/api/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ The following types are commonly used in the rest of the interface:
// 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 };

// data types, as seen by the user
enum db_type { db_string, db_date, db_double, db_int8, db_uint8, db_int16, db_uint16, db_int32, db_uint32, db_int64, db_uint64 };

// the enum type for indicator variables
enum indicator { i_ok, i_null, i_truncated };

// the type used for reporting exceptions
class soci_error : public std::runtime_error { /* ... */ };
```

The `data_type` type defines the basic SOCI data types. User provided data types need to be associated with one of these basic types.
The `data_type` and `db_type` types define the basic SOCI data types. User provided data types need to be associated with one of these basic types.
`data_type` is deprecated in favor of `db_type`, so users are encouraged to use the latter.

The `indicator` type defines the possible states of data.

Expand Down Expand Up @@ -443,14 +447,16 @@ class column_properties
{
public:
std::string get_name() const;
data_type get_data_type() const;
data_type_type get_data_type() const;
db_type get_db_type() const;
};
```

This class contains the following members:

* `get_name` function that returns the name of the column.
* `get_data_type` that returns the type of the column.
* `get_data_type` that returns the type of the column (deprecate in favor of `get_db_type`).
* `get_db_type` that returns the type of the column.

See [Dynamic resultset binding](../types.md#dynamic-binding) for examples.

Expand Down Expand Up @@ -642,13 +648,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 +691,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 +726,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 +772,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 +788,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 +809,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
27 changes: 19 additions & 8 deletions docs/backends/firebird.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,25 @@ 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 (`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 (`db_type`) | `row::get<T>` specializations |
| --------------------------------------- | --------------------------------------- | --------------------------------- |
| numeric, decimal (where scale > 0) | db_double | double |
| numeric, decimal [^1] (where scale = 0) | db_int16/db_int32/db_int64, db_double | int16_t/int32_t/int64_t, double |
| double precision, float | db_double | double |
| smallint | db_int16 | int16_t |
| integer | db_int32 | int32_t |
| bigint | db_int64 | int64_t |
| char, varchar | db_string | std::string |
| date, time, timestamp | db_date | std::tm |

[^1] There is also 64bit integer type for larger values which is
currently not supported.
Expand Down
Loading