Method and system for realizing infinite domain extraction of PLPGSQL language

By generating domain expressions and traversing the domain variable collection, the problem of PLPGSQL language in PostgreSQL database does not support the assignment operation after more than 4 domain operations, and the infinite domain and assignment of variables is realized, which improves application migration efficiency and reduces costs.

CN114461719BActive Publication Date: 2025-06-17HIGHGO SOFTWARE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210141151.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-16
Publication Date
2025-06-17
Estimated Expiration
2042-02-16

AI Technical Summary

Technical Problem

The PLPGSQL language in the PostgreSQL database does not support the value assignment operation after more than 4 domain fetching operations, resulting in the application development of PLSQL syntax based on Oracle Database, which increases the workload of existing users.

Method used

By generating a domain expression, obtaining the variable names at each level and storing them in the domain variable set, traversing the domain variable set to determine whether the variable is in the previous variable. If a session variable set is generated, otherwise an error message will be reported to realize infinite domain and assignment of the variable.

Benefits of technology

PostgreSQL supports unlimited domain fetching and assignment of domains to improve application migration efficiency, reduce application migration costs, and make the database easy to use, easy to use and practical.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114461719B_ABST
    Figure CN114461719B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for realizing infinite domain extraction of the PLPGSQL language. The method for realizing infinite domain extraction of the PLPGSQL language includes: generating a domain extraction expression based on a domain extraction command; obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set; traversing the domain variable set to determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name. If so, generating a session variable set; otherwise, reporting an error message. By adopting the present invention, PostgreSQL can be enabled to support infinite domain extraction of variables and assignment of domains, thereby improving the application migration efficiency, reducing the application migration cost, and making the database easy to use, user-friendly, and practical.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of fetching domains, and in particular, to a method and system for realizing infinite domain fetching in the PLPGSQL language. Background Art

[0002] Currently, the PLPGSQL language in the PostgreSQL database does not support fetch and assignment operations after more than 4 domain fetch operations. For applications developed based on the PLSQL syntax of Oracle Database, the database cannot support them, increasing the workload of existing users. Summary of the Invention

[0003] Embodiments of the present invention provide a method and system for realizing infinite domain fetching in the PLPGSQL language to solve the problem that the PLPGSQL language in the PostgreSQL database in the prior art does not support fetch and assignment operations after more than 4 domain fetch operations.

[0004] The method for realizing infinite domain fetching in the PLPGSQL language according to the embodiments of the present invention includes:

[0005] Generating a domain fetch expression based on a domain fetch command;

[0006] Obtaining variable names at all levels in the domain fetch expression and storing them in a domain variable set in sequence;

[0007] Traversing the domain variable set, and determining whether variables corresponding to the current variable name are all in variables corresponding to the previous variable name. If so, generating a session variable set; otherwise, reporting an error message.

[0008] According to some embodiments of the present invention, the method further includes:

[0009] Determining the number of domain fetch operations based on the domain fetch expression;

[0010] Only when the number of domain fetch operations is greater than a threshold, obtaining variable names at all levels in the domain fetch expression and storing them in a domain variable set in sequence.

[0011] According to some embodiments of the present invention, the traversing the domain variable set and determining whether variables corresponding to the current variable name are all in variables corresponding to the previous variable name includes:

[0012] Extracting the current variable name from the domain variable set, and obtaining the variable definition of the current variable name. The variable definition includes a variable type and a value, and the variable type includes a composite variable and a domain variable;

[0013] Based on the variable definition of the current variable name, determining whether variables corresponding to the current variable name are all in variables corresponding to the previous variable name.

[0014] According to some embodiments of the present invention, the composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value;

[0015] The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

[0016] According to some embodiments of the present invention, the method further includes:

[0017] According to the assignment instruction, determine the variable name to be assigned, and determine the current position of the variable name to be assigned in the domain variable set;

[0018] Based on the current position, perform an assignment operation on the variable corresponding to the variable name to be assigned and each variable containing it in sequence.

[0019] A system for implementing infinite domain fetching of the PLPGSQL language according to an embodiment of the present invention includes:

[0020] A parsing unit for generating a domain fetching expression based on a domain fetching command;

[0021] A storage unit for obtaining variable names at all levels in the domain fetching expression and storing them in the domain variable set in sequence;

[0022] A processing unit for traversing the domain variable set, determining whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name, and if so, generating a session variable set, otherwise, reporting an error message.

[0023] According to some embodiments of the present invention, the system further includes:

[0024] A statistical unit for determining the number of domain fetches based on the domain fetching expression;

[0025] A storage unit for obtaining variable names at all levels in the domain fetching expression and storing them in the domain variable set in sequence only when the number of domain fetches is greater than a threshold.

[0026] According to some embodiments of the present invention, the processing unit is used for:

[0027] Extract the current variable name from the domain variable set, and obtain the variable definition of the current variable name, where the variable definition includes a variable type and a value, and the variable type includes a composite variable and a domain variable;

[0028] Based on the variable definition of the current variable name, determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name.

[0029] According to some embodiments of the present invention, the composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value;

[0030] The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

[0031] According to some embodiments of the present invention, the system further includes:

[0032] An assignment unit, configured to determine the variable name to be assigned according to an assignment instruction, and determine the current position of the variable name to be assigned in the domain variable set;

[0033] Based on the current position, perform an assignment operation on the variable corresponding to the variable name to be assigned and each variable including it in sequence.

[0034] By adopting the embodiments of the present invention, PostgreSQL can be supported to infinitely fetch domains for variables and assign values to domains, thereby improving the application migration efficiency, reducing the cost of application migration, and making the database easy to use, user-friendly, and practical.

[0035] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features, and advantages of the present invention more obvious and understandable, the following specifically illustrates the specific embodiments of the present invention. Brief Description of the Drawings

[0036] By reading the detailed description of the following embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. In the drawings:

[0037] Figure 1 is a flowchart of a method for realizing infinite domain fetching of the PLPGSQL language in an embodiment of the present invention;

[0038] Figure 2 is a flowchart of a method for realizing infinite domain fetching of the PLPGSQL language in an embodiment of the present invention;

[0039] Figure 3 is a schematic diagram of the constraint and reference relationship between data structures in an embodiment of the present invention;

[0040] Figure 4 is a schematic diagram of the relationship between variables a, b, and c in an embodiment of the present invention;

[0041] Figure 5 is a schematic diagram of the relationship between the composite variable and the domain in an embodiment of the present invention. Detailed Embodiments

[0042] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present invention can be more thoroughly understood and the scope of the present invention can be fully conveyed to those skilled in the art. Additionally, in some instances, well-known methods, structures, and technologies are not shown in detail so as not to obscure the understanding of this specification.

[0043] As Figure 1 shown, the method for implementing infinite domain extraction in the PLPGSQL language according to the embodiments of the present invention includes:

[0044] S1. Generate a domain extraction expression based on a domain extraction command; the domain extraction instruction is an input instruction entered by a user into the PostgreSQL database. The PostgreSQL database needs to convert the domain extraction instruction into a computer language, that is, a language that can be recognized and processed by a computer. Here, the computer can be understood as a device with computing and processing functions equipped with the PostgreSQL database.

[0045] For example, domain extraction operators and variables can be defined in advance. The domain extraction expression is constructed by domain extraction operators and variables. After the computer obtains the domain extraction expression, it can know the corresponding operations.

[0046] For example, a.b.c.d.e is a domain extraction expression, where "." is the domain extraction operator, and "a", "b", "c", "d", and "e" all represent variables.

[0047] S2. Obtain the variable names at all levels in the domain extraction expression and store them in the domain variable set in sequence; the variable names in the domain variable set are stored in sequence according to the levels. For example, "a", "b", "c", "d", and "e" can be stored in sequence. In the domain variable set, "a" is on the left of "b", "b" is on the left of "c", "c" is on the left of "d", and "d" is on the left of "e".

[0048] S3. Traverse the domain variable set and determine whether the variables corresponding to the current variable name are all within the variables corresponding to the previous variable name. If so, generate a session variable set; otherwise, report an error message.

[0049] In other words, it is necessary to judge the variables corresponding to the variable names in sequence to determine whether the current variable is in the previous-level variables. For example, if "a", "b", "c", "d", "e" are stored in the domain variable set in sequence, then four judgments are made, successively judging whether "b" is included in "a", whether "c" is included in "b", whether "d" is included in "c", and whether "e" is included in "d".

[0050] It should be noted here that to determine whether the current variable is in the previous-level variable, it is necessary to first find the definition of each variable and judge whether the current variable is in the previous-level variable based on the definition content of each variable.

[0051] Adopting the embodiment of the present invention can enable PostgreSQL to support infinite domain extraction and domain assignment for variables, thereby improving the application migration efficiency, reducing the cost of application migration, and making the database easy to use, user-friendly, and practical.

[0052] Based on the above embodiments, various variant embodiments are further proposed. It should be noted here that for the sake of brief description, only the differences from the above embodiments are described in each variant embodiment.

[0053] According to some embodiments of the present invention, the method further includes:

[0054] Based on the domain extraction expression, determine the number of domain extractions;

[0055] When and only when the number of domain extractions is greater than the threshold, obtain the variable names at all levels in the domain extraction expression and store them in the domain variable set in sequence.

[0056] The present invention is proposed to solve the problem that the PLPGSQL language in the current PostgreSQL database does not support the assignment operation after more than 4 domain extractions.

[0057] Therefore, it is possible to first judge whether the number of domain extractions is greater than the threshold. For example, the threshold can be set to 4. When and only when the number of domain extractions is greater than the threshold, obtain the variable names at all levels in the domain extraction expression and store them in the domain variable set in sequence. If the number of domain extractions is less than the threshold, the domain extraction method of the current PostgreSQL database can be adopted.

[0058] According to some embodiments of the present invention, traversing the domain variable set and judging whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name includes:

[0059] Extract the current variable name from the domain variable set and obtain the variable definition of the current variable name. The variable definition includes the variable type and value, and the variable type includes composite variables and domain variables.

[0060] Based on the variable definition of the current variable name, determine whether the variables corresponding to the current variable name are all within the variables corresponding to the previous variable name.

[0061] For example, after obtaining the current variable name, first determine the variable type corresponding to this variable name. If it is a domain variable, then determine whether this domain variable is part of one of its domain variables / composite variables. If it is a composite variable, then continue to obtain the next variable.

[0062] For example, Figure 3 shows the definitions of the composite variable a and the domain variable b. It can be seen from this figure that the variable b belongs to the variable a, that is, the variable b is within the variable a.

[0063] According to some embodiments of the present invention, the composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value;

[0064] The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

[0065] According to some embodiments of the present invention, the method further includes:

[0066] According to the assignment instruction, determine the variable name to be assigned, and determine the current position of the variable name to be assigned in the domain variable set;

[0067] Based on the current position, perform assignment operations on the variable corresponding to the variable name to be assigned and each variable containing it in sequence.

[0068] Next, refer to Figures 2 - 5 A specific embodiment is used to describe in detail the method for realizing infinite domain extraction of the PLPGSQL language according to the embodiments of the present invention. It should be understood that the following description is only an exemplary illustration and not a specific limitation of the present invention. All similar structures and similar changes using the present invention should be included in the protection scope of the present invention.

[0069] PL / SQL is a procedural language, a proprietary SQL extension language of Oracle Database, specifically designed to include SQL statements in its syntax. PLPGSQL is a procedural language similar to PL / SQL provided by PostgreSQL.

[0070] Currently, the PLPGSQL language in the PostgreSQL database does not support assignment operations after more than 4 times of domain extraction operations (for example: a.b.c.d.e). For applications developed based on the PLSQL syntax of Oracle Database, the database cannot support it, increasing the workload of existing users.

[0071] The purpose of the method for realizing infinite domain extraction of the PLPGSQL language in the embodiments of the present invention is to solve the problem of infinite domain extraction of composite variables and domain assignment in the PLPGSQL language, enabling PostgreSQL to support infinite domain extraction of variables and domain assignment, improving the application migration efficiency and reducing the application migration cost, making the database easy to use, user-friendly, and practical.

[0072] The method for realizing infinite domain extraction of the PLPGSQL language in the embodiments of the present invention is used in the PLPGSQL language of the PostgreSQL database and includes: unrestricted domain extraction compilation, parsing the lexical and semantic of the domain extraction command, and preparing necessary data for the domain assignment calculation; an efficient solution for the extraction and assignment of composite variable domains.

[0073] First, the following explanations are made for the nouns involved in the embodiments of the present invention:

[0074] Variable set: Used to store all variable information in the current language block in the PLPGSQL language.

[0075] Variable node: A certain variable information stored in the variable set, which is divided into basic type, composite type, domain, etc. according to the variable type, and each type contains variable name, variable type, value, etc.

[0076] Assignment syntax: variable name1.element.element.element.element... = variable name2

[0077] Value extraction syntax: variable name2 = variable name1.element.element.element.element...

[0078] Domain extraction operator: Usually, the "." between the variable name and the element or between elements is called the domain extraction operator.

[0079] Domain extraction operation: The variable name, element name, and domain extraction operator together constitute the domain extraction operation.

[0080] Domain and composite variable: Generally, the left part of the domain extraction operator is collectively called the composite variable, and the part from the right part until the next domain extraction operator is called the domain of the variable, and the domain is also called the element.

[0081] Refer to Figure 2 , the method for realizing infinite domain extraction of the PLPGSQL language in the embodiments of the present invention includes:

[0082] Based on the domain extraction command, after compilation, a domain extraction expression is generated; the role of compilation is to convert the character command input by the user into a data structure that can be recognized and processed by a computer. The compilation in the embodiments of the present invention mainly converts the domain extraction command into a domain extraction expression (lexical analysis), and then further pre-judges the feasibility of the language intention of the domain extraction expression, and this step is also called semantic analysis. After passing the semantics, corresponding executable data structures are established for each domain for use in subsequent processes.

[0083] Based on the domain extraction expression, determine the number of domain extractions;

[0084] If and only if the number of domain extractions is greater than a threshold, obtain the variable names at all levels in the domain extraction expression and store them in the domain variable set in sequence.

[0085] Traverse the domain variable set, and determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name. If so, generate a session variable set; otherwise, report an error message.

[0086] The traversing the domain variable set and determining whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name includes:

[0087] Extract the current variable name from the domain variable set, and obtain the variable definition of the current variable name. The variable definition includes the variable type and the value, and the variable type includes a composite variable and a domain variable;

[0088] Based on the variable definition of the current variable name, determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name.

[0089] The final session variable set will add sub-domains (elements) at all levels.

[0090] Since the domain extraction command (such as a.b.c.d.e.f) has been converted into a reference to the data structure of the f domain during the compilation stage, and because the f domain is a partial reference to the value of the variable e, similarly, e is also a partial reference to d, and so on. In fact, f is also a partial application to a. Then, the reading and modification of the f value are also the partial reading and modification of a.

[0091] For example, the following uses a simple example to introduce composite type declaration, composite variable definition, and variable assignment.

[0092] The composite type declaration is as follows:

[0093] create type demotype1 as object(c integer,id4 integer);

[0094] create type demotype2 as object(b demotype1,id5 integer);

[0095] The above two statements create two composite types, namely demotype1 and demotype2. Among them, demotype1 consists of two fields, c and id4, and demotype2 consists of two fields, b and id5.

[0096] The variable is defined as follows: a demotype2;

[0097] The above statement means to create a composite variable a (where the variable name is a and the variable type is demotype2). Then, from the type information, it can be known that the variable a will have two fields, b and id5. a.b and a.id5 are to obtain two different fields of a. Similarly, the type of a.b is demotype1, which is also a composite type, so a.b is also a composite variable. a.b has two fields, c and id4, and its two fields can also be obtained through a.b.c and a.b.id4.

[0098] If we continue to assign the value {{1,1},1} to a, that is, the SQL statement: a = {{1,1},1};

[0099] Then, the data storage format obtained is as follows (before the curly braces is the variable name, and inside the curly braces is the value of the variable):

[0100] The storage format of a in the program: a{b{c{1},id4{1}},id5{1}};

[0101] The storage format of the field a.b in the program: b{c{1},id4{1}};

[0102] Fetching a field is actually for a composite variable, and it can be understood that fetching a field is to take a part of the composite variable.

[0103] Describing the design of the data structure of composite types and fields means stating what the components (structural members) of a composite variable are.

[0104] The design of the data structure (structural members) of composite variables and fields in the program is as follows (only the key structural members in the data structure are listed):

[0105] Table 1 Composite Variable (REC)

[0106]

[0107] Table 2 Field Variable (FIELD)

[0108]

[0109] The design of constraints and references between data structures is as Figure 3 shown. As can be seen from Figure 3 there are two connecting lines. Line 1: The composite variable and the domain variable are related to each other through the variable number, which is actually a unique identification number created by the program for each variable when it is created. The domain variable can find the unique composite variable number through this number. Line 2: The value of the domain variable b is a partial reference to the memory of the value of the composite variable a. If the value of the domain variable b is modified, then the part of the value of the corresponding composite variable a that belongs to the b domain will also be modified. Refer to Figure 3 .

[0110] The following uses a complex example to introduce the declaration of composite types, the definition of composite variables, and the assignment of variables.

[0111] The declaration of composite types is as follows:

[0112] create type demotype1 as object(f integer,id1 integer);

[0113] create type demotype2 as object(e demotype1,id2 integer);

[0114] create type demotype3 as object(d demotype2,id3 integer);

[0115] create type demotype4 as object(c demotype3,id4 integer);

[0116] create type demotype5 as object(b demotype4,id5 integer);

[0117] a demotype5;

[0118] Suppose there is an assignment command a.b.c.d.e.f = 10. The a.b.c.d.e.f on the left side of the equal sign can be regarded as a field extraction command, which becomes a field extraction expression after being processed by the program. The field extraction expression is a data expression composed of the composite variable (REC) and the field (FIELD) of the data structure for convenient program processing.

[0119] Taking a.b.c.d.e.f = 10 as an example:

[0120] First, the lexical and grammatical parts will parse a lexical string containing multiple field extraction operators "." into a field extraction command.

[0121] Secondly, the semantic part needs to determine whether a is a composite type. If so, convert a into a REC data structure; if not, process it according to the original PostgreSQL method.

[0122] If a is a REC data structure, continue to determine whether b is a field in variable a. If so, convert b into a FIELD data structure, and record its value and the number of its father a. Then b will be saved in memory as a field value. If not, process it according to the original PostgreSQL method.

[0123] Continue to determine whether c is a field in variable b. If so, convert c into a FIELD data structure, and record its value and the number of its father b. Then c will be saved in memory as a field value. If not, process it according to the original PostgreSQL method.

[0124] However, if e is not a field in variable d, then e will not be saved in memory. And because the field extraction has exceeded 4 times, it will be interrupted and an error will be reported.

[0125] Finally, and so on, assuming that all field values are correctly converted and stored in memory. Then the parsing is completed. After compilation, the entire a.b.c.d.e.f field extraction command will become a reference (field extraction expression) to the f field (FIELD) data structure. Subsequent fetching and assignment operations are all for reading and modifying the value of the f field (FIELD). The data structure relationship after compilation is as Figure 5 shown.

[0126] The design of the data structures of composite variables and fields makes the number of fields horizontally scalable. It makes it possible for PostgreSQL to be compatible with the field extraction commands of any database.

[0127] The design of the compilation process and compilation method of the field extraction command enables the database to complete fetching and assignment simply and efficiently, reducing the impact on the original design and the defect rate of secondary development.

[0128] It should be noted that the above description is only the preferred embodiment of the present invention and is not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0129] The system for realizing infinite field extraction of the PLPGSQL language according to the embodiment of the present invention includes:

[0130] A parsing unit for generating a domain extraction expression based on a domain extraction command;

[0131] A storage unit for obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set;

[0132] A processing unit for traversing the domain variable set to determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name. If so, a session variable set is generated; otherwise, an error message is reported.

[0133] By adopting the embodiment of the present invention, PostgreSQL can be supported to perform infinite domain extraction on variables and assign values to domains, thereby improving the application migration efficiency, reducing the application migration cost, and making the database easy to use, user-friendly, and practical.

[0134] According to some embodiments of the present invention, the system further includes:

[0135] A statistical unit for determining the domain extraction times based on the domain extraction expression;

[0136] A storage unit for, if and only if the domain extraction times are greater than a threshold, obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set.

[0137] According to some embodiments of the present invention, the processing unit is configured to:

[0138] Extract the current variable name from the domain variable set and obtain the variable definition of the current variable name, where the variable definition includes a variable type and a value, and the variable type includes a composite variable and a domain variable;

[0139] Based on the variable definition of the current variable name, determine whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name.

[0140] According to some embodiments of the present invention, the composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value;

[0141] The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

[0142] According to some embodiments of the present invention, the system further includes:

[0143] An assignment unit for determining an assigned variable name according to an assignment instruction and determining the current position of the assigned variable name in the domain variable set;

[0144] Based on the current position, sequentially perform assignment operations on the variables corresponding to the assigned variable name and each variable containing it.

[0145] It should be noted that the description of reference terms such as "one embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Although some embodiments described herein include certain features included in other embodiments rather than other features, the combination of features of different embodiments means that it is within the scope of the present invention and forms different embodiments. The specific features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. For example, in the claims, any one of the claimed embodiments can be used in any combination.

[0146] The term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

Claims

1. A method for implementing infinite domain extraction in the PLPGSQL language, characterized in that, including: generating a domain extraction expression based on a domain extraction command; obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set; traversing the domain variable set, determining whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name, if so, generating a session variable set, otherwise, reporting an error message; said traversing the domain variable set and determining whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name includes: extracting the current variable name from the domain variable set and obtaining the variable definition of the current variable name, the variable definition including a variable type and a value, the variable type including a composite variable and a domain variable; judging whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name based on the variable definition of the current variable name.

2. The method according to claim 1, characterized in that, The method further includes: determining the number of domain extractions based on the domain extraction expression; when and only when the number of domain extractions is greater than a threshold, obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set.

3. The method according to claim 1, characterized in that, The composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value; The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

4. The method according to claim 1, characterized in that, The method further includes: determining the variable name to be assigned according to an assignment instruction, and determining the current position of the variable name to be assigned in the domain variable set; performing an assignment operation on the variable corresponding to the variable name to be assigned and each variable containing it in sequence based on the current position.

5. A system for implementing infinite domain extraction in the PLPGSQL language, characterized in that, including: a parsing unit for generating a domain extraction expression based on a domain extraction command; a storage unit for obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set; a processing unit for traversing the domain variable set, determining whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name, if so, generating a session variable set, otherwise, reporting an error message; The processing unit is configured to: extract the current variable name from the domain variable set and obtain the variable definition of the current variable name, the variable definition including a variable type and a value, the variable type including a composite variable and a domain variable; judging whether the variables corresponding to the current variable name are all in the variables corresponding to the previous variable name based on the variable definition of the current variable name.

6. The system according to claim 5, characterized in that, The system further includes: a statistical unit for determining the number of domain extractions based on the domain extraction expression; a storage unit for obtaining variable names at all levels in the domain extraction expression and sequentially storing them in a domain variable set when and only when the number of domain extractions is greater than a threshold.

7. The system according to claim 5, characterized in that, The composite variable is defined with a composite variable number, a composite variable name, a composite variable type, and a composite variable value; The domain variable is defined with a domain variable number, a domain variable name, a subordinate variable number, a domain variable type, and a domain variable value.

8. The system according to claim 5, characterized in that, The system further includes: an assignment unit for determining the variable name to be assigned according to an assignment instruction, and determining the current position of the variable name to be assigned in the domain variable set; performing an assignment operation on the variable corresponding to the variable name to be assigned and each variable containing it in sequence based on the current position.

Citation Information

Patent Citations

  • Syntax tree extraction method of JSON data

    CN111046630A

  • DDL synchronization method and device for PostgreSQL database, equipment and medium

    CN112231407A