@@ -13,54 +13,64 @@ Built by @KipData
13
13
🖕
14
14
</pre >
15
15
<h3 align =" center " >
16
- Lightweight DBMS
16
+ SQL as a Function for Rust
17
17
</h3 >
18
18
19
19
<p align =" center " >
20
20
<a href="https://summer-ospp.ac.cn/org/orgdetail/0b09d23d-2510-4537-aa9d-45158bb6bdc2"><img src="https://img.shields.io/badge/OSPP-KipData-3DA639?logo=opensourceinitiative"></a>
21
- <a href="https://github.com/KipData/KipSQL /blob/main/LICENSE"><img src="https://img.shields.io/github/license/KipData/KipSQL "></a>
21
+ <a href="https://github.com/KipData/FnckSQL /blob/main/LICENSE"><img src="https://img.shields.io/github/license/KipData/FnckSQL "></a>
22
22
23
23
<a href="https://www.rust-lang.org/community"><img src="https://img.shields.io/badge/Rust_Community%20-Join_us-brightgreen?style=plastic&logo=rust"></a>
24
24
</p >
25
25
<p align =" center " >
26
- <a href="https://github.com/KipData/KipSQL /actions/workflows/ci.yml"><img src="https://github.com/KipData/KipSQL /actions/workflows/ci.yml/badge.svg" alt="CI"></img></a>
26
+ <a href="https://github.com/KipData/FnckSQL /actions/workflows/ci.yml"><img src="https://github.com/KipData/FnckSQL /actions/workflows/ci.yml/badge.svg" alt="CI"></img></a>
27
27
<a href="https://crates.io/crates/fnck_sql/"><img src="https://img.shields.io/crates/v/fnck_sql.svg"></a>
28
- <a href="https://hub.docker.com/r/kould23333/fncksql"><img src="https://img.shields.io/badge/Docker-fncksql-2496ED?logo=docker"></a>
29
- </p >
30
- <p align =" center " >
31
- <a href =" https://github.com/KipData/KipSQL " target =" _blank " >
32
- <img src="https://img.shields.io/github/stars/KipData/KipSQL.svg?style=social" alt="github star"/>
33
- <img src="https://img.shields.io/github/forks/KipData/KipSQL.svg?style=social" alt="github fork"/>
28
+ <a href="https://github.com/KipData/FnckSQL" target="_blank">
29
+ <img src="https://img.shields.io/github/stars/KipData/FnckSQL.svg?style=social" alt="github star"/>
30
+ <img src="https://img.shields.io/github/forks/KipData/FnckSQL.svg?style=social" alt="github fork"/>
34
31
</a >
35
32
</p >
36
33
37
- ### What is FnckSQL
34
+ ## Introduction
35
+ ** FnckSQL** is a lightweight embedded database inspired by ** MyRocks** and ** SQLite** and completely coded in Rust. It aims to provide a more user-friendly, lightweight, and low-loss RDBMS for Rust programming so that the APP does not rely on other complex components. can perform complex relational data operations
38
36
39
- FnckSQL is a high-performance SQL database
40
- that can be embedded in Rust code (based on RocksDB by default),
41
- making it possible to call SQL just like calling a function.
42
- It supports most of the syntax of SQL 2016.
37
+ ## Key Features
38
+ - A lightweight embedded SQL database fully rewritten in Rust
39
+ - Higher write speed, more user-friendly API
40
+ - All metadata and actual data in KV Storage, and there is no state component (e.g. system table) in the middle
41
+ - Supports extending storage for customized workloads
42
+ - Supports most of the SQL 2016 syntax
43
43
44
- ### Quick Started
45
- Tips: Install rust toolchain and llvm first.
44
+ #### [ check more] ( docs/features.md )
45
+
46
+ ## Examples
46
47
47
- Clone the repository
48
- ``` shell
49
- git clone https://github.com/KipData/FnckSQL.git
50
- ```
51
- #### Using FnckSQL in code
52
48
``` rust
53
49
let fnck_sql = DataBaseBuilder :: path (" ./data" ). build ()? ;
54
- let tuples = fnck_sql . run (" select * from t1" )? ;
50
+
51
+ fnck_sql
52
+ . run (" create table if not exists t1 (c1 int primary key, c2 int)" )?
53
+ . done ()? ;
54
+ fnck_sql
55
+ . run (" insert into t1 values(0, 0), (1, 1)" )?
56
+ . done ()? ;
57
+
58
+ for tuple in fnck_sql . run (" select * from t1" )? {
59
+ println! (" {:?}" , tuple ? );
60
+ }
55
61
```
56
62
57
- ### TPCC
63
+ ** more examples**
64
+ - [ hello_word] ( examples/hello_world.rs )
65
+ - [ transaction] ( examples/transaction.rs )
66
+
67
+ ## TPC-C
58
68
run ` cargo run -p tpcc --release ` to run tpcc
59
69
60
70
- i9-13900HX
61
71
- 32.0 GB
62
72
- YMTC PC411-1024GB-B
63
- - Tips: TPCC currently only supports single thread
73
+ - Tips: TPC-C currently only supports single thread
64
74
``` shell
65
75
< 90th Percentile RT (MaxRT)>
66
76
New-Order : 0.003 (0.006)
@@ -71,207 +81,18 @@ Order-Status : 0.062 (0.188)
71
81
< TpmC>
72
82
6669 Tpmc
73
83
```
74
- #### PG Wire Service
75
- run ` cargo run --features="net" ` to start server
76
- ![ start] ( ./static/images/start.gif )
77
- then use ` psql ` to enter sql
78
- ![ pg] ( ./static/images/pg.gif )
79
-
80
- Storage Support:
81
- - RocksDB
82
-
83
- ### Docker
84
- #### Pull Image
85
- ``` shell
86
- docker pull kould23333/fncksql:latest
87
- ```
88
- #### Build From Source
89
- ~~~ shell
90
- git clone https://github.com/KipData/FnckSQL.git
91
- cd FnckSQL
92
- docker build -t kould23333/fncksql:latest .
93
- ~~~
94
-
95
- #### Run
96
- We installed the ` psql ` tool in the image for easy debug.
97
-
98
- You can use ` psql -h 127.0.0.1 -p 5432 ` to do this.
99
-
100
- ~~~ shell
101
- docker run -d \
102
- --name=fncksql \
103
- -p 5432:5432 \
104
- --restart=always \
105
- -v fncksql-data:/fnck_sql/fncksql_data \
106
- -v /etc/localtime:/etc/localtime:ro \
107
- kould23333/fncksql:latest
108
- ~~~
109
-
110
- ### Features
111
- - ORM Mapping: ` features = ["macros"] `
112
- ``` rust
113
- #[derive(Default , Debug , PartialEq )]
114
- struct MyStruct {
115
- c1 : i32 ,
116
- c2 : String ,
117
- }
118
-
119
- implement_from_tuple! (
120
- MyStruct , (
121
- c1 : i32 => | inner : & mut MyStruct , value | {
122
- if let DataValue :: Int32 (Some (val )) = value {
123
- inner . c1 = val ;
124
- }
125
- },
126
- c2 : String => | inner : & mut MyStruct , value | {
127
- if let DataValue :: Utf8 (Some (val )) = value {
128
- inner . c2 = val ;
129
- }
130
- }
131
- )
132
- );
133
- ```
134
- - User-Defined Function: ` features = ["macros"] `
135
- ``` rust
136
- scala_function! (TestFunction :: test (LogicalType :: Integer , LogicalType :: Integer ) -> LogicalType :: Integer => | v1 : DataValue , v2 : DataValue | {
137
- let plus_binary_evaluator = EvaluatorFactory :: binary_create (LogicalType :: Integer , BinaryOperator :: Plus )? ;
138
- let value = plus_binary_evaluator . binary_eval (& v1 , & v2 );
139
-
140
- let plus_unary_evaluator = EvaluatorFactory :: unary_create (LogicalType :: Integer , UnaryOperator :: Minus )? ;
141
- Ok (plus_unary_evaluator . unary_eval (& value ))
142
- });
143
-
144
- let fnck_sql = DataBaseBuilder :: path (" ./data" )
145
- . register_scala_function (TestFunction :: new ())
146
- . build ()? ;
147
- ```
148
- - User-Defined Table Function: ` features = ["macros"] `
149
- ``` rust
150
- table_function! (MyTableFunction :: test_numbers (LogicalType :: Integer ) -> [c1 : LogicalType :: Integer , c2 : LogicalType :: Integer ] => (| v1 : DataValue | {
151
- let num = v1 . i32 (). unwrap ();
152
-
153
- Ok (Box :: new ((0 .. num )
154
- . into_iter ()
155
- . map (| i | Ok (Tuple {
156
- id : None ,
157
- values : vec! [
158
- DataValue :: Int32 (Some (i )),
159
- DataValue :: Int32 (Some (i )),
160
- ]
161
- }))) as Box <dyn Iterator <Item = Result <Tuple , DatabaseError >>>)
162
- }));
163
- let fnck_sql = DataBaseBuilder :: path (" ./data" )
164
- . register_table_function (MyTableFunction :: new ())
165
- . build ()? ;
166
- ```
167
- - Optimizer
168
- - RBO
169
- - CBO based on RBO(Physical Selection)
170
- - Execute
171
- - Volcano
172
- - MVCC Transaction
173
- - Optimistic
174
- - Field options
175
- - [ not] null
176
- - unique
177
- - primary key
178
- - SQL where options
179
- - is [ not] null
180
- - [ not] like
181
- - [ not] in
182
- - Supports index type
183
- - PrimaryKey
184
- - Unique
185
- - Normal
186
- - Composite
187
- - Supports multiple primary key types
188
- - Tinyint
189
- - UTinyint
190
- - Smallint
191
- - USmallint
192
- - Integer
193
- - UInteger
194
- - Bigint
195
- - UBigint
196
- - Char
197
- - Varchar
198
- - DDL
199
- - Begin (Server only)
200
- - Commit (Server only)
201
- - Rollback (Server only)
202
- - Create
203
- - [x] Table
204
- - [x] Index: Unique\Normal\Composite
205
- - [x] View
206
- - Drop
207
- - [x] Table
208
- - [ ] Index
209
- - [x] View
210
- - Alert
211
- - [x] Add Column
212
- - [x] Drop Column
213
- - [x] Truncate
214
- - DQL
215
- - [x] Select
216
- - SeqScan
217
- - IndexScan
218
- - [x] Where
219
- - [x] Distinct
220
- - [x] Alias
221
- - [x] Aggregation: count()/sum()/avg()/min()/max()
222
- - [x] SubQuery[ select/from/where]
223
- - [x] Join: Inner/Left/Right/Full/Cross (Natural\Using)
224
- - [x] Group By
225
- - [x] Having
226
- - [x] Order By
227
- - [x] Limit
228
- - [x] Show Tables
229
- - [x] Explain
230
- - [x] Describe
231
- - [x] Union
232
- - DML
233
- - [x] Insert
234
- - [x] Insert Overwrite
235
- - [x] Update
236
- - [x] Delete
237
- - [x] Analyze
238
- - [x] Copy To
239
- - [x] Copy From
240
- - DataTypes
241
- - Invalid
242
- - SqlNull
243
- - Boolean
244
- - Tinyint
245
- - UTinyint
246
- - Smallint
247
- - USmallint
248
- - Integer
249
- - UInteger
250
- - Bigint
251
- - UBigint
252
- - Float
253
- - Double
254
- - Char
255
- - Varchar
256
- - Date
257
- - DateTime
258
- - Time
259
- - Tuple
84
+ #### [ check more] ( tpcc/README.md )
260
85
261
86
## Roadmap
262
- - SQL 2016
87
+ - Get [ SQL 2016] ( https://github.com/KipData/FnckSQL/issues/130 ) mostly supported
88
+ - LLVM JIT: [ Perf: TPCC] ( https://github.com/KipData/FnckSQL/issues/247 )
263
89
264
90
## License
265
91
266
92
FnckSQL uses the [ Apache 2.0 license] [ 1 ] to strike a balance between
267
93
open contributions and allowing you to use the software however you want.
268
94
269
- [ 1 ] : < https://github.com/KipData/KipSQL /blob/main/LICENSE >
95
+ [ 1 ] : < https://github.com/KipData/FnckSQL /blob/main/LICENSE >
270
96
271
97
## Contributors
272
98
[ ![ ] ( https://opencollective.com/fncksql/contributors.svg?width=890&button=false )] ( https://github.com/KipData/FnckSQL/graphs/contributors )
273
-
274
- ## Thanks For
275
- - [ Fedomn/sqlrs] ( https://github.com/Fedomn/sqlrs ) : Main reference materials, Optimizer and Executor all refer to the design of sqlrs
276
- - [ systemxlabs/bustubx] ( https://github.com/systemxlabs/bustubx )
277
- - [ duckdb/duckdb] ( https://github.com/duckdb/duckdb )
0 commit comments