odbc_sys/
attributes.rs

1use crate::Pointer;
2
3/// Governs behaviour of EnvironmentAttribute
4#[repr(i32)]
5#[derive(Debug, PartialEq, Eq, Clone, Copy)]
6pub enum EnvironmentAttribute {
7    OdbcVersion = 200,
8    ConnectionPooling = 201,
9    CpMatch = 202,
10    // This attribute was commented out because there is no mention of it in the ODBC specification
11    // nor does this attribute exist in unixODBC or iODBC implementations. This attribute exists in
12    // Microsoft implementation only and it's usage is unclear.
13    // For private driver manager
14    // SQL_ATTR_APPLICATION_KEY = 203,
15    OutputNts = 10001,
16}
17
18/// ODBC verions
19///
20/// Possible values for `OdbcVersion` attribute set with `SQLSetEnvAttr` to declare ODBC version
21#[repr(i32)]
22#[derive(Debug, PartialEq, Eq, Clone, Copy)]
23pub enum AttrOdbcVersion {
24    // Not supported by this crate
25    // SQL_OV_ODBC2 = 2,
26    Odbc3 = 3,
27    #[cfg(feature = "odbc_version_3_80")]
28    Odbc3_80 = 380,
29    #[cfg(feature = "odbc_version_4")]
30    Odbc4 = 400,
31}
32
33impl From<AttrOdbcVersion> for Pointer {
34    fn from(source: AttrOdbcVersion) -> Pointer {
35        source as i32 as Pointer
36    }
37}
38/// Connection pool configuration
39///
40/// Possible values for `ConnectionPooling` attribute set with `SQLSetEnvAttr` to define which
41/// pooling scheme will be used.
42///
43/// See: <https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetenvattr-function>
44#[repr(u32)]
45#[derive(Debug, PartialEq, Eq, Clone, Copy)]
46pub enum AttrConnectionPooling {
47    /// Connection pooling is turned off. This is the default.
48    Off = 0,
49    /// A single connection pool is supported for each driver. Every connection in a pool is
50    /// associated with one driver.
51    OnePerDriver = 1,
52    /// A single connection pool is supported for each environment. Every connection in a pool is
53    /// associated with one environment.
54    OnePerHenv = 2,
55    /// Use the connection-pool awareness feature of the driver, if it is available. If the driver
56    /// does not support connection-pool awareness, `DriverAware` is ignored and `OnePerHenv` is
57    /// used.
58    DriverAware = 3,
59}
60
61/// Connection pool default configuration
62impl Default for AttrConnectionPooling {
63    fn default() -> Self {
64        AttrConnectionPooling::Off
65    }
66}
67
68impl From<AttrConnectionPooling> for Pointer {
69    fn from(source: AttrConnectionPooling) -> Pointer {
70        source as u32 as Pointer
71    }
72}
73
74/// Determines how a connection is chosen from a connection pool.
75///
76/// Possible values for `CpMatch` attribute set with [`crate::SQLSetEnvAttr`] to define which connection
77/// attributes must match for a connection returned from the pool
78#[repr(u32)]
79#[derive(Debug, PartialEq, Eq, Clone, Copy)]
80pub enum AttrCpMatch {
81    /// Only connections that exactly match the connection options in the call and the connection
82    /// attributes set by the application are reused. This is the default.
83    Strict = 0,
84    /// Connections with matching connection string keywords can be used. Keywords must match, but
85    /// not all connection attributes must match.
86    Relaxed = 1,
87}
88
89/// Default matching for connections returned from the pool
90impl Default for AttrCpMatch {
91    fn default() -> Self {
92        AttrCpMatch::Strict
93    }
94}
95
96impl From<AttrCpMatch> for Pointer {
97    fn from(source: AttrCpMatch) -> Pointer {
98        source as u32 as Pointer
99    }
100}
101
102/// Statement attributes are characteristics of the statement. For example, whether to use bookmarks
103/// and what kind of cursor to use with the statement's result set are statement attributes.
104///
105/// Statement attributes are set with `SQLSetStmtAttr` and their current settings retrieved with
106/// `SQLGetStmtAttr`. There is no requirement that an application set any statement attributes; all
107/// statement attributes have defaults, some of which are driver-specific.
108/// When a statement attribute can be set depends on the attribute itself. The
109/// `Concurrency`, `CursorType, `SimulateCursor`, and `UseBookmars` statement attributes must be set
110/// before the statement is executed. The `AsyncEnable` and `NoScan` statement attributes can be set
111/// at any time but are not applied until the statement is used again. `MaxLength`, `MaxRows`, and
112/// `QueryTimeout` statement attributes can be set at any time, but it is driver-specific whether
113/// they are applied before the statement is used again. The remaining statement attributes can be
114/// set at any time.
115#[repr(i32)]
116#[derive(Debug, PartialEq, Eq, Clone, Copy)]
117pub enum StatementAttribute {
118    /// SQL_ATTR_APP_ROW_DESC
119    AppRowDesc = 10010,
120    /// SQL_ATTR_APP_PARAM_DESC
121    AppParamDesc = 10011,
122    /// SQL_ATTR_IMP_ROW_DESC
123    ImpRowDesc = 10012,
124    /// SQL_ATTR_IMP_PARAM_DESC
125    ImpParamDesc = 10013,
126    /// SQL_ATTR_CURSOR_SCROLLABLE
127    CursorScrollable = -1,
128    /// SQL_ATTR_CURSOR_SENSITIVITY
129    CursorSensitivity = -2,
130
131    // Extensions
132    /// SQL_ATTR_ASYNC_ENABLE
133    AsyncEnable = 4,
134    /// SQL_ATTR_CONCURRENCY
135    Concurrency = 7,
136    /// SQL_ATTR_CURSOR_TYPE
137    CursorType = 6,
138    /// SQL_ATTR_ENABLE_AUTO_IPD
139    EnableAutoIpd = 15,
140    /// SQL_ATTR_FETCH_BOOKMARK_PTR
141    FetchBookmarkPtr = 16,
142    /// SQL_ATTR_KEYSET_SIZE
143    KeysetSize = 8,
144    /// SQL_ATTR_MAX_LENGTH
145    MaxLength = 3,
146    /// SQL_ATTR_MAX_ROWS
147    MaxRows = 1,
148    /// SQL_ATTR_NOSCAN
149    NoScan = 2,
150    /// SQL_ATTR_PARAM_BIND_OFFSET_PTR
151    ParamBindOffsetPtr = 17,
152    /// SQL_ATTR_PARAM_BIND_TYPE
153    ParamBindType = 18,
154    /// SQL_ATTR_PARAM_OPERATION_PTR
155    ParamOpterationPtr = 19,
156    /// SQL_ATTR_PARAM_STATUS_PTR
157    ParamStatusPtr = 20,
158    /// SQL_ATTR_PARAMS_PROCESSED_PTR
159    ParamsProcessedPtr = 21,
160    // SQL_ATTR_PARAMSET_SIZE
161    ParamsetSize = 22,
162    /// SQL_ATTR_QUERY_TIMEOUT
163    QueryTimeout = 0,
164    /// SQL_ATTR_RETRIEVE_DATA
165    RetrieveData = 11,
166    /// SQL_ATTR_ROW_BIND_OFFSET_PTR
167    RowBindOffsetPtr = 23,
168    /// SQL_ATTR_ROW_BIND_TYPE
169    RowBindType = 5,
170    /// SQL_ATTR_ROW_NUMBER `GetStmtAttr`
171    RowNumber = 14,
172    /// SQL_ATTR_ROW_OPERATION_PTR
173    RowOperationPtr = 24,
174    /// SQL_ATTR_ROW_STATUS_PTR
175    RowStatusPtr = 25,
176    /// SQL_ATTR_ROWS_FETCHED_PTR
177    RowsFetchedPtr = 26,
178    /// SQL_ATTR_ROW_ARRAY_SIZE
179    RowArraySize = 27,
180    /// SQL_ATTR_SIMULATE_CURSOR
181    SimulateCursor = 10,
182    /// SQL_ATTR_USE_BOOKMARKS
183    UseBookmarks = 12,
184    #[cfg(feature = "odbc_version_3_80")]
185    /// SQL_ATTR_ASYNC_STMT_EVENT
186    AsyncStmtEvent = 29,
187    #[cfg(feature = "odbc_version_4")]
188    /// SQL_ATTR_SAMPLE_SIZE
189    SampleSize = 30,
190    #[cfg(feature = "odbc_version_4")]
191    /// SQL_ATTR_DYNAMIC_COLUMNS
192    DynamicColumns = 31,
193    #[cfg(feature = "odbc_version_4")]
194    /// SQL_ATTR_TYPE_EXCEPTION_BEHAVIOR
195    TypeExceptionBehaviour = 32,
196    #[cfg(feature = "odbc_version_4")]
197    /// SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR
198    LengthExceptionBehaviour = 33,
199    /// SQL_ATTR_METADATA_ID
200    MetadataId = 10014,
201}