A language operation method and program product for heterogeneous database

By building standard language scripts in business systems and identifying and converting statement blocks at runtime, the PL/SQL language portability compatibility problem in heterogeneous databases is solved, the script operation efficiency is improved and maintenance costs is reduced, and different databases are realized Compatibility solution.

CN118672560BActive Publication Date: 2024-12-03HUNDSUN TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411162761.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-03
Estimated Expiration
2044-08-23

AI Technical Summary

Technical Problem

In heterogeneous databases, there are compatibility problems in the porting of PL/SQL languages, resulting in low script operation efficiency and high maintenance costs. The existing technology needs to be artificially converted and deployed to a new database, making it difficult to solve the compatibility problems.

Method used

By building standard language scripts in the business system and identifying and converting statement blocks at runtime, syntax conversion of specific databases is realized, avoiding the implementation of separate statement block conversion schemes for each target database one by one, and using the compilation module to generate a logical execution tree and Stored in critical shared memory, the running module converts and runs statement blocks according to the target database type.

Benefits of technology

It improves script operation efficiency in heterogeneous database scenarios, reduces operation and maintenance costs, realizes compatibility solutions for different databases, and simplifies script deployment and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672560B_ABST
    Figure CN118672560B_ABST
Patent Text Reader

Abstract

The present application proposes a language operation method and program product for a heterogeneous database, wherein a standard language script is compiled by a compilation module to obtain a logical execution tree, and the logical execution tree is stored in a critical shared memory. When an operation requirement is generated, the operation module obtains the logical execution tree from the critical shared memory, and identifies the type of each statement block in the logical execution tree through the statement block operation route. Then, when it is a default statement block, the operation module runs the default statement block. Alternatively, when it is a non-default statement block, the operation module converts the non-default statement block into a target statement block corresponding to the target database, and runs the target statement block. Thus, the syntax conversion of the statement block is realized on the business system side, and then the statement blocks that do not need to be converted and the converted statement blocks are run to complete the operation of the standard language script for a specific database. Thereby improving the efficiency of script operation in heterogeneous database scenarios and reducing operation and maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to database technology, and in particular to a language operation method and a program product for a heterogeneous database. Background Art

[0002] When developing languages ​​and running products for heterogeneous databases, language migration is usually involved. Specifically, for block-structured languages, such as Procedure Language & Structured Query Language (PL / SQL), they generally contain one or more logic blocks, and these logic blocks can be used to add program logic to command statements, thereby migrating stored procedures to the database of the operating platform.

[0003] However, due to the differences in technical characteristics when different database vendors implement PL / SQL capabilities, there are often compatibility issues in migration among heterogeneous databases. Summary of the invention

[0004] The purpose of the present application is to provide a language operation method and program product for heterogeneous databases, which are used to improve the efficiency of script operation in heterogeneous database scenarios and reduce operation and maintenance costs.

[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a language operation method for a heterogeneous database, the method being applied to a business system, the business system comprising a compilation module and an operation module, the business system being communicatively connected to at least one database, the method comprising:

[0007] The compiling module compiles the standard language script to obtain a logic execution tree, and stores the logic execution tree in the critical shared memory;

[0008] When the target database generates an operation demand, the operation module obtains the logic execution tree from the critical shared memory, and identifies the type of each statement block in the logic execution tree through the statement block operation route;

[0009] When the statement block is a default statement block, the running module runs the default statement block;

[0010] When the statement block is a non-default statement block, the running module converts the non-default statement block into a target statement block corresponding to the target database, and runs the target statement block.

[0011] Optionally, the step of obtaining the logic execution tree from the critical shared memory by the running module and identifying the type of each statement block in the logic execution tree through statement block running routing includes:

[0012] After the operation module obtains the logic execution tree, the operation module obtains the first statement block in the logic execution tree through depth-first search;

[0013] The running module determines the type information of the statement block by running the statement block route;

[0014] If the type information is a parameter class, a logic control class, a transaction commit class, a cursor class, or a default SQL class, the statement block is a default statement block;

[0015] If the type information is a non-default SQL class, the statement block is a non-default statement block.

[0016] Optionally, also include

[0017] The running module outputs an execution log after the default statement block or the target statement block is executed.

[0018] Optionally, the step of the running module converting the non-default statement block into a target statement block corresponding to the target database and running the target statement block includes:

[0019] The running module intercepts the non-default statement block through the execution agent;

[0020] The running module parses the non-default statement block through the execution agent to obtain an original abstract syntax tree corresponding to the non-default statement block;

[0021] The operation module confirms the type of the target database through the execution agent;

[0022] The running module converts the original abstract syntax tree into a target abstract syntax tree corresponding to the target database through the execution agent according to the type of the target database;

[0023] The running module generates a target statement block corresponding to the target database according to the target abstract syntax tree through the execution agent;

[0024] The running module transfers the target statement block to the target database driver through the execution agent to complete the running.

[0025] Optionally, the step of the compiling module compiling the standard language script to obtain a logic execution tree, and storing the logic execution tree in a critical shared memory includes:

[0026] The compiling module scans the storage files in the specified path to obtain the standard language script;

[0027] The compiling module parses and precompiles the standard language script to obtain the logic execution tree;

[0028] The compiling module stores the logic execution tree in the critical shared memory according to an executable data structure.

[0029] Optionally, the step of the compiling module parsing and precompiling the standard language script to obtain the logic execution tree includes:

[0030] The compiling module performs syntax analysis on the standard language script to obtain each statement block included in the standard language script;

[0031] The compiling module parses each of the statement blocks and constructs the logic execution tree.

[0032] In the second aspect, the embodiment of the present application provides a language operation device for a heterogeneous database, the device is applied to a business system, the business system is connected to at least one database communication, including: a compilation module and an operation module;

[0033] The compiling module is used to compile the standard language script to obtain a logic execution tree, and store the logic execution tree in the critical shared memory;

[0034] The running module is used to obtain the logic execution tree from the critical shared memory when the target database generates an operation demand, and identify the type of each statement block in the logic execution tree through the statement block running route; when the statement block is a default statement block, the default statement block is run; when the statement block is a non-default statement block, the non-default statement block is converted into a target statement block corresponding to the target database, and the target statement block is run.

[0035] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0036] A memory for storing one or more programs;

[0037] processor;

[0038] When the one or more programs are executed by the processor, the method as described in any one of the first aspects above is implemented.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method as described in any one of the above-mentioned first aspects.

[0040] In a fifth aspect, an embodiment of the present application provides a program product, which, when executed by a processor, implements a method as described in any one of the above-mentioned first aspects.

[0041] Compared with the prior art, the language operation method of a heterogeneous database provided in the embodiment of the present application compiles the standard language script through the compilation module to obtain the logical execution tree, and stores the logical execution tree to the critical shared memory. When the target database generates an operation demand, the operation module obtains the logical execution tree from the critical shared memory, and identifies the type of each statement block in the logical execution tree through the statement block operation route. Then, when the statement block is a default statement block, the operation module runs the default statement block. Or, when the statement block is a non-default statement block, the operation module converts the non-default statement block into a target statement block corresponding to the target database, and runs the target statement block. Thereby, the syntax conversion of the statement block is realized on the business system side, and then the statement blocks that do not need to be converted and the converted statement blocks are run to complete the operation of the standard language script for a specific database. Thereby improving the efficiency of script operation in heterogeneous database scenarios and reducing operation and maintenance costs.

[0042] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 A schematic diagram of a language operation architecture of a heterogeneous database provided by an embodiment of the present invention;

[0045] Figure 2 A flow chart of a language operation method for a heterogeneous database provided by an embodiment of the present invention;

[0046] Figure 3 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention;

[0047] Figure 4 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention;

[0048] Figure 5 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention;

[0049] Figure 6 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention;

[0050] Figure 7 A schematic diagram of the structure of a language running device for a heterogeneous database provided by an embodiment of the present invention;

[0051] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0053] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0054] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0055] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0056] In the existing technology, different database vendors have some technical characteristics (such as differences in keywords and function naming, etc.) when implementing PL / SQL capabilities. For example, a script developed under Oracle will often have some compatibility issues when ported to another heterogeneous database, such as MySQL.

[0057] To solve the compatibility problem at the database level, the original language needs to be manually converted and then deployed to the new database for execution. From the perspective of solving compatibility problems, this greatly reduces the efficiency of the solution implementation and increases the implementation cost.

[0058] At the same time, since anomalies occurred in the database storage process after the script was migrated, it was difficult to troubleshoot the migrated script, thereby increasing the subsequent maintenance costs of the migration.

[0059] In view of the above problems, the inventors of the present application found in the process of research that the statement block structure in PL / SQL can be used to complete the syntax conversion of heterogeneous data on the business system side. Its core logic is: only one standard language script is constructed in the business system, and the syntax differences of the standard language script and different target databases are decoupled as much as possible. And when the operation demand for the script arises, for example, when data needs to be stored for a specific database, the business system side identifies which statement blocks in the standard language script need to be grammatically converted for the specific database. Thereby, the syntax conversion of the statement block is realized on the business system side, and then the statement blocks that do not need to be converted and the converted statement blocks are run to complete the operation of the standard language script for a specific database. Avoid implementing a separate statement block conversion scheme for each target database one by one. Thereby improving the efficiency of script operation in heterogeneous database scenarios and reducing operation and maintenance costs.

[0060] On this basis, Figure 1 A schematic diagram of a language operation architecture of a heterogeneous database provided in an embodiment of the present invention, wherein the language operation architecture includes a business system 10 and at least one database, such as Figure 1 The Oracle database, MySQL database and PostgreSQL database shown in the figure further include a compilation module 101, a critical shared memory 102 and an operation module 103 in the business system 10.

[0061] The compiling module 101 is used to load the standard language script after the application is started, compile the standard language script, and store the compilation result, such as the logic execution tree, in the critical shared memory.

[0062] The critical shared memory 102 is a memory area allocated by the business system 10 for storing the compilation result.

[0063] The running module 103 is used to call the corresponding compilation result from the critical shared memory 102 to run after the running is triggered, so as to complete the running requirement.

[0064] When the running module 103 runs the compilation result, it will identify each sentence block of the compilation result, identify the sentence block that needs to be grammatically converted, and run it after the grammatical conversion is completed.

[0065] Optionally, in Figure 1 Based on the language operation architecture shown in , the language operation method of the heterogeneous database provided by the present application is exemplarily described below. Specifically, Figure 2 A flow chart of a language operation method for a heterogeneous database provided by an embodiment of the present invention, see Figure 2 , the method comprising:

[0066] Step 200: The compiling module compiles the standard language script to obtain a logic execution tree, and stores the logic execution tree in the critical shared memory.

[0067] Optionally, for standard language scripts, during their design process, an anchored language may be used for design, such as Oracle language. At this time, if the designed statement blocks are standard, then for these statement blocks, when the target database for subsequent deployment is an Oracle database, or other databases that do not require syntax conversion, no conversion is required. If the statement block involves the characteristics of the Oracle language, then when the target database for subsequent deployment is other databases, such as MySQL, the statement block needs to be converted.

[0068] Step 201: When the target database generates an operation requirement, the operation module obtains a logic execution tree from the critical shared memory, and identifies the type of each statement block in the logic execution tree through the statement block operation route.

[0069] Step 202: When the statement block is a default statement block, the running module runs the default statement block.

[0070] Specifically, the default statement block refers to the corresponding statement block anchored by the default language. For example, when the deployed environment database is an Oracle database, the statement block built for the Oracle language does not need to be converted and can be run directly.

[0071] Step 203: When the statement block is a non-default statement block, the running module converts the non-default statement block into a target statement block corresponding to the target database, and runs the target statement block.

[0072] Furthermore, if the deployment environment database is an Oracle database, and the statement block is based on MySQL, the statement block needs to be converted into a statement block of MySQL syntax.

[0073] The language operation method of a heterogeneous database provided in an embodiment of the present invention compiles a standard language script through a compilation module to obtain a logical execution tree, and stores the logical execution tree in a critical shared memory. When the target database generates an operation demand, the operation module obtains the logical execution tree from the critical shared memory, and identifies the type of each statement block in the logical execution tree through the statement block operation route. Then, when the statement block is a default statement block, the operation module runs the default statement block. Alternatively, when the statement block is a non-default statement block, the operation module converts the non-default statement block into a target statement block corresponding to the target database, and runs the target statement block. Thus, the syntax conversion of the statement block is realized on the business system side, and then the statement blocks that do not need to be converted and the converted statement blocks are run to complete the operation of the standard language script for a specific database. Thereby, the efficiency of script operation in the heterogeneous database scenario is improved, and the operation and maintenance costs are reduced.

[0074] Optionally, for the specific functions of the compilation module, a possible implementation is provided below. Specifically, Figure 2 On the basis of Figure 3 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention is shown in FIG. Figure 3 , step 200, comprising:

[0075] Step 200-1: The compiling module scans the storage files in the specified path to obtain the standard language script.

[0076] Specifically, when the application project is started, the compilation module can scan the standard language script xml file in the specified path.

[0077] Step 200-2: The compiling module parses and precompiles the standard language script to obtain a logic execution tree.

[0078] Step 200-3: The compiling module stores the logic execution tree in the critical shared memory according to the executable data structure.

[0079] Specifically, Map can be set in critical shared memory<String, LogicExecuteTree> Data structure, the key is the ID of the parsed standard language script, such as the ID of the standard language script is the tag <procedure>The ID on the function is procedureID. The value is the compiled executable logic execution tree. When calling the function later, if Key=procureID is passed in, the compiled executable data structure of the defined XML script can be obtained.

[0080] Specifically, the XML script example is as follows:

[0081] <?xml version="1.0" encoding="UTF-8"?>

[0082] <!DOCTYPE transform PUBLIC

[0083] "- / / hsrcm.h**dsun.com / / DTD Transform 1.0 / / EN"

[0084] "http: / / hsrcm.h**dsun.com / dtd / hsrcm-1-transform.dtd">

[0085] <transform id="procedureId" datasource="hsinfo">

[0086] <desc><![CDATA[ Application layer PL / SQL mode stored procedure ]]>< / desc>

[0087] <param id="userId" dataType="string" value="#{userId}" desc="入参:用户id">

[0088] <param id="age" dataType="int" value="#{age}" default="18" desc="入参:用户年龄">

[0089] <!-- Return logic control -->

[0090] <if test="userId == null">

[0091] <return mode="exception" message="入参age不能为空!" / >

[0092] < / if>

[0093] <!-- Query SQL statement block -->

[0094] <selectsql id="selectUserCount">

[0095] select count(1) as "COUNT" from USER where USER_ID = #{userId}

[0096] < / selectsql>

[0097] <!-- Logic control statement block -->

[0098] <if test="selectUserCount.COUNT lte 0 ">

[0099] <updatesql id="updateUser">

[0100] update USER set AGE = #{age} where USER_ID = #{userId}

[0101] < / updatesql>

[0102] < / if>

[0103] <selectlistsql id="selectUserList">

[0104] select user_id as "userId" from USER limit 10

[0105] < / selectlistsql>

[0106] <!-- Cursor statement block -->

[0107] <cursor list="selectUserList" item="myItem" index="myIndex">

[0108] <param id="userId" dataType="string" value="#{myItem.userId}">

[0109] <updatesql id="updateUser">

[0110] update USER set AGE = #{age} where USER_ID = #{userId}

[0111] < / updatesql>

[0112] < / cursor>

[0113] < / transform>

[0114] Optionally, since the examples provided by the present invention need to identify each statement block in the logic execution tree, it is also necessary to parse each statement block in the standard language script when constructing the logic execution tree. The following provides a possible implementation method for how to parse statement blocks and how to use statement blocks to construct a logic execution tree. Specifically, in Figure 3 On the basis of Figure 4 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention is shown in FIG. Figure 4 , step 200-2, comprising:

[0115] Step 200 - 2a: The compiling module performs syntax analysis on the standard language script to obtain each statement block included in the standard language script.

[0116] Specifically, taking the above example standard language script xml file as an example, in order to parse the xml file, SAX (Simple API for XML) parsing can be used. Since the SAX parsing does not need to load the entire file into memory, it is suitable for processing large xml files. In addition, in order to verify the syntax of the standard language script xml file, the document type definition (DTD) can be used to verify the syntax of the xml file. Therefore, for step 200-2a, if there is a problem with the syntax of the xml file, the compilation of this stage is terminated due to an abnormality.

[0117] Step 200 - 2b: The compiling module parses each statement block and constructs a logic execution tree.

[0118] Specifically, after passing the syntax check, the statement block is parsed, such as parameters, logic control classes, and SQL statement fragments. The key SQL statement fragments are parsed, and the SQL is subjected to basic syntax check. If an exception occurs during the process, the compilation of this stage is terminated abnormally.

[0119] Specifically, when analyzing a statement block, if the current statement block is a statement block of the default syntax, for example, the default syntax is anchored to the Oracle language, and the deployed environment database is an Oracle database, then there is no need to convert the statement block in the future. If the deployed database is MySQL, the statement block of the default syntax needs to be converted to a statement block of the MySQL syntax.

[0120] Optionally, since the embodiment of the present invention utilizes the type of statement blocks, when the syntax conversion of heterogeneous databases is required, the statement blocks that need to be converted are identified. Therefore, the embodiment of the present invention introduces statement block execution routing to identify statement blocks. Specifically, in Figure 2 On the basis of Figure 5 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention is shown in FIG. Figure 5 , step 201, comprising:

[0121] Step 201 - 1 : After the running module obtains the logic execution tree, the first statement block in the logic execution tree is obtained through depth-first search.

[0122] Step 201-2: The running module determines the type information of the statement block by running the statement block route.

[0123] Step 201 - 3 : If the type information is parameter class, logic control class, transaction commit class, cursor class or default SQL class, the statement block is a default statement block.

[0124] Specifically, if the type information is a parameter class, the parameter is constructed from the context. If the parameter has not been defined before, an exception is raised. If the type information is a logic control class, such as an if-type conditional control, the Object-Graph Navigation Language (OGNL) expression engine determines whether the expression is satisfied; if it is a return statement block, the standard language script is jumped out. If the type information is a transaction commit class, the transaction is committed, and subsequent statement block exceptions will not be able to roll back the currently committed data. If the type information is a cursor class, the list data is traversed and processed one by one, and each processing has an independent stack space and does not affect each other. If the type information is a default SQL class, it means that the deployed database is consistent with the anchored default environment and language, and there is no need to perform syntax conversion on the SQL statement block.

[0125] Specifically, based on the example of the XML script in the previous article, the statement block of the parameter class can include: <param> . Logical control class, whose statement block can contain: <if> 、 <choose> 、 <when> 、 <otherwise> 、 <return>. Transaction commit class, whose statement block can contain: <commit>. Cursor class, whose statement block can contain: <cursor>.

[0126] Similarly, if the SQL statement block is a non-default statement block, for example, its statement block can contain: DQL class: <selectsql>. DML class: <insertsql> 、 <updatesql> 、 <deletesql> 、 <callsql>. DDL class: <createtablesql> 、 <droptablesql> 、 <createindexsql> 、 <dropindexsql>。

[0127] Further, in the above example, "if the type information is of the logical control type, use the OGNL expression engine to determine whether the expression is satisfied", refer to the example in the previous xml script:

[0128] <!-- Logical control statement block -->

[0129] <if test="selectUserCount.COUNT lte 0 ">

[0130] Among them, "selectUserCount.COUNT lte 0" is an OGNL expression. Therefore, the OGNL expression engine is used to determine whether the content after test is an OGNL expression. If so, the type information is confirmed to be a logic control class.

[0131] Step 201-4: If the type information is a non-default SQL class, the statement block is a non-default statement block.

[0132] Specifically, for the non-default SQL class, it may include but is not limited to: Data Query Language (DQL) class statement blocks, Data Manipulation Language (DML) class statement blocks, and Data Definition Language (DDL) class statement blocks.

[0133] The operation module operates as follows: For DQL statement blocks: the query results are put into the context for use by subsequent statement blocks. For DML statement blocks: SQL statements for adding, deleting, and modifying are executed, and the number of changed rows is put into the context for use by subsequent statement blocks. For DDL statement blocks: SQL statements such as adding, deleting, and modifying tables, changing tables, and changing indexes are executed.

[0134] Preferably, the running module can also output an execution log after the default statement block or the target statement block is executed.

[0135] Specifically, the execution log includes the start time, end time, and context parameters. If a SQL statement block is executed, the execution log also includes the executed SQL statement block for subsequent debugging and location of abnormal problems.

[0136] Optionally, for a non-default SQL statement block, a possible implementation method is provided below, which is an implementation method for how to implement syntax conversion, that is, converting a non-default statement block into a language that conforms to the target database. Specifically, Figure 5 On the basis of Figure 6 A flowchart of another method for operating a language in a heterogeneous database provided by an embodiment of the present invention is shown in FIG. Figure 6 , step 203, comprising:

[0137] Step 203-1: The running module intercepts the non-default statement block by executing the proxy.

[0138] Optionally, a Java Database Connectivity (JDBC) agent may be used as the execution agent. The JDBC agent may be embedded in the business system, that is, as a part of the running module; or, it may be arranged as an independent agent between the business system and the database.

[0139] Step 203-2: The running module parses the non-default statement block by executing the proxy to obtain the original abstract syntax tree corresponding to the non-default statement block.

[0140] Specifically, for example Figure 1 In the example shown, the original abstract syntax tree is Oracle AST.

[0141] Step 203-3: The operation module confirms the type of the target database by executing the agent.

[0142] Specifically, taking the JDBC proxy as an example, it can determine the type of the target database through the JDBC URL. The JDBC URL can be obtained from database documents, database management tools, integrated development environments, database driver documents, application servers, etc.

[0143] For example, the JDBC URL example: s_devops_oracle.urljdbc:oracle:thin:@10.20.38.188:1521 / srm5, you can confirm that the type of the target database is "Oracle database".

[0144] Step 203 - 4 : The running module converts the original abstract syntax tree into a target abstract syntax tree corresponding to the target database by executing the agent according to the type of the target database.

[0145] Step 203-5: The running module generates a target statement block corresponding to the target database according to the target abstract syntax tree by executing the agent.

[0146] Specifically, taking SQL statements as an example, a target SQL statement block corresponding to the target database may be generated according to the target abstract syntax tree.

[0147] Step 203-6: The running module transfers the executable statement block to the target database driver through the execution agent to complete the running.

[0148] For each example of the language operation method of the heterogeneous database shown above, a language operation device of the heterogeneous database is provided below, which is used to implement each step of the above method flow to achieve the corresponding technical effect. Specifically, Figure 7 A schematic diagram of a language operation device for a heterogeneous database provided by an embodiment of the present invention, see Figure 7 The device 30 includes: a compiling module 300 and an operating module 301.

[0149] A compiling module 300 is used to compile a standard language script, obtain a logic execution tree, and store the logic execution tree in a critical shared memory;

[0150] The operation module 301 is used to obtain the logic execution tree from the critical shared memory when the target database generates an operation demand, and identify the type of each statement block in the logic execution tree through the statement block operation route; when the statement block is a default statement block, the default statement block is run; when the statement block is a non-default statement block, the non-default statement block is converted into a target statement block corresponding to the target database, and the target statement block is run.

[0151] The embodiment of the present invention further provides an electronic device, which can execute all the steps of the above examples of the embodiment of the present invention to achieve the corresponding technical effects. Specifically, Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, see Figure 8 , the electronic device 50, comprises: a memory 501, a processor 500;

[0152] Memory 501, used to store one or more programs;

[0153] Processor 500;

[0154] When one or more programs are executed by the processor, when the electronic device 50 is used to execute the steps shown in the above-mentioned method examples, it can achieve each step and the corresponding technical effects.

[0155] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0156] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0157] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a program product, which is stored in a computer-readable storage medium and includes a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

[0158] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0159] It will be apparent to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present application. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.< / if> < / dropindexsql> < / createindexsql> < / droptablesql> < / createtablesql> < / callsql> < / deletesql> < / updatesql> < / insertsql> < / selectsql> < / cursor> < / commit> < / return> < / otherwise> < / when> < / choose> < / if> < / procedure>

Claims

1. A language operation method for a heterogeneous database, characterized in that: The method is applied to a business system, the business system includes a compiling module and an operating module, the business system is connected to at least one database, and the method includes: The compiling module compiles the standard language script to obtain a logic execution tree, and stores the logic execution tree in the critical shared memory; When the target database generates an operation demand, the operation module obtains the logic execution tree from the critical shared memory, and obtains the first statement block in the logic execution tree through depth-first search; The running module determines the type information of the statement block through the statement block running route; If the language of the target database is consistent with the language of the standard language script, and the type information is a parameter class, a logic control class, a transaction submission class, a cursor class or a default SQL class, then the statement block is a default statement block; the default SQL class is used to indicate that the corresponding SQL statement block is a statement block corresponding to anchoring using the default language; the default language is the language used when developing the standard language script; If the language of the target database is inconsistent with the language of the standard language script, and the type information is a non-default SQL class, then the statement block is a non-default statement block; the non-default SQL class is used to indicate that the type information of the statement block is: a data query language DQL class statement block, a data manipulation language DML class statement block, and a data definition language DDL class statement block; When the sentence block is a default sentence block, the running module runs the default sentence block; the default sentence block is a corresponding sentence block anchored in a default language; When the statement block is a non-default statement block, the running module converts the non-default statement block into a target statement block corresponding to the target database and runs the target statement block; the non-default statement block is a statement block that is not converted based on the default language requirements.

2. The method according to claim 1, characterized in that Also includes: The running module outputs an execution log after the default statement block or the target statement block is executed.

3. The method according to claim 1, characterized in that The step of converting the non-default statement block into a target statement block corresponding to the target database and running the target statement block by the running module includes: The running module intercepts the non-default statement block by executing the proxy; The running module parses the non-default statement block through the execution agent to obtain an original abstract syntax tree corresponding to the non-default statement block; The operation module confirms the type of the target database through the execution agent; The running module converts the original abstract syntax tree into a target abstract syntax tree corresponding to the target database through the execution agent according to the type of the target database; The running module generates a target statement block corresponding to the target database according to the target abstract syntax tree through the execution agent; The running module transfers the target statement block to the target database driver through the execution agent to complete the running.

4. The method according to claim 1, characterized in that The step of the compiling module compiling the standard language script to obtain a logic execution tree and storing the logic execution tree in the critical shared memory includes: The compiling module scans the storage files in the specified path to obtain the standard language script; The compiling module parses and precompiles the standard language script to obtain the logic execution tree; The compiling module stores the logic execution tree in the critical shared memory according to an executable data structure.

5. The method according to claim 4, characterized in that The step of the compiling module parsing and precompiling the standard language script to obtain the logic execution tree includes: The compiling module performs syntax analysis on the standard language script to obtain each statement block included in the standard language script; The compiling module parses each of the statement blocks and constructs the logic execution tree.

6. A language operation device for a heterogeneous database, characterized in that: The device is applied to a business system, and the business system is connected to at least one database for communication, and includes: a compiling module and an operating module, The compiling module is used to compile the standard language script to obtain a logic execution tree, and store the logic execution tree in the critical shared memory; The operation module is used to obtain the logic execution tree from the critical shared memory when the target database generates an operation demand, and obtain the first statement block in the logic execution tree through depth-first search; determine the type information of the statement block through the statement block operation route; if the language of the target database is consistent with the language of the standard language script, and the type information is a parameter class, a logic control class, a transaction submission class, a cursor class or a default SQL class, then the statement block is a default statement block; the default SQL class is used to indicate that the corresponding SQL statement block is a corresponding statement block anchored by the default language; the default language is the language used when developing the standard language script; if the language of the target database is consistent with the language of the standard language script, If the languages ​​of the quasi-language scripts are inconsistent and the type information is a non-default SQL class, the statement block is a non-default statement block; the non-default SQL class is used to indicate that the type information of the statement block is: data query language DQL class statement block, data manipulation language DML class statement block and data definition language DDL class statement block; when the statement block is a default statement block, the default statement block is run; the default statement block is a corresponding statement block anchored in the default language; when the statement block is a non-default statement block, the non-default statement block is converted into a target statement block corresponding to the target database, and the target statement block is run; the non-default statement block is a statement block that is not converted based on the default language.

7. An electronic device, characterized in that: include: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

9. A program product, characterized in that When the program product is executed by a processor, the method according to any one of claims 1 to 5 is implemented.