CN117806965A - Database testing method and device, electronic equipment and storage medium - Google Patents

Database testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117806965A
CN117806965A CN202311862566.0A CN202311862566A CN117806965A CN 117806965 A CN117806965 A CN 117806965A CN 202311862566 A CN202311862566 A CN 202311862566A CN 117806965 A CN117806965 A CN 117806965A
Authority
CN
China
Prior art keywords
test
grammar
database
sql
syntax
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311862566.0A
Other languages
Chinese (zh)
Inventor
陆天炜
李磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinzhuan Xinke Co Ltd
Original Assignee
Jinzhuan Xinke Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinzhuan Xinke Co Ltd filed Critical Jinzhuan Xinke Co Ltd
Priority to CN202311862566.0A priority Critical patent/CN117806965A/en
Publication of CN117806965A publication Critical patent/CN117806965A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database testing method, a database testing device, electronic equipment and a storage medium, and relates to the field of database testing. The method comprises the following steps: acquiring SQL grammar supported by a database; generating test cases required by database testing according to the SQL grammar; and testing the databases of different versions according to the test case, and determining the grammar compatibility of the databases according to the test result. In the scheme of the invention, in the process of testing the grammar compatibility of the database, the corresponding test cases are automatically generated according to the grammar supported by the database, the pressure for enumerating SQL test cases is reduced, and the generated test cases are correct and accord with the SQL grammar, so that the test efficiency and the test range of the database are improved.

Description

Database testing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of databases, and in particular, to a database testing method, apparatus, electronic device, and storage medium.
Background
The database provides services through the SQL access interface, the number of SQL categories which can be supported by the database is an important index, and SQL sentences are relatively close to natural language, so that various nesting processes are supported in grammar. It is basically impossible to collect SQL case sets to form full test cases, and the problems of low efficiency and low correctness exist in exhaustive traversal.
Disclosure of Invention
The invention provides a database testing method, a database testing device, electronic equipment and a storage medium.
According to an aspect of the present invention, there is provided a database testing method, including:
acquiring SQL grammar supported by a database;
generating test cases required by database testing according to the SQL grammar;
and testing the databases of different versions according to the test case, and determining the grammar compatibility of the databases according to the test result.
In an alternative implementation, generating test cases required for database testing according to the SQL grammar includes:
performing iterative analysis on the SQL grammar to obtain an abstract grammar tree;
and converting the abstract syntax tree into a test SQL statement to obtain a test case required by database test.
In an alternative implementation, performing iterative parsing on the SQL grammar to obtain an abstract syntax tree includes:
determining sub-statements included in the SQL grammar;
and for any sub-sentence, carrying out iterative analysis on the SQL grammar according to a predetermined iterative parameter to obtain an abstract grammar tree.
In an alternative implementation, the converting the abstract syntax tree into a test SQL sentence to obtain a test case required for testing the database includes:
traversing upwards from the leaf nodes of the abstract syntax tree, and supplementing text to each node to obtain the test case comprising the test SQL sentence.
In an alternative implementation, text supplementation is performed for each node, including:
acquiring text contents to be supplemented from a library table paved in a database, and supplementing the text to each node; or alternatively, the first and second heat exchangers may be,
the text content required by each node is automatically created according to the table or the field relied by each node so as to supplement the text of each node.
In an alternative implementation, the SQL syntax is any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax.
According to another aspect of the present invention, there is provided a database test apparatus comprising:
the acquisition module is used for acquiring SQL grammar supported by the database;
the use case generation module is used for generating test use cases required by database testing according to the SQL grammar;
and the test module is used for testing the databases of different versions according to the test case and determining the grammar compatibility of the databases according to the test result.
In an alternative implementation, the use case generation module includes:
the iteration analysis unit is used for carrying out iteration analysis on the SQL grammar to obtain an abstract grammar tree;
the conversion unit is used for converting the abstract syntax tree into a test SQL statement to obtain a test case required by database test. In an alternative implementation, the iterative parsing unit is further configured to:
determining sub-statements included in the SQL grammar;
and for any sub-sentence, carrying out iterative analysis on the SQL grammar according to a predetermined iterative parameter to obtain an abstract grammar tree.
In an alternative implementation, the conversion unit is further configured to:
traversing upwards from the leaf nodes of the abstract syntax tree, and supplementing text to each node to obtain the test case comprising the test SQL sentence.
In an alternative implementation, text supplementation is performed for each node, including:
acquiring text contents to be supplemented from a library table paved in a database, and supplementing the text to each node; or alternatively, the first and second heat exchangers may be,
the text content required by each node is automatically created according to the table or the field relied by each node so as to supplement the text of each node.
In an alternative implementation, the SQL syntax is any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the database testing method of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to execute a database test method according to an embodiment of the present invention.
According to the technical scheme, in the process of testing the grammar compatibility of the database, the corresponding test cases are automatically generated according to the grammar supported by the database, the pressure for enumerating SQL test cases is reduced, the generated test cases are correct and accord with the SQL grammar, and further the test efficiency and the test range of the database are improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a database testing method according to an embodiment of the present invention;
FIG. 2a is a flowchart of a database testing method according to an embodiment of the present invention;
fig. 2b is a schematic diagram of a result of iterative parsing of an expression expr according to an embodiment of the present invention;
FIG. 2c is a schematic diagram of an abstract syntax tree provided according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a database testing apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device implementing a database testing method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
Example 1
Fig. 1 is a flowchart of a database testing method according to an embodiment of the present invention, where the method is applicable to a scenario of database testing, typically a scenario of testing the syntax compatibility of a database, and the method may be performed by a database testing device, where the database testing device may be implemented in a hardware and/or software form, and the database testing device may be configured in an electronic device.
As shown in fig. 1, the database test method includes:
s101, acquiring SQL grammar supported by a database.
In this embodiment, the database is optionally a container (typically a file or a group of files) holding organized data. The SQL syntax supported by the database may be any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax. Each SQL grammar typically involves one or more sub-statements, each with its own grammar rules, and even some sub-statements support nesting and looping. Illustratively, taking the SQL syntax as an example of a data query syntax, the data query syntax (e.g., select syntax) refers to sub-statements such as from (for specifying the source of the data for the query), where (for filtering the result set based on specified conditions), part (for partitioning the data into different partitions), group by (for grouping the data in one or more columns), have (for filtering the result set after group by grouping), order by (for ordering the result set), and the like. The select statement compatible syntax of the generic database is exemplified as follows:
SELECT
expr,...
[FROM table_references]
[WHERE where_condition]
[PARTITION number]
[GROUP BY col_name]
[HAVING where_condition]
[ORDER BY col_name[ASC|DESC],...]。
s102, generating test cases required by database testing according to the SQL grammar.
The proposal of the invention considers that the formation of the full test case by collecting the SQL case set is basically impossible, and the problems of low efficiency and low correctness exist in the exhaustive traversal. Therefore, a new test case generation method is provided, mainly, corresponding test SQL sentences are automatically generated according to SQL grammar supported by a database, namely, test cases required by database test are generated, so that the cost of test case preparation and the cost of accuracy are reduced.
In an alternative implementation, according to the SQL grammar, the test cases required by the database test are generated, and the method comprises the following steps: performing iterative analysis on the SQL grammar to obtain an abstract grammar tree; optionally, each sub-sentence related to the SQL grammar is unfolded in a hierarchical iteration mode to obtain the grammar type supported by each sub-sentence, and the grammar type supported by each sub-sentence obtained through multiple iterations can be recorded through an abstract grammar tree. Further, the abstract syntax tree is converted into a test SQL sentence, and test cases required by database test are obtained.
It can be understood that the test cases in the embodiment are obtained by analyzing the SQL grammar, so that the generated test cases are correct and conform to the SQL grammar, thereby ensuring the accuracy of the test cases; and the SQL grammar is analyzed to automatically generate the test cases, so that the pressure for enumerating the SQL test cases can be reduced.
S103, testing the databases of different versions according to the test case, and determining the grammar compatibility of the databases according to the test result.
In this embodiment, after the test case is obtained according to step S102, the test case may be executed in databases of different versions, to obtain test results output by the databases of different versions; and comparing test results of the databases of different versions after executing the test cases according to each test case, and determining grammar compatibility of the databases of different versions according to the comparison results. For example, if the test results of the databases of different versions are the same after the same test case is executed, it is determined that the grammars of the databases of different versions are compatible.
In the database grammar compatibility test process, the embodiment automatically generates the corresponding test cases according to the grammar supported by the database, reduces the pressure of enumerating SQL test cases, and ensures that the generated test cases are correct and conform to the SQL grammar, thereby improving the database test efficiency and test range.
Example two
Fig. 2a is a flowchart of a database testing method according to an embodiment of the present invention. Referring to fig. 2a, the flow of the database test method is as follows:
s201, acquiring SQL grammar supported by a database.
In this embodiment, the database is optionally a container (typically a file or a group of files) holding organized data. The SQL syntax supported by the database may be any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax. Each SQL grammar would involve one or more sub-statements, each with its own grammar rules, even part of the sub-statements supporting nesting and looping. Illustratively, taking the SQL syntax as an example of a data query syntax, the data query syntax (e.g., select syntax) refers to sub-statements such as from (for specifying the source of the data for the query), where (for filtering the result set based on specified conditions), part (for partitioning the data into different partitions), group by (for grouping the data in one or more columns), have (for filtering the result set after group by grouping), order by (for ordering the result set), and the like. The select statement compatible syntax of the generic database is exemplified as follows:
SELECT
expr,...
[FROM table_references]
[WHERE where_condition]
[PARTITION number]
[GROUP BY col_name]
[HAVING where_condition]
[ORDER BY col_name[ASC|DESC],...]。
after the SQL grammar is obtained, the process of generating test cases required for database testing according to the SQL grammar can be seen in steps S202-S203.
S202, carrying out iterative analysis on the SQL grammar to obtain an abstract grammar tree.
In an alternative implementation, the sub-statements included in the SQL grammar are first determined; for any sub-sentence, carrying out iterative analysis on the SQL grammar according to a predetermined iterative parameter to obtain an abstract grammar tree; wherein the iteration parameter is optionally an iteration round.
Illustratively, taking the SQL grammar as an example of the data query grammar, determining the sub-statement involved in the SQL grammar may include the expression expr, from sub-statement, where sub-statement, and the like. An iterative parsing process of the expression expr is illustrated. For example, if the iteration parameter is 4, it indicates that 4 rounds of iterative expansion of the expression expr are required. In the first iteration expansion, various logic algorithms can be utilized to expand the expression expr, AND the obtained iteration analysis results can include "expr OR expr", "expr AND expr", "++! Syntax types such as expr and bootean_primary; and during the second iteration, determining whether grammar types which can be continuously expanded exist in the analysis result of the first iteration, and expanding the grammar types if the grammar types exist. Optionally, after the first iteration analysis, the primary key judgment operation "booty_primary" may be further expanded, so that the second iteration mainly expands the primary key judgment operation "booty_primary", and the obtained iteration analysis result may include "booty_primary < = >," booty_primary IS [ NOT ] NULL ", and the precursor. And in the third iteration, judging whether grammar types which can be continuously expanded exist in the analysis result of the second iteration, and expanding the grammar types if the grammar types exist. Optionally, after the second iteration analysis, the predicate operation prediction may be continuously expanded, so that the third iteration mainly expands the predicate operation prediction, and the obtained iteration analysis result may include: "bit_expr [ NOT ] IN (sub)", "bit_expr [ NOT ] IN (expr [, expr ] … …)", "bit_expr", and the like. And during the fourth round of iterative analysis, judging whether grammar types which can be continuously expanded exist in the third round of iterative analysis results, and expanding the grammar types if the grammar types exist. Optionally, after the third round of iterative parsing, the bit expression "bit_exp" may be further expanded, so that the fourth round of iteration mainly expands the bit expression "bit_exp", and the obtained result may include "bit_exp+bit_exp", "bit_exp-bit_exp", "bit_exp_bit_exp", "bit_exp DIV bit_exp", "bit_exp% bit_exp", and the like. For example, the result of the iterative parsing of the expression expr can be seen in fig. 2b.
It can be appreciated that in the iterative parsing result, OR, XOR, AND, & &, NOT, ≡! The terms "+, -,/, DIV, MOD,% and the like are keys corresponding to the database. When the subsequent database test analyzes the test SQL statement, the keywords are mainly identified through the lexical rule.
For other sub-sentences related to SQL grammar, the method can also be developed according to the iterative parsing process of expr. An abstract syntax tree can thus be obtained. It can be understood that the scheme of the invention generates the abstract syntax tree in a two-stage iteration mode, wherein one stage is to perform multi-round iteration analysis on one sub-sentence, and the other stage is to perform iteration analysis on other sub-sentences.
For example, referring to FIG. 2c, a schematic diagram of an abstract syntax tree is shown. Referring to FIG. 2c, a SQL grammar can generate multiple test case cases, each case being a grammar tree.
S203, converting the abstract syntax tree into a test SQL sentence to obtain a test case required by database test.
In an alternative implementation scheme, for each case corresponding grammar tree, traversing upwards from leaf nodes of the abstract grammar tree, and performing text supplementation on each node to obtain a test case comprising a test SQL statement. Wherein, carry out text supplementation to each node, include: acquiring text contents to be supplemented from a library table paved in a database, and supplementing the text to each node; or, automatically creating text content required by each node according to the table or the field relied by each node so as to supplement the text of each node; illustratively, when traversing to a node, if a table of the table1_name is relied on, a table needs to be created; if the field of col_name varchar (100) is relied upon, then the table will be recorded to contain such a field; after traversing the entire AST, the table and corresponding fields are completely created. Thus, the test case needed for data test can be obtained through the steps.
For example, referring to fig. 2c, the test SQL statement corresponding to case1 may be: "Selectcol1_Name1+col2_Name2, col3_Namefrom table1_name wherecol1_name-! =0part_p1; ".
S204, testing the databases of different versions according to the test cases, and determining the grammar compatibility of the databases according to the test results.
In the embodiment, when the constructed SQL test case is utilized to perform database test, the SQL test case is analyzed through lexical analysis and grammar analysis, specifically, SQL is decomposed into character strings through lexical analysis, and database keywords and non-keywords are matched; matching corresponding sentence types aiming at the keywords; corresponding execution grammar trees are generated aiming at different sentence types, and specific operation is carried out on the database through the execution grammar trees, so that a final test result is obtained.
In the embodiment, the SQL grammar is unfolded in a two-stage iteration mode to obtain the axial grammar tree, and then the abstract grammar tree is instantiated by utilizing the library table to obtain the executable SQL test cases, so that the correctness and the quantity of the obtained SQL test cases can be ensured, and the database test efficiency and the test range can be improved.
Example III
Fig. 3 is a schematic structural diagram of a database testing device according to an embodiment of the present invention, where the embodiment is applicable to a scenario of database testing, typically, a scenario of testing the syntax compatibility of a database. As shown in fig. 3, the apparatus specifically includes:
an obtaining module 301, configured to obtain an SQL grammar supported by a database;
the use case generating module 302 is configured to generate a test use case required by a database test according to the SQL grammar;
and the test module 303 is used for testing the databases of different versions according to the test cases and determining the grammar compatibility of the databases according to the test results.
In an alternative implementation, the use case generation module includes:
the iteration analysis unit is used for carrying out iteration analysis on the SQL grammar to obtain an abstract grammar tree;
the conversion unit is used for converting the abstract syntax tree into a test SQL statement to obtain a test case required by database test. In an alternative implementation, the iterative parsing unit is further configured to:
determining sub-statements included in the SQL grammar;
and for any sub-sentence, carrying out iterative analysis on the SQL grammar according to a predetermined iterative parameter to obtain an abstract grammar tree.
In an alternative implementation, the conversion unit is further configured to:
traversing upwards from the leaf nodes of the abstract syntax tree, and supplementing text to each node to obtain the test case comprising the test SQL sentence.
In an alternative implementation, text supplementation is performed for each node, including:
acquiring text contents to be supplemented from a library table paved in a database, and supplementing the text to each node; or alternatively, the first and second heat exchangers may be,
the text content required by each node is automatically created according to the table or the field relied by each node so as to supplement the text of each node.
In an alternative implementation, the SQL syntax is any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax.
The database testing device provided by the embodiment of the invention can execute the database testing method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM12 and the RAM13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as performing database testing methods.
In some embodiments, the database testing method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM12 and/or the communication unit 19. When the computer program is loaded into RAM13 and executed by processor 11, one or more steps of the database testing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the database test method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above can be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable database testing apparatus, such that the computer programs, when executed by the processor, cause the functions/operations specified in the flowchart and/or block diagram block or blocks to be performed. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A database testing method, comprising:
acquiring SQL grammar supported by a database;
generating test cases required by database testing according to the SQL grammar;
and testing the databases of different versions according to the test case, and determining the grammar compatibility of the databases according to the test result.
2. The method of claim 1, wherein generating test cases required for database testing according to the SQL syntax comprises:
performing iterative analysis on the SQL grammar to obtain an abstract grammar tree;
and converting the abstract syntax tree into a test SQL statement to obtain a test case required by database test.
3. The method of claim 2, wherein iteratively parsing the SQL grammar results in an abstract syntax tree, comprising:
determining sub-statements included in the SQL grammar;
and for any sub-sentence, carrying out iterative analysis on the SQL grammar according to a predetermined iterative parameter to obtain an abstract grammar tree.
4. The method of claim 2, wherein converting the abstract syntax tree into a test SQL statement results in a test case required for a database test, comprising:
traversing upwards from the leaf nodes of the abstract syntax tree, and supplementing text to each node to obtain the test case comprising the test SQL sentence.
5. The method of claim 4, wherein text supplementing each node comprises:
acquiring text contents to be supplemented from a library table paved in a database, and supplementing the text to each node; or alternatively, the first and second heat exchangers may be,
the text content required by each node is automatically created according to the table or the field relied by each node so as to supplement the text of each node.
6. The method of claim 4, wherein the SQL syntax is any one of a data query syntax, a data definition syntax, a data manipulation syntax, and a data control syntax.
7. A database testing apparatus, comprising:
the acquisition module is used for acquiring SQL grammar supported by the database;
the use case generation module is used for generating test use cases required by database testing according to the SQL grammar;
and the test module is used for testing the databases of different versions according to the test case and determining the grammar compatibility of the databases according to the test result.
8. The apparatus of claim 7, wherein the use case generation module comprises:
the iteration analysis unit is used for carrying out iteration analysis on the SQL grammar to obtain an abstract grammar tree;
the conversion unit is used for converting the abstract syntax tree into a test SQL statement to obtain a test case required by database test.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the method of any one of claims 1-6.
CN202311862566.0A 2023-12-29 2023-12-29 Database testing method and device, electronic equipment and storage medium Pending CN117806965A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311862566.0A CN117806965A (en) 2023-12-29 2023-12-29 Database testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311862566.0A CN117806965A (en) 2023-12-29 2023-12-29 Database testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117806965A true CN117806965A (en) 2024-04-02

Family

ID=90421461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311862566.0A Pending CN117806965A (en) 2023-12-29 2023-12-29 Database testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117806965A (en)

Similar Documents

Publication Publication Date Title
WO2021083239A1 (en) Graph data query method and apparatus, and device and storage medium
CN106202207B (en) HBase-ORM-based indexing and retrieval system
CN109726298B (en) Knowledge graph construction method, system, terminal and medium suitable for scientific and technical literature
US20230004721A1 (en) Method for training semantic representation model, device and storage medium
CN107644073A (en) A kind of field consanguinity analysis method, system and device based on depth-first traversal
CN111125064B (en) Method and device for generating database schema definition statement
CN114579104A (en) Data analysis scene generation method, device, equipment and storage medium
CN110909126A (en) Information query method and device
CN113779062A (en) SQL statement generation method and device, storage medium and electronic equipment
CN113609100B (en) Data storage method, data query device and electronic equipment
CN113220710B (en) Data query method, device, electronic equipment and storage medium
CN114676678A (en) Structured query language data parsing method and device and electronic equipment
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN117806965A (en) Database testing method and device, electronic equipment and storage medium
CN115146070A (en) Key value generation method, knowledge graph generation method, device, equipment and medium
CN115292347A (en) Active SQL algorithm performance checking device and method based on rules
CN112988778A (en) Method and device for processing database query script
US20240193135A1 (en) Systems, methods, and media for accessing derivative properties from a post relational database utilizing a logical schema instruction that includes a base object identifier
CN118012897A (en) Heterogeneous database grammar conversion method, device, equipment and storage medium
CN116383333A (en) Data storage method, device, equipment and storage medium
CN117667976A (en) Data processing method, device, equipment and storage medium
CN117667112A (en) Self-adaptive generation method of front-end development document based on babel
CN114925095A (en) Operation specification auditing method and device, electronic equipment and storage medium
CN116361323A (en) Relation tree adjustment method, device, equipment and storage medium
CN115495368A (en) Data testing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination