Database adaptation and debugging method, device, equipment and storage medium

By analyzing processor mapping, generating function use case tables, and processing based on SQL statements and replacement rules, the problem of high adaptability compatibility testing time of domestic databases is solved, and the effect of quickly generating adapted SQL statements is achieved.

CN119046176BActive Publication Date: 2025-02-11HANGZHOU XINZHONGDA ENTERPRISE MANAGEMENT TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411555289.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-04
Publication Date
2025-02-11
Estimated Expiration
2044-11-04

AI Technical Summary

Technical Problem

In the process of replacing the foreign database used by enterprise-level software with domestic databases, a lot of time is spent on adaptability compatibility testing, resulting in high time costs.

Method used

By analyzing the acquired processor map, a function use case table is generated; based on the executed SQL statement and replacement rules, a MySQL statement is built and the execution plan is processed, and a primary adaptation SQL statement is generated; the records in the final execution function use case table correspond to the record The primary adaptation SQL statement generates target adaptation SQL statement.

Benefits of technology

It can quickly generate target adaptation SQL statements that are adapted to domestic databases, reducing the time cost of replacing foreign databases used by enterprise-level software with domestic databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046176B_ABST
    Figure CN119046176B_ABST
Patent Text Reader

Abstract

The present application relates to the field of database technology, and in particular to a database adaptation and debugging method, device, equipment and storage medium, wherein the method comprises: parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result; replacing the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement; in response to the new SQL statement being a preset type statement, building a MySQL statement based on the new SQL statement; processing the new SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement; executing the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and processing the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement. The present application facilitates reducing the time cost of replacing a foreign database used by enterprise-level software with a domestic database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database adaptation and debugging method, device, equipment and storage medium. Background Art

[0002] Domestic database manufacturers have actively launched a variety of domestic databases, and domestic companies have also actively replaced the foreign databases used in enterprise-level software with domestic databases.

[0003] Enterprise-level software is mostly developed using the JAVA language. In the process of replacing the foreign databases used by enterprise-level software with domestic databases, due to the large differences between different domestic databases, the enterprise-level software needs to spend a lot of time on adaptability compatibility testing for the SQL statements used by each domestic database, resulting in a high time cost for replacing the foreign databases used by enterprise-level software with domestic databases. Summary of the invention

[0004] In order to reduce the time cost of replacing a foreign database used by enterprise-level software with a domestic database, the present application provides a database adaptation and debugging method, device, equipment and storage medium.

[0005] In a first aspect, the present application provides a database adaptation and debugging method, comprising:

[0006] Parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result;

[0007] Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement;

[0008] In response to the newly installed SQL statement being a preset type statement, constructing a MySQL statement based on the newly installed SQL statement; processing the newly installed SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement;

[0009] The primary adaptation SQL statement corresponding to the record in the function use case table is executed to obtain a target execution record, and the primary adaptation SQL statement is processed based on the target execution record to obtain a target adaptation SQL statement.

[0010] In a second aspect, the present application provides a database adaptation and debugging device, including:

[0011] A use case table generation module, used to parse the acquired processor mapping to obtain a parsing result, and obtain a function use case table based on the parsing result;

[0012] A statement replacement module, used to replace the current SQL statement to obtain a new SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule;

[0013] A primary statement generation module, configured to construct a MySQL statement based on the newly installed SQL statement in response to the newly installed SQL statement being a preset type statement; and to process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement;

[0014] The target statement generation module is used to execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain the target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain the target adaptation SQL statement.

[0015] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.

[0016] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.

[0017] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0018] The above-mentioned database adaptation and debugging method, device, equipment and storage medium parse the acquired processor mapping to obtain the parsing result, and obtain the function use case table based on the parsing result; replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement; in response to the new SQL statement being a preset type statement, build a MySQL statement based on the new SQL statement; process the new SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement; execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain the target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain the target adaptation SQL statement. Through the above implementation, a target adaptation SQL statement adapted to the domestic database can be quickly generated for each domestic database, thereby facilitating the reduction of the time cost of replacing the foreign database used by enterprise-level software with a domestic database.

[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0021] Figure 1 A flowchart of a database adaptation and debugging method provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of a recording structure provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of the structure of a database adaptation and debugging device provided in an embodiment of the present application;

[0024] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application;

[0025] Figure 5 This is a diagram of the internal structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0028] In this article, the term "and / or" is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship.

[0029] Embodiment 1

[0030] Figure 1 A flowchart of a database adaptation and debugging method provided in Example 1 of the present application, refer to Figure 1 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:

[0031] S110, parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result.

[0032] Among them, users can generate SQL statements adapted to domestic databases through the preset database adapter. The database adapter has corresponding rest requests. The processor mapping is the mapping between the rest request and the corresponding processor method. The obtained processor mapping is stored in the preset Spring container; the parsing results include the URL (Uniform Resource Locator), Class class and method corresponding to the processor mapping, and the parsing results are stored in the preset metadata container; the function use case table is a collection of information including the URL, Class class and method corresponding to each processor mapping.

[0033] Specifically, obtain the processor mapping corresponding to each rest request of the database adapter, and store each processor mapping in a preset Spring container; take one of the processor mappings as an example, parse the processor mapping to obtain a parsing result. In this embodiment, the parsing result includes URL, Class class and method. In other embodiments, there is no specific limitation; further, the parsing result is further processed to obtain a functional use case table.

[0034] S120: Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement.

[0035] Among them, the current SQL statement is the SQL statement that operates the domestic database in the current period. This embodiment presets a mybatis method interceptor, which is used to intercept the current SQL statement; JDBC (Java Database Connectivity) is provided in the Spring container. JDBC is a Java API. The current SQL statement can be executed through JDBC and the corresponding execution result can be obtained. In this embodiment, the execution result specifically includes: execution time and execution status, wherein the execution status is used to characterize whether the SQL statement is executed successfully. In other embodiments, the execution result is not specifically limited; the SQL replacement rule is used to replace the current SQL statement that may not be adapted to the domestic database with a SQL statement that may be adapted to the domestic database; the newly installed SQL statement is a SQL statement that may be adapted to the domestic database after being replaced by the SQL replacement rule.

[0036] Specifically, the mybatis method interceptor is used to intercept the SQL statements that operate on the domestic database in the current period to obtain the current SQL statement, and then the JDBC set in the Spring container is used to execute the current SQL statement and obtain the corresponding execution result; further, the current SQL statement is replaced by the execution result and the preset SQL replacement rule to obtain a newly installed SQL statement.

[0037] S130: In response to the newly installed SQL statement being a preset type statement, construct a MySQL statement based on the newly installed SQL statement; and process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement.

[0038] Among them, the newly installed SQL statement in this embodiment may be one of the statements such as SELECT statement, INSERT statement, UPDATE statement and DELETE statement; the preset type statement in this embodiment is specifically a SELECT statement, and in other embodiments, it is not specifically limited; the MySQL statement is an SQL statement applicable to the MySQL database; the execution plan is used to characterize the execution order of the data tables to be operated by the SQL statement. For example, a certain SQL statement currently needs to operate two data tables, which are respectively recorded as Table 1 and Table 2. In this SQL statement, Table 1 is operated first and then Table 2. The execution plan corresponding to the SQL statement is "operate on Table 1 first and then Table 2"; the primary adaptation SQL statement is an SQL statement adapted to the domestic database.

[0039] Specifically, determine whether the newly installed SQL statement is a SELECT statement. If so, construct an SQL statement suitable for the MySQL database based on the newly installed SQL statement to obtain a MySQL statement; further, determine an execution plan for the MySQL statement, and process the newly installed SQL statement according to the execution plan to obtain a primary adaptation SQL statement.

[0040] S140: Execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0041] Among them, the function use case table contains multiple records, which correspond to the processor mapping one by one. The records include information such as URL, Class and method. Each record has its corresponding primary adaptation SQL statement. By executing the primary adaptation SQL statement, the corresponding execution record can be obtained, that is, the target execution record. The target execution record includes execution time, execution status, etc.; through the target execution record, it can be determined whether the corresponding primary adaptation SQL statement meets the performance standard. If not, the primary adaptation SQL statement will continue to be optimized to obtain the target adaptation SQL statement. The target adaptation SQL statement is a SQL statement that is adapted to the domestic database and meets the performance standard.

[0042] Specifically, taking a record in the function use case table as an example, determine the primary adaptive SQL statement corresponding to the record, and then execute the primary adaptive SQL statement to obtain the corresponding target execution record, and then judge whether the performance of the primary adaptive SQL statement meets the standard through the target execution record. If so, use the primary adaptive SQL statement as the target adaptive SQL statement. Otherwise, perform performance optimization on the primary adaptive SQL statement until the performance of the primary adaptive SQL statement meets the standard, thereby obtaining the target adaptive SQL statement.

[0043] It should be noted that, in this embodiment, the obtained processor mapping is parsed to obtain the parsing result, and the functional use case table is obtained based on the parsing result; the current SQL statement is replaced based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement; in response to the new SQL statement being a preset type statement, a MySQL statement is constructed based on the new SQL statement; the new SQL statement is processed based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement; the primary adaptation SQL statement corresponding to the record in the functional use case table is executed to obtain a target execution record, and the primary adaptation SQL statement is processed based on the target execution record to obtain a target adaptation SQL statement. Through the above implementation, a target adaptation SQL statement adapted to the domestic database can be quickly generated for each domestic database, thereby facilitating the reduction of the time cost of replacing the foreign database used by the enterprise-level software with the domestic database.

[0044] Embodiment 2

[0045] A database adaptation and debugging method is provided in the second embodiment of the present application. The method optimizes the "obtaining a function use case table based on the analysis result" in the first embodiment. It should be noted that for the parts not described in detail in the present embodiment, reference may be made to the descriptions of other embodiments. The method includes:

[0046] S211. Analyze the acquired processor mapping to obtain a analysis result.

[0047] S212: Determine the program package corresponding to the method class in the parsing result, and obtain the method class corresponding to the program package to obtain a class set.

[0048] Among them, the method class is also the above-mentioned Class class, and the method class belongs to the corresponding package, such as "java.*" or "javax.*". Each package has multiple method classes, and the class collection is the collection of all method classes stored in the Spring container under the corresponding package.

[0049] Specifically, first obtain the method class in the parsing result, and determine the package corresponding to the method class. Further, obtain all method classes belonging to the package in the Spring container to obtain a class collection.

[0050] S213: Determine a method class containing a preset keyword from the class set to obtain a target class, and determine a SQL statement corresponding to the target class to obtain a SQL statement to be referenced.

[0051] Among them, the preset keyword is specifically "Mapper" in this embodiment, and is not specifically limited in other embodiments; each method class contains its corresponding keyword, the target class is the method class containing the keyword "Mapper" in the class set, the target class is the method class used to process domestic databases, and the SQL statement to be referenced is the SQL statement corresponding to the target class.

[0052] Specifically, taking a method class in the class collection as an example, determine whether the keyword in the method class is the preset keyword "Mapper". If so, determine the method class as the target class; further, determine the SQL statement corresponding to the target class, thereby obtaining the SQL statement to be referenced.

[0053] S214: extracting entity classes and table names from the target class based on the SQL statement to be referenced and method parameters of the target class.

[0054] Among them, the target class contains the corresponding method, and the method parameters are the parameters in the method; the entity class is used in the target class to represent objects with clear identities and states in the real world, and each entity class has its corresponding ID; the table name is the name of the data table operated by the method corresponding to the method parameters in the target class.

[0055] Specifically, information of the target class is extracted according to the SQL statement to be referenced and the method parameters of the target class, so as to obtain the corresponding entity class and table name.

[0056] S215. Obtain a function use case table based on the parsing result, the entity class and the table name.

[0057] The parsing result includes URL, Class and method in this embodiment; it should be noted that, in this example, the rest request corresponding to the processor mapping is also included in the function use case table; Figure 2 As shown, a record in the function use case table includes: URL, Class, method, rest request, entity class and table name.

[0058] Specifically, determine the rest request, URL, Class, method, entity class and table name corresponding to each processor mapping, so as to obtain a record corresponding to the processor mapping, and collect the records corresponding to each processor mapping to obtain a functional use case table.

[0059] S220: Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement.

[0060] S230: In response to the newly installed SQL statement being a preset type statement, construct a MySQL statement based on the newly installed SQL statement; and process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement.

[0061] S240: Execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0062] Embodiment 3

[0063] A database adaptation and debugging method is provided in the third embodiment of the present application. The method optimizes the "replacing the current SQL statement with a new SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule" in the first embodiment. It should be noted that for the part not described in detail in the present embodiment, reference can be made to the description of other embodiments. The method includes:

[0064] S310, parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result.

[0065] S321. Locally store the current SQL statement and the execution result obtained by executing the current SQL statement to obtain local variables.

[0066] Among them, this embodiment presets a local storage area, which is used to locally store the execution results. The execution results include execution time and execution status. The local variables are the current SQL statement stored in the local storage area and the execution result corresponding to the current SQL statement.

[0067] Specifically, the current SQL statement is executed through the JDBC in the Spring container to obtain a corresponding execution result. Further, the current SQL statement and the execution result corresponding to the current SQL statement are stored in a local storage area to obtain a local variable.

[0068] S322: In response to the first execution state in the local variable being execution failure, replace the current SQL statement based on a preset SQL replacement rule to obtain an initial SQL statement.

[0069] The first execution state is the execution state in the execution result in the local variable, and the execution state includes two situations: execution success and execution failure; replacing the current SQL statement is to reassemble the current SQL statement according to the SQL replacement rule.

[0070] Specifically, the execution result in the local variable is obtained, and the first execution state in the execution result is further obtained, and then it is determined whether the first execution state is an execution failure. If so, the current SQL statement is reassembled according to the preset SQL replacement rule to obtain the initial SQL statement.

[0071] S323: Execute the initial SQL statement to obtain a second execution state, and in response to the second execution state being successful, use the initial SQL statement as a new SQL statement.

[0072] Among them, the corresponding execution result can be obtained by executing the initial installation SQL statement, and the execution result includes the execution state of the initial installation SQL statement, that is, the second execution state.

[0073] Specifically, execute the initial SQL statement and obtain the corresponding execution result, and obtain the second execution state in the execution result; determine whether the second execution state is successful, and if so, use the initial SQL statement as the newly installed SQL statement; the newly installed SQL statement is an SQL statement that may be compatible with the domestic database after being replaced by the SQL replacement rule.

[0074] S330: In response to the newly installed SQL statement being a preset type statement, construct a MySQL statement based on the newly installed SQL statement; and process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptive SQL statement.

[0075] S340: Execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0076] Embodiment 4

[0077] A database adaptation and debugging method is provided in a fourth embodiment of the present application. The method optimizes the "constructing a MySQL statement based on the newly installed SQL statement in response to the newly installed SQL statement being a preset type statement" in the first embodiment. It should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments. The method includes:

[0078] S410, parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result.

[0079] S420: Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement.

[0080] S431. In response to the new SQL statement being a preset type statement, determine a table name, a field, and a statement condition corresponding to the new SQL statement.

[0081] Among them, the preset type statement is the SELECT statement. The newly installed SQL statement contains table name, field and statement conditions. Among them, the table name is the name of the data table to be operated by the newly installed SQL statement, the field is the field in the data table, and the statement condition is the query condition for querying the data table.

[0082] Specifically, it is determined whether the newly installed SQL statement is a SELECT statement, and if so, the table name, field, and statement condition involved in the newly installed SQL statement are determined.

[0083] S432: Construct a MySQL statement based on the table name, the field, and the statement condition.

[0084] Among them, the table name, field, and statement condition are the components required to construct a MySQL statement.

[0085] S433: Process the newly installed SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement.

[0086] S440: Execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0087] Embodiment 5

[0088] A database adaptation and debugging method is provided in Embodiment 5 of the present application. The method optimizes the "processing the newly installed SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement" in Embodiment 1. It should be noted that for the parts not described in detail in this embodiment, reference may be made to the descriptions of other embodiments. The method includes:

[0089] S510: parse the acquired processor mapping to obtain a parsing result, and obtain a function use case table based on the parsing result.

[0090] S520: Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement.

[0091] S531. In response to the newly installed SQL statement being a preset type statement, construct a MySQL statement based on the newly installed SQL statement.

[0092] S532: Obtain an execution plan for the MySQL statement based on a preset EXPLAIN statement.

[0093] Among them, each MySQL statement has its corresponding execution plan. Exemplarily, the execution plan corresponding to a certain MySQL statement is "operate on table 1 first and then operate on table 2". In this embodiment, an EXPLAIN statement is preset, and the EXPLAIN statement is used to obtain the execution plan of the MySQL statement.

[0094] Specifically, the MySQL statement is processed through the preset EXPLAIN statement to obtain the execution plan of the MySQL statement.

[0095] S533: Determine the plan type of the execution plan.

[0096] Among them, the plan type includes a sequential type and a synchronous type, etc. For example, if the execution plan is "operate on Table 1 first and then on Table 2", the plan type corresponding to the execution plan is a sequential type; if the execution plan is "operate on Table 1 and Table 2 at the same time", the plan type corresponding to the execution plan is a synchronous type.

[0097] Specifically, determine the plan type for executing the plan.

[0098] S534: Adjust the newly installed SQL statement based on the plan type to obtain a primary adaptive SQL statement.

[0099] Among them, adjusting the newly installed SQL statement is to reversely adjust the execution plan, so as to achieve the adjustment of the newly installed SQL statement; illustratively, assuming that the plan type of a newly installed SQL statement is a sequential type, and the execution plan is "operate on Table 1 first and then on Table 2", the reversely adjusted execution plan is "operate on Table 2 first and then on Table 1", and the newly installed SQL statement is further adjusted according to the reversely adjusted execution plan; the primary adaptation SQL statement is the SQL statement obtained after the adjustment of the newly installed SQL statement.

[0100] Specifically, the execution plan is reversely adjusted according to the plan type, and the newly installed SQL statement is further adjusted through the reversely adjusted execution plan, so that the adjusted newly installed SQL statement is consistent with the reversely adjusted execution plan, thereby obtaining a primary adaptive SQL statement.

[0101] S140: Execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0102] Embodiment 6

[0103] A database adaptation debugging method is provided in Embodiment 6 of the present application. The method optimizes the "executing the primary adaptation SQL statement corresponding to the record in the function use case table to obtain the target execution record" in Embodiment 1. It should be noted that for the part not described in detail in this embodiment, reference may be made to the description of other embodiments. The method includes:

[0104] S610: parse the acquired processor mapping to obtain a parsing result, and obtain a function use case table based on the parsing result.

[0105] S620: Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement.

[0106] S630: In response to the newly installed SQL statement being a preset type statement, construct a MySQL statement based on the newly installed SQL statement; and process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement.

[0107] S641. Obtain the table name corresponding to the record in the function use case table to obtain the target table name.

[0108] Among them, refer to Figure 2 ,The records in the function use case table include the table name.

[0109] Specifically, taking a record in the function use case table as an example, the table name in the record is obtained, and the table name is recorded as the target table name.

[0110] S642. Construct a test SQL statement based on the target table name, and execute the test SQL statement to obtain simulated data.

[0111] Among them, the test SQL statement is constructed according to the target table name, and the test SQL statement is used to perform query operations on the data table corresponding to the target table name; the simulation data is the execution result obtained by executing the test SQL statement; a thread pool is preset locally, the number of threads in the thread pool is 1000, and the threads in the thread pool are used to execute the test SQL statement, and the simulation data corresponding to the execution result is specifically mock data.

[0112] Specifically, the test SQL statement is processed by the threads in the preset thread pool to obtain the corresponding mock data.

[0113] S643: Determine the corresponding request parameters in the record, and construct a primary adaptation SQL statement based on the simulation data and the request parameters.

[0114] Among them, taking a record in the function use case table as an example, refer to Figure 2The record includes a rest request, which specifically includes request parameters, request address, and request type. A primary adaptation SQL statement can be constructed by simulating the request parameters in the rest request in the data and record.

[0115] Specifically, taking a record as an example, the rest request in the record is determined, and the request parameters in the rest request are further determined, and then a primary adaptation SQL statement is constructed according to the request parameters and the simulation data.

[0116] S644: Execute the primary adaptation SQL statement to obtain a target execution record.

[0117] The target execution record includes the execution time and execution status.

[0118] Specifically, during the execution of the primary adaptation SQL statement, the corresponding execution time and execution status are recorded to obtain the target execution record.

[0119] S645: Process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement.

[0120] Specifically, the execution status in the target execution record is obtained. If the execution status is execution failure, the performance of the corresponding primary adaptation SQL statement is continued to be optimized to obtain the target adaptation SQL statement. If the execution status is execution success, it is further determined whether the execution time exceeds the preset time threshold. If it exceeds, the performance of the corresponding primary adaptation SQL statement is continued to be optimized to obtain the target adaptation SQL statement. Otherwise, the primary adaptation SQL statement is used as the target adaptation SQL statement.

[0121] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0122] Embodiment 7

[0123] Based on the same inventive concept, this embodiment also provides a database adaptation and debugging device for implementing the database adaptation and debugging method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more database adaptation and debugging device embodiments provided below can refer to the limitations on the database adaptation and debugging method above, and will not be repeated here.

[0124] In this embodiment, Figure 3 As shown, a database adaptation and debugging device is provided, comprising:

[0125] A use case table generation module, used to parse the acquired processor mapping to obtain a parsing result, and obtain a function use case table based on the parsing result;

[0126] A statement replacement module, used to replace the current SQL statement to obtain a new SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule;

[0127] A primary statement generation module, configured to construct a MySQL statement based on the newly installed SQL statement in response to the newly installed SQL statement being a preset type statement; and to process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement;

[0128] The target statement generation module is used to execute the primary adaptation SQL statement corresponding to the record in the function use case table to obtain the target execution record, and process the primary adaptation SQL statement based on the target execution record to obtain the target adaptation SQL statement.

[0129] Each module in the above database adaptation and debugging device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0130] It should be noted that, in this embodiment, the obtained processor mapping is parsed to obtain the parsing result, and the functional use case table is obtained based on the parsing result; the current SQL statement is replaced based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement; in response to the new SQL statement being a preset type statement, a MySQL statement is constructed based on the new SQL statement; the new SQL statement is processed based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement; the primary adaptation SQL statement corresponding to the record in the functional use case table is executed to obtain a target execution record, and the primary adaptation SQL statement is processed based on the target execution record to obtain a target adaptation SQL statement. Through the above implementation, a target adaptation SQL statement adapted to the domestic database can be quickly generated for each domestic database, thereby facilitating the reduction of the time cost of replacing the foreign database used by the enterprise-level software with the domestic database.

[0131] Embodiment 8

[0132] In this embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a database adaptation and debugging method is implemented.

[0133] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0134] Embodiment 9

[0135] In this embodiment, a computer readable storage medium is provided. Figure 5 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0136] Embodiment 10

[0137] In this embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0138] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0139] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.

[0140] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0141] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.

Claims

1. A database adaptation and debugging method, characterized in that: include: Parsing the acquired processor mapping to obtain a parsing result, and obtaining a function use case table based on the parsing result; Replace the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement; In response to the newly installed SQL statement being a preset type statement, constructing a MySQL statement based on the newly installed SQL statement; Processing the newly installed SQL statement based on the execution plan of the MySQL statement to obtain a primary adaptation SQL statement; Executing the primary adaptation SQL statement corresponding to the record in the function use case table to obtain a target execution record, and processing the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement; Wherein, the function use case table obtained based on the analysis result includes: Determine a program package corresponding to the method class in the parsing result, and obtain the method class corresponding to the program package to obtain a class set; Determine a method class containing a preset keyword from the class set to obtain a target class, and determine a SQL statement corresponding to the target class to obtain a SQL statement to be referenced; Extracting entity classes and table names from the target class based on the SQL statement to be referenced and method parameters of the target class; A function use case table is obtained based on the parsing result, the entity class and the table name.

2. The method according to claim 1, characterized in that The step of replacing the current SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule to obtain a new SQL statement includes: Locally storing the current SQL statement and the execution result obtained by executing the current SQL statement to obtain a local variable; In response to the first execution state in the local variable being execution failure, replacing the current SQL statement based on a preset SQL replacement rule to obtain an initial SQL statement; The initial SQL statement is executed to obtain a second execution state, and in response to the second execution state being successful, the initial SQL statement is used as a new SQL statement.

3. The method according to claim 1, characterized in that In response to the newly installed SQL statement being a preset type statement, constructing a MySQL statement based on the newly installed SQL statement includes: In response to the newly installed SQL statement being a preset type statement, determining a table name, a field, and a statement condition corresponding to the newly installed SQL statement; A MySQL statement is constructed based on the table name, the field, and the statement condition.

4. The method according to claim 1, characterized in that: The step of processing the newly installed SQL statement based on the execution plan of the MySQL statement to obtain a primary adapted SQL statement includes: Obtaining an execution plan for the MySQL statement based on a preset EXPLAIN statement; determining a plan type for the execution plan; The newly installed SQL statement is adjusted based on the plan type to obtain a primary adaptive SQL statement.

5. The method according to claim 1, characterized in that The executing the primary adaptation SQL statement corresponding to the record in the function use case table to obtain the target execution record includes: Obtain the table name corresponding to the record in the function use case table to obtain the target table name; Construct a test SQL statement based on the target table name, and execute the test SQL statement to obtain simulated data; Determine the corresponding request parameters in the record, and construct a primary adaptation SQL statement based on the simulation data and the request parameters; Execute the primary adaptation SQL statement to obtain a target execution record.

6. A database adaptation and debugging device, characterized in that: The device comprises: A use case table generation module, used to parse the acquired processor mapping to obtain a parsing result, and obtain a function use case table based on the parsing result; A statement replacement module, used to replace the current SQL statement to obtain a new SQL statement based on the execution result obtained by executing the current SQL statement and the SQL replacement rule; A primary statement generation module, configured to construct a MySQL statement based on the newly installed SQL statement in response to the newly installed SQL statement being a preset type statement; and to process the newly installed SQL statement based on an execution plan of the MySQL statement to obtain a primary adaptation SQL statement; A target statement generation module, configured to execute a primary adaptation SQL statement corresponding to a record in the function use case table to obtain a target execution record, and to process the primary adaptation SQL statement based on the target execution record to obtain a target adaptation SQL statement; Wherein, the function use case table obtained based on the analysis result includes: Determine a program package corresponding to the method class in the parsing result, and obtain the method class corresponding to the program package to obtain a class set; Determine a method class containing a preset keyword from the class set to obtain a target class, and determine a SQL statement corresponding to the target class to obtain a SQL statement to be referenced; Extracting entity classes and table names from the target class based on the SQL statement to be referenced and method parameters of the target class; A function use case table is obtained based on the parsing result, the entity class and the table name.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

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

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

Citation Information

Patent Citations

  • Statement type conversion method and device, storage medium and electronic device

    CN113505143A

  • SQL (Structured Query Language) execution plan management method, device and equipment and readable storage medium

    CN115495481A