"how numbers are stored and used in computers"
The btree.c
file is a core component of SQLite's storage engine. It implements the B-tree structures that manage how data is stored and retrieved from the database. a B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time.
code.txt1rc = allocateBtreePage(pBt, &pPage, &pgno, nearby, flags); 2zeroPage(pPage, flags | PTF_LEAF);
The page header is the first 64 bytes of the page. The page header contains information about the page, such as the page type, the page number, and the page size.
code.txt1rc = balance(pCur);
code.txt1rc = btreeCreateTable(pBt, pTable, zName, nCol, aCol, aType, aColl, pSchema);
code.txt1rc = sqlite3BtreeMovetoUnpacked(pCur, pKey, biasRight, &pCur->ix, &loc);
code.txt1rc = sqlite3BtreeInsert(pCur, pKey, pData, nData, pRowid); 2rc = sqlite3BtreeDelete(pCur, pKey, pData, nData, pRowid);
code.txt1rc = sqlite3BtreeClearCursor(pCur); 2rc = sqlite3BtreeCloseCursor(pCur);
code.txt1rc = sqlite3BtreeClose(pBt);
code.txt1rc = sqlite3BtreeGetPage(pBt, pgno, &pPage, flags);
The page is the smallest unit of data in SQLite. The page is 512 bytes.
code.txt1sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL); 2sqlite3_step(stmt); 3sqlite3_finalize(stmt);
code.txt1sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL); 2sqlite3_step(stmt); 3sqlite3_finalize(stmt);
The B-tree header is the next 64 bytes of the page. The B-tree header contains information about the B-tree, such as the root page number, the page type, and the page size.
code.txt1sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL); 2sqlite3_step(stmt); 3sqlite3_finalize(stmt);
The B-tree leaf page is the next 64 bytes of the page. The B-tree leaf page contains information about the B-tree, such as the root page number, the page type, and the page size.
code.txt1sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL); 2sqlite3_step(stmt); 3sqlite3_finalize(stmt);
The B-tree interior page is the next 64 bytes of the page. The B-tree interior page contains information about the B-tree, such as the root page number, the page type, and the page size.
code.txt1sqlite3_prepare_v2(db, "SELECT * FROM test", -1, &stmt, NULL); 2sqlite3_step(stmt); 3sqlite3_finalize(stmt);