Method, device and equipment for constructing distributed database trigger and medium

By interacting with the computing nodes and trigger controllers in the distributed database, and parsing and mapping trigger requests, the complexity of trigger implementation in distributed databases is solved, enabling efficient trigger construction and management.

CN116049309BActive Publication Date: 2026-04-24JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINZHUAN INFORMATION TECHNOLOGY CO LTD
Filing Date
2022-12-30
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Implementing triggers in distributed databases is complex, and effective solutions are lacking.

Method used

Through the interaction between the compute nodes and the trigger controller, client requests are parsed, trigger identifiers are generated and mapping relationships are established. The trigger controller is used to construct triggers and share the processing logic of the compute nodes.

Benefits of technology

It simplifies the construction process of distributed database triggers, enables efficient construction and management of triggers, and reduces the processing burden on computing nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049309B_ABST
    Figure CN116049309B_ABST
Patent Text Reader

Abstract

The application relates to a distributed database trigger construction method, device, equipment and medium, wherein the method comprises the following steps: in the case that a first creation request sent by a client is received by a computing node, the first creation request is parsed to obtain a parsing result; the parsing result is sent to a trigger controller as a second creation request; a mapping relationship is established for a trigger identification code, a trigger condition and a trigger subject in the second creation request by the trigger controller and is stored, and a first confirmation signal is returned to the computing node in response to the second creation request; and the second confirmation signal is returned to the client by the computing node in response to the first creation request, so that the construction of the trigger is completed. The trigger is constructed through the interaction between the trigger controller and the computing node, the constructed trigger can be realized through the trigger controller, the processing logic of the computing node is shared, and the problem that the trigger of the distributed data is relatively complex to realize is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of distributed database technology, and in particular to a method, apparatus, device and medium for constructing a distributed database trigger. Background Technology

[0002] Triggers are a method provided by relational database management systems (RDBMS) for programmers and data analysts to ensure data integrity. They are special stored procedures associated with table events; their execution is not initiated by a program call or manual activation, but rather triggered by an event. For distributed databases that evolved from single-machine databases, trigger implementation is also essential. However, distributed databases involve multiple data nodes, making trigger implementation more complex.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This application provides a method, apparatus, device, and medium for constructing distributed database triggers to solve the technical problem of complex implementation of distributed data triggers.

[0005] According to one aspect of the embodiments of this application, this application provides a method for constructing a distributed database trigger, comprising: upon receiving a first creation request sent by a client, parsing the first creation request to obtain a parsing result, wherein the parsing result includes a trigger identifier code, a trigger condition, and a trigger body; sending the parsing result as a second creation request to a trigger controller; establishing and storing a mapping relationship between the trigger identifier code, the trigger condition, and the trigger body in the second creation request through the trigger controller; and responding to the second creation request by returning a first confirmation signal to the computing node; and utilizing the computing node's response to the first creation request by returning a second confirmation signal to the client to complete the construction of the trigger.

[0006] Optionally, the first creation request is parsed to obtain the following parsing results: extracting the creation trigger statement from the first creation request; parsing the creation trigger statement to obtain the target database corresponding to the trigger, the table name of the table in the target database, the trigger ID of the table name, the trigger name, the trigger condition, and the trigger body; storing the trigger ID, trigger name, and trigger condition in the compute node; generating a trigger identifier code using the target database, table, and trigger ID, and using the trigger identifier code, trigger condition, and trigger body as the parsing results.

[0007] Optionally, after the trigger is constructed, the method further includes: when the computing node receives a trigger request sent by the client, determining the trigger statement corresponding to the target statement in the trigger request; executing the trigger statement; sending the target statement to the data node through the computing node so that the target statement can be executed through the data node; and returning a trigger success signal in response to the trigger request to the client through the computing node.

[0008] Optionally, when the compute node receives a trigger request sent by the client, determining the trigger statement corresponding to the target statement in the trigger request includes: determining whether a first trigger exists in the table corresponding to the target statement; if the first trigger exists, determining whether the target statement meets the triggering conditions; if the target statement meets the triggering conditions, generating a first identifier code corresponding to the first trigger; sending a query statement carrying the first identifier code to the data node through the compute node, so that the data node generates an execution trigger request corresponding to the query statement, and sending the execution trigger request to the trigger controller; and finding a trigger statement matching the first identifier code through the trigger controller according to the mapping relationship.

[0009] Optionally, executing a trigger statement includes: executing the trigger statement through a trigger controller; or sending the trigger statement to a compute node through a trigger controller, so that the compute node executes the trigger statement through a data node.

[0010] Optionally, after the trigger is constructed, the method further includes: when the computing node receives a first deletion request sent by the client, determining whether there is a second trigger corresponding to the deletion request; if there is a second trigger, obtaining the second identifier code of the second trigger, and sending a second deletion request carrying the second identifier code to the trigger controller through the computing node; determining the target data that has a mapping relationship with the second identifier code through the trigger controller; deleting the target data, and returning a third confirmation signal in response to the second deletion request to the computing node through the trigger controller; the computing node generating a fourth confirmation signal based on the third confirmation signal, and returning a fourth confirmation signal in response to the first deletion request to the client.

[0011] Optionally, the method further includes: if a change operation is performed on the metadata with a mapping relationship in the trigger controller, the change information corresponding to the change operation is sent to each computing node in the distributed database through the metadata management module, so that each computing node can synchronize the change information through the trigger controller.

[0012] According to another aspect of the embodiments of this application, this application provides a distributed database trigger construction apparatus, comprising: a parsing module, configured to parse the first creation request sent by a client when a computing node receives the first creation request, and obtain a parsing result, wherein the parsing result includes a trigger identifier code, a trigger condition, and a trigger body; a sending module, configured to send the parsing result as a second creation request to a trigger controller; a mapping module, configured to establish and store a mapping relationship between the trigger identifier code, the trigger condition, and the trigger body in the second creation request through the trigger controller, and to return a first confirmation signal to the computing node in response to the second creation request; and a response module, configured to use the computing node to respond to the first creation request and return a second confirmation signal to the client to complete the construction of the trigger.

[0013] According to another aspect of the embodiments of this application, this application provides an electronic device, including a memory, a processor, a communication interface and a communication bus. The memory stores a computer program that can run on the processor. The memory and the processor communicate with each other through the communication bus and the communication interface. When the processor executes the computer program, it implements the steps of the above method.

[0014] According to another aspect of the embodiments of this application, this application also provides a computer-readable medium having processor-executable non-volatile program code that causes the processor to perform the above-described method.

[0015] Compared with related technologies, the technical solutions provided in this application have the following advantages:

[0016] This application discloses a method for constructing a distributed database trigger, comprising: upon receiving a first creation request from a client, parsing the first creation request to obtain a parsing result, wherein the parsing result includes the trigger identifier code, trigger condition, and trigger body of the trigger; sending the parsing result as a second creation request to a trigger controller; establishing and storing a mapping relationship between the trigger identifier code, trigger condition, and trigger body in the second creation request through the trigger controller; and responding to the second creation request by returning a first confirmation signal to the computing node; and utilizing the computing node's response to the first creation request by returning a second confirmation signal to the client to complete the construction of the trigger. By constructing the trigger through interaction between the trigger controller and the computing node, the constructed trigger can be implemented through the trigger controller, distributing the processing logic of the computing node and solving the problem of the complexity of implementing triggers in distributed data. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating an optional method for constructing a distributed database trigger according to an embodiment of this application;

[0020] Figure 2 This is a schematic diagram of an optional distributed database provided according to an embodiment of this application;

[0021] Figure 3 This is a flowchart illustrating an optional trigger creation method according to an embodiment of this application;

[0022] Figure 4 This is a flowchart of an optional trigger provided according to an embodiment of this application;

[0023] Figure 5 This is a flowchart of an optional deletion trigger provided according to an embodiment of this application;

[0024] Figure 6 This is a block diagram of an optional distributed database trigger construction apparatus provided according to an embodiment of this application;

[0025] Figure 7 This is a schematic diagram of an optional electronic device structure provided in an embodiment of this application. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustration and has no specific meaning in itself. Therefore, "module" and "part" may be used interchangeably.

[0028] For single-machine databases, triggers are a relatively important feature, offering flexibility and powerful functionality. For example, they can ensure data security by restricting user operations based on time and data, perform auditing, track user actions on database tables, and synchronize table data in real time. For distributed databases, which evolved from single-machine databases, trigger implementation is also essential; however, distributed databases involve multiple data nodes, making trigger implementation relatively complex.

[0029] To address the problems mentioned in the background art, according to one aspect of an embodiment of this application, a method for constructing a distributed database trigger is provided, such as... Figure 1 As shown, it includes:

[0030] Step 101: When the computing node receives the first creation request sent by the client, it parses the first creation request to obtain the parsing result, wherein the parsing result includes the trigger identifier code, trigger condition and trigger body of the trigger;

[0031] Specifically, when using the `create trigger` statement to create a trigger, CN will parse the trigger creation statement from the client. After parsing, it will store the trigger ID (each trigger ID is unique), name, and condition information. On the other hand, it will generate a trigger identifier key (the trigger identifier key is unique) from the database, table name, and ID involved in the trigger.

[0032] Step 103: Send the parsing result as a second creation request to the trigger controller;

[0033] Specifically, the compute node sends the trigger identifier, trigger conditions, and trigger body (i.e., trigger SQL) to the trigger controller and waits for the trigger controller's response.

[0034] Step 105: Establish and store the mapping relationship between the trigger identifier code, trigger condition and trigger body in the second creation request through the trigger controller, and return a first confirmation signal to the computing node in response to the second creation request;

[0035] Specifically, when the trigger controller receives the second creation request (i.e., the trigger creation request) from the compute node, it extracts the trigger identifier key, trigger condition, and trigger body (trigger SQL) from the second creation request, establishes a mapping and saves it, and returns the first confirmation signal (i.e., success response) to the compute node in response to the second creation request.

[0036] Step 107: The compute node responds to the first creation request and returns a second confirmation signal to the client to complete the construction of the trigger.

[0037] Specifically, after receiving a successful response from the trigger controller, the compute node returns a second confirmation signal (i.e., a successful trigger creation response) to the client in response to the first creation request.

[0038] Optionally, if a creation exception occurs during the creation of a trigger, the compute node will notify the trigger controller to delete the stored corresponding mapped data and return a failure response to the client.

[0039] This application is applied to distributed databases, and particularly to triggers in distributed databases.

[0040] This application provides a method for constructing triggers in a distributed database. The triggers are constructed through the interaction between the CN (Computer Node) and DTC (Distributed Trigger Controller) in the distributed database, so that the CN, DN (Data Node), and DTC in the distributed database can cooperate to realize the triggers in the distributed database.

[0041] Figure 2 This is a schematic diagram of the distributed database provided in this application. The client is the client, the CN is the compute node, the DTC is the trigger controller, and the DN is the data node. When the CN receives a request from the client to create a trigger, the CN interacts with the DTC to construct the trigger. When the CN receives a request from the client to trigger a trigger, the CN interacts with both the DN and the DTC to trigger the trigger. The metadata management module is used to push change information to other CNs when metadata changes, so as to enable data synchronization between the nodes.

[0042] As an optional embodiment, parsing the first creation request to obtain the parsing result includes: extracting the creation trigger statement from the first creation request; parsing the creation trigger statement to obtain the target database corresponding to the trigger, the table name of the table in the target database, the trigger ID of the table name, the trigger name, the trigger condition, and the trigger body; storing the trigger ID, trigger name, and trigger condition in the compute node; generating a trigger identifier code using the target database, table, and trigger ID, and using the trigger identifier code, trigger condition, and trigger body as the parsing result.

[0043] Specifically, relevant information about the trigger can be parsed from the trigger creation statement. On the one hand, the relevant information is stored in the compute node. On the other hand, a trigger identification code is further generated based on the target database, table, and trigger ID. Then, the trigger identification code, trigger condition, and trigger body are sent to the trigger controller as the parsing result.

[0044] Figure 3 The flowchart for creating a trigger provided in this application shows that in the diagram, client is the client, CN is the compute node, and DTC is the trigger controller. When CN receives a creation request from the client, the compute node creates the trigger by interacting with the trigger controller.

[0045] The triggers constructed using the scheme provided in this application are much simpler to trigger. With the participation of the trigger controller, a lot of processing logic is also shared by the computing nodes, which can simply and efficiently implement the distributed database trigger function.

[0046] As an optional embodiment, after the trigger is constructed, the method further includes: when the computing node receives a trigger request sent by the client, determining the trigger statement corresponding to the target statement in the trigger request; executing the trigger statement; sending the target statement to the data node through the computing node so that the target statement can be executed through the data node; and returning a trigger success signal in response to the trigger request to the client through the computing node.

[0047] Specifically, this application provides an embodiment of a trigger implementation described in the context of a pre-triggered trigger, but it can also be applied to a post-triggered trigger (which executes the SQL sent by the client first, and then executes the trigger SQL). This application does not limit this to the latter.

[0048] As an optional embodiment, when the computing node receives a trigger request sent by the client, determining the trigger statement corresponding to the target statement in the trigger request includes: determining whether a first trigger exists in the table corresponding to the target statement; if the first trigger exists, determining whether the target statement meets the triggering conditions; if the target statement meets the triggering conditions, generating a first identifier code corresponding to the first trigger; sending a query statement carrying the first identifier code to the data node through the computing node, so that the data node generates an execution trigger request corresponding to the query statement, and sending the execution trigger request to the trigger controller; and finding a trigger statement matching the first identifier code through the trigger controller according to the mapping relationship.

[0049] As an optional embodiment, executing a trigger statement includes: executing the trigger statement through a trigger controller; or sending the trigger statement to a compute node through a trigger controller, so that the compute node executes the trigger statement through a data node.

[0050] For example, when a compute node receives a trigger request from a client, it will determine whether there are triggers on the tables involved in the SQL in the trigger request based on the parsing results. If not, the statement will be sent to the data node for execution. If there are triggers, the compute node will determine whether the trigger conditions are met.

[0051] If the triggering conditions are met, the compute node sends a query statement to the data node to retrieve the data in the corresponding row of the table before the update. Then, it generates the query result, the new value of the corresponding row in the table after the update, and the first identifier key corresponding to the trigger, and sends the trigger execution request to the trigger controller. For example, if the pre-triggered trigger conditions for UPDATE are met, the compute node will generate the first identifier key corresponding to the trigger.

[0052] When the trigger controller receives a request from the compute node, it searches in the mapping relationship based on the first identifier. If it does not find the data, it returns a relevant failure response to the compute node. If it finds the data, it temporarily saves the data before and after the update of the corresponding row in the table, and then executes the trigger SQL (i.e., the trigger statement). If the SQL needs to be executed by the compute node, it sends the corresponding trigger SQL to the compute node for execution.

[0053] When a compute node receives a response from the trigger controller, if it is a failure response, it directly sends the client's SQL (target statement) to the data node for execution. Otherwise, the compute node first sends the trigger SQL from the trigger controller to the data node for execution, and after receiving all responses, it returns a success response to the trigger controller. Then, it sends the client's SQL to the data node for execution through the compute node.

[0054] The compute node sends a response back to the client indicating that execution is complete.

[0055] Figure 4 The flowchart for triggering the trigger provided in this application is shown. In the flowchart, client is the client, CN is the compute node, DTC is the trigger controller, and DN is the data node. The trigger is triggered by the interaction between the compute node and the trigger controller and the data node, respectively. The specific triggering process corresponds to the above-mentioned pre-trigger process.

[0056] As an optional embodiment, after the trigger is constructed, the method further includes: when the computing node receives a first deletion request sent by the client, determining whether there is a second trigger corresponding to the deletion request; if there is a second trigger, obtaining a second identifier code of the second trigger, and sending a second deletion request carrying the second identifier code to the trigger controller through the computing node; determining the target data that has a mapping relationship with the second identifier code through the trigger controller; deleting the target data, and returning a third confirmation signal responding to the second deletion request to the computing node through the trigger controller; the computing node generating a fourth confirmation signal based on the third confirmation signal, and returning a fourth confirmation signal responding to the first deletion request to the client.

[0057] For example, in step 1, when a compute node receives a request to delete a trigger from a client, it first checks if the trigger exists. If it does not exist, it sends a failure response to the client. If it exists, it sends a request to delete the trigger to the trigger controller.

[0058] Step 2: After receiving the request to delete the trigger, the trigger controller deletes the trigger-related information from the maintained trigger mapping based on the trigger-related key and sends a response back to the compute node.

[0059] Step 3: After receiving the response from the trigger controller, the compute node deletes the trigger ID, name, and condition information, and then sends a success response back to the client.

[0060] Figure 5 The flowchart for deleting a trigger provided in this application is shown. In the diagram, client is the client, CN is the compute node, and DTC is the trigger controller. When the compute node receives a deletion request from the client, the trigger is deleted through the interaction between the compute node and the trigger controller.

[0061] As an optional embodiment, the method further includes: if a change operation is performed on the metadata with a mapping relationship in the trigger controller, the change information corresponding to the change operation is sent to each computing node in the distributed database through the metadata management module, so that each computing node can synchronize the change information through the trigger controller.

[0062] The embodiments of this application are aimed at a certain computing node in a distributed database cluster. Considering that there may be multiple computing nodes in a distributed database cluster, the above creation of triggers is a DDL operation, which will cause metadata changes. Other computing nodes in the cluster will receive metadata change messages from the metadata management module, and then each computing node will push the metadata change messages to the corresponding trigger controller, so that the metadata in the entire cluster can be synchronized.

[0063] For example, if a table delete statement is executed and a trigger exists on the table, the trigger deletion process will also be triggered. The metadata changes caused by this operation will also be pushed to other compute nodes in the cluster by the metadata management module, and then each compute node will notify the corresponding trigger controller to update the information.

[0064] This application provides a method for constructing triggers in a distributed database, and the constructed triggers...

[0065] The generator enables simple and efficient distributed database implementation. Under the premise of distribution, its usage is no different from that of a single-machine database for 5 businesses, and no SQL modification is required for its use.

[0066] This application discloses a method for constructing a distributed database trigger, comprising: upon receiving a first creation request from a client on a computing node, parsing the first creation request to obtain a parsing result, wherein the parsing result includes the trigger identifier code of the trigger, the trigger...

[0067] The trigger condition and trigger body are defined; the parsing result is sent to the trigger controller as a second creation request; the trigger controller assigns the trigger identifier code and trigger condition to the second creation request.

[0068] The system establishes and stores the mapping relationship between the trigger body and the trigger, and responds to the second creation request by returning a first confirmation signal to the compute node; the compute node then responds to the first creation request by returning a second confirmation signal to the client, thus completing the construction of the trigger. This is achieved through the trigger controller and the compute node.

[0069] Interactions between nodes are used to build triggers, which can then be implemented through a trigger controller. This offloads the processing logic of computing nodes and solves the problem of triggering distributed data.

[0070] The device implements a relatively complex problem.

[0071] According to another aspect of the embodiments of this application, this application provides a distributed database.

[0072] The construction device of the trigger, such as Figure 6 As shown, it includes: a parsing module 602, used to parse the first creation request sent by the client when the computing node receives the first creation request, and obtain the parsing result, wherein the parsing result includes the trigger identifier code, trigger condition and trigger body of the trigger;

[0073] Sending module 604 is used to send the parsing result as a second creation request to the trigger controller.

[0074] Manufacturing tools;

[0075] 5. Mapping module 606 is used to establish and store the mapping relationship between the trigger identifier code, trigger condition and trigger body in the second creation request through the trigger controller, and to return a first confirmation signal to the computing node in response to the second creation request;

[0076] The response module 608 is used to return a second confirmation signal to the client in response to the first creation request by the computing node, so as to complete the construction of the trigger.

[0077] It should be noted that the parsing module 602 in this embodiment can be used to execute step 101 in this application embodiment, the sending module 604 in this embodiment can be used to execute step 103 in this application embodiment, the mapping module 606 in this embodiment can be used to execute step 105 in this application embodiment, and the response module 608 in this embodiment can be used to execute step 107 in this application embodiment.

[0078] Optionally, the first creation request is parsed to obtain the following parsing results: extracting the creation trigger statement from the first creation request; parsing the creation trigger statement to obtain the target database corresponding to the trigger, the table name of the table in the target database, the trigger ID of the table name, the trigger name, the trigger condition, and the trigger body; storing the trigger ID, trigger name, and trigger condition in the compute node; generating a trigger identifier code using the target database, table, and trigger ID, and using the trigger identifier code, trigger condition, and trigger body as the parsing results.

[0079] Optionally, the device further includes a trigger module, which includes:

[0080] The determination submodule is used to determine the trigger statement corresponding to the target statement in the trigger request after the trigger has been built and the compute node receives the trigger request sent by the client.

[0081] The execution submodule is used to execute trigger statements;

[0082] The sending submodule is used to send the target statement to the data node through the compute node so that the target statement can be executed through the data node; and to return a successful trigger signal to the client through the compute node to respond to the trigger request.

[0083] Optionally, the determining submodule is also used to determine whether a first trigger exists in the table corresponding to the target statement; if a first trigger exists, it is determined whether the target statement meets the triggering conditions; if the target statement meets the triggering conditions, a first identifier code corresponding to the first trigger is generated; a query statement carrying the first identifier code is sent to the data node through the compute node, so that the data node generates an execution trigger request corresponding to the query statement, and the execution trigger request is sent to the trigger controller; the trigger controller finds a trigger statement that matches the first identifier code according to the mapping relationship.

[0084] Optionally, the execution submodule is also used to execute trigger statements through the trigger controller; or, to send trigger statements to compute nodes through the trigger controller so that the compute nodes execute the trigger statements through the data nodes.

[0085] Optionally, the device further includes a deletion module, configured to, after completing the construction of the trigger, determine whether a second trigger corresponding to the deletion request exists when the computing node receives a first deletion request sent by the client; if a second trigger exists, obtain the second identifier code of the second trigger, and send a second deletion request carrying the second identifier code to the trigger controller through the computing node; determine the target data that has a mapping relationship with the second identifier code through the trigger controller; delete the target data, and return a third confirmation signal responding to the second deletion request to the computing node through the trigger controller; the computing node generates a fourth confirmation signal based on the third confirmation signal, and returns a fourth confirmation signal responding to the first deletion request to the client.

[0086] Optionally, the device further includes a synchronization module, which, if a change operation is performed on the metadata with a mapping relationship in the trigger controller, sends the change information corresponding to the change operation to each computing node in the distributed database through the metadata management module, so that each computing node can synchronize the change information through the trigger controller.

[0087] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments.

[0088] According to another aspect of the embodiments of this application, this application provides an electronic device, such as... Figure 7 As shown, the device includes a memory 701, a processor 703, a communication interface 705, and a communication bus 707. The memory 701 stores a computer program that can run on the processor 703. The memory 701 and the processor 703 communicate through the communication interface 705 and the communication bus 707. When the processor 703 executes the computer program, it implements the steps of the above method.

[0089] The memory and processor in the aforementioned electronic devices communicate with each other via a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0090] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0091] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0092] According to another aspect of the embodiments of this application, a computer-readable medium having processor-executable non-volatile program code is also provided.

[0093] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0094] In specific implementation, the embodiments of this application can be referred to the above embodiments and have corresponding technical effects.

[0095] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0096] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0097] 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, or a combination of computer software and electronic hardware. 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 implementation should not be considered beyond the scope of this application.

[0098] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0099] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0100] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0101] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0102] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. In the absence of further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0103] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for constructing a distributed database trigger, characterized in that, include: When the computing node receives the first creation request sent by the client, it parses the first creation request to obtain a parsing result, wherein the parsing result includes the trigger identifier code, trigger condition and trigger body of the trigger; The parsing result is sent as a second creation request to the trigger controller, wherein both the trigger controller and the computing node are components in the distributed database, and the trigger controller and the computing node have an interactive relationship; The trigger controller establishes and stores a mapping relationship between the trigger identifier, the trigger condition, and the trigger body in the second creation request, and returns a first confirmation signal to the computing node in response to the second creation request. This includes: extracting the trigger identifier, the trigger condition, and the trigger body from the second creation request; establishing the mapping relationship between the trigger identifier, the trigger condition, and the trigger body; saving the mapping relationship; and returning the first confirmation signal in response to the second creation request to the computing node. The computing node responds to the first creation request and returns a second confirmation signal to the client to complete the construction of the trigger.

2. The method according to claim 1, characterized in that, The parsing of the first creation request to obtain the parsing result includes: Extract the creation trigger statement from the first creation request; The trigger creation statement is parsed to obtain the target database corresponding to the trigger, the table name of the table in the target database, the trigger ID of the table name, the trigger name, the trigger condition, and the trigger body; The trigger ID, the trigger name, and the trigger condition are stored in the computing node; The trigger identifier code is generated using the target database, the table, and the trigger ID, and the trigger identifier code, the trigger condition, and the trigger body are used as the parsing result.

3. The method according to claim 1, characterized in that, After completing the construction of the trigger, the method further includes: When the computing node receives a trigger request sent by the client, it determines the trigger statement corresponding to the target statement in the trigger request; Execute the trigger statement; The target statement is sent to the data node through the computing node so that the target statement can be executed through the data node; The computing node returns a successful trigger signal to the client in response to the trigger request.

4. The method according to claim 3, characterized in that, When the computing node receives a trigger request sent by the client, determining the trigger statement corresponding to the target statement in the trigger request includes: Determine whether a first trigger exists in the table corresponding to the target statement; If the first trigger exists, then determine whether the target statement satisfies the triggering condition; If the target statement satisfies the triggering condition, a first identifier code corresponding to the first trigger is generated; The computing node sends a query statement carrying the first identifier to the data node, so that the data node generates an execution trigger request corresponding to the query statement, and sends the execution trigger request to the trigger controller. The trigger controller searches for a trigger statement that matches the first identifier code based on the mapping relationship.

5. The method according to claim 3, characterized in that, Executing the trigger statement includes: The trigger statement is executed through the trigger controller; or... The trigger controller sends the trigger statement to the compute node, so that the compute node executes the trigger statement through the data node.

6. The method according to claim 1, characterized in that, After completing the construction of the trigger, the method further includes: When the computing node receives the first deletion request sent by the client, it determines whether there is a second trigger corresponding to the deletion request; If the second trigger exists, obtain the second identifier code of the second trigger, and send a second deletion request carrying the second identifier code to the trigger controller through the computing node; The trigger controller determines the target data that has the mapping relationship with the second identifier code; The target data is deleted, and a third confirmation signal responding to the second deletion request is returned to the computing node through the trigger controller; The computing node generates a fourth confirmation signal based on the third confirmation signal and returns the fourth confirmation signal in response to the first deletion request to the client.

7. The method according to any one of claims 1 or 6, characterized in that, The method further includes: If the metadata in the trigger controller that contains the mapping relationship is changed, the metadata management module sends the change information corresponding to the change operation to each computing node in the distributed database, so that each computing node can synchronize the change information through the trigger controller.

8. A device for constructing distributed database triggers, characterized in that, include: The parsing module is used to parse the first creation request sent by the client when the computing node receives the first creation request to obtain the parsing result, wherein the parsing result includes the trigger identifier code, trigger condition and trigger body of the trigger; The sending module is used to send the parsing result as a second creation request to the trigger controller, wherein the trigger controller and the computing node are both components in the distributed database, and the trigger controller and the computing node have an interactive relationship; The mapping module is configured to establish and store a mapping relationship between the trigger identifier, the trigger condition, and the trigger body in the second creation request through the trigger controller, and to return a first confirmation signal to the computing node in response to the second creation request. The module includes: extracting the trigger identifier, the trigger condition, and the trigger body from the second creation request; establishing the mapping relationship between the trigger identifier, the trigger condition, and the trigger body; saving the mapping relationship; and returning the first confirmation signal in response to the second creation request to the computing node. The response module is used to respond to the first creation request by the computing node and return a second confirmation signal to the client to complete the construction of the trigger.

9. An electronic device comprising a memory, a processor, a communication interface, and a communication bus, wherein the memory stores a computer program executable on the processor, and the memory and the processor communicate via the communication bus and the communication interface, characterized in that... When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable medium having processor-executable non-volatile program code, characterized in that, The program code causes the processor to execute the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Collaborative triggers in distributed and dynamic computing systems

    US20190165993A1

  • Trigger implementing method and device

    WO2021103969A1