A method and device for checking a distributed database table structure, an electronic device and a storage medium

By verifying the consistency of table creation statements in the distributed database, system anomalies caused by differences in table structures were resolved, and stable operation of the distributed database was achieved.

CN115827637BActive Publication Date: 2025-11-18JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211644033.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2025-11-18
Estimated Expiration
2042-12-20

AI Technical Summary

Technical Problem

In a distributed database system, table structures may differ after executing table creation or modification statements, leading to system anomalies and errors and affecting the stable operation of the system.

Method used

The system obtains the user-inputted table creation statement from the computing nodes in the distributed database, stores it locally as the first table creation statement, sends the table creation statement to the management node and each data node to generate the second and third table creation statements, and verifies the consistency of these statements to ensure that the table structure remains consistent across all nodes.

Benefits of technology

It can quickly detect and repair abnormal table structures in distributed databases, ensuring the normal and stable operation of the system and improving the system's reliability and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827637B_ABST
    Figure CN115827637B_ABST
Patent Text Reader

Abstract

A distributed database table structure checking method and device, electronic equipment and storage medium are disclosed. The method is executed by a computing node in a distributed database, and includes: obtaining a table creation statement input by a user, and storing the table creation statement input by the user locally as a first table creation statement; sending the table creation statement input by the user to a management node in the distributed database, and storing the table creation statement in the management node as a second table creation statement; obtaining third table creation statements of each data node in the distributed database respectively; the third table creation statements are generated according to actually existing tables in corresponding data nodes; checking whether the first table creation statement, the second table creation statement and each third table creation statement are consistent; in the case of consistency, it is determined that the processing of the table creation statement input by the user by the distributed database is normal. The application realizes consistency checking of a distributed database system table structure, and ensures normal and stable operation of the distributed database system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to database management technology, and more particularly to a method, apparatus, electronic device and storage medium for verifying distributed database table structures. Background Technology

[0002] With the rapid development of internet businesses and the ever-increasing volume of data, the performance of single-machine databases is becoming a bottleneck for online businesses. Distributed databases, on the other hand, can provide high-performance, large-capacity, and high-concurrency database services, and are thus being rapidly applied to various online business scenarios.

[0003] A distributed database comprises multiple data nodes. By coordinating transactions across these nodes, it allows users to access the same information in a dataset at the same time. For example, a user in location A can access data in a data node in location B. If the data in the data node in location B changes, this change is synchronized across all data nodes in the database. Each data node's tables exist independently but are interconnected. When a database system malfunctions, differences may arise between tables on different database nodes after executing SQL statements that create or modify tables. After creating or modifying a large number of tables, system anomalies can lead to discrepancies in table structures, potentially causing further errors when executing subsequent DML or DQL statements.

[0004] A distributed database system typically consists of compute nodes, data nodes, and management nodes. The system can only function correctly if the table structures on these three nodes are completely consistent. To ensure table structure consistency in a distributed database system, it is necessary to perform table consistency checks periodically or after executing a large number of DDL statements (data definition statements used to create, delete, and modify database objects). Summary of the Invention

[0005] This invention provides a method, apparatus, electronic device, and storage medium for verifying the table structure of a distributed database, so as to realize the consistency verification of the table structure in each node of the distributed database system and ensure the normal and stable operation of the distributed database system.

[0006] In a first aspect, embodiments of the present invention provide a method for verifying the structure of a distributed database table, executed by a computing node in the distributed database, the method comprising:

[0007] Get the table creation statement entered by the user and store it locally as the first table creation statement;

[0008] Send the user-inputted table creation statement to the management node in the distributed database, and use the table creation statement in the management node as the second table creation statement;

[0009] The third table creation statement is obtained for each data node in the distributed database; the third table creation statement is generated based on the tables that actually exist in the corresponding data node.

[0010] Verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if they are consistent, determine that the distributed database is processing the table creation statement input by the user normally.

[0011] Optionally, the step of verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent includes:

[0012] Verify that the third table creation statements described are consistent;

[0013] If the verification results of each of the third table creation statements are consistent, then verify whether the first table creation statement and the third table creation statement are consistent.

[0014] If the validation results of the first and third table creation statements are consistent, then validate whether the first and second table creation statements are consistent.

[0015] Optionally, the verification of whether the first table creation statement and the third table creation statement are consistent includes:

[0016] The first table creation statement and the third table creation statement are parsed respectively to obtain the first syntax tree corresponding to the first table creation statement and the third syntax tree corresponding to the third table creation statement.

[0017] Verify whether the first syntax tree and the third syntax tree are consistent.

[0018] Optionally, the verification of whether each of the third table creation statements is consistent includes: verifying whether the strings of the third table creation statements of each data node are consistent;

[0019] The verification of whether the first table creation statement and the second table creation statement are consistent includes: verifying whether the strings of the first table creation statement and the second table creation statement are consistent.

[0020] Optionally, the step of verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent further includes:

[0021] If the validation results of the third table creation statements are inconsistent, or if the validation results of the first and third table creation statements are inconsistent, then the validation will stop, and it will be determined that the distributed database is processing the user-input table creation statement abnormally.

[0022] Optionally, before verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent, the following steps are included:

[0023] Check the integrity of the tables in the distributed database. If the check passes, verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent.

[0024] Secondly, embodiments of the present invention also provide a distributed database table structure verification device, configured on a computing node in a distributed database, the device comprising:

[0025] The first acquisition module is used to acquire the table creation statement input by the user and store the table creation statement input by the user locally as the first table creation statement.

[0026] The second acquisition module is used to send the user-inputted table creation statement to the management node in the distributed database, and to use the table creation statement in the management node as the second table creation statement.

[0027] The third acquisition module is used to acquire the third table creation statement for each data node in the distributed database; the third table creation statement is generated based on the tables that actually exist in the corresponding data node.

[0028] The statement validation module is used to verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if they are consistent, it is determined that the distributed database has processed the user-input table creation statement normally.

[0029] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising:

[0030] One or more processors;

[0031] Storage device for storing one or more programs.

[0032] When the one or more programs are executed by the one or more processors, the one or more processors implement the distributed database table structure verification method as described in any embodiment of this application.

[0033] Fourthly, embodiments of the present invention also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a method for verifying a distributed database table structure as described in any embodiment of the present application.

[0034] The technical solution of this application is executed by computing nodes in a distributed database, including: obtaining a table creation statement input by the user, storing the user-inputted table creation statement locally as a first table creation statement; sending the user-inputted table creation statement to a management node in the distributed database, and using the table creation statement in the management node as a second table creation statement; obtaining third table creation statements from each data node in the distributed database; the third table creation statement is generated based on the tables actually existing in the corresponding data node; verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if consistent, determining that the distributed database is processing the user-inputted table creation statement normally. This application performs consistency verification on the table structure in each node of the distributed database system, which can quickly find abnormal tables in the distributed database and point out error information, allowing maintenance personnel to quickly repair abnormal tables. This ensures the normal and stable operation of the distributed database. Attached Figure Description

[0035] Figure 1 This is a flowchart illustrating a method for verifying a distributed database table structure according to Embodiment 1 of the present invention.

[0036] Figure 2 This is a flowchart illustrating another method for verifying a distributed database table structure provided in Embodiment 2 of the present invention.

[0037] Figure 3 The diagram shown is a schematic representation of a distributed database table structure verification device provided in Embodiment 2 of the present invention.

[0038] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Detailed Implementation

[0039] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0040] Example 1

[0041] Figure 1 This is a flowchart illustrating a method for verifying the table structure of a distributed database according to Embodiment 1 of the present invention. This embodiment is applicable to verifying the table structure of each node in a distributed database. The method can be executed by a distributed database table structure verification device, which can be implemented in software and / or hardware. This device can be configured in an electronic device, and the method is executed by the computing nodes in the distributed database. Specifically, it includes:

[0042] S110. Obtain the table creation statement input by the user and store the table creation statement input by the user locally as the first table creation statement.

[0043] S120. Send the user-inputted table creation statement to the management node in the distributed database, and use the table creation statement in the management node as the second table creation statement.

[0044] A distributed database system typically includes compute nodes, data nodes, and management nodes. These nodes (compute nodes, data nodes, and management nodes) can be connected by wired or wireless bidirectional secure communication links. Each node can be a device providing computing services in a virtual network environment, or a device that provides services via a network. These services can include computation, storage, and querying. Physically, it can be any device capable of providing computing services, responding to service requests, and delivering services, such as cloud servers, cloud hosts, virtual data centers, and conventional servers. The components of a distributed database node primarily include processors, hard drives, memory, and system buses, similar to a general computer architecture.

[0045] Distributed databases separate computation from storage. Computation nodes receive tasks, forward tasks and computation results, data nodes store data, and management nodes perform backups. Preferably, in this embodiment, the distributed database system is GoldenDB, which maintains good compatibility with mainstream databases such as Oracle and MySQL in terms of data maintenance.

[0046] In this embodiment, the table creation statement can be a commonly used standardized statement for accessing the database, such as an SQL statement. Specifically, the table creation statement can be a DDL (Data Definition Language) statement used to create, delete, or modify database objects (databases, tables, columns, indexes, etc.). The table creation statement input by the user can be a command statement that modifies data objects. The first table creation statement can be the table creation statement most recently used to modify data objects, stored locally on the compute node. The modification can include operations such as creation, deletion, and modification. The second table creation statement can be a backup of the first table creation statement and is identical to it.

[0047] Optionally, in this embodiment, a distributed database client may exist. The client can be installed on a device with certain computing capabilities, and this device can communicate with the nodes of the distributed database. Optionally, a wired or wireless bidirectional secure communication link may exist between the device (client) and the distributed database. Physically, the device includes at least one processor. The number of processors may depend on the configuration and type of the device with certain computing capabilities. The device with certain computing capabilities may also include memory, which can be volatile, such as RAM, or non-volatile, such as read-only memory (ROM), flash memory, etc., or may include both types simultaneously. Optionally, the device can be a smart terminal, such as a mobile phone, desktop computer, laptop, tablet computer, etc.

[0048] Optionally, in this embodiment, when a user needs to modify a database object, the user can log in to the distributed system through a distributed database client and input a table creation statement within the client. The distributed database's computing node obtains the user-inputted table creation statement through a secure communication link between the client and the distributed database and stores it in the computing node's local storage, which can be volatile, such as RAM. To prevent the loss of table creation statements due to accidents such as computing node restarts or power outages, the computing node also pushes the table creation statements to a management node for backup and storage. The management node then stores the table creation statements in the distributed database.

[0049] S130. Obtain the third table creation statement for each data node in the distributed database; the third table creation statement is generated based on the tables that actually exist in the corresponding data node.

[0050] The distributed database may include multiple data nodes for storing data, and may also include at least one compute node and a management node corresponding to the multiple data nodes. Each data node includes tables for storing data. The table structure defines the table's fields, types, primary keys, foreign keys, indexes, etc. Data nodes can create actual tables based on table creation statements issued by compute nodes. The third table creation statement can be a table creation statement used to generate tables in data nodes; therefore, for a table that actually exists in a data node, the table creation statement for that table can be retrieved.

[0051] Specifically, the user enters a query statement in the client, which is then sent to the compute node. The compute node then sends the query statement to the data node, which executes the statement to retrieve the third table creation statement for the actual table existing in the data node. For example, the `SHOW CREATE TABLE` statement can be used to view the table structure. The syntax for using `SHOW CREATE TABLE` to retrieve the table structure is: `SHOW CREATE TABLE tbl_name`, where `tbl_name` represents the table name, such as the system dictionary table `crm_dictionary`. The DDL table creation statement can be retrieved using the `SHOW CREATE TABLE crm_dictionary` statement. The third table creation statement for the data node is as follows:

[0052] CREATE TABLE `crm_dictionary`(

[0053] id`bigint(20)NOTNULLAUTO_INCREMENT,

[0054] `code`int(16)NOTNULL,

[0055] `value` varchar(256) NOT NULL,

[0056] `type`varchar(32)NOTNULL,

[0057] `remark`varchar(64)DEFAULTNULL,

[0058] `enable`tinyint(4)NOTNULLDEFAULT'1'COMMENT'Configure switch(0: Off|1: On)',

[0059] PRIMARYKEY(`id`),

[0060] KEY`type`(`type`)

[0061] )ENGINE=InnoDB AUTO_INCREMENT=204DEFAULT CHARSET=utf8COMMENT='crm system dictionary table'.

[0062] S140. Verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if they are consistent, determine that the distributed database is processing the table creation statement input by the user normally.

[0063] If the table structure in a distributed database changes, the compute nodes, data nodes, and management nodes will all update the table structure, i.e., update the table creation statements. A distributed database system can only function correctly when the table structures on these three nodes are completely identical.

[0064] Optionally, in this embodiment of the application, the step of verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent includes:

[0065] Verify that the third table creation statements described are consistent;

[0066] If the verification results of each of the third table creation statements are consistent, then verify whether the first table creation statement and the third table creation statement are consistent.

[0067] If the validation results of the first and third table creation statements are consistent, then validate whether the first and second table creation statements are consistent.

[0068] Each data node in the distributed data is used to store data, which may include identical data of the highest importance. Therefore, preferably, the consistency of each of the third table creation statements can be checked first. Since the data nodes create actual tables based on the table creation statements issued by the computing nodes, preferably, after checking each of the third table creation statements, the consistency of the first and third table creation statements is checked. The management node is used to back up the table creation statements entered by the user. Therefore, preferably, after checking the first and third table creation statements, the consistency of the first and second table creation statements is checked.

[0069] Only when all three verification processes pass can it be determined that the table structures of the three nodes are completely consistent, and the distributed database has correctly processed the user-inputted table creation statements. Therefore, further, the verification of whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent may also include:

[0070] If the validation results of the third table creation statements are inconsistent, or if the validation results of the first and third table creation statements are inconsistent, then the validation will stop, and it will be determined that the distributed database is processing the user-input table creation statement abnormally.

[0071] If any verification fails, the database is identified as abnormal and verification is stopped. This reduces the burden on computing nodes and improves verification efficiency.

[0072] The table creation statements stored on compute nodes and management nodes are those issued by the client. The table creation statements executed by data nodes are those processed by the compute nodes and differ from the original table creation statements. Therefore, the verification methods of each node are different.

[0073] The third table creation statement is generated based on the actual tables existing in the corresponding data nodes. It can be considered that the third table creation statement is generated by the computing node after processing the first table creation statement. The first table creation statement and the third table creation statement may include the same semantic logic rules.

[0074] Optionally, the verification of whether the first table creation statement and the third table creation statement are consistent includes:

[0075] The first table creation statement and the third table creation statement are parsed respectively to obtain the first syntax tree corresponding to the first table creation statement and the third syntax tree corresponding to the third table creation statement.

[0076] Verify whether the first syntax tree and the third syntax tree are consistent.

[0077] Specifically, parsing the table creation statement to obtain the corresponding syntax tree can be achieved by generating the first syntax tree from the table creation statement using a syntax analyzer. Preferably, the syntax analyzer includes, but is not limited to, Lex and Bison. For each table creation statement, it undergoes several steps before being processed by the compute nodes to generate a table. One of these steps is generating the corresponding abstract syntax tree by Lex / Bison based on its defined syntax and semantic rules. This process is the statement parsing phase. During the parsing phase, the system parses the query statement to be executed according to the user-defined syntax and semantic rules and generates the corresponding abstract syntax tree based on the corresponding semantic rules.

[0078] Optionally, the verification of whether each of the third table creation statements is consistent includes: verifying whether the strings of the third table creation statements of each data node are consistent;

[0079] Optionally, the step of verifying whether the first table creation statement and the second table creation statement are consistent includes: verifying whether the strings of the first table creation statement and the second table creation statement are consistent;

[0080] Specifically, each character in the two table creation statements can be compared according to its ASCII code value. If the two are exactly the same, it returns 0; if the ASCII code value is larger first, it returns 1; if the ASCII code value is smaller first, it returns -1. At the same time, for places where there is a discrepancy, it returns the characters of both. This can quickly locate the place where the misalignment occurs, making it easier for the user to correct it.

[0081] Furthermore, before verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent, the following steps are included:

[0082] Check the integrity of the tables in the distributed database. If the check passes, verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent.

[0083] Specifically, the `CHECK TABLE` statement can be used to check the integrity of tables in a distributed database. If the check fails, it proves that an error occurred during the table creation process. The `CHECK TABLE` statement can directly return the table with the erroneous table creation without needing to verify the consistency of the first, second, and third table creation statements.

[0084] The technical solution of this application is executed by computing nodes in a distributed database, including: obtaining a table creation statement input by the user, storing the user-inputted table creation statement locally as a first table creation statement; sending the user-inputted table creation statement to a management node in the distributed database, and using the table creation statement in the management node as a second table creation statement; obtaining third table creation statements from each data node in the distributed database; the third table creation statement is generated based on the tables actually existing in the corresponding data node; verifying whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if consistent, determining that the distributed database is processing the user-inputted table creation statement normally. This application performs consistency verification on the table structure in each node of the distributed database system, which can quickly find abnormal tables in the distributed database and point out error information, allowing maintenance personnel to quickly repair abnormal tables. This ensures the normal and stable operation of the distributed database.

[0085] Example 2

[0086] Figure 2 This is a flowchart illustrating another method for verifying a distributed database table structure provided in Embodiment 2 of the present invention, including:

[0087] The distributed database client executes a check table statement, which is then sent to the compute nodes via the client.

[0088] The compute node sends a check table statement to each data node, and the data node executes the check table statement to verify its correctness.

[0089] The compute node retrieves the results of the check table from each data node. If all results are correct, it continues to the next step. If there are errors, it returns an error result to the client.

[0090] The compute node sends a statement to each data node, and the data node executes the show create table statement to obtain the table structure.

[0091] The compute node obtains the table structure of each data node and performs string comparison. If they are completely consistent, it continues to the next step. If there is a discrepancy, it returns the discrepancy information to the client.

[0092] The compute node retrieves the table creation statement from its local storage;

[0093] The compute nodes parse the table creation statements stored locally and the table creation statements of the data nodes respectively, resulting in two syntax trees;

[0094] The compute nodes compare the syntax trees. If they are completely identical, the next step is continued. If there is an inconsistency, the inconsistency information is returned to the client.

[0095] The compute node retrieves the table creation statements stored in the management node's metadata;

[0096] The compute node compares the table creation statements stored locally with those stored in the metadata management node. If they are completely identical, it returns the correct information to the client; otherwise, it returns the inconsistent information to the client.

[0097] It is worth noting that the method for verifying a distributed database table structure provided in Embodiment 2 of this application is merely an example and is not intended to limit the scope of protection of this invention.

[0098] Example 3

[0099] Figure 3 The diagram shows a distributed database table structure verification device according to Embodiment 2 of the present invention. The device can be configured on a computing node in a distributed database and includes a first acquisition module 310, a second acquisition module 320, a third acquisition module 330, and a statement verification module 340.

[0100] The first acquisition module 310 is used to acquire the table creation statement input by the user and store the table creation statement input by the user locally as the first table creation statement;

[0101] The second acquisition module 320 is used to send the user-inputted table creation statement to the management node in the distributed database, and to use the table creation statement in the management node as the second table creation statement.

[0102] The third acquisition module 330 is used to acquire the third table creation statement for each data node in the distributed database; the third table creation statement is generated based on the tables that actually exist in the corresponding data node.

[0103] The statement verification module 340 is used to verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if they are consistent, it is determined that the distributed database is processing the table creation statement input by the user normally.

[0104] This application performs consistency checks on the table structures of each node in a distributed database system. It can quickly identify abnormal tables in the distributed database and indicate error messages, allowing maintenance personnel to quickly repair abnormal tables and ensure the normal and stable operation of the distributed database.

[0105] As an optional implementation, the statement validation module includes:

[0106] The first verification unit is used to verify whether the third table creation statements are consistent.

[0107] The second verification unit is used to verify whether the first table creation statement and the third table creation statement are consistent if the verification results of each of the third table creation statements are consistent.

[0108] The third verification unit is used to verify whether the first table creation statement and the second table creation statement are consistent if the verification results of the first table creation statement and the third table creation statement are consistent.

[0109] As an optional implementation, the second verification unit is specifically used to perform syntax parsing on the first table creation statement and the third table creation statement respectively, to obtain a first syntax tree corresponding to the first table creation statement and a third syntax tree corresponding to the third table creation statement; and to verify whether the first syntax tree and the third syntax tree are consistent.

[0110] As an optional implementation, the statement verification module further includes a verification termination unit, which is used to stop verification if the verification results of each of the third table creation statements are inconsistent or the verification results of the first table creation statement and the third table creation statement are inconsistent, and to determine that the distributed database is processing the user-input table creation statement abnormally.

[0111] As an optional implementation, the device further includes a table checking module for checking the integrity of tables in the distributed database. If the check passes, the module verifies whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent.

[0112] The distributed database table structure verification device provided in this embodiment of the invention can execute the distributed database table structure verification method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0113] Example 4

[0114] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention, as shown below. Figure 4As shown, the electronic device includes a processor 410, a memory 420, an input device 430, and an output device 440; the number of processors 410 in the electronic device can be one or more. Figure 4 Taking a processor 410 as an example; the processor 410, memory 420, input device 430, and output device 440 in the electronic device can be connected via a bus or other means. Figure 4 Taking the example of a connection between China and Israel via a bus.

[0115] The memory 420, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the distributed database table structure verification method in this embodiment of the invention (e.g., the first acquisition module 310, the second acquisition module 320, the third acquisition module 330, and the statement verification module 340 in the distributed database table structure verification device). The processor 410 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 420, thereby implementing the aforementioned distributed database table structure verification method.

[0116] The memory 420 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 420 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 420 may further include memory remotely located relative to the processor 410, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0117] Input device 430 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the electronic device. Output device 440 may include display devices such as a display screen.

[0118] Example 5

[0119] Embodiment 5 of the present invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a method for verifying a distributed database table structure, the method comprising:

[0120] Get the table creation statement entered by the user and store it locally as the first table creation statement;

[0121] Send the user-inputted table creation statement to the management node in the distributed database, and use the table creation statement in the management node as the second table creation statement;

[0122] The third table creation statement is obtained for each data node in the distributed database; the third table creation statement is generated based on the tables that actually exist in the corresponding data node.

[0123] Verify whether the first table creation statement, the second table creation statement, and each of the third table creation statements are consistent; if they are consistent, determine that the distributed database is processing the table creation statement input by the user normally.

[0124] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the method operations described above, but can also execute related operations in the distributed database table structure verification method provided in any embodiment of the present invention.

[0125] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0126] It is worth noting that in the embodiments of the search device described above, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.

[0127] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A method for checking a distributed database table structure, characterized in that, The method is executed by a computing node in a distributed database, and comprises the following steps: obtaining a table creation statement input by a user, and storing the table creation statement input by the user locally as a first table creation statement; sending the table creation statement input by the user to a management node in the distributed database, and storing the table creation statement in the management node as a second table creation statement; obtaining third table creation statements of respective data nodes in the distributed database; the third table creation statements are generated according to actually existing tables in the respective data nodes; checking whether the first table creation statement, the second table creation statement and the third table creation statements are consistent; if consistent, determining that the processing of the table creation statement input by the user by the distributed database is normal.

2. The method of claim 1, wherein, The checking whether the first table creation statement, the second table creation statement and the third table creation statements are consistent comprises the following steps: checking whether the third table creation statements are consistent; if the checking results of the third table creation statements are consistent, checking whether the first table creation statement and the third table creation statements are consistent; if the checking results of the first table creation statement and the third table creation statements are consistent, checking whether the first table creation statement and the second table creation statement are consistent.

3. The method of claim 2, wherein, The checking whether the first table creation statement and the third table creation statements are consistent comprises the following steps: respectively performing syntax analysis on the first table creation statement and the third table creation statement to obtain a first syntax tree corresponding to the first table creation statement and a third syntax tree corresponding to the third table creation statement; checking whether the first syntax tree and the third syntax tree are consistent.

4. The method of claim 2, wherein, The checking whether the third table creation statements are consistent comprises checking whether strings of the third table creation statements of the respective data nodes are consistent. The checking whether the first table creation statement and the second table creation statement are consistent comprises checking whether strings of the first table creation statement and the second table creation statement are consistent.

5. The method of claim 2, wherein, The checking whether the first table creation statement, the second table creation statement and the third table creation statements are consistent further comprises the following steps: if the checking results of the third table creation statements are inconsistent or the checking results of the first table creation statement and the third table creation statements are inconsistent, stopping the checking, and determining that the processing of the table creation statement input by the user by the distributed database is abnormal.

6. The method of claim 1, wherein, Before the checking whether the first table creation statement, the second table creation statement and the third table creation statements are consistent, the following step is further comprised: checking the integrity of tables in the distributed database; if the checking is passed, checking whether the first table creation statement, the second table creation statement and the third table creation statements are consistent.

7. An apparatus for checking a distributed database table structure, characterized by The computing node configured in the distributed database comprises the following modules: a first obtaining module, configured to obtain a table creation statement input by a user, and store the table creation statement input by the user locally as a first table creation statement; a second obtaining module, configured to send the table creation statement input by the user to a management node in the distributed database, and store the table creation statement in the management node as a second table creation statement; a third obtaining module, configured to obtain third table creation statements of respective data nodes in the distributed database; the third table creation statements are generated according to actually existing tables in the respective data nodes The statement checking module is configured to check whether the first table creation statement, the second table creation statement and each of the third table creation statements are consistent; and in the case of consistency, determine that the processing of the table creation statements input by the user by the distributed database is normal.

8. The apparatus of claim 7, wherein, The statement checking module comprises: A first checking unit configured to check whether each of the third table creation statements is consistent; A second checking unit configured to check whether the first table creation statement and the third table creation statement are consistent if the checking results of each of the third table creation statements are consistent; A third checking unit configured to check whether the first table creation statement and the second table creation statement are consistent if the checking results of the first table creation statement and the third table creation statement are consistent.

9. An electronic device, comprising: The electronic device comprises: One or more processors; A storage device configured to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the checking method of the distributed database table structure according to any one of claims 1-6.

10. A storage medium containing computer-executable instructions for performing the checking method of the distributed database table structure according to any one of claims 1-6 when executed by a computer processor.

Citation Information

Patent Citations

  • Heterogeneous database access method, apparatus and device, plug-in and storage medium

    CN110727693A

  • Routing table structures

    US6600724B1