Skip to content

Commit ecb4599

Browse files
authored
Update PROTOCOL.md
1 parent f6d9f8b commit ecb4599

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

PROTOCOL.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ The format is `:VALUE `. Where `VALUE` is a string representation of the integer
6868
The format is `,VALUE `. Where `VALUE` is a string representation of the float/double value. In C, `VALUE` can be parsed using the `strtod` API. In this first implementation `VALUE` is guarantee to be a Double number.
6969

7070
### SCSP **Rowset**
71-
The format is `*LEN 0:VERS NROWS NCOLS DATA`. The whole command is built by eight parts:
71+
The format is `*LEN 0:VERS NROWS NCOLS DATA`. The whole command is built by ten parts:
7272

7373
1. The single `*` character
7474
2. LEN is a string representation of Rowset length (theoretically the maximum supported value is UINT64_MAX but it is usually much lower. LEN does not include the length of the first `*LEN ` part.
7575
3. A single space is used to separate LEN from 0:VERS
76-
4. a single `0:` string followed by a VERS number (a string representation of the number) which specifies the version of the Rowset (`1` means that only column names is included in the header, `2` means that column names, declared types, database names, table names and origin names are included in the header) `MORE ABOUT THE VERSION MEANING`
76+
4. a single `0:` string followed by a VERS number (a string representation of the number) which specifies the version of the Rowset.
77+
* `0`: means that only column names are included in the header
78+
* `1`: means that column names, declared types, database names, table names, origin names, not null flags, primary key flags and autoincrement flags are included in the header (one value for each column)
7779
5. A single space is used to separate 0:VERS from NROWS
7880
6. NROWS is a string representation of the number of rows contained in the Rowset (can be zero)
7981
7. A single space is used to separate NROWS from NCOLS
@@ -140,5 +142,18 @@ The format is `=LEN N VALUE1 VALUE2 ... VALUEN`. The whole command is built by N
140142
3. N is the number of items in the array
141143
4. N values separated by a space ` ` character
142144

145+
### SQLite Statements
146+
SQLite statements are usually sent from client to server as `SCSP Strings`.
147+
In case of bindings the whole statement can be sent as `SCSP Array`.
148+
149+
The server replies to READ statements (like SELECT) with a `SCSP Rowset` or SCSP Rowset Chunk. In case of WRITE statements (like INSERT, UPDATE, DELETE) the SQLite Cloud server replies with a `SCSP Array` in the following format: `=LEN 6 TYPE INDEX ROWID CHANGES TOTAL_CHANGES FINALIZED`:
150+
151+
1. TYPE is always 10 in this case
152+
2. INDEX is always 0 in this case
153+
3. ROWID is the result of the [sqlite3_last_insert_rowid](https://www.sqlite.org/c3ref/last_insert_rowid.html) function
154+
4. CHANGES is the result of the [sqlite3_changes64](https://www.sqlite.org/c3ref/changes.html) function
155+
5. TOTAL_CHANGES is the result of the [sqlite3_total_changes64](https://www.sqlite.org/c3ref/total_changes.html) function
156+
6. FINALIZED is always 1 in this case
157+
143158
---
144-
```Last revision: April 13th, 2022```
159+
```Last revision: January 24th, 2024```

0 commit comments

Comments
 (0)