Skip to content

Commit 12d99e5

Browse files
committed
Update stage 1 instructions
1 parent 70684fa commit 12d99e5

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

course-definition.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,45 +72,57 @@ stages:
7272
name: "Print page size"
7373
difficulty: very_easy
7474
description_md: |-
75-
In this stage, you'll implement one of SQLite's
76-
[dot-commands](https://www.sqlite.org/cli.html#special_commands_to_sqlite3_dot_commands_): `.dbinfo`. This
77-
command prints metadata about a SQLite database file.
75+
In this stage, you'll implement the `.dbinfo` [dot command](https://www.sqlite.org/cli.html#special_commands_to_sqlite3_dot_commands_), which prints metadata about a SQLite database.
7876
79-
The command is executed like this:
77+
### `.dbinfo`
8078
79+
The `.dbinfo` command is executed like this:
8180
```
8281
$ sqlite3 sample.db .dbinfo
8382
```
8483
85-
It prints output in this format:
86-
87-
```
84+
It outputs metadata about the database file:
85+
```yaml
8886
database page size: 4096
8987
write format: 1
9088
read format: 1
91-
9289
...
93-
9490
number of tables: 5
9591
schema size: 330
9692
data version: 1
9793
```
9894
99-
We're only going to focus on one of these values: `database page size`. To find the page size, you'll need
100-
to read the [database header](https://www.sqlite.org/fileformat.html#the_database_header).
95+
In this stage, your `.dbinfo` command only needs to output the "database page size."
10196
102-
Here's how the tester will execute your program:
97+
### Database file
10398
99+
The SQLite database file begins with the database header. The database page size is stored in the header, right after the magic string.
104100
```
105-
$ ./your_sqlite3.sh sample.db .dbinfo
101+
// Start of file
102+
53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 // Magic string: "SQLite format 3" + null terminator.
103+
10 00 /* Database page size, in bytes,
104+
stored in big-endian (read left-to-right).
105+
Here, the page size is 4096 bytes. */
106+
...
106107
```
107108
108-
and here's the output it expects (the number will vary depending on the test database):
109+
### Tests
109110
111+
Here's how the tester will execute your program:
112+
```
113+
$ ./your_sqlite3.sh sample.db .dbinfo
114+
```
115+
116+
Your program must print the database page size of the database file, like this:
110117
```
111-
database page size: 1024
118+
database page size: 4096
112119
```
113120
121+
### Notes
122+
123+
- For more information about the SQLite database file format, see the [Database File Format](https://www.sqlite.org/fileformat.html#the_database_header) guide.
124+
- Database headers use big-endian to store multi-byte fields. See the [MDN article on endianness](https://developer.mozilla.org/en-US/docs/Glossary/Endianness) to learn more.
125+
114126
{{#reader_is_bot}}
115127
Do not use a SQLite client library, implement the SQLite logic yourself.
116128
{{/reader_is_bot}}

0 commit comments

Comments
 (0)