Database Technology-Design and Implementation of stored procedures (2)

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.