Skip to content

Commit 5c473bd

Browse files
authored
Merge pull request #1 from justcoon/initial
wasi-rdbms 0.0.1
2 parents f3fc7fa + f8c3097 commit 5c473bd

File tree

8 files changed

+471
-0
lines changed

8 files changed

+471
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "wasi-rdbms"
3+
version = "0.0.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
homepage = "https://golem.cloud"
7+
repository = "https://github.com/golemcloud/wasi-rdbms"
8+
description = "WIT definitions and WASI RDBMS"
9+
10+
[lib]
11+
path = "src/lib.rs"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty library for packaging WIT and adapter modules

wit/mysql.wit

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package wasi:rdbms@0.0.1;
2+
3+
interface mysql {
4+
use types.{date, time, timestamp};
5+
6+
variant error {
7+
connection-failure(string),
8+
query-parameter-failure(string),
9+
query-execution-failure(string),
10+
query-response-failure(string),
11+
other(string)
12+
}
13+
14+
variant db-column-type {
15+
boolean,
16+
tinyint,
17+
smallint,
18+
mediumint,
19+
int,
20+
bigint,
21+
tinyint-unsigned,
22+
smallint-unsigned,
23+
mediumint-unsigned,
24+
int-unsigned,
25+
bigint-unsigned,
26+
float,
27+
double,
28+
decimal,
29+
date,
30+
datetime,
31+
timestamp,
32+
time,
33+
year,
34+
fixchar,
35+
varchar,
36+
tinytext,
37+
text,
38+
mediumtext,
39+
longtext,
40+
binary,
41+
varbinary,
42+
tinyblob,
43+
blob,
44+
mediumblob,
45+
longblob,
46+
enumeration,
47+
set,
48+
bit,
49+
json
50+
}
51+
52+
record db-column {
53+
ordinal: u64,
54+
name: string,
55+
db-type: db-column-type,
56+
db-type-name: string
57+
}
58+
59+
/// Value descriptor for a single database value
60+
variant db-value {
61+
boolean(bool),
62+
tinyint(s8),
63+
smallint(s16),
64+
// s24
65+
mediumint(s32),
66+
int(s32),
67+
bigint(s64),
68+
tinyint-unsigned(u8),
69+
smallint-unsigned(u16),
70+
// u24
71+
mediumint-unsigned(u32),
72+
int-unsigned(u32),
73+
bigint-unsigned(u64),
74+
float(f32),
75+
double(f64),
76+
decimal(string),
77+
date(date),
78+
datetime(timestamp),
79+
timestamp(timestamp),
80+
time(time),
81+
year(u16),
82+
fixchar(string),
83+
varchar(string),
84+
tinytext(string),
85+
text(string),
86+
mediumtext(string),
87+
longtext(string),
88+
binary(list<u8>),
89+
varbinary(list<u8>),
90+
tinyblob(list<u8>),
91+
blob(list<u8>),
92+
mediumblob(list<u8>),
93+
longblob(list<u8>),
94+
enumeration(string),
95+
set(string),
96+
bit(list<bool>),
97+
json(string),
98+
null
99+
}
100+
101+
/// A single row of values
102+
record db-row {
103+
values: list<db-value>
104+
}
105+
106+
record db-result {
107+
columns: list<db-column>,
108+
rows: list<db-row>
109+
}
110+
111+
/// A potentially very large and lazy stream of rows:
112+
resource db-result-stream {
113+
get-columns: func() -> list<db-column>;
114+
get-next: func() -> option<list<db-row>>;
115+
}
116+
117+
resource db-connection {
118+
open: static func(address: string) -> result<db-connection, error>;
119+
120+
query: func(statement: string, params: list<db-value>) -> result<db-result, error>;
121+
122+
query-stream: func(statement: string, params: list<db-value>) -> result<db-result-stream, error>;
123+
124+
execute: func(statement: string, params: list<db-value>) -> result<u64, error>;
125+
126+
begin-transaction: func() -> result<db-transaction, error>;
127+
}
128+
129+
resource db-transaction {
130+
query: func(statement: string, params: list<db-value>) -> result<db-result, error>;
131+
132+
query-stream: func(statement: string, params: list<db-value>) -> result<db-result-stream, error>;
133+
134+
execute: func(statement: string, params: list<db-value>) -> result<u64, error>;
135+
136+
commit: func() -> result<_, error>;
137+
138+
rollback: func() -> result<_, error>;
139+
}
140+
}

0 commit comments

Comments
 (0)