Skip to content

Commit 9e831fa

Browse files
committed
ODBC changes
1 parent 6f3947d commit 9e831fa

File tree

3 files changed

+114
-134
lines changed

3 files changed

+114
-134
lines changed

.github/workflows/dub.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,6 @@ jobs:
2222
os: [ ubuntu-latest, windows-latest ]
2323
compiler:
2424
- dmd-latest
25-
- ldc-latest
26-
- dmd-2.109.1 # (released in 2024)
27-
- dmd-2.108.1 # (released in 2024)
28-
- dmd-2.107.1 # (released in 2024)
29-
- dmd-2.106.1 # (released in 2024)
30-
- dmd-2.105.3 # (released in 2023)
31-
- dmd-2.104.2 # (released in 2023)
32-
- dmd-2.103.1 # (released in 2023)
33-
- dmd-2.102.2 # (released in 2023)
34-
- dmd-2.101.2 # (released in 2023)
35-
- dmd-2.100.2 # (released in 2022) ## GDC 12 can support 2.100
36-
- dmd-2.099.1 # (released in 2022)
37-
- dmd-2.098.1 # (released in 2021) ## Has issue re: phobos/std/variant.d
38-
- dmd-2.097.2 # (released in 2021)
39-
- ldc-1.33.0 # eq to dmd v2.103.1
40-
- ldc-1.32.2 # eq to dmd v2.102.2
41-
- ldc-1.28.1 # eq to dmd v2.098.1
42-
- ldc-1.27.1 # eq to dmd v2.097.2
43-
include:
44-
## LDC supports Apple silicon
45-
- { os: macos-latest, compiler: ldc-latest }
46-
## macos-13 is the latest Mac runner with Intel cpu
47-
- { os: macos-13, compiler: dmd-latest }
48-
- { os: macos-13, compiler: ldc-latest }
49-
- { os: macos-13, compiler: dmd-2.108.1 }
50-
- { os: macos-13, compiler: ldc-1.32.2 }
5125
exclude:
5226
- { os: windows-latest, compiler: dmd-2.098.1 }
5327
- { os: windows-latest, compiler: dmd-2.097.2 }

source/ddbc/core.d

Lines changed: 86 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/**
2-
* DDBC - D DataBase Connector - abstraction layer for RDBMS access, with interface similar to JDBC.
3-
*
2+
* DDBC - D DataBase Connector - abstraction layer for RDBMS access, with interface similar to JDBC.
3+
*
44
* Source file ddbc/core.d.
55
*
66
* DDBC library attempts to provide implementation independent interface to different databases.
7-
*
7+
*
88
* Set of supported RDBMSs can be extended by writing Drivers for particular DBs.
99
* Currently it only includes MySQL Driver which uses patched version of MYSQLN (native D implementation of MySQL connector, written by Steve Teale)
10-
*
10+
*
1111
* JDBC documentation can be found here:
1212
* $(LINK http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/package-summary.html)$(BR)
1313
*
1414
* Limitations of current version: readonly unidirectional resultset, completely fetched into memory.
15-
*
15+
*
1616
* Its primary objects are:
1717
* $(UL
1818
* $(LI Driver: $(UL $(LI Implements interface to particular RDBMS, used to create connections)))
@@ -134,64 +134,64 @@ enum SqlType {
134134
VARCHAR,
135135
}
136136

137-
138-
/**
139-
* The level of isolation between transactions. Various isolation levels provide tradeoffs between
140-
* performance, reproducibility, and interactions with other simultaneous transactions.
141-
*
142-
* The default transaction isolation level depends on the DB driver. For example:
143-
* - Postgresql: Defaults to READ_COMMITTED
144-
* - MySQL: Defaults to REPEATABLE_READ
145-
* - SQLite: Defaults to SERIALIZABLE
146-
*
147-
* Generally, `SELECT` statements do see the effects of previous `UPDATE` statements within the same
148-
* transaction, despite the fact that they are not yet committed. However, there can be differences
149-
* between database implementations depending on the transaction isolation level.
150-
*/
151-
enum TransactionIsolation {
152-
/**
153-
* Transactions are not supported at all, thus there is no isolation.
154-
*/
155-
NONE,
156-
157-
/**
158-
* Statements can read rows that have been modified by other transactions but are not yet
159-
* committed. High parallelism, but risks dirty reads, non-repeatable reads, etc.
160-
*/
161-
READ_UNCOMMITTED,
162-
163-
/**
164-
* Statements cannot read data that has been modified by other transactions but not yet
165-
* committed. However, data can be changed when other transactions are commited between statements
166-
* of a transaction resulting in non-repeatable reads or phantom data.
167-
*/
168-
READ_COMMITTED,
169-
170-
/**
171-
* Shared locks are used to prevent modification of data read by transactions, preventing dirty
172-
* reads and non-repeatable reads. However, new data can be inserted, causing transactions to
173-
* potentially behave differently if the transaction is retried, i.e. "phantom reads".
174-
*/
175-
REPEATABLE_READ,
176-
177-
/**
178-
* Locks are used to make sure transactions using the same data cannot run simultaneously. This
179-
* prevents dirty reads, non-repeatable reads, and phantom reads. However, this transaction
180-
* isolation level has the worst performance.
181-
*/
182-
SERIALIZABLE,
183-
}
184-
185-
/**
186-
* A connection represents a session with a specific database. Within the context of a Connection,
187-
* SQL statements are executed and results are returned.
188-
*
189-
* Note: By default the Connection automatically commits changes after executing each statement. If
190-
* auto commit has been disabled, an explicit commit must be done or database changes will not be
191-
* saved.
192-
*
193-
* See_Also: https://docs.oracle.com/cd/E13222_01/wls/docs45/classdocs/java.sql.Connection.html
194-
*/
137+
138+
/**
139+
* The level of isolation between transactions. Various isolation levels provide tradeoffs between
140+
* performance, reproducibility, and interactions with other simultaneous transactions.
141+
*
142+
* The default transaction isolation level depends on the DB driver. For example:
143+
* - Postgresql: Defaults to READ_COMMITTED
144+
* - MySQL: Defaults to REPEATABLE_READ
145+
* - SQLite: Defaults to SERIALIZABLE
146+
*
147+
* Generally, `SELECT` statements do see the effects of previous `UPDATE` statements within the same
148+
* transaction, despite the fact that they are not yet committed. However, there can be differences
149+
* between database implementations depending on the transaction isolation level.
150+
*/
151+
enum TransactionIsolation {
152+
/**
153+
* Transactions are not supported at all, thus there is no isolation.
154+
*/
155+
NONE,
156+
157+
/**
158+
* Statements can read rows that have been modified by other transactions but are not yet
159+
* committed. High parallelism, but risks dirty reads, non-repeatable reads, etc.
160+
*/
161+
READ_UNCOMMITTED,
162+
163+
/**
164+
* Statements cannot read data that has been modified by other transactions but not yet
165+
* committed. However, data can be changed when other transactions are commited between statements
166+
* of a transaction resulting in non-repeatable reads or phantom data.
167+
*/
168+
READ_COMMITTED,
169+
170+
/**
171+
* Shared locks are used to prevent modification of data read by transactions, preventing dirty
172+
* reads and non-repeatable reads. However, new data can be inserted, causing transactions to
173+
* potentially behave differently if the transaction is retried, i.e. "phantom reads".
174+
*/
175+
REPEATABLE_READ,
176+
177+
/**
178+
* Locks are used to make sure transactions using the same data cannot run simultaneously. This
179+
* prevents dirty reads, non-repeatable reads, and phantom reads. However, this transaction
180+
* isolation level has the worst performance.
181+
*/
182+
SERIALIZABLE,
183+
}
184+
185+
/**
186+
* A connection represents a session with a specific database. Within the context of a Connection,
187+
* SQL statements are executed and results are returned.
188+
*
189+
* Note: By default the Connection automatically commits changes after executing each statement. If
190+
* auto commit has been disabled, an explicit commit must be done or database changes will not be
191+
* saved.
192+
*
193+
* See_Also: https://docs.oracle.com/cd/E13222_01/wls/docs45/classdocs/java.sql.Connection.html
194+
*/
195195
interface Connection : DialectAware {
196196
/// Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.
197197
void close();
@@ -214,21 +214,21 @@ interface Connection : DialectAware {
214214
Statement createStatement();
215215
/// Creates a PreparedStatement object for sending parameterized SQL statements to the database.
216216
PreparedStatement prepareStatement(string query);
217-
218-
/**
219-
* Returns the currently active transaction isolation level used by the DB connection.
220-
*/
221-
TransactionIsolation getTransactionIsolation();
222-
223-
/**
224-
* Attempt to change the Transaction Isolation Level used for transactions, which controls how
225-
* simultaneous transactions will interact with each other. In general, lower isolation levels
226-
* require fewer locks and have better performanc, but also have fewer guarantees for
227-
* consistency.
228-
*
229-
* Note: setTransactionIsolation cannot be called while in the middle of a transaction.
230-
*/
231-
void setTransactionIsolation(TransactionIsolation level);
217+
218+
/**
219+
* Returns the currently active transaction isolation level used by the DB connection.
220+
*/
221+
TransactionIsolation getTransactionIsolation();
222+
223+
/**
224+
* Attempt to change the Transaction Isolation Level used for transactions, which controls how
225+
* simultaneous transactions will interact with each other. In general, lower isolation levels
226+
* require fewer locks and have better performanc, but also have fewer guarantees for
227+
* consistency.
228+
*
229+
* Note: setTransactionIsolation cannot be called while in the middle of a transaction.
230+
*/
231+
void setTransactionIsolation(TransactionIsolation level);
232232
}
233233

234234
interface ResultSetMetaData {
@@ -349,18 +349,19 @@ interface DataSetWriter {
349349

350350
interface ResultSet : DataSetReader {
351351
void close();
352+
/// Will return true if the ResultSet is pointing at the first row
352353
bool first();
353354
bool isFirst();
354355
bool isLast();
355356
bool next();
356357

357-
//Retrieves the number, types and properties of this ResultSet object's columns
358+
/// Retrieves the number, types and properties of this ResultSet object's columns
358359
ResultSetMetaData getMetaData();
359-
//Retrieves the Statement object that produced this ResultSet object.
360+
/// Retrieves the Statement object that produced this ResultSet object.
360361
Statement getStatement();
361-
//Retrieves the current row number
362+
/// Retrieves the current row number
362363
int getRow();
363-
//Retrieves the fetch size for this ResultSet object.
364+
/// Retrieves the fetch size for this ResultSet object.
364365
deprecated("Marked for removal as Cannot be used by all supported drivers. See Github issue #85")
365366
ulong getFetchSize();
366367

@@ -436,7 +437,7 @@ interface Statement : DialectAware {
436437
void close();
437438
}
438439

439-
/// An object that represents a precompiled SQL statement.
440+
/// An object that represents a precompiled SQL statement.
440441
interface PreparedStatement : Statement, DataSetWriter {
441442
/// Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
442443
int executeUpdate();
@@ -495,7 +496,7 @@ string makeDDBCUrl(string driverName, string[string] params) {
495496
}
496497

497498
/// Helper function to make url in form driverName://host:port/dbname?param1=value1,param2=value2
498-
string makeDDBCUrl(string driverName, string host = null, int port = 0,
499+
string makeDDBCUrl(string driverName, string host = null, int port = 0,
499500
string dbName = null, string[string] params = null) {
500501
import std.algorithm.searching : canFind;
501502
enforce(canFind(["sqlite", "postgresql", "mysql", "sqlserver", "oracle", "odbc"], driverName), "driver must be one of sqlite|postgresql|mysql|sqlserver|oracle|odbc");
@@ -593,4 +594,4 @@ private unittest {
593594

594595
string url = makeDDBCUrl("odbc", params);
595596
assert(url == "odbc://?dsn=myDSN", "ODBC URL is not correct: "~url);
596-
}
597+
}

0 commit comments

Comments
 (0)