SQLite - SPLessons

SQLite Architecture

Home > Lesson > Chapter 3
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQLite Architecture

SQLite Architecture

shape Description

SQLite Architecture portrays the SQLite library and is very supportive for the clients who wants to understand the concepts and can alter the internal working components of SQLite. The SQLite block structure describes the working components, and each component will provide a better understanding. The present version of SQLite is 3.0 and differs from earlier versions like version 2.7 and version 2.8. And the block structure of SQLite is as follows

shape Conceptual figure

Below is the SQLite Architecture.

Interface

The functions found in legacy.c, main.c and vdbeapi.c will give the public interface along with SQLite library in light of the source records that are containing in another documents and can stretch these auxiliary information with checked files.In table.c, SQLite3_get_table() will be as implemented.SQLite3_mprintf() and is found in print.c.In tokenize.c, where SQLite3_complete() is available.The tclsqlite.cwill actualizes the TCL interface.

Tokenizer

The strings comprising of SQL proclamations have to be accomplished, and these strings will be passed to the tokenizer by the interface. And the operation of tokenizer is to divide the strings into tokens and send it to parser in an order. And tokenizer is coded in C++ dialect and rests in a file tokenize.c.In the structure of tokenizer, generally the parser will be called by the tokenizer.

Parser

Parser is a fragment that relegates intending to tokens taking the connection into account. By utilizing Lemon LALR1, the parser for SQLite is generated. Both YACC/BISON and Lemon will perform the same operation, except lemon will utilize the input syntax differently and which is having limited mistakes and at the same time a parser will be generated which safe-threads and penetrates. Furthermore, the ideas of lemon portrays the destructor which is non-terminal, and does not discharge the memory while error syntaxes occurrs. And the parse.y will contain the source file that is a part of lemon. And these lemon program are not found in machines that are developed based on the features of temporary files.

Code generator

Ensuring with the parser amasses tokens within exhaustive SQL statements, it calls the code generator to create virtual machine code that will perform all the fundamental steps that the SQL articulations demand. The code generators consisting of various files such as The delete.c,insert.c,attach.c,trigger.c,update.c,select.c files control the source code in the SQL proclamation.The expression for code generator will be controlled by expr.c file and the where.c will control the source code generation for select, update and delete statements using the where clause and all other proclamation will be coded out of build.c and the sqlite3_set_authorizer() functionalities will be implemented using auth.c file.

B-tree

The database of SQLite is upheld on drives that are implemented using the source documents containing in the B-tree. And for every index and table in the database a isolated B-tree is used. And each and every B-tree will be preserved in similar files in the disk and complete format of the file will be listed in tremendous arrangement while starting of a btree.c.

OS Interface

To contribute adaptability among  Win32 and POSIX working framework, SQLite uses a reflection layer to fuse with the working framework. Each upheld working framework has its own usage: os_win.c for Windows, os_unix.c for Unix.The interface to the OS reflection layer is characterized in os.h. Each of these working particular executes commonly has its own particular header document like  os_win.h,os_unix.h.

Utilities

Caseless string comparison and memory allocation patterns are positioned in util.c. Symbol tables utilized by the parser are kept up by hash tables established in hash.c. SQLite has its own private usuage of printf() in printf.c and its own particular irregular number generator in random.c. The utf.c source document accommodate Unicode change subroutines.

Text code

In the event where relapse approval character number, more than a large portion of the aggregate code base of SQLite, is dedicated to testing. There are numerous affirm() explanations in the principle code documents. There are numerous affirm() explanations in the principle code documents. In extra, the source records test1.c through test5.c together with md5.c actualize expansions utilized for testing purpose. The os_test.c back-end interface is used to recreate power disappointments to check the accident recuperation instrument in the pager.

Summary

shape Key Points

  • SQLite architecture - Describes the working frame of SQLite library and other components.