mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-28 13:34:24 +01:00
Implement prepare
This commit is contained in:
@@ -78,31 +78,6 @@ public abstract class AbstractDB {
|
||||
*/
|
||||
public abstract long connect() throws SQLException;
|
||||
|
||||
// /**
|
||||
// * Compiles an SQL statement.
|
||||
// *
|
||||
// * @param stmt The SQL statement to compile.
|
||||
// * @throws SQLException if a database access error occurs.
|
||||
// */
|
||||
// public final void prepare(CoreStatement stmt) throws SQLException {
|
||||
// if (stmt.sql == null) {
|
||||
// throw new SQLException("Statement must not be null");
|
||||
// }
|
||||
//
|
||||
// // TODO: check whether closing the pointer and replacing stamt.pointer should work atomically using locks etc
|
||||
// final SafeStatementPointer pointer = stmt.getStmtPointer();
|
||||
// if (pointer != null) {
|
||||
// pointer.close();
|
||||
// }
|
||||
//
|
||||
// final SafeStatementPointer newPointer = stmt.connection.prepare(stmt.sql);
|
||||
// stmt.setStmtPointer(newPointer);
|
||||
// final boolean added = statementPointerSet.add(newPointer);
|
||||
// if (!added) {
|
||||
// throw new IllegalStateException("The pointer is already added to statements set");
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Destroys a statement.
|
||||
*
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class LimboDB extends AbstractDB {
|
||||
|
||||
byte[] filePathBytes = stringToUtf8ByteArray(filePath);
|
||||
if (filePathBytes == null) {
|
||||
throw LimboExceptionUtils.buildLimboException(LimboErrorCode.LIMBO_ETC.code, "File name cannot be converted to byteArray. File name: " + filePath);
|
||||
throw LimboExceptionUtils.buildLimboException(LimboErrorCode.LIMBO_ETC.code, "File path cannot be converted to byteArray. File name: " + filePath);
|
||||
}
|
||||
|
||||
dbPointer = openUtf8(filePathBytes, openFlags);
|
||||
@@ -102,7 +102,11 @@ public final class LimboDB extends AbstractDB {
|
||||
|
||||
@Override
|
||||
public long connect() throws SQLException {
|
||||
return connect0(ByteArrayUtils.stringToUtf8ByteArray(filePath), dbPointer);
|
||||
byte[] filePathBytes = stringToUtf8ByteArray(filePath);
|
||||
if (filePathBytes == null) {
|
||||
throw LimboExceptionUtils.buildLimboException(LimboErrorCode.LIMBO_ETC.code, "File path cannot be converted to byteArray. File name: " + filePath);
|
||||
}
|
||||
return connect0(filePathBytes, dbPointer);
|
||||
}
|
||||
|
||||
private native long connect0(byte[] path, long databasePtr) throws SQLException;
|
||||
|
||||
Reference in New Issue
Block a user