Data processing method, device and equipment and computer readable storage medium

By constructing initial prompts and utilizing pre-trained models and mutation operators to process test cases, the scalability and coverage issues of database testing are solved, achieving efficient compatibility and diverse test case generation for different databases.

CN121807686APending Publication Date: 2026-04-07TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies for database testing suffer from low scalability and narrow test coverage, making it difficult to be compatible with the syntax rules of different databases, and SQL test cases are relatively simple.

Method used

By constructing initial prompts and using pre-trained models for identification and processing, and combining mutation operators to mutate test cases, diverse test cases are generated, thereby improving test coverage.

Benefits of technology

It improves the scalability and coverage of database testing, can efficiently support testing of different databases, and generates diverse test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807686A_ABST
    Figure CN121807686A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method, device and equipment and a computer readable storage medium, and the method comprises the steps: constructing an initial prompt according to a grammar analysis file of a test database and database information of the test database, inputting the initial prompt into a pre-training model, carrying out the recognition processing of the initial prompt through the pre-training model, and obtaining a recognition result of the initial prompt; obtaining a first test case; obtaining a mutation operator, and performing mutation processing on the first test case through the pre-training model and the mutation operator to obtain a second test case different from the first test case; executing the test cases in the test case library through the test database to obtain a first execution result output by the test database, and determining a test report of the test database according to the first execution result; the test case library comprises a first test case and a second test case. By adopting the method and the device, the expandability and the coverage rate of database testing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a data processing method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] Databases play a vital role across various industries, encompassing data storage, data processing, data security, and support for complex data management. Therefore, database testing is a crucial step in ensuring software quality and data security. Structured Query Language (SQL) is a database query and programming language that can be used to test databases.

[0003] Existing generative fuzzing tools can generate test cases based on the syntax rules of the database. However, since different databases have different syntax rules, existing technologies require a large amount of compatibility work for different databases, resulting in low scalability of database testing. In addition, the SQL test cases written by existing technologies are relatively simple, resulting in narrow test coverage. Summary of the Invention

[0004] This application provides a data processing method, apparatus, device, and computer-readable storage medium to improve the scalability and coverage of database testing.

[0005] One embodiment of this application provides a data processing method, including:

[0006] Based on the syntax analysis file of the test database and the database information of the test database, an initial prompt is constructed. The initial prompt is input into the pre-trained model, and the pre-trained model is used to identify and process the initial prompt to obtain the first test case.

[0007] Obtain the mutation operator, and use the pre-trained model and the mutation operator to mutate the first test case to obtain a second test case that is different from the first test case;

[0008] The test database executes the test cases in the test case library to obtain the first execution result output by the test database. The test report of the test database is determined based on the first execution result. The test case library includes the first test case and the second test case.

[0009] One embodiment of this application provides a data processing apparatus, including:

[0010] The construction module is used to construct initial prompts based on the syntax analysis file of the test database and the database information of the test database. The initial prompts are then input into the pre-trained model, which processes the initial prompts to obtain the first test case.

[0011] The mutation module is used to obtain mutation operators. Through the pre-trained model and mutation operators, the first test case is mutated to obtain a second test case that is different from the first test case.

[0012] The execution module is used to execute test cases in the test case library through the test database, obtain the first execution result output by the test database, and determine the test report of the test database based on the first execution result; the test case library includes the first test case and the second test case.

[0013] In one possible implementation, the build module constructs an initial prompt based on the syntax analysis file of the test database and the database information of the test database, for performing the following operations:

[0014] Obtain the syntax analysis file from the test database, parse and process the syntax analysis file, and construct an abstract syntax tree; the abstract syntax tree is used to generate syntax paths;

[0015] The test database is queried and processed to obtain the database information. The database information is then randomly selected to obtain the first local database information. The first local database information and the syntax path together instruct the pre-trained model to generate sample test cases.

[0016] Generate initial instructions to instruct the pre-trained model to perform inference, and construct an initial prompt by combining the initial instructions, sample test cases, syntax paths, and first local database information.

[0017] In one possible implementation, the build module parses the parsing file and constructs an abstract syntax tree for performing the following operations:

[0018] Retrieve the rule segments from the parsing file; each rule segment includes the rule name and the rule content corresponding to that rule name.

[0019] The rule name is determined as the index key, the rule content is determined as the index value, an index table including the index key and the index value is constructed, and an abstract syntax tree is constructed based on the index table.

[0020] In one possible implementation, the building module is also used to perform the following operations:

[0021] Obtain the probability table for the test database; the probability table includes A candidate start nodes and the initial probability corresponding to each of the A candidate start nodes; A is a positive integer greater than 1; all A candidate start nodes belong to the abstract syntax tree;

[0022] Based on the initial probabilities corresponding to the A candidate starting nodes, the starting node is obtained from the A candidate starting nodes;

[0023] In the abstract syntax tree, obtain the first child node of the child node belonging to the start node. If there is no child node of the first child node in the abstract syntax tree, generate the syntax path based on the start node and the first child node.

[0024] If there is a child node of the first child node in the abstract syntax tree, then obtain the second child node from the child node of the first child node;

[0025] Generate a syntax path based on the starting node, the first child node, the second child node, and the child nodes of the second child node in the abstract syntax tree.

[0026] In one possible implementation, the mutation module obtains the mutation operator and uses it to perform the following operations:

[0027] Perform rule detection on the first test case and obtain the rule detection results;

[0028] If the rule detection result indicates that the first test case does not conform to the syntax rules, the initial prompt is updated to obtain an updated prompt;

[0029] The update prompts are input into the pre-trained model, which then identifies and processes them to obtain test cases to be evaluated. These test cases are used to generate variant test cases when the evaluation process is passed. Both the test cases to be evaluated and the variant test cases that have passed the evaluation process are added to the test database.

[0030] If the rule detection result indicates that the first test case conforms to the syntax rule, then the first test case is evaluated to obtain the evaluation result;

[0031] When the evaluation result is a pass, obtain the mutation operator.

[0032] In one possible implementation, the mutation module updates the initial hint to obtain an updated hint, which is then used to perform the following operations:

[0033] The syntax path in the initial prompt is simplified to obtain the simplified syntax path;

[0034] Retrieve second local database information that differs from the first local database information from the database information;

[0035] Generate error messages from the rule detection results, and update the initial instructions in the initial messages based on the error messages to obtain update instructions;

[0036] The update prompt is constructed by combining the update instructions, sample test cases, simplified syntax paths, and second local database information.

[0037] In one possible implementation, the mutation module evaluates the first test case to obtain the evaluation result, which is then used to perform the following operations:

[0038] Determine the first number of subquery statements and the second number of structural operations in the first test case;

[0039] The score for the subquery statement is multiplied by the first quantity to obtain the first score;

[0040] The score for the structural operation and the second quantity are multiplied to obtain the second score;

[0041] The first score and the second score are summed to obtain the total score of the first test case. Based on the total score, the evaluation result of the first test case is determined.

[0042] In one possible implementation, the mutation module determines the evaluation result of the first test case based on the total score, and uses it to perform the following operations:

[0043] If the total score is less than the scoring threshold, the evaluation failure result will be determined as the evaluation result of the first test case; the evaluation failure result is used to indicate the deletion of the first test case;

[0044] If the total score is equal to or greater than the scoring threshold, the evaluation result will be determined as the evaluation result of the first test case.

[0045] In one possible implementation, the mutation operator includes the thought chain mutation operator;

[0046] The mutation module uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case. This second test case is then used to perform the following operations:

[0047] Input the thought chain mutation operator and the first test case into the pre-trained model;

[0048] In the pre-trained model, the first test case is mutated according to the thought chain mutation operator to obtain a second test case that is different from the first test case; the structural complexity of the second test case is better than that of the first test case.

[0049] In one possible implementation, the mutation module mutates the first test case according to the thought chain mutation operator to obtain a second test case that is different from the first test case, which is used to perform the following operations:

[0050] If the thought chain mutation operator is a structure mutation operator, then the first test case is subjected to structure mutation processing to obtain a second test case with a structure different from the first test case.

[0051] If the thought chain mutation operator is a condition mutation operator, then the condition statement in the first test case is mutated to obtain a second test case with a condition statement that is different from the condition statement in the first test case.

[0052] If the thought chain mutation operator is the projection mutation operator, then the column query statement in the first test case will be mutated to obtain a second test case with a column query statement that is different from the column query statement in the first test case.

[0053] If the thought chain mutation operator is an aggregation mutation operator, then the aggregation statement mutation processing is performed on the first test case to obtain a second test case with an aggregation statement that is different from the aggregation statement in the first test case.

[0054] In one possible implementation, the mutation operator includes a supplementary mutation operator;

[0055] The mutation module uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case. This second test case is then used to perform the following operations:

[0056] By adding mutation operators, the first test case is deleted to obtain local test cases;

[0057] Local test cases are input into a pre-trained model. The pre-trained model then performs supplementary processing on the local test cases to obtain a second test case that is different from the first test case.

[0058] In one possible implementation, the mutation operator includes a hint mutation operator;

[0059] The mutation module uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case. This second test case is then used to perform the following operations:

[0060] Input the mutation operator and the first test case into the pre-trained model;

[0061] In the pre-trained model, the first test case is mutated according to the prompt mutation operator to obtain a second test case that is different from the first test case.

[0062] In one possible implementation, the mutation module mutates the first test case according to the prompted mutation operator to obtain a second test case that is different from the first test case, which is used to perform the following operations:

[0063] If the mutation operator is indicated to be a logically equivalent mutation operator, then a second test case with the same logic as the first test case will be generated.

[0064] If the mutation operator is indicated to be a complex mutation operator, then a second test case with a complexity better than that of the first test case will be generated.

[0065] In one possible implementation, the execution module is also used to perform the following operations:

[0066] Combine the first and second test cases to obtain the third test case, and add the third test case to the test case library;

[0067] The execution module is used to perform the following operations:

[0068] By testing the database, the third test case is executed, and the first execution result output by the test database is obtained.

[0069] In one possible implementation, the execution module determines a test report for the test database based on the first execution result, and uses it to perform the following operations:

[0070] By using the reference database, test cases in the test case library are executed to obtain the second execution result output by the reference database;

[0071] The first execution result and the second execution result are compared. If the first execution result and the second execution result are the same, the test pass report is determined as the test report of the test database.

[0072] If the first execution result is different from the second execution result, the test failure report will be determined as the test report of the test database.

[0073] This application provides a computer device, including: a processor, a memory, and a network interface;

[0074] The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs so that the computer device executes the methods in the embodiments of this application.

[0075] One aspect of this application provides a computer-readable storage medium storing a computer program adapted for loading by a processor and executing the methods described in this application.

[0076] One aspect of this application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method described in this application.

[0077] In this embodiment, the computer device constructs initial prompts based on the syntax analysis file and database information of the test database. These initial prompts are input into a pre-trained model, which then processes them to obtain a first test case. A mutation operator is acquired, and the first test case is mutated using the pre-trained model and the mutation operator to obtain a second test case different from the first. The test cases in the test case library are executed through the test database to obtain a first execution result. A test report for the test database is then determined based on the first execution result. The test case library includes both the first and second test cases. As can be seen, this embodiment constructs model prompts (including initial prompts) using the syntax analysis file and database information provided with the test database, enabling the pre-trained model to generate test cases for the test database. This efficiently supports different test databases and improves the scalability of database testing. Furthermore, this embodiment uses a mutation operator to mutate the first test case to obtain a second test case, thus increasing the diversity of test cases and consequently improving the test coverage of the test database. Attached Figure Description

[0078] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0079] Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application;

[0080] Figure 2 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 1 ;

[0081] Figure 3 This is a schematic diagram of a data processing scenario provided in an embodiment of this application. Figure 1 ;

[0082] Figure 4This is a schematic diagram of a data processing scenario provided in an embodiment of this application. Figure 2 ;

[0083] Figure 5 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 2 ;

[0084] Figure 6 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 3 ;

[0085] Figure 7 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application;

[0086] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0087] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0088] To facilitate understanding, the following brief explanations are provided for some of the terms:

[0089] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0090] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, pre-trained model technology, operating / interactive systems, and mechatronics. Among these, pre-trained models, also known as large-scale models or foundational models, can be widely applied to downstream tasks across various AI fields after fine-tuning. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0091] The pre-trained models described in this application include, but are not limited to, large language models. A large language model (LLM) is an artificial intelligence model trained using a large amount of data that can understand and generate human language. Such models can be used for various tasks, such as code generation, text generation, machine translation, and question-answering systems.

[0092] Learning methods based on large language models (LLMs) are mainly divided into two types: context learning and fine-tuning. Context learning allows LLMs to adjust their output by parsing information in the input context, such as the output format (output according to a specific format) and the task domain (e.g., translating a first language into a second language). The embodiments of this application primarily employ the context learning method, combined with two different strategies: few-shot learning and zero-shot learning. The appropriate strategy can be selected according to the specific scenario.

[0093] Structured Query Language (SQL): SQL is a database query and programming language used to access, query, update, and manage relational database systems. SQL is a high-level, non-procedural programming language that allows users to work on high-level data structures.

[0094] Fuzzing: Fuzzing is an automated software testing technique that provides random input data and detects whether the program under test exhibits unexpected behavior, such as crashes, exceptions, and invalid output. Fuzzing tools can be generation-based or mutation-based, depending on whether the input data is generated from scratch or by modifying given input data. SQL fuzzing tools, such as random query generators (RQGs), require knowledge of the input and program structure; more general fuzzing tools can treat the test environment as a complete black box.

[0095] Syntax analysis files: Each database contains a syntax analysis definition file that defines the grammatical structure. For example, in PostgreSQL, the syntax analysis file is gram.y, located in the src / common / backend / parser directory; in MySQL, it's SQL / sql_yacc.yy; and in SQLite, it's parse.y. Syntax analysis files typically contain all the grammatical rules of the database query language, which can be used to generate valid database queries.

[0096] Taking gram.y as an example, this file consists of three parts: a definition section, a rule section, and a code section. In PostgreSQL, the yyparse function of Bison (a program used to generate a parser) is used to parse query (SQL) statements. Based on the grammar rules defined in gram.y, the yyparse function constructs an Abstract Syntax Tree (AST) that represents the grammar structure.

[0097] Please see Figure 1 , Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application. For example... Figure 1 As shown, the system may include a business server 100 and a cluster of terminal devices. The cluster of terminal devices may include: terminal devices 200a, 200b, 200c, ..., 200n. It is understood that the above system may include one or more terminal devices, and this application does not limit the number of terminal devices.

[0098] The terminal devices in the cluster can have communication connections with each other. For example, there is a communication connection between terminal devices 200a and 200b, and between terminal devices 200a and 200c. Simultaneously, any terminal device in the cluster can have a communication connection with the service server 100. For example, there is a communication connection between terminal device 200a and the service server 100. The communication connection method is not limited; it can be established directly or indirectly through wired communication, wireless communication, or other methods. This application does not impose any restrictions on this method.

[0099] like Figure 1 Each terminal device in the terminal device cluster shown can run an application client. When the application client runs on each terminal device, it can interact with the aforementioned... Figure 1 The business server 100 shown interacts with the data, i.e., the communication connection described above. The application client can be a standalone client or an embedded sub-client integrated into a client (e.g., a video client, an educational client, and a multimedia client, etc.), and there is no limitation here.

[0100] One feasible implementation is that the application client can be a business application, and the target end users can be end clients corresponding to the business platform. For example, the business application could be a video application, payment application, navigation application, music application, shopping application, electronic map application, browser, or other application client with database functionality. Another feasible implementation is that the application client can be an application management client for business applications, and the target end users can be application administrators such as business application developers. This application management client has database testing capabilities.

[0101] The business server 100 can be a collection of multiple servers, including the backend server corresponding to the business application and the data processing server. Therefore, each terminal device can transmit data with the business server 100 through the application client. For example, each terminal device can send a database test request to the business server 100 through the application client. Then, the business server 100 can test the test database indicated by the database test request, obtain the test results, and return the test results to the terminal device.

[0102] It is understood that in the specific implementation of this application, data related to user information (such as test databases and database information) is involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant regions.

[0103] For ease of subsequent understanding and explanation, the embodiments of this application may be... Figure 1 The terminal device cluster shown is selected as an example for description, for example, terminal device 200a. When a test instruction for the first database is obtained in the application client, terminal device 200a can identify the first database as the test database. That is, in this embodiment, the test database refers to the database that needs to be tested. Terminal device 200a generates a test request for the test database and sends the test request to the business server 100. This embodiment does not limit the type of test database, which can be determined according to the actual application scenario, including but not limited to MySQL, SQLite, PostgreSQL, etc.

[0104] The business server 100 receives a test request sent by the terminal device 200a and retrieves the test database based on the test request. This embodiment does not limit the method by which the business server 100 retrieves the test database; it can be set according to the actual application scenario. One feasible method is that the terminal device 200a generates a test request including the test database, so the business server 100 can retrieve the test database from the test request. Another feasible method is that the terminal device 200a determines the database identifier of the test database and generates a test request including the database identifier, so the business server 100 can retrieve the test database indicated by the database identifier from local storage or the cloud. Yet another feasible method is that the test request sent by the terminal device 200a carries the storage address of the test database, so the business server 100 can retrieve the test database based on the storage address.

[0105] The business server 100 obtains the syntax analysis file that comes with the test database kernel, queries the test database using SQL commands, and retrieves database information, which describes the database, including the data stored in it. Based on the syntax analysis file and the database information, the business server 100 constructs initial prompts, inputs the initial prompts into a pre-trained model, and processes the initial prompts to obtain the first test cases generated by the pre-trained model based on the initial prompts.

[0106] The business server 100 obtains a mutation operator. Using the pre-trained model and the mutation operator, the business server 100 can mutate the first test case to obtain a second test case that differs from the first test case. The business server 100 then executes the test cases in the test case library through the test database, obtaining the first execution result output by the test database. Based on the first execution result, the business server 100 determines the test report of the test database. The test case library includes the first test case and the second test case.

[0107] The business server 100 returns the test report to the terminal device 200a. After receiving the test report, the terminal device 200a can display the test report on its corresponding screen.

[0108] Optionally, the business server 100 returns the first execution result to the terminal device 200a, so the terminal device 200a can determine the test report of the test database based on the first execution result.

[0109] Optionally, the business server 100 returns the test case library to the terminal device 200a. Therefore, the terminal device 200a can test the test database locally using the test cases in the test case library to obtain the first execution result of the test database under the test cases. Subsequent processing is the same as described above, so it will not be repeated.

[0110] Optionally, if the terminal device 200a has the aforementioned pre-trained model stored locally and possesses computing power and mutation operators, then upon receiving a test instruction for the first database (i.e., the test database), it can locally construct an initial prompt based on the syntax analysis file and database information of the test database, input the initial prompt into the pre-trained model, and process the initial prompt through the pre-trained model to obtain the first test case; furthermore, the terminal device 200a obtains the mutation operator, and through the pre-trained model and the mutation operator, performs mutation processing on the first test case to obtain a second test case different from the first test case; subsequent processing is the same as described above, and therefore will not be repeated.

[0111] Since pre-training a model involves a large amount of computation, the pre-trained model on the terminal device 200a can be sent to the terminal device 200a after pre-training by the business server 100.

[0112] As described above, the embodiments of this application construct model hints (including initial hints) by using the syntax analysis files and database information provided with the test database to enable the pre-trained model to generate test cases for the test database. Therefore, it can efficiently support different test databases and improve the scalability of database testing. In addition, the embodiments of this application use mutation operators to mutate the first test cases to obtain the second test cases, which can improve the diversity of test cases and thus improve the test coverage of the test database.

[0113] It is understood that the methods provided in this application embodiment can be executed by computer devices, including but not limited to terminal devices or business servers. The business server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud databases, cloud services, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal devices and business servers can be directly or indirectly connected via wired or wireless means, and this application embodiment does not impose any limitations on this connection.

[0114] Further, please see Figure 2 , Figure 2 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 1 The embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, and autonomous driving. This data processing method can be provided by a business server (e.g., the one described above). Figure 1 The business server 100 shown can execute the service, or it can be executed by a terminal device (e.g., the one described above). Figure 1 The terminal device 200a) shown can execute the method, but it can also be executed interactively by the business server and the terminal device. For ease of understanding, this embodiment uses the execution by the business server as an example, where the business server acts as a computer device to execute the data processing method. Figure 2 As shown, the data processing method may include at least the following steps S101-S103.

[0115] Step S101: Based on the syntax analysis file of the test database and the database information of the test database, construct the initial prompt, input the initial prompt into the pre-trained model, and use the pre-trained model to identify and process the initial prompt to obtain the first test case.

[0116] Specifically, the process involves obtaining syntax analysis files from the test database, parsing the syntax analysis files, and constructing an abstract syntax tree. The abstract syntax tree is used to generate syntax paths. The test database is then queried to obtain database information. This database information is randomly selected to obtain first local database information. The first local database information and the syntax paths together instruct the pre-trained model to generate sample test cases. Initial instructions are generated to instruct the pre-trained model to perform inference. The initial instructions, sample test cases, syntax paths, and first local database information are then combined to form an initial prompt.

[0117] The specific process of parsing the syntax analysis file and constructing the abstract syntax tree may include: obtaining rule segments from the syntax analysis file; rule segments include rule names and rule content corresponding to the rule names; determining the rule names as index keys and the rule content as index values, constructing an index table including index keys and index values, and constructing the abstract syntax tree based on the index table.

[0118] Pre-trained models possess powerful learning and generative capabilities. Therefore, this application proposes a fully automated method for database fuzzing using a large-scale pre-trained language model. A pre-trained model, also known as a foundational model or large model, refers to a deep neural network (DNN) with a large number of parameters. It is trained on massive amounts of unlabeled data, leveraging the function approximation capabilities of the large-parameter DNN to enable the PTM (Programmable Matrix Transformer) to extract common features from the data. Through fine-tuning, efficient parameter fine-tuning (PEFT), and prompt-tuning techniques, it becomes suitable for downstream tasks. Therefore, pre-trained models can achieve ideal results in small-shot or zero-shot scenarios. Based on the data modalities they process, PTMs can be categorized into language models (ELMO, BERT, GPT), visual models (Swin-transformer, ViT, V-MOE), speech models (VALL-E), and multimodal models (ViBERT, CLIP, Flamingo, Gato), among others. Multimodal models refer to models that establish feature representations for two or more data modalities. Pre-trained models are important tools for outputting AI-generated content (AIGC) and can also serve as a universal interface connecting multiple task-specific models.

[0119] This application embodiment constructs the initial prompts of the pre-trained model through the syntax analysis file and metadata information (i.e., database information) that come with the database, so that the pre-trained model can generate fuzzy test cases of the database according to the initial prompts. The whole process can include three parts: (1) seed generation; (2) seed mutation; (3) test execution.

[0120] Seed generation mainly consists of two parts: the generation of the initial prompt and the generation of the seed (i.e., the first test case). To generate syntactically and semantically correct test cases (including the first and second test cases), this application embodiment sets up a general prompt template, which includes the following four parts:

[0121] 1. Database information, which includes database schema information and database system function information, covering table structure, column types, index constraints, built-in functions and their input and output parameter types, etc.

[0122] 2. SQL use case syntax path information, or simply syntax path.

[0123] 3. A small amount of sample information, referred to as sample test cases in this application embodiment.

[0124] 4. Instruction information; Instruction information can be divided into initial instructions and update instructions.

[0125] Please see also Figure 3 , Figure 3 This is a schematic diagram of a data processing scenario provided in an embodiment of this application. Figure 1 .like Figure 3 As shown, the business server can use SQL commands (i.e., query commands) to query information from the test database 20a (i.e., the database to be tested) and obtain database information 20c. As described above, database information 20c includes database schema information and database system function information. Figure 3 Example database information 20c includes information 1, information 2, ..., information 3, therefore... Figure 3 The information in example 1 could belong to database schema information or database system function information; similarly, Figure 3 The information in example 2 could be database schema information or database system function information. Figure 3 The information in example 3 could be database schema information or database system function information.

[0126] To control the size (i.e., space occupied) of the initial prompts input to the pre-trained model, such as Figure 3 As shown, the business server randomly selects a portion of database information from database information 20c, such as... Figure 3 Example information 1, which is used as the first local database information 201c, is added to the prompt template.

[0127] The test database contains a parsing file that defines the grammatical structure of the test database. For example, the parsing file gram.y in the PostgreSQL database is located in the src / common / backend / parser directory; SQL / sql_yacc.yy in the MySQL database; and parse.y in the SQLite database.

[0128] Taking gram.y as an example, the file includes three parts: definition section, rule section, and code section. The stmt (full name statement) in gram.y includes all statements supported by the test database. The most common one is the query statement (SelectStmt), which is used to retrieve data that meets the conditions from the test database.

[0129] In PostgreSQL, the application server uses Bison's `yyparse` function to parse query (SQL) statements. The `yyparse` function constructs an abstract syntax tree representing the grammatical structure based on the syntax rules defined in `gram.y`. This embodiment of the application utilizes Python (a computer programming language) to implement the parsing process from a syntax analysis file to an abstract syntax tree, compatible with syntax files not defined by Bison.

[0130] Please see again. Figure 3 The business server parses the 201a parsing file (e.g., gram.y file), ignoring the code portion and loading the rule portion into a dictionary (also referred to as an index table in this application). The index key of the dictionary is the rule name, and the content of each rule is stored in the index value of the dictionary.

[0131] By parsing the syntax analysis file 201a, the application server can obtain the abstract syntax tree, such as... Figure 3 In the example abstract syntax tree 20b, the statement block stmtblock is the root of the tree. The statement block stmtblock has child nodes, namely the statement set stmtmulti. The statement block stmtblock can be used as the rule name, and its child nodes (i.e. the statement set stmtmulti) can be used as the rule content. Therefore, the statement block stmtblock and the statement set stmtmulti can form an index key-value pair.

[0132] Please see again. Figure 3 The statement set stmtmulti has child nodes, that is... Figure 3 The statement `stmt` and statement set `stmtmulti` can be used as rule names, and their child nodes (i.e., statements `stmt`) can be used as rule content. Therefore, statement set `stmtmulti` and statement `stmt` can form an index key-value pair.

[0133] The `stmt` statement has child nodes, such as... Figure 3 In the example, the insert statement `insertstmt`, the query statement `selectstmt`, and the update statement `updatestmt` all use `stmt` as the rule name, and its child nodes (such as the update statement `updatestmt`) as the rule content. Therefore, `stmt` and the update statement `updatestmt` can form an index key-value pair. Similarly, `stmt` and the query statement `selectstmt` can form an index key-value pair, and `stmt` and the insert statement `insertstmt` can form an index key-value pair. These will not be elaborated further here.

[0134] Please see again. Figure 3The query statement `selectstmt` has child nodes: the query statement `select_no_parens` (without parentheses) and the query statement `select_with_parens` (with parentheses). Therefore, `selectstmt` can be used as the rule name, and `select_no_parens` (without parentheses) can be used as the rule content. Thus, `selectstmt` and `select_no_parens` can form an index key-value pair. Similarly, `selectstmt` and `select_with_parens` can form an index key-value pair.

[0135] This application does not describe the process of generating syntax paths based on abstract syntax trees in detail in the embodiments below. Figure 5 The description in the corresponding embodiments.

[0136] To improve the accuracy of the pre-trained model, this application adopts a small sample learning method, adding a small number of test cases as context content to the prompt template to assist the pre-trained model in generating new predictions, namely the first test cases.

[0137] Please see again. Figure 3 The business server combines the first local database information 201c (in this example, information 1) and the syntax path to form a sample test case generation prompt. This prompt instructs the pre-trained model to generate test cases, which then serve as sample test cases. The business server inputs the sample test case generation prompt into the pre-trained model, which then generates candidate sample test cases by recognizing the prompt.

[0138] The business server identifies and processes candidate sample test cases, adding those that conform to the syntax rules to the sample test case dataset. To improve the compliance of sample test cases, candidate sample test cases can be manually revised to generate sample test cases that conform to the syntax rules. The business server randomly selects a small amount of sample data (i.e., sample test cases) from the sample test case dataset as part of the initial prompt input.

[0139] To enhance the inference capability of the pre-trained model, this application embodiment designs different prompting instructions according to different execution stages. In the initial prompting stage, the initial instructions can be as follows:

[0140] Initial instructions:

[0141] You are a PostgreSQL database expert. Given a database schema and table information, as well as available functions, translate SQL keywords into usable SQL statements. Map placeholders to expressions containing actual table names, columns, and functions, handle conflicts, and use PostgreSQL-specific clauses and commands. Expressions can be merge expressions, null value expressions, subquery expressions, column reference expressions, function call expressions, constant expressions, etc. SQL statements should use specified tables and functions whenever possible. These SQL statements will be executed later, so they should be error-free and compatible with PostgreSQL syntax. Your output should be clear and wrapped in "sql" and "". Furthermore, do not add any comments to the generated SQL statements; simply return the SQL statements.

[0142] By integrating the four parts of information—the first local database information, the initial instructions, the sample test cases, and the syntax path—the business server can construct the initial prompts.

[0143] Step S102: Obtain the mutation operator. Using the pre-trained model and the mutation operator, mutate the first test case to obtain a second test case that is different from the first test case.

[0144] Specifically, rule detection is performed on the first test case to obtain the rule detection result; if the rule detection result indicates that the first test case does not conform to the syntax rules, the initial prompt is updated to obtain the updated prompt; the updated prompt is input into the pre-trained model, and the pre-trained model identifies and processes the updated prompt to obtain the test case to be evaluated; the test case to be evaluated is used to generate mutated test cases when the evaluation process is passed; both the test case to be evaluated and the mutated test cases that have passed the evaluation process are added to the test database; if the rule detection result indicates that the first test case conforms to the syntax rules, the first test case is evaluated to obtain the evaluation result; when the evaluation result is a pass result, the mutation operator is obtained.

[0145] The specific process of updating the initial prompt to obtain the updated prompt may include: simplifying the syntax path in the initial prompt to obtain a simplified syntax path; obtaining second local database information that is different from the first local database information; generating an error message in the rule detection result; updating the initial instruction in the initial prompt based on the error message to obtain an update instruction; and constructing the update instruction, sample test cases, simplified syntax path, and second local database information into an updated prompt.

[0146] The specific process of evaluating the first test case to obtain the evaluation result may include: determining the first number of subquery statements and the second number of structural operations in the first test case; multiplying the score for the subquery statement and the first number to obtain a first score; multiplying the score for the structural operation and the second number to obtain a second score; summing the first score and the second score to obtain the total score of the first test case; and determining the evaluation result of the first test case based on the total score.

[0147] The specific process of determining the evaluation result of the first test case based on the total score may include: if the total score is less than the scoring threshold, the evaluation failure result is determined as the evaluation result of the first test case; the evaluation failure result is used to indicate the deletion of the first test case; if the total score is equal to or greater than the scoring threshold, the evaluation pass result is determined as the evaluation result of the first test case.

[0148] Specifically, the mutation operator includes the thought chain mutation operator; the thought chain mutation operator and the first test case are input into the pre-trained model; in the pre-trained model, the first test case is mutated according to the thought chain mutation operator to obtain a second test case that is different from the first test case; the structural complexity of the second test case is better than that of the first test case.

[0149] The specific process of mutating the first test case according to the thought chain mutation operator to obtain a second test case that is different from the first test case may include: if the thought chain mutation operator is a structural mutation operator, then the first test case is subjected to structural mutation to obtain a second test case with a structure different from the first test case.

[0150] If the thought chain mutation operator is a condition mutation operator, then the conditional statement in the first test case is mutated to obtain a second test case with a different conditional statement than the one in the first test case.

[0151] If the thought chain mutation operator is the projection mutation operator, then the column query statement in the first test case will be mutated to obtain a second test case with a column query statement that is different from the column query statement in the first test case.

[0152] If the thought chain mutation operator is an aggregation mutation operator, then the aggregation statement mutation processing is performed on the first test case to obtain a second test case with an aggregation statement that is different from the aggregation statement in the first test case.

[0153] This embodiment utilizes the syntax analysis file built into the test database to generate an abstract syntax tree, and randomly generates SQL syntax paths from the abstract syntax tree. The business server sends the syntax path information as part of the prompt template to the pre-trained model. This embodiment achieves full automation of the testing process, and ensures test case coverage through the mutation process of the abstract syntax tree and seeds in the test database.

[0154] The business server inputs the initial prompt generated in step S101 into the pre-trained model, which then generates the first test case. The business server needs to determine whether the SQL (i.e., the first test case) generated by the pre-trained model conforms to syntactic and semantic rules; please refer to [link to relevant documentation]. Figure 4 , Figure 4 This is a schematic diagram of a data processing scenario provided in an embodiment of this application. Figure 2 .like Figure 4 As shown, the business server checks whether the first test case conforms to the syntax rules. If the first test case does not conform to the syntax rules, the business server updates the initial prompt to obtain an updated prompt, and re-inputs the updated prompt into the pre-trained model 20d. The pre-trained model 20d then generates the test cases to be evaluated. The process of generating the updated prompt and outputting the test cases to be evaluated from the pre-trained model can be regarded as one loop process.

[0155] Understandably, the subsequent processing method for the test cases to be evaluated is the same as that for the first test case. That is, the business server will also perform rule checks on the test cases to be evaluated. If the test cases to be evaluated do not conform to the syntax rules, the loop processing will be executed again, that is, the update prompt will be updated to obtain a second update prompt. The second update prompt will be re-input into the pre-trained model 20d until the pre-trained model 20d outputs test cases that conform to the syntax rules, or the recorded number of loops reaches the preset maximum number of loops. At this time, the business server will re-execute step S101, that is, generate a new initial prompt.

[0156] If the test case to be evaluated conforms to the syntax rules, the business server evaluates the test case and obtains the evaluation result. If the test case passes the evaluation, the business server obtains the mutation operator and, using the pre-trained model and the mutation operator, mutates the test case to obtain a new test case, namely the mutated test case described above. The processing method for the mutated test case is the same as that for the second test case described below, so it will not be repeated here. If the test case fails the evaluation, the business server deletes the mutated test case.

[0157] Please see again. Figure 4When the first test case does not conform to the syntax rules, the specific processing procedure for the business server to update the initial prompt is as follows: Obtain the error message, which indicates the reason why the first test case does not conform to the syntax rules. Based on the error message, update the initial instructions in the initial prompt to obtain the update instructions. During the update prompt stage, the update instructions can be as follows:

[0158] Update command:

[0159] You are a PostgreSQL expert. Based on the given SQL execution error, modify the SQL query and convert it into an executable SQL query, using the provided tables, columns, and functions. Map placeholders to actual table names, column names, and functions, handle conflicts, and use PostgreSQL-specific clauses and commands.

[0160] The business server simplifies the syntax path in the initial prompt, including but not limited to removing parentheses and their contents from the syntax path, truncating the path (that is, dividing a syntax path into at least two sub-syntax paths), etc., to obtain a simplified syntax path.

[0161] On the other hand, the business server retrieves second local database information that differs from the first local database information from the database information, such as... Figure 3 as well as Figure 4 As shown, database information 20c includes information 1, information 2 and information 3. The first local database information 201c in the initial prompt is information 1, and the second local database information 202c is information 2, which is different from information 1.

[0162] The business server will update instructions, sample test cases, simplified syntax paths, and second local database information 202c. Figure 4 Example 2), constructed as an update prompt.

[0163] If the first test case conforms to the syntax rules, the business server evaluates and processes it. To enhance the diversity of test cases, this embodiment selects structurally complex test cases as "seed test cases" for subsequent mutation operations. To achieve this goal, this embodiment designs a scoring function to evaluate the first test case; the first test case with a score exceeding a preset threshold is included in the seed test case library (i.e., the test case library).

[0164] Please see again. Figure 4 The scoring function includes evaluation items and their corresponding scores. Evaluation items can be divided into two categories: subquery statements and structural operations. Figure 4The score corresponding to the subquery statement is 3. The structure operation can be further divided into set operation, join operation, aggregation operation and logical join condition.

[0165] Figure 4 Example score for set operations (such as UNION / UNION ALL / INTERSECT / EXCEPT) is 2; example score for join operations (such as JOIN) is 1; example score for GROUP BY aggregation operation is 1; example score for logical join conditions (such as AND / OR) is 1.

[0166] The business server determines the first number of subquery statements in the first test case. Figure 4 The first quantity is 3; determine the second quantity of the structure operations. Figure 4 The number of example set operations is 2, the number of example join operations is 2, the number of example aggregation operations is 1, and the number of example logical join conditions is 1. Furthermore, the business server performs product and summation processing on the number of evaluation items and their scores, such as... Figure 4 The example of 2*3+2*2+1*2+1*1+1*1 yields a total score of 14 for the first test case. The business server compares the total score of the first test case with a scoring threshold. If the total score is greater than or equal to the scoring threshold, the first test case is deemed to have passed evaluation; otherwise, the first test case is deemed to have failed evaluation.

[0167] Using a scoring function, the business server can select test cases that contain multiple subqueries and have more complex structures, aiming to cover deeper levels of database logic. Test cases that pass the evaluation are added to a seed pool, while those that fail are discarded.

[0168] After generating a certain number of initial seeds (i.e., the first test cases), to improve test coverage, this embodiment employs a mutation strategy (i.e., mutation operator) to mutate the initial seeds, generating diverse test cases that cover new code and discover new errors. To achieve this goal, this embodiment uses prompts to guide the pre-trained model to mutate the seed test cases. Due to the probabilistic nature of the pre-trained model, prompts with the same pattern are likely to generate the same or similar SQL test cases. Therefore, this embodiment sets up three mutation strategies, corresponding to three different prompting methods, to help the pre-trained model generate diverse SQL test cases. Overall, the idea behind the mutation loop is to use seed test cases and mutation strategies to generate prompts, guiding the pre-trained model to generate new test cases and enrich the seed library.

[0169] This application employs three strategies in its mutation algorithm design to enhance the complexity and diversity of seed test cases by stimulating the generative potential of the pre-trained model through different methods. The first mutation strategy (i.e., the mutation operator) is the thought chain mutation operator, which uses "thought chain hints" to guide the pre-trained model to mutate seed test cases (i.e., the first test cases) according to specific rules, aiming to generate more complex second test cases. The second mutation strategy involves randomly truncating a portion of the seed test case, retaining some content, and using the pre-trained model's completion capabilities to complete the remaining test case portion. The third mutation strategy provides complete seed test cases and guides the pre-trained model to mutate them through concise hints.

[0170] During testing, the business server randomly selects one of the three mutation strategies mentioned above to process the current seed test case. This ensures that the generative pre-trained model can continuously generate novel and diverse fuzzy test inputs. The first mutation strategy, the thought chain mutation operator, is described in detail below; the remaining two mutation operators are described in the following text. Figure 5 The description in the corresponding embodiments.

[0171] Inspired by thought chain cues, this application employs a step-by-step guided approach, requiring the pre-trained model to progressively construct a mutation process according to certain steps. The specific mutation methods are as follows:

[0172] Structural variations: adding or removing JOIN clauses, subqueries, UNION operations, nested SELECT statements, etc.

[0173] Conditional variation: Changing the conditions in the WHERE clause, such as using different operators, adding additional conditions, or changing the order of conditions.

[0174] Projection mutation: Changes the columns in the SELECT clause, which can be adding, removing, or changing the order of columns.

[0175] Aggregate variation: Add or change the GROUP BY and HAVING clauses, or use different aggregate functions.

[0176] Step S103: Execute test cases in the test case library through the test database to obtain the first execution result output by the test database, and determine the test report of the test database based on the first execution result; the test case library includes the first test case and the second test case.

[0177] Specifically, by referencing the database, test cases in the test case library are executed to obtain the second execution result output by the reference database. The first execution result and the second execution result are compared. If the first execution result and the second execution result are the same, the test pass report is determined as the test report of the test database; if the first execution result and the second execution result are different, the test failure report is determined as the test report of the test database.

[0178] Understandably, the business server will perform rule checks on the second test case. If the second test case does not conform to the syntax rules, it will be discarded; if the second test case conforms to the syntax rules, it will be evaluated. The way the business server evaluates the second test case is the same as the way it evaluates the first test case, so it will not be repeated here, but can be found in the description of step S102 above.

[0179] The business server adds the first and second test cases that pass evaluation to the test case library, also referred to as the seed test case library in this embodiment. The business server sends the test cases in the test case library, specifically the first test case, the second test case, or both the first and second test cases, to the test database and the reference database for execution. The test database outputs the first execution result, and the reference database inputs the second execution result. Through differential testing, that is, comparing the first and second execution results, logical errors in the kernel of the test database are checked.

[0180] In addition, the business server can randomly select some test cases from the test case library to form new test cases with a context format, and send them to the test database for testing.

[0181] This application proposes a database fuzzing tool based on a pre-trained model. This tool introduces pre-trained models into the database testing field, utilizing the code generation capabilities of the pre-trained model and combining it with the syntax parsing file (i.e., syntax analysis file) built into the test database kernel to automatically generate test cases. This application has the following advantages:

[0182] (1) High scalability. It uses the syntax parsing file built into the test database kernel to generate test case frameworks, and automatically generates hints for the pre-trained model by combining the table schema of the test database. The hints are sent to the pre-trained model to generate different SQL statements (i.e., the first test cases), which can be compatible with different test databases.

[0183] (2) High accuracy. Test cases with correct syntax and semantics are generated through iterative modification of prompts.

[0184] (3) High coverage. The SQL test cases, namely the first test case and the second test case, are reorganized to generate new test cases, thereby increasing the coverage.

[0185] (4) Less noisy data. The embodiments of this application have set up a dedicated verification function to ensure that the generated data is grammatically correct and has practical significance, which greatly reduces noisy data.

[0186] In this embodiment, the computer device constructs initial prompts based on the syntax analysis file and database information of the test database. These initial prompts are input into a pre-trained model, which then processes them to obtain a first test case. A mutation operator is acquired, and the first test case is mutated using the pre-trained model and the mutation operator to obtain a second test case different from the first. The test cases in the test case library are executed through the test database to obtain a first execution result. A test report for the test database is then determined based on the first execution result. The test case library includes both the first and second test cases. As can be seen, this embodiment constructs model prompts (including initial prompts) using the syntax analysis file and database information provided with the test database, enabling the pre-trained model to generate test cases for the test database. This efficiently supports different test databases and improves the scalability of database testing. Furthermore, this embodiment uses a mutation operator to mutate the first test case to obtain a second test case, thus increasing the diversity of test cases and consequently improving the test coverage of the test database.

[0187] Further, please see Figure 5 , Figure 5 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 2 This method can be implemented by a business server (e.g., the one mentioned above). Figure 1 The business server 100 shown can execute the service, or it can be executed by a terminal device (e.g., the one described above). Figure 1 The terminal device 200a) shown can execute the method, but it can also be executed interactively by the business server and the terminal device. For ease of understanding, this embodiment uses the execution by the business server as an example, where the business server acts as a computer device to execute the data processing method. Figure 5 As shown, the method may include at least the following steps S201-S206.

[0188] Step S201: Based on the syntax analysis file of the test database and the database information of the test database, construct the initial prompt, input the initial prompt into the pre-trained model, and use the pre-trained model to identify and process the initial prompt to obtain the first test case.

[0189] Specifically, obtain a probability table for the test database; the probability table includes A candidate start nodes and their respective initial probabilities; A is a positive integer greater than 1; all A candidate start nodes belong to the abstract syntax tree; based on the initial probabilities corresponding to the A candidate start nodes, obtain the start node from among the A candidate start nodes; obtain the first child node of the child node belonging to the start node in the abstract syntax tree; if there is no child node of the first child node in the abstract syntax tree, generate a syntax path based on the start node and the first child node; if there is a child node of the first child node in the abstract syntax tree, obtain the second child node from among the child nodes of the first child node; generate a syntax path based on the start node, the first child node, the second child node, and the child node of the second child node in the abstract syntax tree.

[0190] The above text Figure 2 Step S101 in the corresponding embodiment describes in detail the construction of the abstract syntax tree and the composition of the initial prompt. This step mainly describes the generation of the syntax path.

[0191] The business server can use multiple initial rules (equivalent to the starting node above) to generate the syntax path, for example, using the above... Figure 3 This includes query statements like "SelectStmt", update statements like "UpdateStmt", insert statements like "InsertStmt", and statement blocks like "stmt", as well as database statements like "DeleteStmt" and "MergeStmt". Initial rules can be controlled using a probability table, which can be configured according to the test objectives.

[0192] For better understanding, please refer to [link / reference]. Figure 3 For example, the business server uses the statement block "stmt" as the initial rule (i.e., the starting node), and randomly selects a rule content with "stmt" as the index key, that is, a child node of the statement block "stmt", such as... Figure 3 The statement set `stmtmulti` can be used as the first child node mentioned above; continuing to parse according to the rules of the statement set `stmtmulti`, it can be used as the second child node mentioned above, and so on recursively until a terminal character is encountered, which can be understood as no child node remaining. To increase the probability of generating common syntax, ensure the coverage of marginal syntax, and ensure that the generated syntax path is compliant, the embodiments of this application have made the following processing:

[0193] 1. Remove unsupported syntax paths.

[0194] 2. Increase the maximum number of iterations to avoid infinite recursion.

[0195] 3. Increase the maximum character length of the path to specify the length of the generated SQL path.

[0196] The following are some examples of common syntax paths:

[0197] ##Example of query syntax path

[0198] SELECT ALL target_list into_clause FROM from_list WHERE a_expr GROUPBY();

[0199] ## Example of inserting a syntax path

[0200] INSERT INTO()TABLE ONLY ORDER BY USING OPERATOR()NULLS FIRST ONCONFLICT ON CONSTRAINT DO NOTHING RETURNING;

[0201] ## Example of deleting a syntax path

[0202] WITH RECURSIVE AS(TABLE)DELETE FROM USING WHERE RETURNING;

[0203] Step S202: Obtain the mutation operator; the mutation operator includes the supplementary mutation operator.

[0204] Specifically, above Figure 2 The corresponding embodiment describes step S102 in detail the thought chain mutation operator, and this application embodiment describes the supplementary mutation operator and the prompt mutation operator in detail.

[0205] Step S203: By supplementing the mutation operator, the first test case is deleted to obtain the local test case.

[0206] Specifically, the mutation operator supplements test cases using a large model. The specific strategy is as follows: The business server selects a seed test case, which can be a complete SQL statement randomly selected from the test case library. The business server then randomly deletes a portion of the SQL statement, such as a suffix, to obtain a partial test case.

[0207] Step S204: Input the local test cases into the pre-trained model, and use the pre-trained model to supplement the local test cases to obtain a second test case that is different from the first test case.

[0208] Specifically, the business server provides an incomplete SQL statement fragment (i.e., a partial test case) as input to the pre-trained model. The pre-trained model is then required to complete the remaining part based on the provided SQL statement fragment, resulting in a second test case that differs from the first test case. Further, the correctness of the second test case completed by the pre-trained model is evaluated. This process is the same as the rule detection and evaluation of the first test case described above, except that no loop processing is performed in the rule detection. That is, if the second test case does not conform to the syntax rules, the business server discards it without further evaluation.

[0209] Specifically, the mutation operator includes a cue mutation operator; the specific process of mutating the first test case using the pre-trained model and the mutation operator to obtain a second test case different from the first test case may include: inputting the cue mutation operator and the first test case into the pre-trained model; in the pre-trained model, mutating the first test case according to the cue mutation operator to obtain a second test case different from the first test case.

[0210] The specific process of mutating the first test case according to the prompt mutation operator to obtain a second test case different from the first test case may include: if the prompt mutation operator is a logically equivalent mutation operator, then a second test case with the same logic as the first test case is generated; if the prompt mutation operator is a complex mutation operator, then a second test case with a complexity greater than that of the first test case is generated.

[0211] This application also utilizes concise prompts to mutate seed use cases, specifically employing the following two strategies:

[0212] 1. Generate a logically equivalent SQL statement, meaning the logic of the generated second test case is identical to that of the first test case. The prompt template can be set as follows:

[0213] Please rewrite this query using different syntax or structure to generate a logically equivalent SQL statement. Ensure the new query returns the same result set; this can be achieved using different functions, subqueries, JOIN types, or other SQL constructs.

[0214] 2. Modify the current SQL (i.e., the first test case) to generate a more complex SQL statement, i.e., the second test case. The prompt template can be set as follows:

[0215] Please modify this query to make it more complex. You can add extra conditions, use aggregate functions, introduce GROUP BY or HAVING clauses, or combine it with multiple queries. The goal is to increase the query's complexity while ensuring it functions correctly.

[0216] In conjunction with the above text Figure 2 The mutation operators described in the corresponding embodiments, as well as the supplementary mutation operators and hint mutation operators described in the embodiments of this application, have the following mutation algorithm flow:

[0217] 1) Randomly select a seed test case from the seed test case library and randomly select a mutation strategy. The selected mutation strategy will be applied to the selected seed test case to generate new test hints.

[0218] 2) Input the newly generated prompts into the pre-trained model to generate mutated test cases.

[0219] 3) For each newly generated test case, perform a syntax rule check to determine its validity. Test cases that are deemed invalid will be discarded, i.e., discard new test cases that do not conform to the syntax rules.

[0220] 4) Valid test cases will be evaluated according to a predefined scoring function. Test cases that pass the evaluation will be added to the seed test case library, providing more options for subsequent seed selection.

[0221] Step S205: Combine the first test case and the second test case to obtain the third test case, and add the third test case to the test case library; the test case library includes the first test case and the second test case.

[0222] Specifically, this application does not limit the number of first test cases; there can be one or more. Therefore, when there are multiple first test cases, such as test case a and test case b, test case a and test case b can be reorganized to generate new test cases. Similarly, the number of second test cases can be one or more. When there are multiple second test cases, such as test case c and test case d, test case c and test case d can be reorganized to generate new test cases. One feasible implementation involves reorganizing three or more test cases to generate new test cases.

[0223] This application uses a pre-trained model as the engine for generating database fuzzy test cases, expanding the application scope of pre-trained models. It generates fuzzy test cases using database syntax analysis files and metadata information, exhibiting strong scalability and adaptability to database types including MySQL and SQLite. Simultaneously, using the syntax file for syntax tree traversal ensures comprehensive database test coverage.

[0224] This application incorporates a verification and correction process during test case generation, ensuring that the generated test cases conform to syntactic and semantic rules, resulting in higher accuracy compared to traditional database fuzzing tools. Furthermore, this application employs different mutation strategies to mutate the seed, enabling the generation of diverse test cases and achieving higher coverage than traditional tools.

[0225] As described above, this application utilizes the database's syntax file to guide the pre-trained model in fuzz testing. This is a fully automated process that can be easily extended to different database systems, thus demonstrating the great potential of using pre-trained models for database testing.

[0226] Step S206: Execute the test cases in the test case library through the test database to obtain the first execution result output by the test database, and determine the test report of the test database based on the first execution result.

[0227] Specifically, by testing the database, the third test case is executed to obtain the first execution result output by the test database.

[0228] Combination Figure 2 Please refer to the corresponding embodiments and the embodiments of this application. Figure 6 , Figure 6 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 3 .like Figure 6 As shown, the data processing method includes the following steps.

[0229] Step S301: Obtain the syntax analysis file of the test database.

[0230] Step S302: Construct the abstract syntax tree.

[0231] Step S303: Query database information.

[0232] Step S304: Generate initial prompts.

[0233] Step S305: Generate the first test case using the pre-trained model.

[0234] Step S306: Perform rule detection on the first test case.

[0235] Step S307: If the first test case conforms to the syntax rules, then the first test case is evaluated.

[0236] In step S308, if the first test case does not conform to the syntax rules, the initial prompt is updated to obtain an updated prompt.

[0237] Step S309: If the first test case passes the evaluation process, it is added to the test case library.

[0238] Step S310: Reorganize the test cases in the test case library to obtain reorganized test cases.

[0239] Specifically, steps S301-S310 can be used for seed generation, i.e., generating test cases, including the first test case and the second test case mentioned above. First, the initial hints for the pre-trained model are constructed using the syntax analysis file and database information of the test database. Then, the initial hints are input into the pre-trained model to generate basic SQL seed test cases, i.e., the first test case.

[0240] To improve the correctness of the generated test cases, this application embodiment adds an SQL verification process and uses the error information generated during the verification process to iteratively update the prompts in order to generate basic test cases that conform to the syntax and semantics.

[0241] Step S311: Select a mutation operator and use the mutation operator to mutate the first test case to obtain the second test case.

[0242] Specifically, this step is used for seed mutation. To enhance the diversity of the test case set, an evolutionary strategy is further adopted to mutate the seed SQL. The mutation process encompasses three mutation operators. In this embodiment, a thought chain approach is used to progressively mutate the seed test cases to generate complex test cases. Secondly, in this embodiment, some seed content (e.g., suffixes) is randomly removed, and the generation capability of the pre-trained model is used to complete the test cases. In addition, in this embodiment, simple prompts are provided to mutate the seed test cases.

[0243] Step 312: Execute the test cases in the test case library through the test database to obtain the first execution result output by the test database. Execute the test cases in the test case library through the reference database to obtain the second execution result output by the reference database.

[0244] Step S313: Compare the first execution result and the second execution result to obtain the test report of the test database.

[0245] Specifically, steps S312-S313 are used for test execution. In this embodiment, seed test cases are randomly combined to form new test cases, which are then sent to the test database and the reference database for execution. Differential testing is used to check for logical errors in the test database kernel.

[0246] This application's embodiments leverage the syntax parsing files of the database and the code generation capabilities of pre-trained models to generate diverse database test case inputs, achieving completely black-box database fuzz testing. The key technical points of this application include:

[0247] (1) An algorithmic framework for database fuzzing based on parsing files and pre-trained models is proposed;

[0248] (2) An algorithm for parsing a database syntax analysis file into an abstract syntax tree, and an algorithm for randomly generating syntax paths using the abstract syntax tree;

[0249] (3) A prompt template containing instructions, some database information, syntax path and a small number of samples;

[0250] (4) Algorithm for iteratively updating hints in the seed generation loop;

[0251] (5) Evaluation algorithm for seed use cases;

[0252] (6) Three mutation strategies of seeds;

[0253] (7) Algorithm for score comparison test by reorganizing test cases.

[0254] In this embodiment, the computer device constructs initial prompts based on the syntax analysis file and database information of the test database. These initial prompts are input into a pre-trained model, which then processes them to obtain a first test case. A mutation operator is acquired, and the first test case is mutated using the pre-trained model and the mutation operator to obtain a second test case different from the first. The test cases in the test case library are executed through the test database to obtain a first execution result. A test report for the test database is then determined based on the first execution result. The test case library includes both the first and second test cases. As can be seen, this embodiment constructs model prompts (including initial prompts) using the syntax analysis file and database information provided with the test database, enabling the pre-trained model to generate test cases for the test database. This efficiently supports different test databases and improves the scalability of database testing. Furthermore, this embodiment uses a mutation operator to mutate the first test case to obtain a second test case, thus increasing the diversity of test cases and consequently improving the test coverage of the test database.

[0255] Further, please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application. The aforementioned data processing apparatus 1 can be a computer program (including program code) running on a computer device; for example, the data processing apparatus 1 is an application software. The data processing apparatus 1 can be used to execute the corresponding steps in the method provided in the embodiments of this application. Figure 7 As shown, the data processing device 1 may include: a construction module 11, a mutation module 12, and an execution module 13.

[0256] Module 11 is used to construct initial prompts based on the syntax analysis file of the test database and the database information of the test database, input the initial prompts into the pre-trained model, and process the initial prompts through the pre-trained model to obtain the first test case;

[0257] The mutation module 12 is used to obtain mutation operators, and to mutate the first test case using the pre-trained model and mutation operators to obtain a second test case that is different from the first test case.

[0258] The execution module 13 is used to execute test cases in the test case library through the test database, obtain the first execution result output by the test database, and determine the test report of the test database based on the first execution result; the test case library includes the first test case and the second test case.

[0259] In one possible implementation, the construction module 11 constructs an initial prompt based on the syntax analysis file of the test database and the database information of the test database, for performing the following operations:

[0260] Obtain the syntax analysis file from the test database, parse and process the syntax analysis file, and construct an abstract syntax tree; the abstract syntax tree is used to generate syntax paths;

[0261] The test database is queried and processed to obtain the database information. The database information is then randomly selected to obtain the first local database information. The first local database information and the syntax path together instruct the pre-trained model to generate sample test cases.

[0262] Generate initial instructions to instruct the pre-trained model to perform inference, and construct an initial prompt by combining the initial instructions, sample test cases, syntax paths, and first local database information.

[0263] In one possible implementation, the construction module 11 parses the parsing file and constructs an abstract syntax tree for performing the following operations:

[0264] Retrieve the rule segments from the parsing file; each rule segment includes the rule name and the rule content corresponding to that rule name.

[0265] The rule name is determined as the index key, the rule content is determined as the index value, an index table including the index key and the index value is constructed, and an abstract syntax tree is constructed based on the index table.

[0266] In one possible implementation, module 11 is also used to perform the following operations:

[0267] Obtain the probability table for the test database; the probability table includes A candidate start nodes and the initial probability corresponding to each of the A candidate start nodes; A is a positive integer greater than 1; all A candidate start nodes belong to the abstract syntax tree;

[0268] Based on the initial probabilities corresponding to the A candidate starting nodes, the starting node is obtained from the A candidate starting nodes;

[0269] In the abstract syntax tree, obtain the first child node of the child node belonging to the start node. If there is no child node of the first child node in the abstract syntax tree, generate the syntax path based on the start node and the first child node.

[0270] If there is a child node of the first child node in the abstract syntax tree, then obtain the second child node from the child node of the first child node;

[0271] Generate a syntax path based on the starting node, the first child node, the second child node, and the child nodes of the second child node in the abstract syntax tree.

[0272] In one possible implementation, mutation module 12 acquires a mutation operator to perform the following operations:

[0273] Perform rule detection on the first test case and obtain the rule detection results;

[0274] If the rule detection result indicates that the first test case does not conform to the syntax rules, the initial prompt is updated to obtain an updated prompt;

[0275] The update prompts are input into the pre-trained model, which then identifies and processes them to obtain test cases to be evaluated. These test cases are used to generate variant test cases when the evaluation process is passed. Both the test cases to be evaluated and the variant test cases that have passed the evaluation process are added to the test database.

[0276] If the rule detection result indicates that the first test case conforms to the syntax rule, then the first test case is evaluated to obtain the evaluation result;

[0277] When the evaluation result is a pass, obtain the mutation operator.

[0278] In one possible implementation, the mutation module 12 updates the initial prompt to obtain an updated prompt, which is used to perform the following operations:

[0279] The syntax path in the initial prompt is simplified to obtain the simplified syntax path;

[0280] Retrieve second local database information that differs from the first local database information from the database information;

[0281] Generate error messages from the rule detection results, and update the initial instructions in the initial messages based on the error messages to obtain update instructions;

[0282] The update prompt is constructed by combining the update instructions, sample test cases, simplified syntax paths, and second local database information.

[0283] In one possible implementation, the mutation module 12 evaluates the first test case to obtain an evaluation result, which is then used to perform the following operations:

[0284] Determine the first number of subquery statements and the second number of structural operations in the first test case;

[0285] The score for the subquery statement is multiplied by the first quantity to obtain the first score;

[0286] The score for the structural operation and the second quantity are multiplied to obtain the second score;

[0287] The first score and the second score are summed to obtain the total score of the first test case. Based on the total score, the evaluation result of the first test case is determined.

[0288] In one possible implementation, the mutation module 12 determines the evaluation result of the first test case based on the total score, and performs the following operations:

[0289] If the total score is less than the scoring threshold, the evaluation failure result will be determined as the evaluation result of the first test case; the evaluation failure result is used to indicate the deletion of the first test case;

[0290] If the total score is equal to or greater than the scoring threshold, the evaluation result will be determined as the evaluation result of the first test case.

[0291] In one possible implementation, the mutation operator includes the thought chain mutation operator;

[0292] Mutation module 12 uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case, for use in performing the following operations:

[0293] Input the thought chain mutation operator and the first test case into the pre-trained model;

[0294] In the pre-trained model, the first test case is mutated according to the thought chain mutation operator to obtain a second test case that is different from the first test case; the structural complexity of the second test case is better than that of the first test case.

[0295] In one possible implementation, mutation module 12 mutates the first test case according to the thought chain mutation operator to obtain a second test case that is different from the first test case, which is used to perform the following operations:

[0296] If the thought chain mutation operator is a structure mutation operator, then the first test case is subjected to structure mutation processing to obtain a second test case with a structure different from the first test case.

[0297] If the thought chain mutation operator is a condition mutation operator, then the condition statement in the first test case is mutated to obtain a second test case with a condition statement that is different from the condition statement in the first test case.

[0298] If the thought chain mutation operator is the projection mutation operator, then the column query statement in the first test case will be mutated to obtain a second test case with a column query statement that is different from the column query statement in the first test case.

[0299] If the thought chain mutation operator is an aggregation mutation operator, then the aggregation statement mutation processing is performed on the first test case to obtain a second test case with an aggregation statement that is different from the aggregation statement in the first test case.

[0300] In one possible implementation, the mutation operator includes a supplementary mutation operator;

[0301] Mutation module 12 uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case, for use in performing the following operations:

[0302] By adding mutation operators, the first test case is deleted to obtain local test cases;

[0303] Local test cases are input into a pre-trained model. The pre-trained model then performs supplementary processing on the local test cases to obtain a second test case that is different from the first test case.

[0304] In one possible implementation, the mutation operator includes a hint mutation operator;

[0305] Mutation module 12 uses a pre-trained model and mutation operators to mutate the first test case, resulting in a second test case that differs from the first test case, for use in performing the following operations:

[0306] Input the mutation operator and the first test case into the pre-trained model;

[0307] In the pre-trained model, the first test case is mutated according to the prompt mutation operator to obtain a second test case that is different from the first test case.

[0308] In one possible implementation, the mutation module 12 mutates the first test case according to the prompted mutation operator to obtain a second test case that is different from the first test case, which is used to perform the following operations:

[0309] If the mutation operator is indicated to be a logically equivalent mutation operator, then a second test case with the same logic as the first test case will be generated.

[0310] If the mutation operator is indicated to be a complex mutation operator, then a second test case with a complexity better than that of the first test case will be generated.

[0311] In one possible implementation, execution module 13 is also used to perform the following operations:

[0312] Combine the first and second test cases to obtain the third test case, and add the third test case to the test case library;

[0313] Then, module 13 is executed to perform the following operations:

[0314] By testing the database, the third test case is executed, and the first execution result output by the test database is obtained.

[0315] In one possible implementation, execution module 13 determines a test report for the test database based on the first execution result, and performs the following operations:

[0316] By using the reference database, test cases in the test case library are executed to obtain the second execution result output by the reference database;

[0317] The first execution result and the second execution result are compared. If the first execution result and the second execution result are the same, the test pass report is determined as the test report of the test database.

[0318] If the first execution result is different from the second execution result, the test failure report will be determined as the test report of the test database.

[0319] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0320] In this embodiment, the computer device constructs initial prompts based on the syntax analysis file and database information of the test database. These initial prompts are input into a pre-trained model, which then processes them to obtain a first test case. A mutation operator is acquired, and the first test case is mutated using the pre-trained model and the mutation operator to obtain a second test case different from the first. The test cases in the test case library are executed through the test database to obtain a first execution result. A test report for the test database is then determined based on the first execution result. The test case library includes both the first and second test cases. As can be seen, this embodiment constructs model prompts (including initial prompts) using the syntax analysis file and database information provided with the test database, enabling the pre-trained model to generate test cases for the test database. This efficiently supports different test databases and improves the scalability of database testing. Furthermore, this embodiment uses a mutation operator to mutate the first test case to obtain a second test case, thus increasing the diversity of test cases and consequently improving the test coverage of the test database.

[0321] Further, please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 8 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to implement communication between these components. In some embodiments, the user interface 1003 may include a display screen and a keyboard, and the network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk drive. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 8 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.

[0322] exist Figure 8 In the computer device 1000 shown, the network interface 1004 provides network communication functionality; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0323] Based on the syntax analysis file of the test database and the database information of the test database, an initial prompt is constructed. The initial prompt is input into the pre-trained model, and the pre-trained model is used to identify and process the initial prompt to obtain the first test case.

[0324] Obtain the mutation operator, and use the pre-trained model and the mutation operator to mutate the first test case to obtain a second test case that is different from the first test case;

[0325] The test database executes the test cases in the test case library to obtain the first execution result output by the test database. The test report of the test database is determined based on the first execution result. The test case library includes the first test case and the second test case.

[0326] It should be understood that the computer device 1000 described in the embodiments of this application can perform the data processing methods or apparatus described in the preceding embodiments, and will not be repeated here. Furthermore, the beneficial effects of using the same methods will also not be repeated.

[0327] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same methods will also not be repeated.

[0328] The aforementioned computer-readable storage medium can be an internal storage unit of the data processing apparatus or computer device provided in any of the foregoing embodiments, such as a hard disk or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the computer device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0329] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated here.

[0330] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.

[0331] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0332] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. A data processing method, characterized in that, include: Based on the syntax analysis file of the test database and the database information of the test database, an initial prompt is constructed, the initial prompt is input into the pre-trained model, and the initial prompt is identified and processed by the pre-trained model to obtain the first test case; Obtain the mutation operator, and use the pre-trained model and the mutation operator to mutate the first test case to obtain a second test case that is different from the first test case. The test cases in the test case library are executed through the test database to obtain the first execution result output by the test database. The test report of the test database is determined based on the first execution result. The test case library includes the first test case and the second test case.

2. The method according to claim 1, characterized in that, The step of constructing initial prompts based on the syntax analysis file of the test database and the database information of the test database includes: Obtain the syntax analysis file from the test database, parse the syntax analysis file, and construct an abstract syntax tree; the abstract syntax tree is used to generate syntax paths; The test database is queried to obtain database information. The database information is then randomly selected to obtain first local database information. The first local database information and the syntax path together instruct the pre-trained model to generate sample test cases. Generate initial instructions to instruct the pre-trained model to perform inference, and construct an initial prompt by combining the initial instructions, the sample test cases, the syntax path, and the first local database information.

3. The method according to claim 2, characterized in that, The parsing and processing of the syntax analysis file to construct an abstract syntax tree includes: Obtain the rule segment from the syntax analysis file; the rule segment includes the rule name and the rule content corresponding to the rule name; The rule name is determined as the index key, the rule content is determined as the index value, an index table including the index key and the index value is constructed, and an abstract syntax tree is constructed based on the index table.

4. The method according to claim 2, characterized in that, Also includes: Obtain a probability table for the test database; the probability table includes A candidate starting nodes and the initial probabilities corresponding to the A candidate starting nodes respectively; A is a positive integer greater than 1; all A candidate start nodes belong to the abstract syntax tree; Based on the initial probabilities corresponding to the A candidate starting nodes, a starting node is obtained from the A candidate starting nodes; Obtain the first child node of the child node belonging to the starting node in the abstract syntax tree. If the first child node does not exist in the abstract syntax tree, generate a syntax path based on the starting node and the first child node. If the abstract syntax tree contains a child node of the first child node, then the second child node is obtained from the child node of the first child node; A syntax path is generated based on the starting node, the first child node, the second child node, and the child nodes of the second child node in the abstract syntax tree.

5. The method according to claim 1, characterized in that, The acquisition of the mutation operator includes: Perform rule detection on the first test case to obtain the rule detection results; If the rule detection result indicates that the first test case does not conform to the syntax rules, then the initial prompt is updated to obtain an updated prompt; The update prompt is input into the pre-trained model, which then identifies and processes the update prompt to obtain test cases to be evaluated. These test cases are used to generate variant test cases when the evaluation process is passed. Both the test cases to be evaluated and the variant test cases that have passed the evaluation process are added to the test database. If the rule detection result indicates that the first test case conforms to the syntax rule, then the first test case is evaluated to obtain the evaluation result; When the evaluation result is a pass result, the mutation operator is obtained.

6. The method according to claim 5, characterized in that, The step of updating the initial prompt to obtain an updated prompt includes: The syntax path in the initial prompt is simplified to obtain a simplified syntax path; Obtain second local database information that is different from the first local database information from the database information; Generate an error message from the rule detection result, and update the initial instruction in the initial message according to the error message to obtain an update instruction; The update instruction, the sample test cases, the simplified syntax path, and the second local database information are combined to form an update prompt.

7. The method according to claim 5, characterized in that, The evaluation process for the first test case to obtain the evaluation result includes: Determine the first number of subquery statements and the second number of structural operations in the first test case; The score for the subquery statement and the first quantity are multiplied to obtain the first score; The score for the structural operation and the second quantity are multiplied to obtain the second score; The first score and the second score are summed to obtain the total score of the first test case. Based on the total score, the evaluation result of the first test case is determined.

8. The method according to claim 7, characterized in that, Determining the evaluation result of the first test case based on the total score includes: If the total score is less than the score threshold, the evaluation failure result is determined as the evaluation result of the first test case; the evaluation failure result is used to indicate the deletion of the first test case; If the total score is equal to or greater than the score threshold, the evaluation result is determined as the evaluation result of the first test case.

9. The method according to claim 1, characterized in that, The mutation operator includes the thought chain mutation operator; The step of mutating the first test case using the pre-trained model and the mutation operator to obtain a second test case different from the first test case includes: The thought chain mutation operator and the first test case are input into the pre-trained model; In the pre-trained model, the first test case is mutated according to the thought chain mutation operator to obtain a second test case that is different from the first test case; the structural complexity of the second test case is better than that of the first test case.

10. The method according to claim 9, characterized in that, The step of mutating the first test case according to the thought chain mutation operator to obtain a second test case different from the first test case includes: If the thought chain mutation operator is a structural mutation operator, then the first test case is subjected to structural mutation processing to obtain a second test case with a structure different from the first test case. If the thought chain mutation operator is a condition mutation operator, then the condition statement in the first test case is mutated to obtain a second test case with a condition statement different from the condition statement in the first test case. If the thought chain mutation operator is a projection mutation operator, then the column query statement in the first test case is mutated to obtain a second test case with a column query statement different from that in the first test case. If the thought chain mutation operator is an aggregation mutation operator, then the first test case is subjected to aggregation statement mutation processing to obtain a second test case with an aggregation statement different from the aggregation statement in the first test case.

11. The method according to claim 1, characterized in that, The mutation operator includes a supplementary mutation operator; The step of mutating the first test case using the pre-trained model and the mutation operator to obtain a second test case different from the first test case includes: The first test case is deleted using the supplementary mutation operator to obtain local test cases. The local test cases are input into the pre-trained model, and the local test cases are supplemented by the pre-trained model to obtain a second test case that is different from the first test case.

12. The method according to claim 1, characterized in that, The mutation operator includes a cue mutation operator; The step of mutating the first test case using the pre-trained model and the mutation operator to obtain a second test case different from the first test case includes: The prompt mutation operator and the first test case are input into the pre-trained model; In the pre-trained model, the first test case is mutated according to the prompt mutation operator to obtain a second test case that is different from the first test case.

13. The method according to claim 12, characterized in that, The step of mutating the first test case according to the suggested mutation operator to obtain a second test case different from the first test case includes: If the suggested mutation operator is a logically equivalent mutation operator, then a second test case with the same logic as the first test case is generated. If the mutation operator is a complex mutation operator, then a second test case with a complexity greater than that of the first test case is generated.

14. The method according to claim 1, characterized in that, The method further includes: The first test case and the second test case are combined to obtain a third test case, and the third test case is added to the test case library; The step of executing test cases in the test case library through the test database to obtain the first execution result output by the test database includes: The third test case is executed using the test database to obtain the first execution result output by the test database.

15. The method according to claim 1, characterized in that, The step of determining the test report for the test database based on the first execution result includes: By using the reference database, test cases in the test case library are executed to obtain the second execution result output by the reference database; The first execution result and the second execution result are compared. If the first execution result and the second execution result are the same, the test pass report is determined as the test report of the test database. If the first execution result is different from the second execution result, then the test failure report is determined as the test report of the test database.

16. A data processing apparatus, characterized in that, include: The construction module is used to construct initial prompts based on the syntax analysis file of the test database and the database information of the test database, input the initial prompts into the pre-trained model, and perform recognition processing on the initial prompts through the pre-trained model to obtain the first test case; The mutation module is used to obtain mutation operators, and to mutate the first test case using the pre-trained model and the mutation operators to obtain a second test case that is different from the first test case. An execution module is configured to execute test cases in a test case library using the test database, obtain a first execution result output by the test database, and determine a test report for the test database based on the first execution result; the test case library includes the first test case and the second test case.

17. A computer device, characterized in that, include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs to cause the computer device to perform the method according to any one of claims 1-15.

18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-15.

19. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, the computer program being adapted to be read and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-15.