Class SqliteHash

Namespace: redb.SQLite.Data
Assembly: redb.SQLite.dll

The stored form of a 128-bit hash in SQLite — _objects._hash, _schemes._structure_hash,
_users._hash: BLOB(16) in RFC 4122 byte order, i.e. the bytes of the canonical text
form read left to right (00112233-4455-6677-8899-aabbccddeeff is 00 11 22 33 44 55 …).

One place for the byte order, because several code paths write it and several read it. Writes go
through the Guid's TEXT parameter and the SQL wrapper — unhex() of the
text without dashes is by construction the order the text shows; the native extension does the same
in its own statements. Reads get a byte[] from the driver and use .
The two must agree, and Guid.ToByteArray() without the big-endian flag does not: it puts the
first three groups in little-endian order.


Only hashes. _values._Guid, _objects._value_guid, _users._code_guid are data and
stay TEXT — they are compared with values users write and read as text.


A database created before V4 holds the hashes as 36-character TEXT. SQLite keeps the storage class
a value was written with regardless of the declared type, so no ALTER is needed: the values
are converted in place on open (ApplySchemaUpgradesAsync), and a reader that meets a TEXT
value anyway still understands it.

public static class SqliteHash

Inheritance

Object→SqliteHash

Methods

FromBlob(ReadOnlySpan<byte>)

The Guid whose canonical text form spells bytes.

public static Guid FromBlob(ReadOnlySpan<byte> bytes)

FromDbValue(object)

A Guid from whatever the driver returned for a uuid-valued column: the BLOB of a hash, the

public static Guid FromDbValue(object value)

FromText(string)

SQL that turns a canonical uuid TEXT expression (a $n parameter, a column) into the

public static string FromText(string sqlExpression)

ToBlob(Guid)

The 16 bytes of value in RFC 4122 order.

public static byte[] ToBlob(Guid value)