Multi-database statement execution result automatic comparison method, system, device and medium

By automatically comparing the execution results of statements from multiple databases through middleware and interface call modules, the problem of low efficiency in comparing multiple database query statements is solved, and efficient and accurate statement execution and optimization reference are achieved.

CN116719836BActive Publication Date: 2026-06-05CHINA CONSTRUCTION BANK +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2023-06-12
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies cannot automate the comparison of query statements across multiple databases, resulting in low comparison efficiency and an inability to guarantee that query statements are executed quickly and accurately in new databases.

Method used

The middleware intercepts and compares the statement execution results of each database, and the interface call module is used to obtain and compare the execution results of multiple databases. It supports parallel calls of multiple interfaces, adapts to different programming languages, and reduces the cost of manual comparison.

Benefits of technology

It enables automated comparison of execution results from multiple databases, improving comparison efficiency, ensuring the accuracy and consistency of execution results, providing access to execution plans and response times, and offering technical support for query optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116719836B_ABST
    Figure CN116719836B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing, and particularly provides a multi-database statement execution result automatic comparison method, system, device and medium, the method comprising the following steps: a middleware acquires a first statement execution result of a first database, and acquires an actual execution statement of the first database based on the first statement execution result; the middleware sends the actual execution statement to a second database corresponding to an interface calling request, so that the second database executes the actual execution statement to obtain a second statement execution result; the middleware acquires the second statement execution result, and compares the first statement execution result with the second statement execution result to obtain a comparison result. In the manner, the statement execution result of each database can be automatically intercepted and compared, and the efficiency of statement execution result comparison is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method, system, device, and medium for automatically comparing the execution results of statements from multiple databases. Background Technology

[0002] With the continuous development of business and the demands of market applications, the types of databases used in the market are becoming increasingly diverse, such as Oracle, MySQL, and distributed databases like TDSQL. Existing database types can no longer meet application needs, necessitating database replacement and transformation. During this transformation process, a significant amount of query statements (i.e., SQL statements) will need to be modified. The most critical challenge in database replacement and transformation is ensuring that these queries can be executed quickly and accurately in the new database.

[0003] Therefore, by optimizing the query statement to ensure its accurate execution across various databases, it is necessary to obtain the execution results of the query statement on each type of database and compare the results to ensure consistency, thus providing a reference for query statement optimization.

[0004] However, current comparison methods still require manual database replacement or input of query statements, which cannot achieve automated comparison processing, resulting in low comparison efficiency. Summary of the Invention

[0005] In view of this, the present invention provides a method, system, device and medium for automatically comparing statement execution results from multiple databases, which can automatically intercept and compare statement execution results from various databases, thereby improving the efficiency of statement execution result comparison.

[0006] To address the aforementioned technical problems, this invention provides an automatic statement execution result comparison method, comprising: middleware obtaining a first statement execution result from a first database, and obtaining the actual executed statement from the first database based on the first statement execution result; wherein the first statement execution result is obtained by an interface calling module responding to a received interface calling request by calling a query statement corresponding to the first database and sending it to the first database to execute the query statement; the middleware sending the actual executed statement to a second database corresponding to the interface calling request, so that the second database executes the actual executed statement to obtain a second statement execution result; the middleware obtaining the second statement execution result and comparing the first statement execution result with the second statement execution result to obtain a comparison result.

[0007] According to some embodiments of the present invention, the interface calling module responds to receiving an interface calling request by calling a query statement of the corresponding first database, including: initializing parameters based on the interface calling request to obtain configuration parameters; and generating a query statement corresponding to the first database based on the configuration parameters and the interface calling request.

[0008] According to some embodiments of the present invention, a query statement corresponding to a first database is generated based on configuration parameters and an interface call request, including: calling the first database based on the interface call request; obtaining statement identification information from the first database based on configuration parameters; and assembling the statement identification information with the configuration parameters to obtain the query statement corresponding to the first database.

[0009] According to some embodiments of the present invention, the middleware obtains the execution result of the first statement, and while obtaining the actual execution statement of the first database based on the execution result of the first statement, it also obtains the execution plan of the first database and / or the response time of the first database.

[0010] According to some embodiments of the present invention, after obtaining the execution result of the first statement, the middleware caches it in the first statement execution result set, and after obtaining the execution result of the second statement, it caches it in the second statement execution result set. The middleware performs a field-by-field comparison based on the first statement execution result set and the second statement execution result set to obtain the comparison result.

[0011] According to some embodiments of the present invention, both the query statement and the actual execution statement are user-defined statements.

[0012] Secondly, embodiments of the present invention provide an automatic comparison system for multi-database statement execution results, including an interface call module and middleware; wherein, the interface call module includes: a receiving module for receiving interface call requests; a calling module for calling a query statement of a corresponding first database based on the interface call request, so that the first database executes the query statement and obtains a first statement execution result; the middleware is extended with a statement execution result comparison plugin for obtaining the first statement execution result and obtaining the actual execution statement of the first database based on the first statement execution result; sending the actual execution statement to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains a second statement execution result; obtaining the second statement execution result and comparing the first statement execution result with the second statement execution result to obtain a comparison result.

[0013] According to some embodiments of the present invention, the calling module is further configured to respond to an interface call request instruction to call two or more interfaces, and simultaneously call the query statements of the first database corresponding to each interface call request, thereby realizing the function of simultaneous multi-interface call, so that each first database executes the corresponding query statement and obtains its corresponding first statement execution result, thereby enabling the statement execution result comparison plugin to simultaneously obtain each first statement execution result, and to complete the comparison task of each first statement execution result with its corresponding second statement execution result in parallel, thereby obtaining the comparison result corresponding to each comparison task.

[0014] According to some embodiments of the present invention, the calling module includes: a parameter configuration module, used to initialize parameters based on the interface call request to obtain configuration parameters; and a statement configuration module, used to generate a query statement corresponding to the first database based on the configuration parameters and the interface call request.

[0015] According to some embodiments of the present invention, a query statement corresponding to a first database is generated based on configuration parameters and an interface call request, including: calling the first database based on the interface call request; obtaining statement identification information from the first database based on configuration parameters; and assembling the statement identification information with the configuration parameters to obtain the query statement corresponding to the first database.

[0016] Thirdly, embodiments of the present invention provide an electronic device, including: a processor; and a memory, wherein computer program instructions are stored in the memory, wherein when the computer program instructions are executed by the processor, the processor performs the following steps:

[0017] The system retrieves the execution result of the first statement from the first database and obtains the actual execution statement from the first database based on the execution result. It then sends the actual execution statement to the second database corresponding to the interface call request, enabling the second database to execute the actual execution statement and obtain the execution result of the second statement. Finally, it retrieves the execution result of the second statement and compares it with the execution result of the first statement to obtain a comparison result. The execution result of the first statement is obtained by the interface call module responding to the interface call request by calling the query statement of the corresponding first database and sending it to the first database to execute the query statement.

[0018] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the following steps:

[0019] The system retrieves the execution result of the first statement from the first database and obtains the actual execution statement from the first database based on the execution result. It then sends the actual execution statement to the second database corresponding to the interface call request, enabling the second database to execute the actual execution statement and obtain the execution result of the second statement. Finally, it retrieves the execution result of the second statement and compares it with the execution result of the first statement to obtain a comparison result. The execution result of the first statement is obtained by the interface call module responding to the interface call request by calling the query statement of the corresponding first database and sending it to the first database to execute the query statement.

[0020] The above-described technical solution of the present invention has at least one of the following beneficial effects:

[0021] This system can proactively trigger middleware during API calls, automatically intercepting the execution results of statements from various databases. This enables automatic comparison of execution results across multiple databases, improving comparison efficiency and reducing manual comparison costs. Simultaneously, the middleware provides accurate statement execution result comparisons, capable of handling large data volumes and field-level comparisons. Furthermore, by obtaining the actual executed statements through middleware and sending them to the next database corresponding to the API, it overcomes the problem of different query languages ​​used for different types of data. This eliminates the need to rewrite query statements and reduces the number of API calls, significantly improving the efficiency of automated comparison and further ensuring the accuracy of statement execution results across databases.

[0022] Furthermore, while intercepting the execution results of statements, it can also obtain the execution plan and response time of the first database, enabling the querying of the execution plan and the viewing of the execution time, providing guidance for table index creation and query statement writing, and providing technical support for subsequent query statement optimization. Attached Figure Description

[0023] Figure 1 This is a schematic diagram of an automatic comparison system for execution results of multiple database statements according to an embodiment of the present invention;

[0024] Figure 2 This is a schematic diagram of the middleware in the multi-database statement execution result automatic comparison system according to an embodiment of the present invention;

[0025] Figure 3 This is a flowchart of the automatic comparison method for statement execution results according to an embodiment of the present invention;

[0026] Figure 4 This is a flowchart illustrating the three-way interaction between the middleware, the interface call module set in the application layer, and the database in the automatic comparison method for statement execution results according to an embodiment of the present invention.

[0027] Figure 5This is a flowchart illustrating the steps of the interface call module invoking the corresponding query statement of the first database based on the interface call request in the automatic comparison method for statement execution results according to an embodiment of the present invention.

[0028] Figure 6 This is a flowchart of the steps in the automatic comparison method for statement execution results of this invention, in which the interface calling module generates a query statement corresponding to the first database based on configuration parameters and interface calling requests;

[0029] Figure 7 This is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0030] With the continuous development of business and the demands of market applications, the types of databases used in the market are becoming increasingly diverse, such as Oracle, MySQL, and distributed databases like TDSQL. Existing database types can no longer meet application needs, necessitating database replacement and transformation. During this transformation process, a significant amount of query statements (i.e., SQL statements) will need to be modified. The most critical challenge in database replacement and transformation is ensuring that these queries can be executed quickly and accurately in the new database.

[0031] Therefore, optimizing query statements to ensure accurate execution across various databases requires obtaining the execution results of the query statements on different database types and comparing these results to determine consistency, thus providing a reference for query optimization. However, current comparison methods still require manually changing the database or inputting the query statement, failing to achieve automated comparison processing and resulting in low comparison efficiency.

[0032] To overcome the aforementioned technical problems, the applicant proposes a method and system for automatically comparing the execution results of statements from multiple databases. This method can automatically intercept and compare the execution results of statements from various databases, thereby improving the efficiency of statement execution result comparison and providing effective reference for subsequent query statement optimization, thus improving the efficiency and accuracy of statement optimization.

[0033] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.

[0034] First, let's introduce the terminology used in this article:

[0035] Middleware: Middleware is a general-purpose service located between the platform (hardware and operating system) and the application layer, and it has standard program interfaces and protocols.

[0036] Database middleware: Database middleware is a middleware service that solves problems related to database capacity, performance bottlenecks, and distributed scaling. It provides capabilities such as database sharding, read / write separation, and elastic scaling to cope with high-concurrency access scenarios of massive data and effectively improve database read and write capabilities.

[0037] like Figure 1 As shown, the automatic comparison system 1000 for multi-database statement execution results in this embodiment of the invention includes an interface call module 1010 and middleware 1020. The interface call module 1010 may be a module set in the application layer.

[0038] The interface call module 1010 includes a receiving module 1011 and a calling module 1012. The receiving module 1011 is used to receive interface call requests. The calling module 1012 is used to call the corresponding query statement of the first database based on the interface call request, so that the first database executes the query statement and obtains the execution result of the first statement.

[0039] The middleware 1020 is extended with a statement execution result comparison plugin 1021. The statement execution result comparison plugin 1021 is used to obtain the execution result of a first statement, and based on the first statement execution result, obtain the actual executed statement from the first database; send the actual executed statement to the second database corresponding to the interface call request, so that the second database executes the actual executed statement and obtains the execution result of the second statement; obtain the execution result of the second statement, and compare it with the execution result of the first statement to obtain the comparison result. Through the middleware 1020 extended with the statement execution result comparison plugin 1021, automated comparison of statement execution results from multiple databases can be achieved, thereby improving the efficiency of statement execution result comparison.

[0040] Understandably, Figure 1 The database set shown may contain one, two, or more first databases and second databases. In this document, the terms "first" and "second" in the first and second databases are used only to distinguish two different databases. The first database indicates the database that executes the query statement, which is called by the interface calling module 1010 in response to the interface calling request. The second database indicates the database that executes the actual query statement, which is called by the middleware 1020. No restrictions are placed on the order of database calls, database types, or number of databases in the database set.

[0041] In one embodiment, such as Figure 2As shown, the statement execution result comparison plugin 1021 may include a database interface for acquiring and sending information with various databases. The middleware 1020 also includes a middleware unit 1022, which is used to configure the various interfaces and parameters within the middleware 1020. Specifically, the middleware unit 1022 may include a plugin manager. The plugin manager is used to select and update appropriate types of statement execution result comparison plugins from the plugin library as the current statement execution result comparison plugin based on the database type and / or the programming language type of the query statement. The statement execution result comparison plugins in the plugin library can be configured according to actual needs and are not limited here.

[0042] In one embodiment, the statement execution result comparison plugin 1021 can be a MyBatis statement execution result comparison plugin. MyBatis is a middleware plugin for the Java database persistence layer that supports custom query statements, stored procedures, and advanced mappings. The MyBatis statement execution result comparison plugin can internally encapsulate Java DataConnectivity (JDBC), a Java database interface (API) for executing query statements. This provides unified access to multiple relational databases, allowing developers to focus solely on the query statement itself without having to deal with complex processes such as loading drivers and creating connections. This significantly improves the flexibility and efficiency of automatic comparison of statement execution results across multiple databases.

[0043] In one embodiment, the calling module 1012 is further configured to respond to an interface call request instruction to call two or more interfaces simultaneously, and to simultaneously call the query statements of the first database corresponding to each interface call request, thereby realizing the function of simultaneous multi-interface call. This allows each first database to execute its corresponding query statement and obtain its corresponding first statement execution result. Consequently, the statement execution result comparison plugin 1021 simultaneously obtains the execution results of each first statement and performs the comparison task of each first statement execution result with its corresponding second statement execution result in parallel, obtaining the comparison result corresponding to each comparison task. The calling module 1012 can realize simultaneous multi-interface call, thereby satisfying the parallel comparison requirement of the statement execution results of multiple query statements, that is, satisfying the parallel processing requirement of multiple comparison tasks.

[0044] In one embodiment, the calling module 1012 may include a parameter configuration module and a statement configuration module (not shown in the figure). The parameter configuration module is used to initialize parameters based on the interface call request to obtain configuration parameters; the statement configuration module is used to generate a query statement corresponding to the first database based on the configuration parameters and the interface call request.

[0045] In one embodiment, the step of generating a query statement corresponding to the first database based on configuration parameters and an interface call request includes: calling the first database based on the interface call request; obtaining statement identification information from the first database based on configuration parameters; and assembling the statement identification information with the configuration parameters to obtain the query statement corresponding to the first database.

[0046] In the above embodiments, the multi-database statement execution result automatic comparison system, by extending middleware with a statement execution result comparison plugin, can achieve automated comparison of statement execution results across multiple databases, improving the efficiency of statement execution result comparison and reducing the cost of population comparison. Furthermore, the interface call module located at the application layer can support simultaneous calls to multiple interfaces, further meeting the parallel processing requirements of multiple comparison tasks. The following section provides a detailed description of the multi-database statement execution result automatic comparison method implemented by the middleware in the multi-database statement execution result automatic comparison system.

[0047] like Figure 3 As shown, the multi-database statement execution result automatic comparison method of this invention is applied to the middleware of the statement execution result automatic comparison system. The statement execution result automatic comparison system also includes an interface call module, comprising:

[0048] Step 110: The middleware obtains the execution result of the first statement in the first database and obtains the actual execution statement in the first database based on the execution result of the first statement.

[0049] The middleware obtains the execution result of the first statement in the first database and obtains the actual execution statement in the first database based on the execution result of the first statement. The actual execution statement may include the statement identification information (sql id) of the query statement executed by the first database and the configuration parameters. The statement identification information is a unique identifier for each query statement, and the configuration parameter information is the dynamic parameters in the query statement.

[0050] In one embodiment, both the query statement and the actual execution statement are custom statements, which can be customized according to the actual application requirements and are not limited here.

[0051] The execution result of the first statement is obtained by the interface calling module responding to the interface calling request by calling the corresponding query statement of the first database and sending it to the first database to execute the query statement. This will not be described in detail here.

[0052] Step 120: The middleware sends the actual execution statement to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result of the second statement.

[0053] The middleware sends the actual execution statement to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result. It can be understood that the relationship between the interface and the database can be one-to-many, meaning one interface can correspond to one, two, or more databases. The correspondence between the interface and the database can be configured according to actual needs and is not limited here.

[0054] Specifically, the interface call module can first respond to the interface call request and call the query statement of the first database corresponding to the interface so that the first database executes the query statement. For the remaining one, two or more databases corresponding to the interface, the middleware can sequentially send the actual execution statement to the corresponding remaining databases so that all databases corresponding to the interface execute the query statement.

[0055] The same query statement in different programming languages ​​has the same actual execution statement. By obtaining the actual execution statement through middleware and sending it to the next database, the problem of different programming languages ​​used by different types of databases can be overcome. It adapts to the programming language format of each database, eliminates the need to rewrite the query statement, and saves the number of interface calls, thereby greatly improving the efficiency of automated comparison and further ensuring the accuracy of the statement execution results of each database.

[0056] In one embodiment, the middleware can obtain the execution result of the first statement, and based on that result, obtain the actual executed statement of the first database, as well as the execution plan and / or response time of the first database. The execution plan of the first database is the statement execution plan for the query statement executed by the first database, i.e., the specific steps of executing the query statement, such as whether to access data in the table through an index or a full table scan, the implementation method of the join query, and the order of the joins. The response time of the first database is the time taken to execute the query statement. Viewing the execution plan of the first database can provide technical evidence to support subsequent query statement optimization; obtaining the response time of the first database can be used to determine the running efficiency of the query statement, thus providing a reference for subsequent query statement optimization.

[0057] Step 130: The middleware obtains the execution result of the second statement and compares it with the execution result of the first statement to obtain the comparison result.

[0058] When the actual execution statement is executed in the second database and the execution result of the second statement is obtained, the middleware can intercept the execution result of the second statement and compare it with the execution result of the first statement to obtain the comparison result. Understandably, in one embodiment, the middleware can also obtain the execution plan of the second database and / or the response time of the second database while obtaining the execution result of the second statement, to provide a reference for optimizing subsequent query statements.

[0059] In one embodiment, the middleware can cache the execution result of the first statement to the first statement execution result set after obtaining the execution result of the second statement, and cache the execution result of the second statement to the second statement execution result set after obtaining the execution result of the second statement. The middleware performs a field-by-field comparison based on the execution result set of the first statement and the execution result set of the second statement to obtain the comparison result.

[0060] In one embodiment, the step of comparing each field based on the first statement execution result set and the second statement execution result set may include, but is not limited to, comparing the number of fields in each statement execution result, the length of each corresponding field, and the semantics.

[0061] This embodiment can proactively trigger middleware during interface calls, automatically intercepting the statement execution results from various databases to achieve automatic comparison of statement execution results across multiple databases. This improves comparison efficiency and reduces manual comparison costs. Simultaneously, the middleware provides accurate statement execution result comparisons, capable of handling large data volumes and field-level comparisons. Furthermore, by obtaining the actual executed statement through the middleware and sending it to the next database corresponding to the interface, it overcomes the problem of different statement writing languages ​​used for different types of data. This eliminates the need to rewrite query statements and reduces the number of interface calls, significantly improving the efficiency of automated comparison and further ensuring the accuracy of statement execution results from each database. In addition, while intercepting statement execution results, it can also obtain the execution plan and response time of the first database, enabling querying of the execution plan and viewing of execution time. This provides guidance for table index creation and query statement writing, and offers technical support for subsequent query statement optimization.

[0062] like Figure 4 As shown below, an embodiment of the above-mentioned method for automatically comparing the execution results of multiple database statements will be described in detail below, taking the form of interaction between middleware, an interface call module set in the application layer, and a database set.

[0063] Step 210: The interface call module receives the interface call request.

[0064] Step 220: The interface call module invokes the corresponding query statement of the first database based on the interface call request.

[0065] In one embodiment, such as Figure 5 As shown, step 220 specifically includes:

[0066] Step 221: Initialize parameters based on the interface call request to obtain configuration parameters.

[0067] Parameters are initialized based on the API call request to obtain configuration parameters, which can be dynamic parameters for generating query statements.

[0068] Step 222: Based on the configuration parameters and the interface call request, generate the query statement corresponding to the first database.

[0069] In one embodiment, such as Figure 6 As shown, step 222 may include:

[0070] Step 2221: Call the first database based on the interface call request.

[0071] Step 2222: Obtain statement identification information from the first database based on configuration parameters.

[0072] In one embodiment, the persistence layer of the first database can be invoked based on an interface call request, and then statement identification information can be obtained from the persistence layer based on configuration parameters. The statement identification information and configuration parameters are then assembled to obtain the query statement corresponding to the first database.

[0073] Step 2223: Assemble the statement identification information with the configuration parameters to obtain the query statement corresponding to the first database.

[0074] Correspondingly, in step 250 below, the middleware can be used to obtain the actual execution statement containing the statement identification information and configuration parameters.

[0075] Step 230: The first database executes the query statement and obtains the execution result of the first statement.

[0076] Step 240: The middleware obtains the execution result of the first statement in the first database and caches it in the first statement execution result set. At the same time, it obtains the execution plan and / or response time of the first database.

[0077] Step 250: The middleware obtains the actual execution statement of the first database based on the execution result of the first statement, and sends the actual execution statement to the second database corresponding to the interface call request.

[0078] Step 260: The second database executes the actual statement and obtains the execution result of the second statement.

[0079] Step 270: The middleware obtains the execution result of the second statement and caches it in the second statement execution result set.

[0080] Step 280: Perform a field-by-field comparison based on the execution result set of the first statement and the execution result set of the second statement to obtain the comparison result and feed it back to the interface call module.

[0081] In this embodiment, middleware is set up between the interface call module at the application layer and the database to automatically intercept and compare the statement execution results of multiple databases, improving comparison efficiency and reducing manual comparison costs. Simultaneously, by obtaining the execution plan and response time of the first database, the execution plan can be queried and the execution time viewed, providing guidance for table index creation and query statement writing, and offering technical support for subsequent query statement optimization.

[0082] An embodiment of the present invention also provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the automatic comparison method for execution results of multi-database statements as provided in the above method embodiments.

[0083] Memory is used to store software programs and modules. The processor executes these stored software programs and modules to perform various functional applications and data processing. Memory can primarily consist of a program storage area and a data storage area. The program storage area stores the operating system, application programs required for functionality, etc.; the data storage area stores data created based on device usage, etc. Furthermore, memory can include high-speed random access memory (RAM) and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory can also include a memory controller to provide the processor with access to the memory.

[0084] In one specific embodiment Figure 7 A schematic diagram of an electronic device 700 for implementing the automatic comparison method for multi-database statement execution results provided in the embodiments of the present invention is shown. The electronic device 700 can be a computer terminal, a mobile terminal or other devices.

[0085] like Figure 7 As shown, this embodiment of the invention provides an electronic device 700, including a processor 701 and a memory 702. The memory 702 stores computer program instructions, wherein when the computer program instructions are executed by the processor, the processor 701 performs the following steps:

[0086] The system retrieves the execution result of the first statement from the first database and obtains the actual execution statement from the first database based on the execution result. It then sends the actual execution statement to the second database corresponding to the interface call request, enabling the second database to execute the actual execution statement and obtain the execution result of the second statement. Finally, it retrieves the execution result of the second statement and compares it with the execution result of the first statement to obtain a comparison result. The execution result of the first statement is obtained by the interface call module responding to the interface call request by calling the query statement of the corresponding first database and sending it to the first database to execute the query statement.

[0087] Furthermore, such as Figure 7 As shown, the electronic device also includes a network interface 703, an input device 704, a hard disk 705, and a display device 706.

[0088] The various interfaces and devices described above can be interconnected via a bus architecture. The bus architecture can include any number of interconnecting buses and bridges. Specifically, various circuits representing one or more central processing units (CPUs), represented by processor 701, and one or more memories, represented by memory 702, are connected together. The bus architecture can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits. It is understood that the bus architecture is used to implement communication between these components. In addition to the data bus, the bus architecture also includes a power bus, a control bus, and a status signal bus, all of which are well known in the art and will not be described in detail herein.

[0089] The network interface 703 can connect to a network (such as the Internet, local area network, etc.), obtain relevant data from the network, and save it to the hard disk 705.

[0090] Input device 704 can receive various instructions input by the operator and send them to processor 701 for execution. Input device 704 may include a keyboard or clicking device (e.g., mouse, trackball, touchpad, or touch screen).

[0091] Display device 706 can display the results obtained by the processor 701 executing instructions.

[0092] The memory 702 is used to store the programs and data necessary for the operation of the operating system, as well as intermediate results and other data during the calculation process of the processor 701.

[0093] It is understood that the memory 702 in the embodiments of the present invention may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. The memory 702 of the apparatus and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0094] In some implementations, memory 702 stores elements such as executable modules or data structures, or subsets thereof, or extended sets thereof: operating system 7021 and application program 7022.

[0095] The operating system 7021 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 7022 includes various applications, such as a browser, used to implement various application functions. The program implementing the method of this embodiment can be included in the application program 7022.

[0096] When the processor 701 calls and executes the application program and data stored in the memory 702, specifically, the program or instructions stored in the application program 7022, it obtains the execution result of the first statement in the first database and obtains the actual execution statement of the first database based on the execution result of the first statement; it sends the actual execution statement to the second database corresponding to the interface call request so that the second database executes the actual execution statement and obtains the execution result of the second statement; it obtains the execution result of the second statement and compares the execution result of the first statement with the execution result of the second statement to obtain a comparison result; wherein, the execution result of the first statement is obtained by the interface call module responding to the interface call request by calling the query statement of the corresponding first database and sending it to the first database so that it executes the query statement.

[0097] The methods disclosed in the above embodiments of the present invention can be applied to processor 701, or implemented by processor 701. Processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 701 or by instructions in software form. The processor 701 may be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), off-the-shelf programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 702, and processor 701 reads the information in memory 702 and completes the steps of the above method in combination with its hardware.

[0098] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions of this application, or combinations thereof.

[0099] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. Memory can be implemented within the processor or externally.

[0100] In addition, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the following steps:

[0101] The system retrieves the execution result of the first statement from the first database and obtains the actual execution statement from the first database based on the execution result. It then sends the actual execution statement to the second database corresponding to the interface call request, enabling the second database to execute the actual execution statement and obtain the execution result of the second statement. Finally, it retrieves the execution result of the second statement and compares it with the execution result of the first statement to obtain a comparison result. The execution result of the first statement is obtained by the interface call module responding to the interface call request by calling the query statement of the corresponding first database and sending it to the first database to execute the query statement.

[0102] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0103] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.

[0104] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the transmission and reception methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0105] 5. The above description is a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for automatically comparing the execution results of statements from multiple databases, characterized in that, Middleware applied to an automatic statement execution result comparison system, the automatic statement execution result comparison system further includes an interface call module, and the method includes the following steps: The middleware obtains the execution result of the first statement in the first database, and obtains the actual execution statement in the first database based on the execution result of the first statement; Wherein, the execution result of the first statement is obtained by the interface calling module responding to the interface calling request by calling the corresponding query statement of the first database and sending it to the first database to execute the query statement; The middleware sends the actual execution statement to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result of the second statement; The middleware obtains the execution result of the second statement and compares it with the execution result of the first statement to obtain a comparison result.

2. The method according to claim 1, characterized in that, The interface call module responds to the received interface call request by calling the corresponding query statement of the first database, including: Based on the interface call request, parameter initialization is performed to obtain configuration parameters; Based on the configuration parameters and the interface call request, a query statement corresponding to the first database is generated.

3. The method according to claim 2, characterized in that, The step of generating a query statement corresponding to the first database based on the configuration parameters and the interface call request includes: The first database is invoked based on the interface call request; Based on the configuration parameters, obtain statement identification information from the first database; The statement identifier information is combined with the configuration parameters to obtain the query statement corresponding to the first database.

4. The method according to claim 1, characterized in that, The middleware obtains the execution result of the first statement, and based on the execution result of the first statement, obtains the actual execution statement of the first database, as well as the execution plan of the first database and / or the response time of the first database.

5. The method according to claim 1, characterized in that, After obtaining the execution result of the first statement, the middleware caches it in the first statement execution result set; and after obtaining the execution result of the second statement, it caches it in the second statement execution result set. Specifically, the comparison results are obtained by comparing each field of the result set of the first statement execution with the result set of the second statement execution.

6. The method according to claim 1, characterized in that, Both the query statement and the actual execution statement are user-defined statements.

7. A system for automatically comparing the execution results of statements from multiple databases, characterized in that, include: The interface call module includes: a receiving module for receiving interface call requests; and a calling module for calling a query statement of the corresponding first database based on the interface call request, so that the first database executes the query statement and obtains the execution result of the first statement. The middleware includes a statement execution result comparison plugin, which is used to obtain the execution result of the first statement and, based on the execution result of the first statement, obtain the actual execution statement of the first database; send the actual execution statement to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result of the second statement; obtain the execution result of the second statement and compare it with the execution result of the first statement to obtain a comparison result.

8. The system according to claim 7, characterized in that, The calling module is further configured to respond to the interface call request instruction to call two or more interfaces, and simultaneously call the query statements of the first database corresponding to each interface call request, thereby realizing the function of simultaneous multi-interface call, so that each of the first databases executes the corresponding query statement and obtains its corresponding first statement execution result, thereby enabling the statement execution result comparison plugin to simultaneously obtain each of the first statement execution results and complete the comparison task of each of the first statement execution results with its corresponding second statement execution results in parallel, and obtain the comparison result corresponding to each comparison task.

9. The system according to claim 7, characterized in that, The calling module includes: The parameter configuration module is used to initialize parameters based on the interface call request and obtain configuration parameters; The statement configuration module is used to generate a query statement corresponding to the first database based on the configuration parameters and the interface call request.

10. The system according to claim 9, characterized in that, The step of generating a query statement corresponding to the first database based on the configuration parameters and the interface call request includes: The first database is invoked based on the interface call request; Based on the configuration parameters, obtain statement identification information from the first database; The statement identifier information is combined with the configuration parameters to obtain the query statement corresponding to the first database.

11. An electronic device, characterized in that, include: processor; and a memory, in which computer program instructions are stored. When the computer program instructions are executed by the processor, the processor performs the following steps: Obtain the execution result of the first statement in the first database, and obtain the actual execution statement in the first database based on the execution result of the first statement; The actual execution statement is sent to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result of the second statement; Obtain the execution result of the second statement, and compare the execution result of the first statement with the execution result of the second statement to obtain the comparison result; The execution result of the first statement is obtained by the interface calling module responding to the interface calling request by calling the corresponding query statement of the first database and sending it to the first database to execute the query statement.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, cause the processor to perform the following steps: Obtain the execution result of the first statement in the first database, and obtain the actual execution statement in the first database based on the execution result of the first statement; The actual execution statement is sent to the second database corresponding to the interface call request, so that the second database executes the actual execution statement and obtains the execution result of the second statement; Obtain the execution result of the second statement, and compare the execution result of the first statement with the execution result of the second statement to obtain the comparison result; The execution result of the first statement is obtained by the interface calling module responding to the interface calling request by calling the corresponding query statement of the first database and sending it to the first database to execute the query statement.