Skip to content

v0.4.0

Choose a tag to compare

@kenshaw kenshaw released this 28 Sep 19:10
· 29 commits to main since this release

This release adds the driver influxdb, for InfluxDB 1, InfluxDB 2, and InfluxDB 3 and later. The drivers couchbase, surrealdb and neo4j do not change.

The InfluxDB driver

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

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

The path is the database. A token is the password, sent with basic authentication. Without a port, the driver uses 8086 for version=1 or version=2, and 8181 otherwise.

The driver speaks two dialects:

  • influxdb is SQL, on InfluxDB 3 and later.
  • influxql is InfluxQL, on every release.

The key sqlmode chooses the dialect, as sslmode does for PostgreSQL. Its default, prefer, asks GET /ping for the release, and speaks SQL to InfluxDB 3 and InfluxQL to InfluxDB 1 and 2. With disable or allow, the driver sends no ping, and the key version names the release. Inside sql.Conn.Raw, influxdb.Version returns the release, and influxdb.Dialect returns the dialect of the connection.

These are the rules that a caller sees:

  • SQL learns the columns and their types from DESCRIBE, because the JSON of the server leaves out every NULL. The key describe=disable turns that off. A NaN or an infinity from an expression reads as math.NaN(), because the JSON writes all three alike.
  • InfluxQL gives each series its own result set. Its first columns are name and the tags of the series. Call Rows.NextResultSet to read the next one. A statement with no series is a result set with no columns.
  • The column time of InfluxQL is a time.Time. A number in InfluxQL is an int64, a uint64 above the range of int64, or a float64, by its text, so a whole float reads as an int64.
  • INSERT [INTO <database>[.<retention-policy>]] <line protocol> writes line protocol, as the influx shell does, in both dialects. Each $name or $1 argument becomes a literal of line protocol. A NULL leaves its tag, its field or its timestamp out of the line.
  • DELETE goes to the server. InfluxDB 1 and 2 run it. InfluxDB 3 Core has no delete of points, and refuses it.
  • The driver asks InfluxDB 1 for chunks, so that a large result streams. The key chunked=disable turns that off.
  • InfluxDB has no transactions, so BeginTx returns dbimp.ErrNotSupported.

The tests passed against 1.11.8, 1.13.1, 2.8.0, 2.9.1, 3.9.13, 3.10.6 and 3.11.5, as the administrator, and as the ordinary user on InfluxDB 1 and 2. docs/INFLUXDB.md holds what the driver knows about each release, and decisions D78 to D87 in docs/decisions/ hold the reasons.

For the authors of a driver

  • dbimptest.RoundTripCase has three new fields: Column, the column of the value in the select; SkipUpdate, the reason why an update cannot run; and an empty Delete, for a database that cannot delete one row (D86). Each keeps the old behavior when it is not set.
  • The recorder in dbimptest/cmd/record keeps a body that the server closed before its end, and Replay closes it at the same place. A request can name the releases that it runs on, and -ordinary can be empty for a release that has no ordinary user.

Other changes

  • The list of targets drops Gel, Blazegraph and Stargate, because each one is retired (D84). Milvus and PostgREST move to P2 (D87).
  • A SurrealDB RecordID writes its text form in JSON (D70). The code was in v0.3.0, and this release accepts the decision.