diff --git a/wit/deps/rdbms/mysql.wit b/wit/deps/rdbms/mysql.wit new file mode 100644 index 0000000..5dfdb78 --- /dev/null +++ b/wit/deps/rdbms/mysql.wit @@ -0,0 +1,140 @@ +package wasi:rdbms@0.0.1; + +interface mysql { + use types.{date, time, timestamp}; + + variant error { + connection-failure(string), + query-parameter-failure(string), + query-execution-failure(string), + query-response-failure(string), + other(string) + } + + variant db-column-type { + boolean, + tinyint, + smallint, + mediumint, + int, + bigint, + tinyint-unsigned, + smallint-unsigned, + mediumint-unsigned, + int-unsigned, + bigint-unsigned, + float, + double, + decimal, + date, + datetime, + timestamp, + time, + year, + fixchar, + varchar, + tinytext, + text, + mediumtext, + longtext, + binary, + varbinary, + tinyblob, + blob, + mediumblob, + longblob, + enumeration, + set, + bit, + json + } + + record db-column { + ordinal: u64, + name: string, + db-type: db-column-type, + db-type-name: string + } + + /// Value descriptor for a single database value + variant db-value { + boolean(bool), + tinyint(s8), + smallint(s16), + // s24 + mediumint(s32), + int(s32), + bigint(s64), + tinyint-unsigned(u8), + smallint-unsigned(u16), + // u24 + mediumint-unsigned(u32), + int-unsigned(u32), + bigint-unsigned(u64), + float(f32), + double(f64), + decimal(string), + date(date), + datetime(timestamp), + timestamp(timestamp), + time(time), + year(u16), + fixchar(string), + varchar(string), + tinytext(string), + text(string), + mediumtext(string), + longtext(string), + binary(list), + varbinary(list), + tinyblob(list), + blob(list), + mediumblob(list), + longblob(list), + enumeration(string), + set(string), + bit(list), + json(string), + null + } + + /// A single row of values + record db-row { + values: list + } + + record db-result { + columns: list, + rows: list + } + + /// A potentially very large and lazy stream of rows: + resource db-result-stream { + get-columns: func() -> list; + get-next: func() -> option>; + } + + resource db-connection { + open: static func(address: string) -> result; + + query: func(statement: string, params: list) -> result; + + query-stream: func(statement: string, params: list) -> result; + + execute: func(statement: string, params: list) -> result; + + begin-transaction: func() -> result; + } + + resource db-transaction { + query: func(statement: string, params: list) -> result; + + query-stream: func(statement: string, params: list) -> result; + + execute: func(statement: string, params: list) -> result; + + commit: func() -> result<_, error>; + + rollback: func() -> result<_, error>; + } +} \ No newline at end of file diff --git a/wit/deps/rdbms/postgres.wit b/wit/deps/rdbms/postgres.wit new file mode 100644 index 0000000..66e7a2f --- /dev/null +++ b/wit/deps/rdbms/postgres.wit @@ -0,0 +1,281 @@ +package wasi:rdbms@0.0.1; + +interface postgres { + use types.{date, time, timetz, timestamp, timestamptz, uuid, ip-address, mac-address}; + + variant error { + connection-failure(string), + query-parameter-failure(string), + query-execution-failure(string), + query-response-failure(string), + other(string) + } + + record interval { + months: s32, + days: s32, + microseconds: s64 + } + + variant int4bound { + included(s32), + excluded(s32), + unbounded + } + + variant int8bound { + included(s64), + excluded(s64), + unbounded + } + + variant numbound { + included(string), + excluded(string), + unbounded + } + + variant tsbound { + included(timestamp), + excluded(timestamp), + unbounded + } + + variant tstzbound { + included(timestamptz), + excluded(timestamptz), + unbounded + } + + variant datebound { + included(date), + excluded(date), + unbounded + } + + record int4range { + start: int4bound, + end: int4bound + } + + record int8range { + start: int8bound, + end: int8bound + } + + record numrange { + start: numbound, + end: numbound + } + + record tsrange { + start: tsbound, + end: tsbound + } + + record tstzrange { + start: tstzbound, + end: tstzbound + } + + record daterange { + start: datebound, + end: datebound + } + + record enumeration-type { + name: string + } + + record enumeration { + name: string, + value: string + } + + record composite-type { + name: string, + attributes: list> + } + + record composite { + name: string, + values: list + } + + record domain-type { + name: string, + base-type: lazy-db-column-type + } + + record domain { + name: string, + value: lazy-db-value + } + + record range-type { + name: string, + base-type: lazy-db-column-type + } + + variant value-bound { + included(lazy-db-value), + excluded(lazy-db-value), + unbounded + } + + record values-range { + start: value-bound, + end: value-bound + } + + record range { + name: string, + value: values-range + } + + variant db-column-type { + character, + int2, + int4, + int8, + float4, + float8, + numeric, + boolean, + text, + varchar, + bpchar, + timestamp, + timestamptz, + date, + time, + timetz, + interval, + bytea, + uuid, + xml, + json, + jsonb, + jsonpath, + inet, + cidr, + macaddr, + bit, + varbit, + int4range, + int8range, + numrange, + tsrange, + tstzrange, + daterange, + money, + oid, + enumeration(enumeration-type), + composite(composite-type), + domain(domain-type), + array(lazy-db-column-type), + range(range-type) + } + + variant db-value { + character(s8), + int2(s16), + int4(s32), + int8(s64), + float4(f32), + float8(f64), + numeric(string), + boolean(bool), + text(string), + varchar(string), + bpchar(string), + timestamp(timestamp), + timestamptz(timestamptz), + date(date), + time(time), + timetz(timetz), + interval(interval), + bytea(list), + json(string), + jsonb(string), + jsonpath(string), + xml(string), + uuid(uuid), + inet(ip-address), + cidr(ip-address), + macaddr(mac-address), + bit(list), + varbit(list), + int4range(int4range), + int8range(int8range), + numrange(numrange), + tsrange(tsrange), + tstzrange(tstzrange), + daterange(daterange), + money(s64), + oid(u32), + enumeration(enumeration), + composite(composite), + domain(domain), + array(list), + range(range), + null + } + + resource lazy-db-value { + constructor(value: db-value); + get: func() -> db-value; + } + + resource lazy-db-column-type { + constructor(value: db-column-type); + get: func() -> db-column-type; + } + + record db-column { + ordinal: u64, + name: string, + db-type: db-column-type, + db-type-name: string + } + + /// A single row of values + record db-row { + values: list + } + + record db-result { + columns: list, + rows: list + } + + /// A potentially very large and lazy stream of rows: + resource db-result-stream { + get-columns: func() -> list; + get-next: func() -> option>; + } + + resource db-connection { + open: static func(address: string) -> result; + + query: func(statement: string, params: list) -> result; + + query-stream: func(statement: string, params: list) -> result; + + execute: func(statement: string, params: list) -> result; + + begin-transaction: func() -> result; + } + + resource db-transaction { + query: func(statement: string, params: list) -> result; + + query-stream: func(statement: string, params: list) -> result; + + execute: func(statement: string, params: list) -> result; + + commit: func() -> result<_, error>; + + rollback: func() -> result<_, error>; + } +} \ No newline at end of file diff --git a/wit/deps/rdbms/types.wit b/wit/deps/rdbms/types.wit new file mode 100644 index 0000000..e230f65 --- /dev/null +++ b/wit/deps/rdbms/types.wit @@ -0,0 +1,47 @@ +package wasi:rdbms@0.0.1; + +interface types { + + record uuid { + high-bits: u64, + low-bits: u64 + } + + variant ip-address { + ipv4(tuple), + ipv6(tuple), + } + + record mac-address { + octets: tuple + } + + record date { + year: s32, + month: u8, + day: u8 + } + + record time { + hour: u8, + minute: u8, + second: u8, + nanosecond: u32 + } + + record timestamp { + date: date, + time: time + } + + record timestamptz { + timestamp: timestamp, + offset: s32 + } + + record timetz { + time: time, + offset: s32 + } + +} \ No newline at end of file diff --git a/wit/deps/rdbms/world.wit b/wit/deps/rdbms/world.wit new file mode 100644 index 0000000..58c842b --- /dev/null +++ b/wit/deps/rdbms/world.wit @@ -0,0 +1,6 @@ +package wasi:rdbms@0.0.1; + +world imports { + import postgres; + import mysql; +} \ No newline at end of file