Logic comparison method for storing program, device thereof, electronic device and storage medium

By converting the stored procedure of the source database into the stored procedure of the target database, and automatically adjusting inconsistent output parameters and table data results based on weight values, the problem of inconsistent stored procedure calculation results after database migration is solved, achieving efficient and accurate logical comparison.

CN116955321BActive Publication Date: 2025-12-26INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310953951.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-12-26
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

During database transformation, inconsistent underlying logic of different databases leads to inconsistent calculation results in stored procedures after migration. In existing technologies, manual verification is inefficient and prone to missing business scenarios, and cannot fully cover code branches.

Method used

The stored procedure of the source database is converted into a stored procedure of the target database. By comparing the source stored procedure with the target stored procedure, the weight value is determined, the call parameters of the code branch are parsed, and the stored procedure is executed based on the weight value, automatically adjusting inconsistent output parameters and table data results.

Benefits of technology

This improves the efficiency and accuracy of stored procedure verification, ensures comprehensive coverage of code branches, and avoids impacting the actual data in the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116955321B_ABST
    Figure CN116955321B_ABST
Patent Text Reader

Abstract

The application discloses a logic comparison method and device for a storage program, an electronic device and a storage medium, and relates to the field of financial technology or other related fields. The method comprises the following steps: converting each source storage program of a source database into a target storage program of a target database, comparing the source storage program with the target storage program to obtain a comparison result, parsing the code branches in each source storage program and each target storage program to obtain the calling parameters of the code branches, executing the same storage program of the two databases simultaneously based on the weight value and the calling parameters to obtain an execution result, and adjusting the target storage program indicated by the second out-parameter result and / or the second table data result in the case that the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent and / or the first table data result and the second table data result are inconsistent. The application solves the technical problem of low efficiency and accuracy in checking the storage program in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of financial technology, in particular to a logic comparison method for stored procedures, a device thereof, an electronic device and a storage medium. BACKGROUND

[0002] In a database transformation stage (i.e. a stage of migrating data from an old database to a new database), the code of a source database (for example, an Oracle database, which is a relational database) is converted into new code adapted to a target database (for example, a GaussDB database, which is a distributed relational database) by a tool.

[0003] Due to the inconsistency of the underlying logic of different databases, in order to adapt to the target database, the conversion tool will rewrite the code. Therefore, even if the same input parameter (i.e. the parameter input into the stored procedure) is used to run the same stored procedure in different databases, different databases may have inconsistent calculation results. In order to ensure the accuracy of the business logic, the developer needs to debug a large number of stored procedures.

[0004] In the related art, the same input parameter is often used to run the same stored procedure in the source database and the target database, and then the output parameter results after running are compared, and the output parameter results are manually checked. However, the output parameter (i.e. the parameter output by the stored procedure) is usually a result flag indicating success or failure, and cannot prove the accuracy of the running logic in the stored procedure and the comprehensiveness of the code branch, so not only a large amount of manpower is consumed, causing low comparison efficiency, but also there are problems such as missing business scenarios and incomplete code branch coverage.

[0005] In view of the above problems, no effective solution has been proposed so far. SUMMARY

[0006] The embodiments of the present application provide a logic comparison method for stored procedures, a device thereof, an electronic device and a storage medium, to at least solve the technical problem of low efficiency and accuracy of checking stored procedures in the related art.

[0007] According to an aspect of the embodiments of the present application, a logic comparison method for a program is provided, comprising: converting each source stored procedure of a source database into a target stored procedure of a target database, wherein the target database is a database to which data in the source database is to be migrated; comparing the source stored procedure with the target stored procedure to obtain a comparison result, wherein the comparison result comprises: a weight value corresponding to each stored procedure set, the stored procedure set comprising: the source stored procedure and the target stored procedure in a corresponding relationship; parsing a code branch in each of the source stored procedure and the target stored procedure to obtain a calling parameter of the code branch; based on the weight value, executing the source stored procedure and the target stored procedure in the stored procedure set simultaneously using the calling parameter to obtain an execution result, wherein the execution result comprises: a first out-parameter result and a first table data result of the source database, a second out-parameter result and a second table data result of the target database; in a case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent, and / or the first table data result and the second table data result are inconsistent, adjusting the target stored procedure indicated by the second out-parameter result and / or the second table data result.

[0008] Optionally, before converting each source stored procedure of a source database into a target stored procedure of a target database, further comprising: determining a first database structure of the source database and a second database structure of the target database; configuring a first configuration environment of the source database based on the first database structure, and configuring a second configuration environment of the target database based on the second database structure; running the first configuration environment and the second configuration environment, and using a preset synchronization tool to migrate table data in the source database to the target database, wherein the table data comprises: multiple tables.

[0009] Optionally, before converting each source stored procedure of a source database into a target stored procedure of a target database, further comprising: scanning all program codes in the source database; analyzing the program codes to generate an execution statement for running the program codes; based on the execution statement, constructing the source stored procedure corresponding to the program codes.

[0010] Optionally, the step of comparing the source stored procedure with the target stored procedure to obtain a comparison result comprises: comparing a first code corresponding to the source stored procedure with a second code corresponding to the target stored procedure to determine a difference code; determining a difference level of the difference code according to a code amount of the difference code; determining the weight value corresponding to the stored procedure set indicated by the difference level according to the difference level to obtain the comparison result.

[0011] Optionally, the step of parsing the code branches in each of the source storage programs and each of the target storage programs comprises: parsing the source storage programs and the target storage programs, determining a preset type table set, and generating a backup table for each of the preset type tables in the preset type table set, wherein each pair of the source storage programs and the target storage programs involves consistent tables; parsing all execution statements in the source storage programs, determining all the code branches, and parsing each of the code branches to determine the call parameters that call the code branches; parsing all the execution statements in the target storage programs, determining all the code branches, and parsing each of the code branches to determine the call parameters that call the code branches.

[0012] Optionally, based on the weight values, the step of executing the source storage programs and the target storage programs in the storage program set simultaneously using the call parameters comprises: sorting all the weight values to obtain a sorting result; generating a storage program execution order based on the sorting result; and executing each of the source storage programs and the target storage programs in each of the storage program sets using the call parameters based on the storage program execution order to obtain the first out-parameter result, the first table data result, the second out-parameter result, and the second table data result corresponding to each of the storage program sets.

[0013] Optionally, in the case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent and / or the first table data result and the second table data result are inconsistent, the step of adjusting the target storage program indicated by the second out-parameter result and / or the second table data result comprises: in the case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent, sending the second code corresponding to the target storage program indicated by the second out-parameter result to a target terminal for adjustment; and / or, in the case where the execution result indicates that the first table data result and the second table data result are inconsistent, sending the second table data result and the second code corresponding to the target storage program indicated by the second table data result to a target terminal for adjustment, and deleting a preset type table indicated by the second table data result from the target database and adding a backup table corresponding to the preset type table to the target database, wherein the target terminal adjusts the second code based on the second table data result.

[0014] According to another aspect of the embodiments of the present application, a logic comparison device for storing programs is also provided, comprising: a conversion unit configured to convert each source stored program of a source database into a target stored program of a target database, wherein the target database is a database to which data in the source database is to be migrated; a comparison unit configured to compare the source stored program with the target stored program to obtain a comparison result, wherein the comparison result comprises a weight value corresponding to each set of stored programs, and the set of stored programs comprises the source stored program and the target stored program in a corresponding relationship; an analysis unit configured to analyze a code branch in each of the source stored program and the target stored program to obtain a call parameter of the code branch; an execution unit configured to execute the source stored program and the target stored program in the set of stored programs based on the weight value and using the call parameter to obtain an execution result, wherein the execution result comprises a first out-parameter result and a first table data result of the source database, and a second out-parameter result and a second table data result of the target database; and an adjustment unit configured to adjust the target stored program indicated by the second out-parameter result and / or the second table data result when the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result, and / or the first table data result is inconsistent with the second table data result.

[0015] Optionally, the logic comparison device further comprises: a first determination module configured to determine a first database structure of the source database and a second database structure of the target database before converting each source stored program of the source database into a target stored program of the target database; a first configuration module configured to configure a first configuration environment of the source database based on the first database structure, and configure a second configuration environment of the target database based on the second database structure; and a first migration module configured to run the first configuration environment and the second configuration environment, and migrate table data in the source database to the target database using a preset synchronization tool, wherein the table data comprises a plurality of tables.

[0016] Optionally, the logic comparison device further comprises: a first scanning module configured to scan all program codes in the source database before converting each source stored program of the source database into a target stored program of the target database; a first analysis module configured to analyze the program codes to generate an execution statement for running the program codes; and a first construction module configured to construct the source stored program corresponding to the program codes based on the execution statement.

[0017] Optionally, the comparing unit comprises: a first comparing module, configured to compare the first code corresponding to the source storage program with the second code corresponding to the target storage program to determine a difference code; a second determining module, configured to determine a difference level of the difference code according to a code amount of the difference code; and a third determining module, configured to determine the weight value corresponding to the storage program set indicated by the difference level according to the difference level to obtain the comparison result.

[0018] Optionally, the analyzing unit comprises: a first analyzing module, configured to analyze the source storage program and the target storage program to determine a preset type table set and generate a backup table for each preset type table in the preset type table set, wherein each pair of tables involved in the source storage program and the target storage program is consistent; a second analyzing module, configured to analyze all execution statements in the source storage program to determine all code branches and analyze each code branch to determine the call parameter calling the code branch; and a third analyzing module, configured to analyze all execution statements in the target storage program to determine all code branches and analyze each code branch to determine the call parameter calling the code branch.

[0019] Optionally, the executing unit comprises: a first sorting module, configured to sort all the weight values to obtain a sorting result; a first generating module, configured to generate a storage program execution order based on the sorting result; and a first executing module, configured to execute the source storage program and the target storage program in each storage program set based on the storage program execution order using the call parameter to obtain the first out-parameter result, the first table data result, the second out-parameter result and the second table data result corresponding to each storage program set.

[0020] Optionally, the adjusting unit comprises: a first sending module, configured to send the second code corresponding to the target storage program indicated by the second out-parameter result to a target terminal for adjustment in a case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent; and a second sending module, configured to send the second table data result and the second code corresponding to the target storage program indicated by the second table data result to a target terminal for adjustment in a case where the execution result indicates that the first table data result and the second table data result are inconsistent, delete a preset type table indicated by the second table data result from the target database, and add a backup table corresponding to the preset type table to the target database, wherein the target terminal adjusts the second code based on the second table data result.

[0021] According to another aspect of the embodiments of the present application, a computer readable storage medium is also provided, which includes a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to perform the logic comparison method of any one of the above stored programs when the computer program is executed.

[0022] According to another aspect of the embodiments of the present application, an electronic device is also provided, which includes one or more processors and a memory, the memory being configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the logic comparison method of any one of the above stored programs.

[0023] In the present disclosure, each source stored program of a source database is converted into a target stored program of a target database, the source stored program is compared with the target stored program to obtain a comparison result, code branches in each source stored program and each target stored program are parsed to obtain calling parameters of the code branches, the source stored programs and the target stored programs in a stored program set are executed simultaneously based on the weight values and the calling parameters to obtain an execution result, and the target stored program indicated by the second out-parameter result and / or the second table data result is adjusted in a case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent and / or the first table data result and the second table data result are inconsistent. In the present disclosure, each source stored program of a source database can be converted into a target stored program of a target database first, then the source stored program is compared with the target stored program to obtain weight values of a stored program set, and then code branches in each source stored program and each target stored program can be parsed to obtain corresponding calling parameters of the code branches. The source stored programs and the target stored programs in the stored program set are executed simultaneously according to the weight values and the corresponding calling parameters. If the obtained execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent or the first table data result and the second table data result are inconsistent, the target stored program indicated by the second out-parameter result or the second table data result needs to be adjusted. The present disclosure can automatically check the running logic of the stored programs and cover all code branches of the stored programs, thereby improving the checking efficiency and accuracy, and further solving the technical problem of low efficiency and accuracy in checking the stored programs in the related art. BRIEF DESCRIPTION OF DRAWINGS

[0024] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:

[0025] Figure 1 is a flowchart of an optional logic comparison method of a stored program according to an embodiment of the present application;

[0026] Figure 2 is a flow chart of an optional comparison of the difference code between the source storage program and the target storage program according to an embodiment of the present application;

[0027] Figure 3 is a schematic diagram of an optional logical comparison device of the storage program according to an embodiment of the present application;

[0028] Figure 4 is a hardware structure block diagram of an electronic device (or mobile device) for a logical comparison method of the storage program according to an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiment of the present application will be described clearly and completely below in combination with the drawings in the embodiment of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.

[0030] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0031] In order to facilitate the person skilled in the art to understand the present application, the following explains some terms or nouns involved in each embodiment of the present application:

[0032] Storage process: that is, storage program, is to store a series of SQL statements (i.e. database statements) in advance on the database server, when execution is needed, the client only needs to issue a command to call the storage process to the server side, the server side can execute the series of SQL statements stored in advance, that is, the storage process is equivalent to an executable storage program.

[0033] It should be noted that the logic comparison method and device of the stored program in the present disclosure can be used in the field of financial technology in the case of logic comparison of the stored program, and can also be used in any field other than the field of financial technology in the case of logic comparison of the stored program. The application field of the logic comparison method and device of the stored program in the present disclosure is not limited.

[0034] It should be noted that the related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present disclosure are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal. For example, the system and the interface between the related users or institutions are provided, and before obtaining the related information, the interface needs to send an acquisition request to the aforementioned user or institution, and after receiving the consent information fed back by the aforementioned user or institution, the related information is acquired.

[0035] The following embodiments of the present application can be applied to various systems / applications / devices for logic comparison of stored programs. The present application can solve the problem that manual execution of a stored process may consume a lot of time and resources and is prone to cause errors in checking results in the related art, and by backing up table data, the influence on actual data in the database before and after execution can be effectively avoided. In addition, it can also ensure that each code branch can be entered for testing during execution of the stored process, reduce the problem of incomplete code branch coverage during testing, thereby effectively improving the accuracy of checking the stored process.

[0036] The present application will be described in detail below in conjunction with various embodiments.

[0037] Embodiment one

[0038] According to an embodiment of the present application, an embodiment of a logic comparison method of a stored program is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in an order different from that shown herein.

[0039] Figure 1 is a flowchart of an optional logic comparison method of a stored program according to an embodiment of the present application, as shown in Figure 1 The method comprises the following steps:

[0040] Step S101, converting each source stored procedure of a source database into a target stored procedure of a target database, wherein the target database is a database to which data in the source database is to be migrated.

[0041] Step S102, comparing the source stored procedure with the target stored procedure to obtain a comparison result, wherein the comparison result includes a weight value corresponding to each pair of stored procedure sets, and the stored procedure set includes the source stored procedure and the target stored procedure in a corresponding relationship.

[0042] Step S103, parsing a code branch in each source stored procedure and each target stored procedure to obtain a calling parameter of the code branch.

[0043] Step S104, executing the source stored procedure and the target stored procedure in the stored procedure set based on the weight value and using the calling parameter to obtain an execution result, wherein the execution result includes a first out parameter result and a first table data result of the source database, and a second out parameter result and a second table data result of the target database.

[0044] Step S105, in a case where the execution result indicates that the first out parameter result is inconsistent with the second out parameter result, and / or the first table data result is inconsistent with the second table data result, adjusting the target stored procedure indicated by the second out parameter result and / or the second table data result.

[0045] By the above steps, each source stored procedure of the source database can be converted into a target stored procedure of the target database, the source stored procedure is compared with the target stored procedure to obtain a comparison result, code branches in each source stored procedure and each target stored procedure are parsed to obtain calling parameters of the code branches, the source stored procedure and the target stored procedure in the stored procedure set are executed simultaneously based on the weight value and the calling parameters to obtain an execution result, and in a case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent and / or the first table data result and the second table data result are inconsistent, the target stored procedure indicated by the second out-parameter result and / or the second table data result is adjusted. In the embodiment of the present application, each source stored procedure of the source database can be converted into a target stored procedure of the target database first, then the source stored procedure is compared with the target stored procedure to obtain a weight value of the stored procedure set, and then the code branches in each source stored procedure and each target stored procedure can be parsed to obtain corresponding calling parameters of the code branches. The source stored procedure and the target stored procedure in the stored procedure set are executed simultaneously according to the weight value and the corresponding calling parameters. If the obtained execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent or the first table data result and the second table data result are inconsistent, the target stored procedure indicated by the second out-parameter result or the second table data result needs to be adjusted. The running logic of the stored procedure can be automatically checked, and all code branches of the stored procedure are covered, so that the checking efficiency and accuracy are improved, and the technical problem of low efficiency and accuracy in checking the stored procedure in the related art is solved.

[0046] The embodiments of the present application will be described in detail below in combination with the above steps.

[0047] In the embodiment of the present application, the program code of the business system can be stored in the database. However, if the current source database is no longer applicable, the stored program code needs to be migrated to the target database. Because the underlying logic of different databases is different, when migrating, the conversion tool will appropriately rewrite the stored program code and the stored procedure for executing the program code in order to adapt to the target database. In order to ensure the normal operation of the business system, the rewritten stored procedure needs to be checked and tested.

[0048] An optional embodiment, before converting each source stored procedure of the source database into a target stored procedure of the target database, further comprising: determining a first database structure of the source database and a second database structure of the target database; configuring a first configuration environment of the source database based on the first database structure, and configuring a second configuration environment of the target database based on the second database structure; running the first configuration environment and the second configuration environment, and migrating table data in the source database to the target database by using a preset synchronization tool, wherein the table data comprises: a plurality of tables.

[0049] In the embodiment of the present application, before logical comparison is performed, a source database environment (such as an Oracle database function environment) needs to be prepared, and a target database environment (such as a GaussDB database function environment) in which converted code is installed also needs to be prepared (that is, a first database structure of the source database and a second database structure of the target database are determined, then a first configuration environment of the source database is configured based on the first database structure, and a second configuration environment of the target database is configured based on the second database structure). Then the first configuration environment and the second configuration environment are run, and a preset synchronization tool (for example, a DRS (Data Replication Service) tool) is used to migrate table data (including multiple tables) in the source database to the target database, so as to ensure that the table data in the two databases is consistent.

[0050] Optionally, before each source stored procedure of the source database is converted into a target stored procedure of the target database, the method further includes: scanning all program codes in the source database; analyzing the program codes to generate execution statements of the program codes; and constructing the source stored procedure corresponding to the program codes based on the execution statements.

[0051] In the embodiment of the present application, the full code of the source database can be scanned first to obtain a stored procedure detail (including PROCEDURE (procedure) and FUNCTION (function)), so as to obtain a stored procedure code (that is, a stored procedure). Specifically, all data codes in the source database can be scanned first, then the data codes are analyzed to generate execution statements of the data codes, and then the stored procedure corresponding to the data codes is constructed according to the execution statements.

[0052] Step S101, converting each source stored procedure of the source database into a target stored procedure of the target database, wherein the target database is a database to which data in the source database is to be migrated.

[0053] In the embodiment of the present application, in order to adapt to the underlying logic of the target database (that is, the database to which the data in the source database is to be migrated), each source stored procedure of the source database needs to be converted into a target stored procedure of the target database.

[0054] Step S102, comparing the source stored procedure with the target stored procedure to obtain a comparison result, wherein the comparison result includes a weight value corresponding to each pair of stored procedure sets, and the stored procedure set includes the source stored procedure and the target stored procedure in a corresponding relationship.

[0055] Optionally, the step of comparing the source storage program with the target storage program to obtain a comparison result comprises: comparing the first code corresponding to the source storage program with the second code corresponding to the target storage program to determine a difference code; determining a difference level of the difference code according to a code amount of the difference code; and determining a weight value corresponding to a storage program set indicated by the difference level according to the difference level to obtain the comparison result.

[0056] Figure 2 is a flowchart of an optional comparison of a difference code between a source storage program and a target storage program according to an embodiment of the present application, as shown in Figure 2 The method comprises the following steps:

[0057] Step S201, comparing the first code corresponding to the source storage program with the second code corresponding to the target storage program to determine a difference code.

[0058] Step S202, determining a difference level of the difference code according to a code amount of the difference code.

[0059] Step S203, determining a weight value corresponding to a storage program set indicated by the difference level according to the difference level to obtain the comparison result.

[0060] In the embodiment of the present application, a code comparison tool (for example, SSDT (SQL Server Data Tools, a database tool), SQL Server (a structured query language tool), Redgate SQLCompare (a database synchronization tool), etc.) can be used to compare the source storage program with the target storage program to mark the difference code and record the comparison result (the comparison result comprises a weight value corresponding to each storage program set, and the storage program set comprises the source storage program and the target storage program corresponding to each other), specifically: the first code corresponding to the source storage program can be compared with the second code corresponding to the target storage program to determine the difference code between the two (that is, the code of the same storage program in two databases is compared), then the difference level of the difference code is determined according to the code amount of the difference code (that is, the greater the code difference, the higher the difference level), and then the weight value corresponding to the storage program set indicated by the difference level is determined according to the difference level (that is, the higher the difference level, the greater the weight of the corresponding storage program set), and is recorded in the comparison result.

[0061] Step S103, parsing the code branch in each source storage program and each target storage program to obtain the calling parameters of the code branch.

[0062] Optionally, the step of parsing the code branches in each source stored procedure and each target stored procedure comprises: parsing the source stored procedure and the target stored procedure, determining a preset type table set, and generating a backup table for each preset type table in the preset type table set, wherein the tables involved in each pair of source stored procedure and target stored procedure are consistent; parsing all execution statements in the source stored procedure, determining all code branches, and parsing each code branch to determine the calling parameters of the calling code branch; parsing all execution statements in the target stored procedure, determining all code branches, and parsing each code branch to determine the calling parameters of the calling code branch.

[0063] In the embodiment of the application, each stored procedure code can be parsed (i.e., the code branches in each source stored procedure and each target stored procedure are parsed) to determine the tables involved in the execution of the stored procedure and the calling parameters required when the code branches are executed. In summary, the source stored procedure and the target stored procedure can be parsed first to determine a preset type table set (i.e., the tables used by the stored procedure when executed are determined, and the preset type tables are determined from the used tables, wherein the preset type tables are tables that can be operated by the data management language (DML), such as tables that can be added, deleted, or modified), and a backup table is generated for each preset type table in the preset type table set (i.e., the tables that can be changed after execution need to be backed up in advance), for example, by "create table source_table_name_bak for select * from source_table_name" to backup, wherein source_table_name_bak is the name of the backup table, and source_table_name is the name of the original table. In this embodiment, the tables involved in each pair of source stored procedure and target stored procedure are consistent.

[0064] In the embodiment of the application, different code branches (such as loop branches, ifelse branches, etc.) can be recorded and the conditions for entering the code branches can be parsed. The table data or mock input parameters (i.e., a tool for simulating various inputs, outputs, states, etc. in testing) can be queried to cover each code branch (i.e., all execution statements in the source stored procedure and the target stored procedure can be parsed to determine all code branches, and then each code branch can be parsed to determine the calling parameters of the calling code branch).

[0065] In step S104, based on the weight value, the source stored procedure and the target stored procedure in the stored procedure set are executed simultaneously using the calling parameters to obtain an execution result, wherein the execution result includes: the first out parameter result and the first table data result of the source database, and the second out parameter result and the second table data result of the target database.

[0066] Optionally, based on the weight values, the steps of executing the source stored procedures and the target stored procedures in the stored procedure set by using the calling parameters simultaneously include: sorting all the weight values to obtain a sorting result; generating a stored procedure execution order based on the sorting result; and executing each source stored procedure and each target stored procedure in each stored procedure set by using the calling parameters based on the stored procedure execution order, to obtain a first out parameter result, a first table data result, a second out parameter result and a second table data result corresponding to each stored procedure set.

[0067] In the embodiment of the present application, the same stored procedure of two databases can be executed by using the parsed calling parameters, and the stored procedure with larger difference is executed preferentially, that is, according to the weight values of each stored procedure set, the source stored procedure and the target stored procedure in the stored procedure set are executed simultaneously by using the corresponding calling parameters to obtain an execution result (the execution result includes a first out parameter result and a first table data result of the source database, a second out parameter result and a second table data result of the target database), and specifically, all the weight values can be sorted first to obtain a sorting result, and then a stored procedure execution order is generated according to the sorting result (that is, the execution order of the stored procedures is generated according to the size of the weight values). Then, according to the stored procedure execution order, the source stored procedure and the target stored procedure in each stored procedure set are executed in sequence by using the corresponding calling parameters, to obtain a first out parameter result (that is, the out parameter result of the source stored procedure of the source database), a first table data result (that is, the table of a preset type involved in the source stored procedure of the source database after the table is changed after the source stored procedure is executed), a second out parameter result (that is, the out parameter result of the target stored procedure of the target database), and a second table data result (that is, the table of a preset type involved in the target stored procedure of the target database after the table is changed after the target stored procedure is executed) corresponding to each stored procedure set.

[0068] In step S105, when the execution result indicates that the first out parameter result is inconsistent with the second out parameter result, and / or the first table data result is inconsistent with the second table data result, the target stored procedure indicated by the second out parameter result and / or the second table data result is adjusted.

[0069] Optionally, in the case that the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result and / or the first table data result is inconsistent with the second table data result, the step of adjusting the target storage program indicated by the second out-parameter result and / or the second table data result comprises: in the case that the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result, sending the second code corresponding to the target storage program indicated by the second out-parameter result to the target terminal for adjustment; and / or in the case that the execution result indicates that the first table data result is inconsistent with the second table data result, sending the second table data result and the second code corresponding to the target storage program indicated by the second table data result to the target terminal for adjustment, deleting the preset type table indicated by the second table data result from the target database, and adding a backup table corresponding to the preset type table to the target database, wherein the target terminal adjusts the second code based on the second table data result.

[0070] In the embodiment of the present application, the first out-parameter result and the second out-parameter result in the execution result, and the first table data result and the second table data result can be compared to determine whether they are consistent. For example, the obtained first table data result and the second table data result can be subjected to full table scanning to check whether the table data after the execution of the storage programs of the two databases is completely consistent.

[0071] In the embodiment of the present application, if the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result, the second code corresponding to the target storage program indicated by the second out-parameter result is sent to the target terminal for adjustment; if the execution result indicates that the first table data result is inconsistent with the second table data result, the second table data result and the second code corresponding to the target storage program indicated by the second table data result are sent to the target terminal for adjustment, so that the target terminal adjusts the second code based on the second table data result. In addition, the preset type table indicated by the second table data result needs to be deleted from the target database, a backup table corresponding to the preset type table needs to be added to the target database, and the name of the backup table needs to be changed to the original table name (i.e. the table data in the target database is restored to the state before the execution of the storage program), so as to ensure that the actual data in the database is not affected before and after the execution.

[0072] In the embodiment of the present application, the running logic of the storage program can be automatically checked, and all code branches of the storage program are covered, so that the checking efficiency and accuracy are improved. In addition, through the backup table data, the influence of the actual data in the database before and after the execution can be effectively avoided.

[0073] The following will be described in detail in combination with another embodiment.

[0074] Embodiment Two

[0075] The logic comparison device for storing programs provided in the embodiment comprises a plurality of implementation units, each of which corresponds to each implementation step in Embodiment 1.

[0076] Figure 3 is a schematic diagram of an optional logic comparison device for storing programs according to an embodiment of the present application, as shown in the figure, the logic comparison device can comprise a conversion unit 30, a comparison unit 31, an analysis unit 32, an execution unit 33, and an adjustment unit 34, wherein, Figure 3

[0077] The conversion unit 30 is configured to convert each source stored program of a source database into a target stored program of a target database, wherein the target database is a database to which data in the source database is to be migrated.

[0078] The comparison unit 31 is configured to compare the source stored program and the target stored program to obtain a comparison result, wherein the comparison result comprises a weight value corresponding to each set of stored programs, and the set of stored programs comprises the source stored program and the target stored program in a corresponding relationship.

[0079] The analysis unit 32 is configured to analyze a code branch in each source stored program and each target stored program to obtain a calling parameter of the code branch.

[0080] The execution unit 33 is configured to execute the source stored program and the target stored program in the set of stored programs based on the weight value and using the calling parameter to obtain an execution result, wherein the execution result comprises a first out-parameter result and a first table data result of the source database, and a second out-parameter result and a second table data result of the target database.

[0081] The adjustment unit 34 is configured to adjust the target stored program indicated by the second out-parameter result and / or the second table data result when the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result, and / or the first table data result is inconsistent with the second table data result.

[0082] ​The logic comparison device can convert each source storage procedure of the source database into a target storage procedure of the target database through the conversion unit 30, compare the source storage procedure with the target storage procedure through the comparison unit 31 to obtain a comparison result, analyze the code branches in each source storage procedure and each target storage procedure through the analysis unit 32 to obtain the calling parameters of the code branches, execute the source storage procedure and the target storage procedure in the storage procedure set based on the weight value and using the calling parameters through the execution unit 33 to obtain an execution result, and adjust the target storage procedure indicated by the second out-parameter result and / or the second table data result when the execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result and / or the first table data result is inconsistent with the second table data result through the adjustment unit 34. In the embodiment of the application, each source storage procedure of the source database can be converted into a target storage procedure of the target database first, then the source storage procedure is compared with the target storage procedure to obtain the weight value of the storage procedure set, then the code branches in each source storage procedure and each target storage procedure are analyzed to obtain the corresponding calling parameters of the code branches, and then the source storage procedure and the target storage procedure in the storage procedure set are executed based on the weight value and using the corresponding calling parameters. If the obtained execution result indicates that the first out-parameter result is inconsistent with the second out-parameter result or the first table data result is inconsistent with the second table data result, the target storage procedure indicated by the second out-parameter result or the second table data result needs to be adjusted. The running logic of the storage procedure can be automatically checked, and all the code branches of the storage procedure are covered, so that the checking efficiency and accuracy are improved, and the technical problem of low efficiency and accuracy in checking the storage procedure in the related art is solved.

[0083] Optionally, the logic comparison device further comprises a first determination module configured to determine a first database structure of the source database and a second database structure of the target database before converting each source storage procedure of the source database into a target storage procedure of the target database; a first configuration module configured to configure a first configuration environment of the source database based on the first database structure and a second configuration environment of the target database based on the second database structure; and a first migration module configured to run the first configuration environment and the second configuration environment and migrate table data in the source database to the target database using a preset synchronization tool, wherein the table data comprises a plurality of tables.

[0084] Optionally, the logic comparison device further comprises a first scanning module configured to scan all program codes in the source database before converting each source storage procedure of the source database into a target storage procedure of the target database; a first analysis module configured to analyze the program codes to generate execution statements of the program codes; and a first construction module configured to construct the source storage procedure corresponding to the program codes based on the execution statements.

[0085] Optionally, the comparison unit comprises: a first comparison module configured to compare the first code corresponding to the source storage program with the second code corresponding to the target storage program to determine a difference code; a second determination module configured to determine a difference level of the difference code according to a code amount of the difference code; and a third determination module configured to determine a weight value corresponding to a storage program set indicated by the difference level according to the difference level, to obtain a comparison result.

[0086] Optionally, the parsing unit comprises: a first parsing module configured to parse the source storage program and the target storage program, to determine a preset type table set, and to generate a backup table for each preset type table in the preset type table set, wherein each pair of tables involved in the source storage program and the target storage program is consistent; a second parsing module configured to parse all execution statements in the source storage program, to determine all code branches, and to parse each code branch to determine a calling parameter of the calling code branch; and a third parsing module configured to parse all execution statements in the target storage program, to determine all code branches, and to parse each code branch to determine a calling parameter of the calling code branch.

[0087] Optionally, the execution unit comprises: a first sorting module configured to sort all weight values to obtain a sorting result; a first generation module configured to generate a storage program execution order based on the sorting result; and a first execution module configured to execute the source storage program and the target storage program in each storage program set based on the storage program execution order using the calling parameter, to obtain a first out-parameter result, a first table data result, a second out-parameter result, and a second table data result corresponding to each storage program set.

[0088] Optionally, the adjustment unit comprises: a first sending module configured to send the second code corresponding to the target storage program indicated by the second out-parameter result to a target terminal for adjustment in a case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent; and a second sending module configured to send the second table data result, the second code corresponding to the target storage program indicated by the second table data result to the target terminal for adjustment in a case where the execution result indicates that the first table data result and the second table data result are inconsistent, to delete the preset type table indicated by the second table data result from the target database, and to add the backup table corresponding to the preset type table to the target database, wherein the target terminal adjusts the second code based on the second table data result.

[0089] The logical comparison device described above can further comprise a processor and a memory, and the above-mentioned conversion unit 30, comparison unit 31, parsing unit 32, execution unit 33, and adjustment unit 34 are all stored in the memory as program units, and the corresponding functions are realized by the processor executing the above-mentioned program units stored in the memory.

[0090] The processor includes a core, and the core retrieves corresponding program units in the memory. The core can be set to one or more, and the core parameters are adjusted to adjust the target storage program indicated by the second out parameter result and / or the second table data result in the case that the execution result indicates that the first out parameter result is inconsistent with the second out parameter result, and / or the first table data result is inconsistent with the second table data result.

[0091] The memory can include a non-permanent memory in a computer readable medium, a random access memory (RAM) and / or a non-volatile memory such as a read-only memory (ROM) or a flash memory (flash RAM), and the memory includes at least one memory chip.

[0092] The application also provides a computer program product adapted to execute the program of the following method steps when executed on a data processing device: converting each source storage program of a source database into a target storage program of a target database, comparing the source storage program with the target storage program to obtain a comparison result, parsing the code branches in each source storage program and each target storage program to obtain the call parameters of the code branches, executing the source storage programs and the target storage programs in the storage program set simultaneously based on the weight values and the call parameters to obtain an execution result, and adjusting the target storage program indicated by the second out parameter result and / or the second table data result in the case that the execution result indicates that the first out parameter result is inconsistent with the second out parameter result, and / or the first table data result is inconsistent with the second table data result.

[0093] According to another aspect of the embodiments of the application, a computer readable storage medium is also provided, and the computer readable storage medium includes a stored computer program, wherein the computer readable storage medium controls the device where the computer readable storage medium is located to execute the above-mentioned storage program logic comparison method when the computer program is running.

[0094] According to another aspect of the embodiments of the application, an electronic device is also provided, which includes one or more processors and a memory, and the memory is used to store one or more programs, wherein the one or more programs make the one or more processors implement the above-mentioned storage program logic comparison method when the one or more programs are executed by the one or more processors.

[0095] Figure 4 It is a hardware structure block diagram of an electronic device (or a mobile device) for a storage program logic comparison method according to an embodiment of the application. As shown in Figure 4 the electronic device can include one or more Figure 4The processor 402 (the processor 402 can include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 404 for storing data. In addition, a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera can be included. Those skilled in the art can understand that Figure 4 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the electronic device can also include more or fewer components than Figure 4 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the electronic device can also include more or fewer components than Figure 4 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the electronic device can also include more or fewer components than

[0096] The above-mentioned embodiment number of the application is only for description, not representing the advantages and disadvantages of the embodiments.

[0097] In the above-mentioned embodiments of the application, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0098] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented by other ways. Among them, the above-mentioned device embodiment is only schematic, for example, the division of the unit can be a logical function division, and actual implementation can have another division way, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between units or modules, which can be electrical or other forms.

[0099] The unit described as a separate component can be or can not be physically separated, and the component displayed as a unit can be or can not be a physical unit, that is, it can be located in one place, or it can be distributed to multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0100] In addition, each functional unit in each embodiment of the application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be realized in the form of hardware or in the form of software functional unit.

[0101] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.

[0102] The above is only the preferred embodiment of the present application, it should be pointed out that, for those skilled in the art, without departing from the principles of the present application, can make a number of improvements and refinements, these improvements and refinements should also be considered as the protection scope of the present application.

Claims

1. A method of comparing logic of programs, characterized by, The method comprises the following steps: converting each source stored procedure of a source database into a target stored procedure of a target database, wherein the target database is a database to which data in the source database is to be migrated; comparing the source stored procedure with the target stored procedure to obtain a comparison result, wherein the comparison result comprises a weight value corresponding to each stored procedure set, and the stored procedure set comprises the source stored procedure and the target stored procedure in a corresponding relationship; parsing a code branch in each of the source stored procedure and the target stored procedure to obtain a calling parameter of the code branch; based on the weight value, executing the source stored procedure and the target stored procedure in the stored procedure set simultaneously using the calling parameter to obtain an execution result, wherein the execution result comprises a first out-parameter result and a first table data result of the source database, and a second out-parameter result and a second table data result of the target database; wherein the step of executing the source stored procedure and the target stored procedure in the stored procedure set simultaneously using the calling parameter based on the weight value comprises: sorting all the weight values to obtain a sorting result; generating a stored procedure execution order based on the sorting result; and executing the source stored procedure and the target stored procedure in each of the stored procedure sets using the calling parameter based on the stored procedure execution order to obtain the first out-parameter result, the first table data result, the second out-parameter result and the second table data result corresponding to each of the stored procedure sets; in the case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent, and / or the first table data result and the second table data result are inconsistent, adjusting the target stored procedure indicated by the second out-parameter result and / or the second table data result.

2. The logical comparison method of claim 1, wherein, Before converting each source stored procedure of a source database into a target stored procedure of a target database, the method further comprises: determining a first database structure of the source database and a second database structure of the target database; configuring a first configuration environment of the source database based on the first database structure, and configuring a second configuration environment of the target database based on the second database structure; running the first configuration environment and the second configuration environment, and migrating table data in the source database to the target database using a preset synchronization tool, wherein the table data comprises a plurality of tables.

3. The logical comparison method of claim 1, wherein, Before converting each source stored procedure of a source database into a target stored procedure of a target database, the method further comprises: scanning all program codes in the source database; analyzing the program codes to generate an execution statement for running the program codes; based on the execution statement, constructing the source stored procedure corresponding to the program codes.

4. The logical comparison method of claim 1, wherein, The step of comparing the source stored procedure with the target stored procedure to obtain a comparison result comprises: comparing a first code corresponding to the source stored procedure with a second code corresponding to the target stored procedure to determine a difference code; determining a difference level of the difference code according to a code amount of the difference code; determining the weight value corresponding to the storage program set indicated by the difference level according to the difference level, to obtain the comparison result.

5. The logical comparison method of claim 1, wherein, The step of parsing the code branches in each of the source storage programs and each of the target storage programs comprises: parsing the source storage programs and the target storage programs, determining a preset type table set, and generating a backup table for each of the preset type tables in the preset type table set, wherein the tables involved in each pair of the source storage programs and the target storage programs are consistent; parsing all execution statements in the source storage programs, determining all the code branches, and parsing each of the code branches to determine the call parameters of the code branches; parsing all the execution statements in the target storage programs, determining all the code branches, and parsing each of the code branches to determine the call parameters of the code branches.

6. The logical comparison method of claim 1, wherein, In the case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent and / or the first table data result and the second table data result are inconsistent, the step of adjusting the target storage program indicated by the second out-parameter result and / or the second table data result comprises: In the case where the execution result indicates that the first out-parameter result and the second out-parameter result are inconsistent, the second code corresponding to the target storage program indicated by the second out-parameter result is sent to a target terminal for adjustment; and / or, In the case where the execution result indicates that the first table data result and the second table data result are inconsistent, the second table data result and the second code corresponding to the target storage program indicated by the second table data result are sent to a target terminal for adjustment, and a preset type table indicated by the second table data result is deleted from the target database, and a backup table corresponding to the preset type table is added to the target database, wherein the target terminal adjusts the second code based on the second table data result.

7. A logic comparison device storing a program, characterized by comprises: a conversion unit configured to convert each source storage program of a source database into a target storage program of a target database, wherein the target database is a database to which data in the source database is to be migrated; a comparison unit configured to compare the source storage programs and the target storage programs to obtain a comparison result, wherein the comparison result comprises a weight value corresponding to each pair of storage program sets, the storage program set comprising the source storage program and the target storage program in a corresponding relationship; a parsing unit configured to parse code branches in each of the source storage programs and each of the target storage programs to obtain call parameters of the code branches; An execution unit is configured to execute the source stored procedure and the target stored procedure in the stored procedure set simultaneously based on the weight value and the call parameter, to obtain an execution result, wherein the execution result includes a first out parameter result and a first table data result of the source database, and a second out parameter result and a second table data result of the target database. The execution unit includes a first sorting module configured to sort all the weight values to obtain a sorting result, a first generating module configured to generate a stored procedure execution order based on the sorting result, and a first execution module configured to execute the source stored procedure and the target stored procedure in each of the stored procedure set based on the stored procedure execution order and the call parameter, to obtain the first out parameter result, the first table data result, the second out parameter result and the second table data result corresponding to each of the stored procedure set. An adjustment unit is configured to adjust the target stored procedure indicated by the second out parameter result and / or the second table data result when the execution result indicates that the first out parameter result is inconsistent with the second out parameter result, and / or the first table data result is inconsistent with the second table data result.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium includes a stored computer program, wherein the computer program controls the device where the computer readable storage medium is located to perform the logic comparison method of the stored procedure according to any one of claims 1 to 6 when the computer program is running.

9. An electronic device, comprising: The device includes one or more processors and a memory configured to store one or more programs, wherein the one or more programs enable the one or more processors to implement the logic comparison method of the stored procedure according to any one of claims 1 to 6 when the one or more programs are executed by the one or more processors.

Citation Information

Patent Citations

  • Performance comparison method and device of storage program, electronic equipment and storage medium

    CN116955322A