v0.4.0
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:
influxdbis SQL, on InfluxDB 3 and later.influxqlis 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 keydescribe=disableturns that off. A NaN or an infinity from an expression reads asmath.NaN(), because the JSON writes all three alike. - InfluxQL gives each series its own result set. Its first columns are
nameand the tags of the series. CallRows.NextResultSetto read the next one. A statement with no series is a result set with no columns. - The column
timeof InfluxQL is atime.Time. A number in InfluxQL is anint64, auint64above the range ofint64, or afloat64, by its text, so a whole float reads as anint64. INSERT [INTO <database>[.<retention-policy>]] <line protocol>writes line protocol, as theinfluxshell does, in both dialects. Each$nameor$1argument 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=disableturns that off. - InfluxDB has no transactions, so
BeginTxreturnsdbimp.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.RoundTripCasehas three new fields:Column, the column of the value in the select;SkipUpdate, the reason why an update cannot run; and an emptyDelete, for a database that cannot delete one row (D86). Each keeps the old behavior when it is not set.- The recorder in
dbimptest/cmd/recordkeeps a body that the server closed before its end, andReplaycloses it at the same place. A request can name the releases that it runs on, and-ordinarycan 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
RecordIDwrites its text form in JSON (D70). The code was inv0.3.0, and this release accepts the decision.