Skip to content

v0.6.0

Choose a tag to compare

@kenshaw kenshaw released this 29 Sep 12:23
· 4 commits to main since this release

This release adds the driver databend, for Databend and its SQL. It also gives every driver the same options for one statement, and it adds the key auth to the drivers influxdb and neo4j. A caller of couchbase.Option needs no change.

The Databend driver

Import github.com/xo/dbimp/databend. It registers the name databend, and it takes a DSN of this form:

databend://user:password@host:port/database?key=value

The path is the database, and default without one. The port is 8000 without one, with tls=true too. The keys are tls, auth=basic|bearer, cancel=kill|none and timezone, and the driver refuses any other key, the keys sslmode, tenant and warehouse of databend-go too (D117).

These are the rules that a caller sees:

  • The server binds each argument. A positional argument fills each ? in order, and sql.Named("k", v) fills :k. One statement cannot take both kinds. A decimal goes as a string, which keeps every digit, and a []byte is refused (D120 and D124).
  • Every value arrives as text, and the driver decodes it by the type of its column: int64, float64, *apd.Decimal, bool, []byte, time.Time and string. An Array, a Map and a Tuple arrive as text of SQL, and the driver decodes them into []any and maps. A Geometry and a Geography are WKT (D118 and D119).
  • A Bitmap cannot be read, because the server writes none of its bytes in JSON. Reading one fails with dbimp.ErrNotSupported (D119).
  • Each result arrives one page at a time. When the context ends, or the rows close early, the driver kills the query on the server, because the server runs it on when the client leaves (D123).
  • BeginTx begins a transaction, which the session of the connection carries. A DDL statement or any error ends it, and Commit then returns why. USE and SET stay on the connection until database/sql hands it to another caller (D121 and D122).
  • RowsAffected is the count that the result names, such as number of rows inserted. A statement whose result names none, such as REPLACE INTO, returns dbimp.ErrNotSupported (D125).

The tests passed against 1.2.881 and 1.2.948 as the administrator and as the ordinary user. docs/DATABEND.md holds what the driver knows about the server, and D117 to D125 in docs/decisions/ hold the reasons.

What changes for a caller

  • All drivers. Each driver takes WithTimeout, WithReadonly, WithParameter and WithDatabase, through WithOptions or as an argument of a statement, and an option for each key of its DSN that can change for one statement. An option that the server cannot honor fails the statement with dbimp.ErrNotSupported, and a value that the DSN would refuse fails it with dbimp.ErrInvalidValue. WithParameter replaces a key that the driver sets itself (D109).
  • Couchbase. couchbase.Option is now dbimp.Option[...], which stays source compatible. WithDatabase sets query_context, as WithQueryContext does.
  • Neo4j. WithTimeout sends maxExecutionTime in whole seconds, and fails with dbimp.ErrNotSupported on a release before 2026.04, which ignores it. WithDatabase and WithCancel are new. The key auth=bearer sends the password as a Bearer token (D116).
  • InfluxDB. WithDatabase, WithRetentionPolicy, WithChunked and WithDescribe are new. WithTimeout and WithReadonly fail with dbimp.ErrNotSupported, because no release has either for one request. The key auth=bearer sends the password as a token: Token to InfluxDB 2, and Bearer to 1 and 3 (D116).
  • ArangoDB. WithTimeout sends maxRuntime, and WithDatabase, WithBatch and WithCancel are new. WithReadonly holds only in a read-only transaction.
  • SurrealDB. WithDatabase and WithNamespace set the database and the namespace of one statement. WithTimeout and WithReadonly fail with dbimp.ErrNotSupported.

Other changes

  • The root package holds the options of every driver: Option, WithOptions, Resolve, Unsupported and MarshalParams. It also holds SetAuth, which sends the secret of a DSN as the key auth says.
  • The recorder of step 6 follows each page of a query, and escapes a captured value inside a JSON body.
  • TestEveryDriverTakesTheCommonOptions holds the options of each driver.