A SQL test set reconstruction method, device, equipment and storage medium
By refactoring the SQL test set, obtaining the unique identification name of the target object and renaming it, the deletion statement is invalidated, solving the problems of inefficient construction of SQL test sets and difficulty in mislocating positioning in the existing technology, and achieving efficient full migration test and fast error positioning.
Patent Information
- Application Number
- CN202011051215.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2040-09-29
AI Technical Summary
In the prior art, SQL test set construction is inefficient, full migration test cannot be carried out, and error location is difficult during the migration process.
By obtaining the original SQL test set, obtaining the unique identification name of the target object, and renaming the target object, and invalidating the delete statement to obtain the refactored SQL test set.
It improves the efficiency and coverage of SQL test set construction, realizes full migration testing, and can quickly locate the source of errors during the migration process.
Smart Images

Figure CN114328160B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and in particular, to a method, device, equipment, and storage medium for reconstructing an SQL test set. Background Art
[0002] Currently, when performing data migration in MySQL, it mainly includes full-scale migration and incremental migration. When testing the migration task, various database schema definition languages (Data Definition Language, abbreviated as DDL), data manipulation languages (Data Manipulation Language, abbreviated as DML), data types, and character sets supported by MySQL need to be considered. Therefore, various SQL statements need to be comprehensively considered.
[0003] In the prior art, there are mainly two testing methods. The first is to construct various SQL statements from scratch to cover various SQL scenarios; the second is to directly use the SQL test set under the MySQL automated test framework (MySQL test framework).
[0004] However, constructing various SQL statements from scratch requires writing a large number of SQL statements, which requires a high technical level of the staff writing the SQL statements. The staff needs to be proficient in various SQL statements, which is time-consuming and laborious, and it is very likely that the coverage is not comprehensive. Directly using the MySQL test framework SQL test set cannot perform full-scale migration testing because the SQL statements in this test set are basically in the mode of create table t1…drop table t1…create table t1…drop tablet1, and the created table structure and data cannot be retained. In addition, when this test set is used for incremental migration testing, if an error occurs during the migration process, the same table name t1 is not convenient for quickly locating the error source. Summary of the Invention
[0005] This application provides a method, device, equipment, and storage medium for reconstructing an SQL test set to solve the problems of low efficiency in the manual writing method and the loss of relational data and inability to locate error statements caused by the undifferentiated testing of multiple test objects in the existing SQL test set.
[0006] In a first aspect, an embodiment of this application provides a method for reconstructing an SQL test set, including: obtaining an original SQL test set; obtaining the unique identification name of a target object in the original SQL test set; renaming the target object in the original SQL test set using the unique identification name, and invalidating the delete statements in the original SQL test set to obtain a reconstructed SQL test set.
[0007] Optionally, obtaining the unique identification name of the target object in the original SQL test set includes: obtaining the target original SQL file in the original SQL test set; obtaining the file name of the target original SQL file, the type of the target object, and the numerical value of the current cumulative count of the same type of objects that have been renamed; generating the unique identification name according to the file name, the type, and the numerical value of the current cumulative count.
[0008] Optionally, renaming the target object in the original SQL test set by using the unique identification name includes: obtaining the operation statement related to the target object in the target original SQL file; changing the original object name of the target object in the related operation statement to the unique identification name.
[0009] Optionally, obtaining the file name of the target original SQL file, the type of the target object, and the numerical value of the current cumulative count of the same type of objects that have been renamed includes: obtaining the file name of the target original SQL file; when the operation statement related to the target object in the target original SQL file is the creation statement of the target object, obtaining the type of the target object and the numerical value of the previous cumulative count of the same type of objects that have been renamed; adding 1 to the numerical value of the previous cumulative count to obtain the numerical value of the current cumulative count of the same type of objects that have been renamed.
[0010] Optionally, after obtaining the unique identification name of the target object in the original SQL test set, the method further includes: saving the correspondence between the original object name and the unique identification name of the target object to a storage table; changing the original object name of the target object in the related operation statement to the unique identification name includes: obtaining the original object name of the target object; obtaining the unique identification name corresponding to the original object name from the storage table; replacing the original object name of the target object in the related operation statement with the unique identification name.
[0011] Optionally, obtaining the original SQL test set includes: obtaining the native SQL test set saved in the SQL server; extracting the partial SQL files supported by the data transformation service in the native SQL test set to obtain the original SQL test set.
[0012] Optionally, invalidating the delete statements in the original SQL test set includes: changing the delete statements in the original test set to comment statements to invalidate the delete statements.
[0013] In a second aspect, an embodiment of the present application provides an SQL test set reconstruction device, including: a first acquisition module configured to acquire an original SQL test set; a second acquisition module configured to acquire a unique identification name of a target object in the original SQL test set; and a processing module configured to rename the target object in the original SQL test set by using the unique identification name, and invalidate a delete statement in the original SQL test set to obtain a reconstructed SQL test set.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is configured to store a computer program; and the processor is configured to execute the program stored in the memory to implement the SQL test set reconstruction method described above.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the SQL test set reconstruction method described above.
[0016] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: The method provided by the embodiments of the present application reconstructs the existing SQL test set, avoiding the need to create an SQL test set from scratch, which requires high-level technical personnel, saving a large amount of SQL development time, and having a higher SQL test coverage. At the same time, different objects are renamed so that different objects have unique identification names, and the delete statement is invalidated, enabling the relationship structure of the objects and the object processing result data to be retained, realizing a full-volume data migration. If an error occurs during the migration process, the source of the error can be quickly located. This method improves the use effect of the test set, obtains more accurate and comprehensive test results, and facilitates subsequent operations and processing based on the test results. Description of the Drawings
[0017] The accompanying drawings here are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0019] Figure 1 It is a flowchart of the SQL test set reconstruction method provided by the embodiment of the present application;
[0020] Figure 2 Schematic diagram of the unique identifier name acquisition process provided by the embodiment of the present application;
[0021] Figure 3 Schematic diagram of the target object type and cumulative number value acquisition process provided by the embodiment of the present application;
[0022] Figure 4 Schematic diagram of the reconstruction process of the table in the SQL test set provided by the embodiment of the present application;
[0023] Figure 5 Schematic diagram of the structure of the SQL test set reconstruction device provided by the embodiment of the present application;
[0024] Figure 6 Schematic diagram of the structure of the electronic device provided by the embodiment of the present application. Detailed implementation manners
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0026] The embodiment of the present application provides a method for reconstructing an SQL test set. After the SQL database is migrated from the source end to the destination end, it is necessary to test the migrated data to verify that the database at the source end is the same as the database transmitted to the destination end to ensure the correctness and integrity of the database. The method provided by the present application is used to reconstruct the SQL test set for testing the SQL database. This test set is located on the server at the source end or the destination end, or can also be located on other servers, as long as this server can obtain relevant data from both the source end and the destination end.
[0027] As Figure 1 shown, the process of reconstructing the SQL test set mainly includes the following steps:
[0028] Step 101, obtain the original SQL test set.
[0029] In one embodiment, the process of obtaining the original SQL test set includes: obtaining the native SQL test set saved in the SQL server; extracting the part of the SQL files supported by the Data Transformation Service (DTS) in the native SQL test set to obtain the original SQL test set.
[0030] It should be noted that only the example of obtaining the native test set from the SQL server is used here for illustration. In the application, the native test set can also be obtained from other locations. The protection scope of this application is not limited by the specific method of obtaining the native test set.
[0031] In one embodiment, the native SQL test set under the MySQL test framework is read, that is, the mysql-test / t / *.test file set under the source code root directory; the part of the SQL files supported by DTS in the native SQL test set is extracted. All the file sets supported by DTS are combined to obtain the original SQL test set. The part of the SQL files supported by DTS includes SQL files containing various data types, character sets, DDL statements, DML statements, and various object-related operation statements, and these files can be identified by their file names.
[0032] By obtaining the existing native test set, it avoids the staff from constructing various SQL statements from scratch, modifies the statements that need to be modified on the existing basis, reduces the technical level requirements for the staff, saves a large amount of SQL development time, makes the process of constructing the SQL test set time-saving and labor-saving, and at the same time avoids missing various types of SQL statements, improving the SQL test coverage.
[0033] Step 102, obtain the unique identification name of the target object in the original SQL test set.
[0034] In one embodiment, as Figure 2 shown, the process of obtaining the unique identification name of the target object in the original SQL test set includes:
[0035] Step 201, obtain the target original SQL file in the original SQL test set;
[0036] Step 202, obtain the file name of the target original SQL file, the type of the target object, and the numerical value of the current cumulative count of the same type of objects that have been renamed;
[0037] Step 203, generate the unique identification name according to the file name, type, and the numerical value of the current cumulative count.
[0038] Among them, the unique identification name includes the file name of the file where the target object is located, the type of the target object, and the value of the cumulative count. After replacing the name of the target object with the unique identification name, relevant information such as the file name and type of the file where the target object is located can be obtained from the unique identification name. At the same time, the uniqueness of the renamed object name can distinguish different objects, avoiding the indiscriminate processing of different objects. When an error occurs in the target object in the test result, the SQL statement when the target object is executed at the target end can also be determined through the unique identification name, quickly matching its corresponding source-end SQL statement, and locating the position of the source-end SQL statement in the target original SQL file to find the source of the error.
[0039] In the embodiments of the present application, the file names that appear are described by taking the file names without extensions as examples, but the file names required by the SQL test set reconstruction method proposed in the present application can also use file names with extensions. The protection scope of the present application is not limited by the composition of the file name.
[0040] It should be noted that the value of the current cumulative count of the same type of objects that have been renamed in the unique identification name, combined with the file name and the type of the target object, realizes the uniqueness of the unique identification name. Other identifiers that can achieve the uniqueness function can also be used to generate the unique identification name. For example, random numbers obtained through algorithms, hash values of the target original SQL file, etc. The protection scope of the present application is not limited by the generation method of the unique identification name.
[0041] In one embodiment, the objects in the original SQL test set include tables, indexes, views, functions, triggers, procedures, and events. The target object can be any one of the objects in the original SQL test set.
[0042] In one embodiment, as Figure 3 shown, the process of obtaining the file name of the target original SQL file, the type of the target object, and the value of the current cumulative count of the same type of objects that have been renamed includes:
[0043] Step 301, obtain the file name of the target original SQL file;
[0044] Step 302, when the operation statement related to the target object in the target original SQL file is the creation statement of the target object, obtain the type of the target object and the value of the previous cumulative count of the same type of objects that have been renamed;
[0045] Step 303, add one to the value of the previous cumulative count to obtain the value of the current cumulative count of the same type of objects that have been renamed.
[0046] In one embodiment, the creation statement can be a create statement or other statements that implement the function of creating new individual objects.
[0047] There can only be one creation statement for the same target object. By obtaining the type and cumulative count value of the target object in the creation statement, it is possible to avoid the problem of multiple names corresponding to the same target object. At the same time, it is convenient to start from the creation statement and replace the original object name in all operation statements related to the target object, avoiding the phenomenon of missing relevant operation statements.
[0048] In one embodiment, when obtaining the current cumulative count of the unified type object that has been renamed, a counter for counting the target objects of this type is set. This counter is only used to count the number of objects of the same type as the target object. For objects of different types, different counters can be set. For example, counter 1 is used for table type objects, and counter 2 is used for view type objects, etc. During the reconstruction process of the SQL test set, when the relevant operation statement is a creation statement, this counter automatically increments by one, accurately providing the cumulative count value of the renamed objects of the same type to distinguish objects of the same type, thereby avoiding the problem of different objects of the same type having the same name. At the same time, the number of all current objects of the same type can be obtained and directly used when certain statistics are required.
[0049] Step 103: Rename the target objects in the original SQL test set with unique identification names, and invalidate the delete statements in the original SQL test set to obtain the reconstructed SQL test set.
[0050] In one embodiment, the process of renaming the target objects in the original SQL test set with unique identification names includes: obtaining the operation statements related to the target objects in the target original SQL file; changing the original object name of the target object in the relevant operation statements to a unique identification name.
[0051] In one embodiment, the operation statements related to the target object include the creation statement, delete statement, and other statements for operating on the target object. Among them, the creation statement is used to create new individual objects, and the delete statement is used to delete the individual objects in this statement.
[0052] In one embodiment, after obtaining the unique identification name of the target object in the original SQL test set, the corresponding relationship between the original object name and the unique identification name of the target object is saved to a storage table. Changing the original object name of the target object in the relevant operation statements to a unique identification name includes:
[0053] Obtaining the original object name of the target object; obtaining the unique identification name corresponding to the original object name from the storage table; replacing the original object name of the target object in the relevant operation statements with the unique identification name.
[0054] In this embodiment, multiple corresponding relationships can be saved in the storage table, that is, the corresponding relationships between the original object names of multiple objects and the unique identifier names corresponding to these objects can be saved simultaneously.
[0055] After saving the corresponding relationship between the original object name and the unique identifier name of the target object to the storage table, it is not necessary to regenerate the unique identifier name of the target object every time the target object is encountered. Instead, it only needs to be read from the storage table, which simplifies the renaming process and also avoids the problem of the same object having different names.
[0056] In one embodiment, the storage table is a hash map (HashMap). When saving the corresponding relationship between the original object name and the unique identifier name of the target object to the HashMap, the original object name is used as the key (key). When there is an original object name (i.e., key) in the relevant operation statement, the HashMap can quickly read the unique identifier name corresponding to the original object name in the HashMap through the key and the corresponding relationship.
[0057] It should be noted that only HashMap is used as an example here for illustration. In applications, other types of storage tables can also be used to store the corresponding relationship, and the protection scope of this application is not limited by the specific type of the storage table.
[0058] In one embodiment, when the relevant operation statement is a deletion statement for the target object, after replacing the original object name in the deletion statement with the unique identifier name, the corresponding relationship between the original object name and the unique identifier name of the target object in the storage table is removed. The deletion statement can be a drop statement or other statements that can delete individual objects. When the relevant operation statement is a deletion statement for the target object, removing the corresponding relationship of the target object in the storage table can save the storage space of the storage table.
[0059] In one embodiment, invalidating the deletion statements in the original SQL test set includes: changing the deletion statements in the original test set to comment statements to invalidate the deletion statements. By changing the deletion statements in the original test set to comment statements, the deletion effect of the deletion statements is invalidated, and at the same time, it can characterize when the processing process of the target object ends. After the deletion statements are invalidated, all the processing result data and structure data of the target object can be retained to achieve full-scale migration testing. At the same time, it is convenient to quickly obtain the search results when relevant data needs to be searched in the test results.
[0060] In one embodiment, each original SQL file in the original SQL test set is used as the target original SQL file, and the relevant operation statements for the target object being a table are reconstructed. Among them, the file name of a certain original SQL file in the original SQL test set is sqlFileName.
[0061] The target object is a table, represented by tb; the file name of the target original SQL file is represented by tnPrefix; the storage table is represented by tnMap, and this storage table uses HashMap to implement the storage function; the counter is represented by tnCount.
[0062] In this embodiment, the native SQL test set under MySQL test framework is read, and the part of the SQL files supported by DTS in the native SQL test set is extracted, that is, the SQL files containing various data types, character sets, DDL statements, DML statements, and various object-related operation statements. All the file sets supported by DTS are obtained to get the original SQL test set.
[0063] In this embodiment, the statement for creating a table is the create table statement, and the statement for deleting a table is the drop table statement.
[0064] In this embodiment, as Figure 4 shown, when the file with the file name sqlFileName is used as the target original SQL file, the process of reconstructing the SQL test set for the target object which is a table includes:
[0065] Step 401, obtain the file with the file name sqlFileName in the original SQL test set as the target original SQL file;
[0066] Step 402, initialize tnPrefix = sqlFileName, tnMap = new HashMap(), and initialize tnCount = 0;
[0067] Step 403, read the first line statement of the target original SQL file as the target statement;
[0068] Step 404, determine whether the target statement is empty. If it is, execute Step 405; if not, execute Step 406;
[0069] Step 405, end the process of reconstructing the SQL test set for the target object which is a table;
[0070] Step 406, determine whether the target statement is a create table statement. If it is, execute Step 4071; if not, execute Step 408;
[0071] Step 4071, increment tnCount by 1, obtain the unique identification name as ${tnPrefix}_tb${tnCount}, store the corresponding relationship between the original name and the unique identification name of the target table in tnMap, and use the original name of the target table as the key;
[0072] Step 4072, extract the unique identification name in the tnMap, replace the original name of the target table in the create table statement with the unique identification name, and execute Step 412;
[0073] Step 408, determine whether the target statement is a drop table statement. If so, execute Step 4091; if not, execute Step 410;
[0074] Step 4091, extract the unique identification name in the tnMap, replace the original name of the target table in the drop table statement with the unique identification name;
[0075] Step 4092, add comments to the target statement, change it to a commented statement, remove the corresponding relationship storage record in the tnMap with the key being the original name of the target table, and execute Step 412;
[0076] Step 410, determine whether the target statement is a table-related operation statement. If so, execute Step 411; if not, execute Step 412;
[0077] Step 411, extract the unique identification name in the tnMap, replace the original name of the target table in the target statement with the unique identification name, and execute Step 412;
[0078] Step 412, read the next line statement of the target statement, use the next line statement as the new target statement, and execute Step 404.
[0079] In this embodiment, when each original SQL file in the original SQL test set is used as the target original SQL file, the process of reconstructing the SQL test set with the target object being a table is the same as the reconstruction process of the original SQL file with the file name sqlFileName.
[0080] It should be noted that in this embodiment, only the case where the target object is a table is used to illustrate the process of reconstructing the SQL test set. The reconstruction process of other types of objects as the target object in this application is the same as the reconstruction process with the table as the target object. When the table in this embodiment is replaced with other types of objects, the same effect can be achieved. For each type of object involved in the SQL test set reconstruction process of this embodiment, just execute according to the process from Step 401 to Step 412.
[0081] The SQL test set reconstruction method provided by this application reconstructs the existing SQL test set, avoiding creating an SQL test set from scratch. It modifies the statements that need to be modified based on the existing ones, reducing the technical level requirements for staff, saving a large amount of SQL development time, making the process of constructing the SQL test set time-saving and labor-saving. At the same time, it avoids omitting various types of SQL statements and improves the SQL test coverage. By renaming different objects to unique identifier names, each object is distinguished, avoiding the indiscriminate processing of different objects. After invalidating the delete statements, when an error occurs in the target object in the test result, the corresponding source-side SQL statement can still be quickly matched through the unique identifier name and the SQL statement when the target object is executed at the target end, and the position of the source-side SQL statement in the target original SQL file can be located to find the source of the error.
[0082] The SQL test set reconstruction method provided by this application obtains the unique identifier name when creating a statement, and there can only be one create statement for the same target object, avoiding the problems of duplicate naming or missing naming in the relevant operation statements. The correspondence between the original object name and the unique identifier name is saved in the storage table, eliminating the need to regenerate the unique identifier name of the target object every time the target object is encountered, simplifying the renaming process; when the relevant operation statement is the delete statement of the target object, removing the corresponding relationship of the target object in the storage table can save the storage space of the storage table. When using a HashMap as the storage table, the unique identifier name can be obtained more quickly, making the SQL test set reconstruction faster. This method improves the usage effect of the test set, obtains more accurate and comprehensive test results, and facilitates subsequent operations and processing based on the test results.
[0083] Based on the same concept, an SQL test set reconstruction device is provided in an embodiment of this application. For the specific implementation of this device, reference can be made to the description in the method embodiment part, and the repeated parts will not be elaborated. As Figure 5 shown, this device mainly includes:
[0084] The first acquisition module 501 is used to acquire the original SQL test set;
[0085] The second acquisition module 502 is used to acquire the unique identifier name of the target object in the original SQL test set;
[0086] The processing module 503 renames the target object in the original SQL test set with the unique identifier name and invalidates the delete statements in the original SQL test set to obtain the reconstructed SQL test set.
[0087] Based on the same concept, an electronic device is also provided in an embodiment of this application, as Figure 6As shown in the figure, the electronic device mainly includes: a processor 601, a communication interface 602, a memory 603, and a communication bus 604. Among them, the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604. Among them, a program executable by the processor 601 is stored in the memory 603. The processor 601 executes the program stored in the memory 603 to implement the following steps: obtaining an original SQL test set; obtaining the unique identification name of the target object in the original SQL test set; renaming the target object in the original SQL test set using the unique identification name, and invalidating the delete statements in the original SQL test set to obtain a reconstructed SQL test set.
[0088] The communication bus 604 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 604 can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 6 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.
[0089] The communication interface 602 is used for communication between the above electronic device and other devices.
[0090] The memory 603 may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor 601.
[0091] The above-mentioned processor 601 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc., or may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0092] In yet another embodiment of the present application, a computer-readable storage medium is further provided. A computer program is stored in the computer-readable storage medium. When the computer program runs on a computer, the computer is caused to execute the SQL test set reconstruction method described in the above embodiment.
[0093] In the above embodiment, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions are transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape, etc.), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.
[0094] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including the said element.
[0095] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features claimed herein.
Claims
1. An SQL test set reconstruction method, characterized in that, it includes: Obtain the original SQL test set; Obtain the unique identification name of the target object in the original SQL test set. The objects in the original SQL test set include tables, indexes, views, functions, triggers, procedures, and events. The target object is any one of the objects in the original SQL test set, and the unique identification name includes the file name of the file where the target object is located, the type of the target object, and the value of the cumulative count; Rename the target object in the original SQL test set using the unique identification name, and invalidate the delete statements in the original SQL test set to obtain a reconstructed SQL test set; The obtaining of the unique identification name of the target object in the original SQL test set includes: Obtain the target original SQL file in the original SQL test set; Obtain the file name of the target original SQL file, the type of the target object, and the value of the current cumulative count of the same type of objects that have been renamed; Generate the unique identification name according to the file name, the type, and the value of the current cumulative count; The obtaining of the file name of the target original SQL file, the type of the target object, and the value of the current cumulative count of the same type of objects that have been renamed includes: Obtain the file name of the target original SQL file; When the operation statement related to the target object in the target original SQL file is the creation statement of the target object, obtain the type of the target object and the value of the previous cumulative count of the same type of objects that have been renamed; Add one to the value of the previous cumulative count to obtain the value of the current cumulative count of the same type of objects that have been renamed.
2. The SQL test set reconstruction method according to claim 1, characterized in that, The renaming of the target object in the original SQL test set using the unique identification name includes: Obtain the operation statement related to the target object in the target original SQL file; Change the original object name of the target object in the related operation statement to the unique identification name.
3. The SQL test set reconstruction method according to claim 2, characterized in that, After obtaining the unique identification name of the target object in the original SQL test set, the method further includes: Save the correspondence between the original object name and the unique identification name of the target object to a storage table; The changing of the original object name of the target object in the related operation statement to the unique identification name includes: Obtain the original object name of the target object; Obtain the unique identification name corresponding to the original object name from the storage table; Replace the original object name of the target object in the related operation statement with the unique identification name.
4. The SQL test set reconstruction method according to claim 1, characterized in that, The obtaining of the original SQL test set includes: Obtain the native SQL test set saved in the SQL server; Extract the partial SQL files supported by the data conversion service in the native SQL test set to obtain the original SQL test set.
5. The SQL test set reconstruction method according to claim 1, wherein, invalidating the delete statements in the original SQL test set includes: changing the delete statements in the original test set to comment statements to invalidate the delete statements.
6. An SQL test set reconstruction device, wherein, it includes: a first acquisition module for acquiring an original SQL test set; a second acquisition module for acquiring the unique identification name of the target object in the original SQL test set, where the objects in the original SQL test set include tables, indexes, views, functions, triggers, procedures, and events, the target object is any one of the objects in the original SQL test set, and the unique identification name includes the file name of the file where the target object is located, the type of the target object, and the value of the cumulative count; a processing module for renaming the target object in the original SQL test set with the unique identification name and invalidating the delete statements in the original SQL test set to obtain a reconstructed SQL test set; The second acquisition module is further configured to: acquire the target original SQL file in the original SQL test set; acquire the file name of the target original SQL file, the type of the target object, and the value of the current cumulative count of the renamed objects of the same type; generate the unique identification name according to the file name, the type, and the value of the current cumulative count; The acquiring the file name of the target original SQL file, the type of the target object, and the value of the current cumulative count of the renamed objects of the same type includes: acquiring the file name of the target original SQL file; when the operation statement related to the target object in the target original SQL file is the creation statement of the target object, acquiring the type of the target object and the value of the previous cumulative count of the renamed objects of the same type; adding 1 to the value of the previous cumulative count to obtain the value of the current cumulative count of the renamed objects of the same type.
7. An electronic device, wherein, it includes: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory for storing a computer program; the processor for executing the program stored in the memory to implement the SQL test set reconstruction method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, wherein, the computer program, when executed by a processor, implements the SQL test set reconstruction method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Renaming method, access method and device
CN106484820A
Information obtaining method and device
CN108572963A