CN115630085B - Database variable parameter scope control method, device and equipment - Google Patents
Database variable parameter scope control method, device and equipment Download PDFInfo
- Publication number
- CN115630085B CN115630085B CN202211533168.XA CN202211533168A CN115630085B CN 115630085 B CN115630085 B CN 115630085B CN 202211533168 A CN202211533168 A CN 202211533168A CN 115630085 B CN115630085 B CN 115630085B
- Authority
- CN
- China
- Prior art keywords
- parameter
- variable
- query statement
- statement
- target query
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2246—Trees, e.g. B+trees
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/253—Grammatical analysis; Style critique
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a method, a device and equipment for controlling the scope of database variable parameters, which are used for acquiring sent SQL sentences; analyzing the nesting relation among all layers of query statements in the SQL statement; carrying out syntax legality analysis and semantic legality analysis on a target query statement, establishing a parameter object list according to prompt contents preset in the target query statement, and checking the legality of parameters; establishing an abstract syntax tree of the target query statement, and storing the parameter object list into a structure of the abstract syntax tree; constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation; and executing the complete syntax tree of the SQL statement and returning an execution result. According to the method, the device and the equipment for controlling the scope of the database variable parameter, the scope of the database variable parameter can be controlled in a finer granularity mode.
Description
Technical Field
The invention belongs to the technical field of databases, and particularly relates to a method, a device and equipment for controlling a scope of a database variable parameter.
Background
There may be a large number of system-level (acting on the current database service) variable parameters in the database product, which are very widely acting, including variable parameters for optimization, variable parameters for isolation of certain functions, and variable parameters for intervention in certain intermediate behaviors of the database. No matter which variable parameter is very important for the database, but the current methods for setting the parameter are only two, namely, the method writes in all relevant configuration files to achieve the purpose of global validity of service level, and the method sets in the database client side by using an independent SQL statement.
However, both the scope of influence (influence range) of the two methods in the database may cause a negative effect hidden danger that the influence is too large, the method one is used for the global effectiveness of the service, namely, the algorithm of all executed SQL statements is influenced, and the method two is used for the effectiveness of the current connection and also used for all the SQL statements operated by the current connection. If a parameter is modified, execution of other statements may be affected and the result may be immeasurable.
Therefore, it is of great significance to control the scope of database variable parameters more finely.
Disclosure of Invention
In view of this, the present invention is directed to a method, an apparatus, and a device for controlling scope of database variable parameters, so as to control the scope of the database variable parameters more finely.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
in a first aspect, the present application provides a method for controlling scope of database variable parameters, including:
acquiring an SQL statement sent by a client;
analyzing the SQL statement and determining the nesting relation among all layers of query statements in the SQL statement;
carrying out syntax legality analysis and semantic legality analysis on a target query statement, establishing a parameter object list according to prompt contents preset in the target query statement, and checking the legality of parameters; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one layer of multi-layer query statements in the SQL statement;
establishing an abstract syntax tree of the target query statement, and storing the parameter object list into a structure of the abstract syntax tree;
constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation;
and executing the complete syntax tree of the SQL statement and returning an execution result.
Optionally, the parsing syntax validity and semantic validity of the target query statement, creating a parameter object list according to a prompt content preset in the target query statement, and checking validity of the parameter includes:
parsing a target query statement to form a structural entity of the target query statement, checking the syntax validity of the target query statement, if the syntax validity is valid, continuing to execute, and if the syntax validity is not valid, reporting an error;
semantic analysis is carried out on the structural entity of the target query statement, the semantic validity of the structural entity of the target query statement is checked, if the structural entity of the target query statement is legal, the execution is continued, and if the structural entity of the target query statement is not legal, an error is reported;
and carrying out parameter objectification on the prompt content in the target query statement, establishing a parameter object list, checking the validity of the parameter, if the parameter is legal, continuing to execute the operation, and if the parameter is not legal, reporting an error.
Optionally, the preset prompting content refers to prompting content written behind a keyword in the target query statement when the user generates the SQL statement.
Optionally, if scope information of the parameter variable of the hint content is that the parent query statement influences the inheritance relationship of the child query statement, a hint including a variable name and a new variable value is set;
and if scope information of variable parameters of the prompt content only acts on the query statement of the layer where the prompt content is located, setting a prompt comprising a scope identifier, a variable name and a new variable value, wherein the scope identifier is local.
Optionally, after constructing all abstract syntax trees in the SQL statement as a complete syntax tree according to the nesting relationship, the method includes:
traversing the complete syntax tree, and determining the incidence relation between the parameter variables and the abstract syntax tree acted by the parameter variables according to the action domain information corresponding to each parameter variable;
storing the parameter object list of the parameter variable to a corresponding abstract syntax tree according to the incidence relation;
the executing the complete syntax tree of the SQL statement comprises the following steps:
and each layer of abstract syntax tree in the SQL statement modifies parameters according to the corresponding parameter object list and executes the complete syntax tree of the SQL statement.
In a second aspect, the present application further provides a database variable parameter scope control apparatus, including:
the acquisition module is used for acquiring SQL sentences sent by the client;
the first analysis module is used for analyzing the SQL statement and determining the nesting relation among all layers of query statements in the SQL statement;
the second analysis module is used for carrying out syntax legality analysis and semantic legality analysis on the target query statement, establishing a parameter object list according to prompt contents preset in the target query statement and checking the legality of parameters; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one layer of multi-layer query statements in the SQL statement;
the first generation module is used for establishing an abstract syntax tree of the target query statement and storing the parameter object list into a structure of the abstract syntax tree;
the second generation module is used for constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation;
and the execution module is used for executing the complete syntax tree of the SQL statement and returning an execution result.
Optionally, the second parsing module includes:
the grammar parsing submodule is used for carrying out grammar parsing on a target query statement to form a structural entity of the target query statement, checking the grammar validity of the target query statement, if the grammar validity is legal, continuing to execute, and if the grammar validity is not legal, reporting an error;
the grammar analysis submodule is used for carrying out semantic analysis on the structural entity of the target query statement and checking the semantic validity of the structural entity of the target query statement, if the structural entity of the target query statement is legal, the execution is continued, and if the structural entity of the target query statement is not legal, an error is reported;
and the objectification sub-module is used for objectifying the parameters of the prompt contents in the target query statement, establishing a parameter object list, checking the validity of the parameters, continuing to execute if the parameters are legal, and reporting an error if the parameters are not legal.
Optionally, the apparatus further includes an association module, configured to traverse the complete syntax tree, and determine, according to scope information corresponding to each parameter variable, an association relationship between the parameter variable and an abstract syntax tree on which the parameter variable acts; storing the parameter object list of the parameter variable to a corresponding abstract syntax tree according to the incidence relation;
the execution module is further configured to modify parameters of each layer of abstract syntax tree in the SQL statement according to the corresponding parameter object list, and execute the complete syntax tree of the SQL statement.
In a third aspect, the present application further provides a database variable parameter scope control apparatus, including a memory and a processor, where the memory is used to store a code or a program, and the processor is used to call the code or the program to implement the database variable parameter scope control method according to the first aspect.
Compared with the prior art, the method, the device and the equipment for controlling the scope of the database variable parameters have the following beneficial effects:
the method sets parameter variables in a prompting mode, establishes the abstract syntax tree of each layer of query statements and establishes the abstract syntax tree according to the nesting relation of each layer of query statements to complete the syntax tree, and completely discloses the implementation mode of the whole SQL statement query process. The corresponding prompt content is set in the query sentence needing parameter adjustment, scope information and parameter variables are set in the prompt content, the scope of the variable parameter of each layer of query sentence with the prompt content is definitely set, and the requirement of controlling the variable parameter with smaller granularity in a service scene is effectively met.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate an embodiment of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
fig. 1 is a flowchart of a method for controlling scope of database variable parameters according to an embodiment of the present invention.
Fig. 2 is a structural diagram of a scope control apparatus for database variable parameters according to an embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
In the description of the present invention, it is to be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like, indicate orientations or positional relationships based on those shown in the drawings, and are used only for convenience in describing the present invention and for simplicity in description, and do not indicate or imply that the referenced devices or elements must have a particular orientation, be constructed and operated in a particular orientation, and thus, are not to be construed as limiting the present invention. Furthermore, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first," "second," etc. may explicitly or implicitly include one or more of that feature. In the description of the present invention, "a plurality" means two or more unless otherwise specified.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art through specific situations.
The present invention will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 is a flowchart of a database variable parameter scope control method provided in an embodiment of the present application, and referring to fig. 1, the database variable parameter scope control method includes the specific steps of:
s101, obtaining the SQL sentences sent by the client.
S102, analyzing the SQL statement, and determining the nesting relation among all layers of query statements in the SQL statement.
S103, carrying out syntax legality analysis and semantic legality analysis on a target query statement, establishing a parameter object list according to prompt contents preset in the target query statement, and checking the legality of a parameter; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one of multiple layers of query statements in the SQL statement.
When the user generates the SQL statement, the prompt content is compiled behind the keyword in the target query statement.
If the scope information of the parameter variable of the prompt content influences the inheritance relationship of the child query statement for the parent query statement, setting a prompt comprising a variable name and a new variable value, wherein the statement structure of the prompt is "/+ the variable name (new variable value)/";
if scope information of variable parameters of the prompt content only acts on the query statement of the layer where the prompt content is located, a prompt including a scope identifier, a variable name and a new variable value is set, and if the scope identifier is local, the statement structure of the prompt is "/+ local variable name (new variable value)/".
S104, establishing an abstract syntax tree of the target query statement, and storing the parameter object list into a structure of the abstract syntax tree.
And S105, constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation.
And S106, executing the complete syntax tree of the SQL statement and returning an execution result.
Based on the above steps S101 to S106, the present application sets parameter variables in a prompting manner, and completely discloses the implementation manner of the entire SQL statement query process by establishing the abstract syntax trees of each layer of query statements and establishing the abstract syntax trees according to the nesting relationship of each layer of query statements. The corresponding prompt content is set in the query sentence needing parameter adjustment, scope information and parameter variables are set in the prompt content, the scope of the variable parameter of each layer of query sentence with the prompt content is definitely set, and the requirement of controlling the variable parameter with smaller granularity in a service scene is effectively met.
In the above embodiments, there may be multiple implementations of step S103, and one implementation of the implementation is described below.
A1, grammatical analysis is carried out on a target query statement to form a structural entity of the target query statement, grammatical validity of the target query statement is checked, if the syntax validity is legal, execution is continued, and if the syntax validity is not legal, an error is reported.
The syntax analysis of the target query statement is to analyze the syntax and the lexical of the SQL statement so that the common SQL character string becomes a meaningful SQL statement structural entity. For example, SELECT represents a query statement and UPDATE represents an UPDATE statement.
And A2, carrying out semantic analysis on the structural entity of the target query statement, checking the semantic validity of the structural entity of the target query statement, if the structural entity of the target query statement is legal, continuing to execute the semantic analysis, and if the structural entity of the target query statement is not legal, reporting an error.
And performing semantic analysis on the structural entity of the target query statement, namely analyzing the semantics of the query statement at the current layer to ensure that the SQL conforms to the SQL specification. Such as query statements, must be written in the order of select. SELECT is followed by the projection column of the output, FROM is followed by the table name, WHERE represents the condition, etc.
And A3, objectifying parameters of the prompt contents in the target query statement, establishing a parameter object list, checking the validity of the parameters, continuing to execute if the parameters are legal, and reporting an error if the parameters are not legal.
The hint content is that hints are added behind the keywords, and there may be one or more hints, and the structure of each hint is/+ variable 1 (variable value 1)/(scope information is an inheritance relationship, and the parameter adjustment change of the parent query statement will be inherited to the child query statement), or/+ local variable 1 (variable value 1)/(scope information is private, and the parameter adjustment change is executed only in the query statement at the current layer).
The prompt is added when the user writes an SQL statement.
Parameter objectification is the conversion of a normal character string into a program object after parsing. The prompt/+ variable 1 (variable value 1)/, after parameter objectification, is converted into a program object class { object name, object value }, one character is not needed to analyze, the object name or the object value is determined integrally, and the reading efficiency of subsequent query statements is improved.
In the above embodiment, there may be multiple implementations of steps S104-S105, and one implementation will be described below.
B1, traversing the complete syntax tree, and determining the incidence relation between the parameter variables and the abstract syntax tree acted by the parameter variables according to the action domain information corresponding to each parameter variable.
The incidence relation determines the scope of the parameter variable and the abstract syntax tree corresponding to the role.
If the inheritance relationship is specified in the parent query, but if the child query is not specified then the child query by default continues with the parameter variable specified by the parent query, and the sibling queries are similar.
If the instruction scope information in the father query is private, the variable parameter is only used as the current layer of the scope.
And B2, storing the parameter object list of the parameter variable to the uppermost query syntax tree in all the query syntax trees which can be acted by the parameter variable according to the incidence relation.
And B3, modifying parameters of each layer of abstract syntax tree in the SQL statement according to the corresponding parameter object list, and executing the complete syntax tree of the SQL statement.
According to the steps B1-B3, the variable parameter list stored in each layer of query syntax tree is avoided, the space is saved, and the query efficiency is improved.
Specifically, for ease of understanding, the following description will be made in conjunction with the sentence structure.
SELECT/+ local parameter 1 (new parameter value)/table 1 column 1 FROM table 1 WHERE table 1 column 2 IN (SELECT table 2 column 1 FROM table 2 WHERE table 2 column 2>0);
parameter 1 is now a private scope (with the local prefix noted IN the hint) that is not passed to the IN sub-query, and the value of parameter 1 IN the IN sub-query is still the original value rather than the new parameter value 1.
SELECT/+ parameter 1 (new parameter value 1)/table 1 column 1 FROM table 1 WHERE table 1 column 2 IN (SELECT table 2 column 1 FR OM table 2 WHERE table 2 column 2>0);
parameter 1 at this point passes the new parameter value 1 to the in sub-query to achieve an inheritance of the sub-query's set-parameters scope to its parent query.
SELECT/+ parameter 1 (new parameter value 1)/column 1 FROM WHERE table 1 column 2 IN (SELECT/+ parameter 1 (parameter value 2)/column 2 FROM WHERE table 2 column 1>0);
parameter 1 at this time is set twice, but the value of parameter 2 is overridden by the new parameter 1 in the parent query, according to the priority principle.
Based on the above method for controlling the scope of database variable parameters, the present application also provides a device for controlling the scope of database variable parameters, which is described in detail below.
Fig. 2 is a schematic diagram of a database variable parameter scope control apparatus proposed in the present application, and referring to fig. 2, a database variable parameter scope control apparatus includes:
an obtaining module 201, configured to obtain an SQL statement sent by a client;
the first analysis module 202 is configured to analyze the SQL statement and determine a nested relationship between query statements in each layer in the SQL statement;
the second analysis module 203 is used for performing syntax validity analysis and semantic validity analysis on the target query statement, establishing a parameter object list according to prompt contents preset in the target query statement, and checking the validity of parameters; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one layer of multi-layer query statements in the SQL statement;
a first generating module 204, configured to establish an abstract syntax tree of the target query statement, and store the parameter object list in a structure of the abstract syntax tree;
a second generating module 205, configured to construct all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relationship;
and the execution module 206 is configured to execute the complete syntax tree of the SQL statement and return an execution result.
In a possible implementation manner, the second parsing module 203 includes:
the grammar parsing submodule is used for carrying out grammar parsing on a target query statement to form a structural entity of the target query statement, checking the grammar validity of the target query statement, if the grammar validity is legal, continuing to execute, and if the grammar validity is not legal, reporting an error;
the grammar analysis submodule is used for carrying out semantic analysis on the structural entity of the target query statement and checking the semantic validity of the structural entity of the target query statement, if the structural entity of the target query statement is legal, the execution is continued, and if the structural entity of the target query statement is not legal, an error is reported;
and the objectification sub-module is used for objectifying the parameters of the prompt contents in the target query statement, establishing a parameter object list, checking the validity of the parameters, continuing to execute if the parameters are legal, and reporting an error if the parameters are not legal.
In another possible implementation manner, a database variable parameter scope control apparatus further includes:
the association module is used for traversing the complete syntax tree and determining the association relation between the parameter variables and the abstract syntax tree acted by the parameter variables according to the action domain information corresponding to each parameter variable; storing the parameter object list of the parameter variable to a corresponding abstract syntax tree according to the incidence relation;
the execution module 206 is further configured to modify parameters of each layer of abstract syntax tree in the SQL statement according to the corresponding parameter object list, and execute the complete syntax tree of the SQL statement.
Based on the above method for controlling scope of database variable parameters, the present application also provides a device for controlling scope of database variable parameters, which is described in detail below.
The scope control device for the database variable parameters comprises a memory and a processor, wherein the memory is used for storing codes or programs, and the processor is used for calling the codes or the programs to realize the scope control method for the database variable parameters.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (7)
1. A method for controlling scope of database variable parameters, comprising:
acquiring an SQL statement sent by a client;
analyzing the SQL statement and determining the nesting relation among all layers of query statements in the SQL statement;
carrying out syntax legality analysis and semantic legality analysis on a target query statement, establishing a parameter object list according to prompt contents preset in the target query statement, and checking the legality of parameters; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one layer of a plurality of layers of query statements in the SQL statement;
establishing an abstract syntax tree of the target query statement, and storing the parameter object list into a structure of the abstract syntax tree;
constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation;
executing the complete syntax tree of the SQL statement and returning an execution result;
the preset prompting content refers to prompting content written behind a keyword in the target query statement when the user generates the SQL statement;
if the scope information of the parameter variable of the prompt content is that the parent query statement influences the inheritance relationship of the child query statement, setting a prompt comprising a variable name and a new variable value;
if the scope information of the variable parameter of the prompt content only acts on the query statement of the layer where the prompt content is located, a prompt comprising a scope identifier, a variable name and a new variable value is set, and the scope identifier is local.
2. The method as claimed in claim 1, wherein the parsing, semantic validity parsing, creating a parameter object list according to the prompt content preset in the target query statement, and checking the validity of the parameter comprises:
performing syntax analysis on a target query statement to form a structural entity of the target query statement, checking the syntax validity of the target query statement, if the syntax validity is valid, continuing to execute, and if the syntax validity is not valid, reporting an error;
semantic analysis is carried out on the structural entity of the target query statement, the semantic validity of the structural entity of the target query statement is checked, if the structural entity of the target query statement is legal, the execution is continued, and if the structural entity of the target query statement is not legal, an error is reported;
and carrying out parameter objectification on the prompt content in the target query statement, establishing a parameter object list, checking the validity of the parameter, if the parameter is legal, continuing to execute the operation, and if the parameter is not legal, reporting an error.
3. The method of claim 1, wherein after constructing all abstract syntax trees in the SQL statement as a complete syntax tree according to the nesting relationship, the method comprises:
traversing the complete syntax tree, and determining the incidence relation between the parameter variables and the abstract syntax tree acted by the parameter variables according to the action domain information corresponding to each parameter variable;
storing the parameter object list of the parameter variable to a corresponding abstract syntax tree according to the incidence relation;
the executing the complete syntax tree of the SQL statement comprises the following steps:
and each layer of abstract syntax tree in the SQL statement modifies parameters according to the corresponding parameter object list and executes the complete syntax tree of the SQL statement.
4. A database variable parameter scope control apparatus, comprising:
the acquisition module is used for acquiring SQL sentences sent by the client;
the first analysis module is used for analyzing the SQL statement and determining the nesting relation among all layers of query statements in the SQL statement;
the second analysis module is used for carrying out syntax legality analysis and semantic legality analysis on the target query statement, establishing a parameter object list according to prompt contents preset in the target query statement and checking the legality of parameters; the prompt content comprises parameter variables and scope information of the parameter variables, the parameter variables comprise variable names and new variable values endowed with the variable names, the parameter object list is used for storing the variable names in the parameter variables and the new variable values corresponding to the variable names, and the target query statement is any one layer of a plurality of layers of query statements in the SQL statement;
the first generation module is used for establishing an abstract syntax tree of the target query statement and storing the parameter object list into a structure of the abstract syntax tree;
the second generation module is used for constructing all abstract syntax trees in the SQL statement into a complete syntax tree according to the nesting relation;
the execution module is used for executing the complete syntax tree of the SQL statement and returning an execution result;
the preset prompting content refers to prompting content written behind a keyword in the target query statement when the user generates the SQL statement;
if the scope information of the parameter variable of the prompt content is that the inheritance relationship of the parent query statement influences the child query statement, setting a prompt comprising a variable name and a new variable value;
and if scope information of variable parameters of the prompt content only acts on the query statement of the layer where the prompt content is located, setting a prompt comprising a scope identifier, a variable name and a new variable value, wherein the scope identifier is local.
5. The apparatus of claim 4, wherein the second parsing module comprises:
the grammar parsing submodule is used for carrying out grammar parsing on a target query statement to form a structural entity of the target query statement, checking the grammar validity of the target query statement, if the grammar validity is legal, continuing to execute, and if the grammar validity is not legal, reporting an error;
a syntax parsing submodule, configured to perform semantic parsing on the structural entity of the target query statement, check semantic validity of the structural entity of the target query statement, if the semantic validity is valid, continue execution, and if the semantic validity is not valid, report an error;
and the objectification sub-module is used for objectifying the parameters of the prompt contents in the target query statement, establishing a parameter object list, checking the validity of the parameters, continuing to execute if the parameters are legal, and reporting an error if the parameters are not legal.
6. The database variable parameter scope control apparatus of claim 4, further comprising:
the association module is used for traversing the complete syntax tree and determining the association relation between the parameter variables and the abstract syntax tree acted by the parameter variables according to the scope information corresponding to each parameter variable; storing the parameter object list of the parameter variable to a corresponding abstract syntax tree according to the incidence relation;
the execution module is further configured to modify parameters of each layer of abstract syntax tree in the SQL statement according to the corresponding parameter object list, and execute the complete syntax tree of the SQL statement.
7. A database variable parameter scoping control device comprising a memory for storing a code or program and a processor for invoking the code or program to implement a database variable parameter scoping control method according to any one of claims 1 to 3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211533168.XA CN115630085B (en) | 2022-12-02 | 2022-12-02 | Database variable parameter scope control method, device and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211533168.XA CN115630085B (en) | 2022-12-02 | 2022-12-02 | Database variable parameter scope control method, device and equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115630085A CN115630085A (en) | 2023-01-20 |
CN115630085B true CN115630085B (en) | 2023-03-28 |
Family
ID=84910507
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211533168.XA Active CN115630085B (en) | 2022-12-02 | 2022-12-02 | Database variable parameter scope control method, device and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115630085B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111522816A (en) * | 2020-04-16 | 2020-08-11 | 云和恩墨(北京)信息技术有限公司 | Data processing method, device, terminal and medium based on database engine |
CN112052255A (en) * | 2020-09-02 | 2020-12-08 | 福建天晴在线互动科技有限公司 | SQL (structured query language) interpretation method and device for splitting multi-table slow query from top to bottom |
CN113032362A (en) * | 2021-03-18 | 2021-06-25 | 广州虎牙科技有限公司 | Data blood margin analysis method and device, electronic equipment and storage medium |
CN114281842A (en) * | 2021-12-07 | 2022-04-05 | 杭州隆埠科技有限公司 | Method and device for sub-table query of database |
CN114416771A (en) * | 2021-12-27 | 2022-04-29 | 深信服科技股份有限公司 | Data processing method and device, electronic equipment and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7716213B2 (en) * | 2007-04-26 | 2010-05-11 | International Business Machines Corporation | Apparatus, system, and method for efficiently supporting generic SQL data manipulation statements |
-
2022
- 2022-12-02 CN CN202211533168.XA patent/CN115630085B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111522816A (en) * | 2020-04-16 | 2020-08-11 | 云和恩墨(北京)信息技术有限公司 | Data processing method, device, terminal and medium based on database engine |
CN112052255A (en) * | 2020-09-02 | 2020-12-08 | 福建天晴在线互动科技有限公司 | SQL (structured query language) interpretation method and device for splitting multi-table slow query from top to bottom |
CN113032362A (en) * | 2021-03-18 | 2021-06-25 | 广州虎牙科技有限公司 | Data blood margin analysis method and device, electronic equipment and storage medium |
CN114281842A (en) * | 2021-12-07 | 2022-04-05 | 杭州隆埠科技有限公司 | Method and device for sub-table query of database |
CN114416771A (en) * | 2021-12-27 | 2022-04-29 | 深信服科技股份有限公司 | Data processing method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115630085A (en) | 2023-01-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110795455B (en) | Dependency analysis method, electronic device, computer apparatus, and readable storage medium | |
US10162613B1 (en) | Re-usable rule parser for different runtime engines | |
US9953639B2 (en) | Voice recognition system and construction method thereof | |
CN106934062A (en) | A kind of realization method and system of inquiry elasticsearch | |
CN102609451A (en) | SQL (structured query language) query plan generation method oriented to streaming data processing | |
CN110597618B (en) | Task splitting method and device of data exchange system | |
US10224034B2 (en) | Voice recognition system and construction method thereof | |
RU2010111118A (en) | FINAL AUTOMATED UNIFIED MESSAGE EXCHANGE | |
CN103559025A (en) | Software refactoring method through clustering | |
CN116483850A (en) | Data processing method, device, equipment and medium | |
EP3438818B1 (en) | Method and device for compiling computer language | |
CN113468873B (en) | Syntax analysis method and device of PL/SQL language | |
CN106570095B (en) | XML data operation method and equipment | |
WO2021259367A1 (en) | Sql unification method, system, and device, and medium | |
CN115630085B (en) | Database variable parameter scope control method, device and equipment | |
CN113342876B (en) | Data fuzzy query method and device of multi-tenant CRM system in SaaS environment | |
CN117215570A (en) | Code generation method of application program interface, terminal device and storage medium | |
CN117407415A (en) | Data query method, device, computer equipment and readable storage medium | |
CN116610697A (en) | Query method, storage medium and device for database query statement | |
WO2023030461A1 (en) | Distributed database detection method and apparatus | |
CN108780452A (en) | A kind of storing process processing method and processing device | |
CN106708954B (en) | Internal and external connection conversion method and conversion device for non-standard SQL statement | |
CN116089476B (en) | Data query method and device and electronic equipment | |
CN117555925B (en) | Database access code conversion method and device and electronic equipment | |
CN116756184B (en) | Database instance processing method, device, equipment, storage medium and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |