This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unsigned u64ToAsciiTable(uint64_t value, char* dst) { | |
| static const char digits[201] = | |
| "0001020304050607080910111213141516171819" | |
| "2021222324252627282930313233343536373839" | |
| "4041424344454647484950515253545556575859" | |
| "6061626364656667686970717273747576777879" | |
| "8081828384858687888990919293949596979899"; | |
| uint32_t const length = digits10(value); | |
| uint32_t next = length - 1; | |
| while (value >= 100) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Note: In this block of examples, newlines and whitespace characters have | |
| been inserted into the document inserted into the FTS table, and the expected | |
| results described in SQL comments. This is done to enhance readability only, | |
| they would not be present in actual SQLite commands or output. | |
| -- Create and populate an FTS table. | |
| CREATE VIRTUAL TABLE text USING fts4(); | |
| INSERT INTO text VALUES(' | |
| During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC | |
| and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Return the docid values associated with all documents that contain the | |
| -- two terms "sqlite" and "database", and/or contain the term "library". | |
| SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database OR library'; | |
| -- This query is equivalent to the above. | |
| SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database' | |
| UNION | |
| SELECT docid FROM docs WHERE docs MATCH 'library'; | |
| -- Query for the set of documents that contains the term "linux", and at least |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Virtual table declaration | |
| CREATE VIRTUAL TABLE docs USING fts3(); | |
| -- Virtual table data | |
| INSERT INTO docs(docid, content) VALUES(1, 'a database is a software system'); | |
| INSERT INTO docs(docid, content) VALUES(2, 'sqlite is a software system'); | |
| INSERT INTO docs(docid, content) VALUES(3, 'sqlite is a database'); | |
| -- Return the set of documents that contain the term "sqlite", and the | |
| -- term "database". This query will return the document with docid 3 only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Virtual table declaration. | |
| CREATE VIRTUAL TABLE docs USING fts4(); | |
| -- Virtual table data. | |
| INSERT INTO docs VALUES('SQLite is an ACID compliant embedded relational database management system'); | |
| -- Search for a document that contains the terms "sqlite" and "database" with | |
| -- not more than 10 intervening terms. This matches the only document in | |
| -- table docs (since there are only six terms between "SQLite" and "database" | |
| -- in the document). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Example schema | |
| CREATE VIRTUAL TABLE docs USING fts4(content); | |
| -- Example queries | |
| SELECT * FROM docs WHERE docs MATCH 'sqlite'; -- OK. | |
| SELECT * FROM docs WHERE docs.docs MATCH 'sqlite'; -- OK. | |
| SELECT * FROM docs WHERE main.docs.docs MATCH 'sqlite'; -- OK. | |
| SELECT * FROM docs WHERE main.docs MATCH 'sqlite'; -- Error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Example schema | |
| CREATE VIRTUAL TABLE mail USING fts3(subject, body); | |
| -- Example table population | |
| INSERT INTO mail(docid, subject, body) VALUES(1, 'software feedback', 'found it too slow'); | |
| INSERT INTO mail(docid, subject, body) VALUES(2, 'software feedback', 'no feedback'); | |
| INSERT INTO mail(docid, subject, body) VALUES(3, 'slow lunch order', 'was a software problem'); | |
| -- Example queries | |
| SELECT * FROM mail WHERE subject MATCH 'software'; -- Selects rows 1 and 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE VIRTUAL TABLE enrondata1 USING fts3(content TEXT); /* FTS3 table */ | |
| CREATE TABLE enrondata2(content TEXT); /* Ordinary table */ | |
| SELECT count(*) FROM enrondata1 WHERE content MATCH 'linux'; /* 0.03 seconds */ | |
| SELECT count(*) FROM enrondata2 WHERE content LIKE '%linux%'; /* 22.5 seconds */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct node | |
| { | |
| struct node * next; | |
| .... | |
| } node; | |
| typedef bool (* remove_fn)(node const * v); | |
| // Remove all nodes from the supplied list for which the | |
| // supplied remove function returns true. |