Connection

class Connection(val allocator: BufferAllocator, dbCat: Database.Catalog, qSrc: IQuerySource, sqlPlanner: SqlPlanner, var dbName: DatabaseName, var clock: InstantSource, var defaultTz: ZoneId, tracer: Tracer?, metrics: ConnectionMetrics?) : 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 BEGINCOMMIT 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.

Constructors

Link copied to clipboard
constructor(allocator: BufferAllocator, dbCat: Database.Catalog, qSrc: IQuerySource, sqlPlanner: SqlPlanner, dbName: DatabaseName, clock: InstantSource, defaultTz: ZoneId, tracer: Tracer?, metrics: ConnectionMetrics?)

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
var user: String?

Functions

Link copied to clipboard
fun attachDb(dbName: DatabaseName, config: Database.Config): Xtdb.ExecutedTx
Link copied to clipboard
fun begin()
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 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 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.