Originality declares that the source of this blog post is blog. csdn. netzhujunxxxxxarticledetails39251353. If you reprint it, please indicate the source. The author of this article original, mailbox zhujunxxxxx@163.com, if you have any questions, please contact the author stored procedure generated flowchart in the previous article we know by a stored procedure statement to generate
Originality declares that the source of this blog post is Ghost. The author of this article original, mailbox zhujunxxxxx@163.com, if you have any questions, please contact the author stored procedure generated flowchart in the previous article we know by a stored procedure statement to generate
Originality statement
The source of this blog post is workshop. Author of this article original, mailbox zhujunxxxxx@163.com, if you have any questions, please contact the author
Storage Process generation Flowchart
In the previous article, we learned that a syntax tree is generated by a stored procedure statement, but the syntax tree is stored in the database system. Here we provide a storage solution for the stored procedure.
The original SQL statement of the stored procedure is saved in a table. In addition, the syntax tree of the stored procedure is saved in the memory, which facilitates execution and does not need to be compiled again.
Execution flowchart of Stored Procedures
The key is how to execute the syntax tree. In order to reduce system coupling, we will not implement the functions in the original system. We will use the built-in functions of the system. The stored procedure is a procedural language and there must be a lot of computing, to reduce the complexity of the system, we need to allocate all the expressions encountered in the stored procedure to the database engine for execution. The SQL statements embedded in the stored procedure are also executed by the database engine.
In this way, we do not need to consider the processing of SQL statements. This reduces the Coupling Degree and increases the logic difficulty.
The flowchart I provided does not include all the execution branches. The specific execution process is like this, and there are some processing methods for none of the nodes.
This part is based on postgresql database practices.
Variable scope in Operation
During the execution of a stored procedure, the range of variables is global and some are local. To solve this problem, you can use the stack data structure to save the variables, I have provided this data structure in the previous article.
This is a figure given in a paper, but I use the Map in the stack style to make it easy to find. I will find it from the current layer when I do not find the variable, cannot be found at the upper layer. This data structure solves the problem of variable scope.
The source of this blog post is workshop. Author of this article original, mailbox zhujunxxxxx@163.com, if you have any questions, please contact the author