Connection

class Connection : AdbcConnection

A connection to one database, dbName.

A query and a transaction run through the same connection resolve table names differently, and nothing in the SQL text distinguishes the two.

A query may reach any attached database:

  • db.schema.table — that table, in that database.

  • a.b — matched against both readings: schema a of dbName, and table b in the public schema of a database a. It resolves to whichever exists, and is an Ambiguous table reference when both do. The database reading only reaches public, so another schema of another database needs all three parts.

  • b — table b in the public schema of dbName.

A transaction resolves only its own database:

  • a.b — schema a of that database, never a database. So INSERT INTO other_db.foo creates foo in schema other_db of the transaction's own database.

  • b — table b in the public schema of that database.

  • A table in another database is unreachable, and referring to one reports that the table was not found, naming the transaction's database.

The transaction's database is:

  • dbName — for SQL DML through a Statement, and for a BEGIN … COMMIT block. Neither can address another database.

  • TxOpts.dbName, defaulting to dbName — for submitTx and executeTx.

The narrowing is deliberate: XTDB guarantees serializability within a database and not between databases, so a transaction that read across them would have no consistent basis to read at.

Types

Link copied to clipboard
data class LastSubmittedTx(val txId: MessageId, val systemTime: Instant?, val committed: Boolean?, val error: Throwable?)

Properties

Link copied to clipboard
val allocator: BufferAllocator
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var currentCatalog: String
Link copied to clipboard
open override var currentDbSchema: String
Link copied to clipboard
var dbName: DatabaseName
Link copied to clipboard
Link copied to clipboard
open val info: ArrowReader?
Link copied to clipboard
open var isolationLevel: IsolationLevel?
Link copied to clipboard
open var readOnly: Boolean
Link copied to clipboard
Link copied to clipboard
open val statisticNames: ArrowReader?
Link copied to clipboard
open override val tableTypes: ArrowReader
Link copied to clipboard
val user: String?

The authenticated user this connection's writes are attributed to; null for an unauthenticated Xtdb.connect.

Functions

Link copied to clipboard
fun attachDb(dbName: DatabaseName, config: Database.Config): Xtdb.ExecutedTx
Link copied to clipboard
fun begin()

Opens a transaction with the session's default access mode (SET SESSION CHARACTERISTICS), or none. setTransactionReadOnly and setTransactionReadWrite shape it until its first query or write.

Link copied to clipboard
fun beginReadOnly(tz: ZoneId = defaultTz, snapshotToken: String? = null, snapshotTime: Instant? = null, currentTime: Instant? = null)
Link copied to clipboard
fun beginWriteOnly(systemTime: Instant? = null, userMetadata: Map<*, *>? = null, async: Boolean = false, tz: ZoneId = defaultTz)
Link copied to clipboard
open fun bulkIngest(): BulkIngestBuilder?
open fun bulkIngest(targetTableName: String?, mode: BulkIngestMode?, vararg options: IngestOption?): AdbcStatement?
open override fun bulkIngest(targetTableName: String, mode: BulkIngestMode): Xtdb.Statement
Link copied to clipboard
open fun cancel()
Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun commit()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun detachDb(dbName: DatabaseName): Xtdb.ExecutedTx
Link copied to clipboard
fun executeTx(ops: List<TxOp>, opts: TxOpts = TxOpts()): Xtdb.ExecutedTx

The transaction goes to TxOpts.dbName (default dbName) and may only refer to tables within it — see Connection.

Link copied to clipboard
fun executeTxOp(op: TxOp)
Link copied to clipboard
open override fun getCurrentCatalog(): String
Link copied to clipboard
open override fun getCurrentDbSchema(): String
Link copied to clipboard
open override fun getInfo(infoCodes: IntArray?): ArrowReader
Link copied to clipboard
open override fun getObjects(depth: AdbcConnection.GetObjectsDepth, catalogPattern: String?, dbSchemaPattern: String?, tableNamePattern: String?, tableTypes: Array<out String>?, columnNamePattern: String?): ArrowReader
Link copied to clipboard
open fun <T : Any?> getOption(key: TypedKey<T?>?): T?
Link copied to clipboard
open fun getStatistics(catalogPattern: String?, dbSchemaPattern: String?, tableNamePattern: String?, approximate: Boolean): ArrowReader?
Link copied to clipboard
open override fun getTableSchema(catalog: String?, dbSchema: String?, tableName: String): Schema
Link copied to clipboard
open override fun getTableTypes(): ArrowReader
Link copied to clipboard
fun latestSubmittedMsgIds(): Map<DatabaseName, List<MessageId>>
Link copied to clipboard
Link copied to clipboard
open fun readPartition(descriptor: ByteBuffer?): ArrowReader?
Link copied to clipboard
open override fun rollback()
Link copied to clipboard
Link copied to clipboard
open override fun setAutoCommit(autoCommit: Boolean)
Link copied to clipboard
open override fun setCurrentCatalog(catalog: String)
Link copied to clipboard
open fun <T : Any?> setOption(key: TypedKey<T?>?, value: T?)
Link copied to clipboard
fun setSessionParameter(name: String, value: String?)
Link copied to clipboard
fun setTimeZone(zone: ZoneId)
Link copied to clipboard
fun setTransactionReadOnly(snapshotToken: String? = null, snapshotTime: Instant? = null, clockTime: Instant? = null, awaitToken: String? = null)

Makes the open transaction read-only, as SET TRANSACTION READ ONLY, … does.

Link copied to clipboard
fun setTransactionReadWrite(systemTime: Instant? = null, userMetadata: Map<*, *>? = null, async: Boolean? = null)

Makes the open transaction read-write, as SET TRANSACTION READ WRITE, … does.

Link copied to clipboard

Sets the open transaction's time zone, as SET TRANSACTION TIMEZONE = … does, for this transaction only. It's kept when the access mode changes.

Link copied to clipboard
fun submitTx(ops: List<TxOp>, opts: TxOpts = TxOpts()): Xtdb.SubmittedTx

The transaction goes to TxOpts.dbName (default dbName) and may only refer to tables within it — see Connection.