Block chain data processing method and device, electronic equipment and storage medium
By acquiring and classifying SQL transactions in the blockchain and using a locked signal mechanism to achieve parallel execution, the problem of low execution efficiency of blockchain SQL transactions is solved, and resource utilization and execution efficiency are improved.
Patent Information
- Application Number
- CN202510657575.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-06-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing blockchains are inefficient when executing SQL transactions, mainly due to serial execution, inadequate resource utilization.
By obtaining the blockchain's SQL transaction, determining the transaction type, and creating corresponding lock signals when non-data query transactions, to achieve efficient parallel execution of transactions.
Improve the execution efficiency of SQL transactions, and make full use of multi-core CPU resources by processing non-conflict transactions in parallel, avoiding the overhead of global locks and read and write sets.
Smart Images

Figure CN120216540A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of blockchain, and particularly relates to a method, device, electronic device and storage medium for processing blockchain data. Background Art
[0002] Currently, some blockchains have implemented the processing function of Structured Query Language (SQL) transactions, and can perform read and write operations on the state data on the blockchain based on SQL transactions. Like other transactions, the execution of SQL transactions on the blockchain requires the execution result of the SQL transactions in the block to be consistent with the result of sequential serial execution. Usually, blockchain SQL transactions are executed in a serial manner, resulting in low execution efficiency. Summary of the Invention
[0003] In view of the above problems, the embodiments of this application provide a method, device, electronic device and storage medium for processing blockchain data, which can achieve efficient parallel execution of SQL transactions.
[0004] In a first aspect, the embodiments of this application provide a method for processing blockchain data, the method includes: Obtain an SQL transaction from the blockchain; Determine the transaction type of the SQL transaction; When the transaction type is not a data query transaction, create a locking signal corresponding to the transaction type; Execute the SQL transaction or block the SQL transaction based on the locking signal corresponding to the transaction type.
[0005] In some embodiments, the executing or blocking the SQL transaction based on the locking signal corresponding to the transaction type includes: Determine whether there is at least one current SQL transaction being executed currently; When there is at least one current SQL transaction being executed, execute the SQL transaction or block the SQL transaction based on the locking signal corresponding to the transaction type of the at least one current SQL transaction and the locking signal corresponding to the transaction type; When there is no current SQL transaction being executed, execute the SQL transaction.
[0006] In some embodiments, the transaction types include: table creation transaction, table structure update transaction, data operation transaction, or data query transaction. The locking signal corresponding to the table creation transaction is the first locking signal, the locking signal corresponding to the table structure update transaction is the second locking signal, and the locking signal corresponding to the data operation transaction is the third locking signal. The first locking signal, the second locking signal, and the third locking signal are different from each other.
[0007] In some embodiments, executing or blocking the SQL transaction based on the locking signal corresponding to the transaction type of at least one current SQL transaction and the locking signal corresponding to the transaction type includes: When the locking signal corresponding to the transaction type of the target current SQL transaction in at least one current SQL transaction is the first locking signal, blocking the SQL transaction; When the locking signal corresponding to the transaction type of the target current SQL transaction in at least one current SQL transaction is not the first locking signal and there is no locking signal corresponding to the transaction type of the current SQL transaction being the first locking signal, blocking the SQL transactions that meet the preset conditions and executing the SQL transactions that do not meet the preset conditions, where the preset conditions include that the locking signal corresponding to the transaction type is the second locking signal or the third locking signal and the table account address of the SQL transaction is the same as the table account address of the target current SQL transaction.
[0008] In some embodiments, the method further includes: When the transaction type is a data query transaction, determining whether there is at least one current SQL transaction being executed currently; When there is a current SQL transaction being executed, executing or blocking the SQL transaction based on the transaction type of at least one current SQL transaction.
[0009] In some embodiments, executing or blocking the SQL transaction based on the transaction type of at least one current SQL transaction includes: When the transaction type of at least one current SQL transaction is a data query transaction, executing the SQL transaction; When the transaction type of the target current SQL transaction in at least one current SQL transaction is not a data query transaction, determining whether the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction. When the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction, blocking the SQL transaction. When the table account address corresponding to the current SQL transaction is not the same as the table account address corresponding to the SQL transaction, executing the SQL transaction.
[0010] In some embodiments, the method further includes: When blocking the SQL transaction and the target current SQL transaction is executed and completed, releasing the lock signal corresponding to the target current SQL transaction; When releasing the lock signal corresponding to the target current SQL transaction, sequentially executing the blocked SQL transactions.
[0011] In some embodiments, the executing the SQL transaction includes: When the SQL transaction is a table creation transaction, creating a table account corresponding to the SQL transaction, and writing metadata of the table under the table account corresponding to the SQL transaction; When the SQL transaction is a table structure update transaction, updating the metadata of the table for the table account corresponding to the SQL transaction, and adjusting the form data of the table; When the SQL transaction is a data operation update transaction, operating on the table of the table account corresponding to the SQL transaction.
[0012] In some embodiments, when there are multiple SQL transactions, obtaining the SQL transactions from the blockchain includes: obtaining multiple SQL transactions from the blockchain in parallel; Determining the transaction type of the SQL transaction includes: determining the transaction types of multiple SQL transactions in parallel; Creating the lock signal corresponding to the transaction type includes: creating the lock signal corresponding to the transaction type in parallel.
[0013] In some embodiments, determining the transaction type of the SQL transaction includes: Converting the statement of the SQL transaction into an abstract syntax tree; Determining the transaction type based on the abstract syntax tree.
[0014] In some embodiments, the method further includes: Recording the abstract syntax tree and the transaction type into the context of the SQL transaction.
[0015] In a second aspect, an embodiment of the present application provides a processing device for blockchain data, including: An obtaining module, configured to obtain SQL transactions from the blockchain; A compiling module, configured to determine the transaction type of the SQL transaction; A creating unit, configured to create a lock signal corresponding to the transaction type when the transaction type is not a data query transaction; An execution unit for executing the SQL transaction or blocking the SQL transaction based on the locking signal corresponding to the transaction type.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method provided in the first aspect is implemented.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the method provided in the first aspect above is implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product including a computer program, and when the computer program is executed by a processor, it is at least used to implement the method according to any one of the first aspect or the third aspect.
[0019] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: The method for processing blockchain data provided by the embodiments of the present application, by obtaining an SQL transaction from the blockchain; determining the transaction type of the SQL transaction; creating a locking signal corresponding to the transaction type when the transaction type is not a data query transaction; executing the SQL transaction or blocking the SQL transaction based on the locking signal corresponding to the transaction type, can achieve efficient parallel execution of SQL transactions.
[0020] It can be understood that the beneficial effects of the second to fifth aspects above can refer to the relevant descriptions in the first aspect, and will not be elaborated here. Description of the Drawings
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0022] Figure 1 It is a schematic flowchart of a method for processing blockchain data provided by an embodiment of the present application; Figure 2 It is a schematic structural diagram of a device for processing blockchain data provided by an embodiment of the present application; Figure 3 It is a schematic processing flowchart of a device for processing blockchain data provided by an embodiment of the present application; Figure 4Schematic structural diagram of the electronic device provided by the embodiment of the present application. Detailed implementation manners
[0023] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system architectures and technologies are presented to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0024] It should be understood that when used in the specification and claims of the present application, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0025] It should also be understood that the term "and / or" used in the specification and claims of the present application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0026] As used in the specification and claims of the present application, the term "if" can be interpreted as "when", "once", "in response to determining", or "in response to detecting" according to the context. Similarly, the phrases "if determined" or "if detected" can be interpreted as meaning "once determined", "in response to determining", "once detected", or "in response to detecting" according to the context.
[0027] In addition, in the description of the specification and claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0028] The reference to "one embodiment" or "some embodiments" etc. described in the specification of the present application means that a specific feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0029] Before introducing the embodiments of the present application, a brief introduction to the related technologies and the problems in the related technologies is given: Currently, some blockchains have implemented SQL functions and can perform read and write operations on the state data on the blockchain based on SQL transactions. When the blockchain executes an SQL transaction, similar to other transactions, it requires that the execution result of the SQL transaction in the block be consistent with the result of sequential serial execution. Usually, blockchain SQL transactions are executed in a serial manner, but the serial execution efficiency is low. To improve the execution efficiency, in related technologies, static analysis-based transaction parallelism or read-write set-based optimistic parallelism is used to process SQL transactions.
[0030] The method of static analysis-based transaction parallelism is as follows: In the intelligent contract transaction parallelism technology, static analysis is performed on the bytecode of the intelligent contract. Combining with the parameters input by the user, the state data that may be operated on is analyzed. For transactions that do not have an intersection of the operated state data, they can be divided into different groups for parallel execution. Since the intelligent contract language is relatively complex, it is impossible to accurately analyze the range of state data operated by a transaction, resulting in inaccurate grouping. Moreover, it is difficult to perform static analysis for SQL, and the effect of static analysis is not good, and the processing efficiency is low.
[0031] The method of read-write set-based optimistic parallelism is as follows: Optimistically execute all transactions in parallel. The state database will record the read-write sets involved in each transaction. For transactions with read-write set conflicts, they are re-executed in sequential order. In the field of intelligent contracts, the operations on state data are often key-value pair operations, and the content of their read-write sets is less and the records are simple. However, in the SQL field, a large number of range queries are involved, and it is difficult to record them through the method of read-write sets, and there is also a problem of low efficiency.
[0032] Based on the technical problems of related technologies, the embodiments of the present application provide a method for processing blockchain data that can be applied to an electronic device. The electronic device may include: mobile phone, tablet computer, wearable device, augmented reality (AR) / virtual reality (VR) device, notebook computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific type of the electronic device. The electronic device can be used as a node of the blockchain.
[0033] The embodiments of the present application provide a method for processing blockchain data, Figure 1 which is a schematic flowchart of a method for processing blockchain data provided by the embodiments of the present application. As Figure 1 shown, the method includes: Step S101, obtain an SQL transaction from the blockchain.
[0034] In the embodiments of the present application, an SQL transaction in a blockchain refers to a transaction request initiated by a user or a smart contract and containing SQL statements (such as CREATE TABLE, INSERT, SELECT, etc.). These transactions will be packed into blocks and executed by blockchain nodes.
[0035] In the embodiments of the present application, SQL transactions may come from user clients, smart contract calls, or cross-chain protocols. The blockchain network forwards the transaction SQL to nodes, enabling electronic devices to obtain the SQL transactions. Each SQL transaction needs to contain a unique number within the block for subsequent lock signal management. The transaction context is the core data structure during the execution process and runs through the entire processing process.
[0036] In the embodiments of the present application, there can be at least one SQL transaction. In the case of multiple SQL transactions, the SQL transactions from the blockchain can be obtained in parallel.
[0037] Step S102, determine the transaction type of the SQL transaction.
[0038] In the embodiments of the present application, the transaction type is a category divided according to the semantics of SQL statements, which directly affects the execution path and locking strategy. The transaction types can include: table creation transaction, table structure update transaction, data operation transaction, and data query transaction. Among them, a table creation transaction is a transaction containing a table creation SQL statement, and the main function of the table creation transaction is to create a new SQL table account and store metadata under the SQL table account. A table structure update transaction is a transaction containing a table structure update SQL statement (such as adding a column, deleting a column, adding an index, deleting an index, etc.). The table structure update transaction is mainly used to update the metadata under the corresponding SQL table account and update the form data according to the new metadata. A data operation transaction is a transaction containing a data operation SQL statement (such as INSERT, UPDATE, DELETE statements), and the main function of the data operation transaction is to query / update / delete form data in the specified SQL table account. A data query transaction is a transaction containing a data query SQL statement (SELECT statement), and the main function of the data query transaction is to read the form data under the specified SQL table account.
[0039] In the embodiments of the present application, the SQL statement can be parsed to generate an Abstract Syntax Tree (AST). Traverse the AST to identify the operation type (such as CREATE, SELECT keywords), thereby obtaining the transaction type. After obtaining the transaction type, the transaction type can be recorded in the context of the transaction.
[0040] In the embodiments of the present application, when there are multiple SQL transactions, the transaction types of the SQL transactions can be determined in parallel.
[0041] Step S103, when the transaction type is not a data query transaction, create a lock signal corresponding to the transaction type.
[0042] In the embodiments of the present application, the lock signal is a synchronization mechanism for coordinating parallel transactions, ensuring that conflicting transactions are executed in a serial order. The transaction types include: table creation transaction, table structure update transaction, data operation transaction, or data query transaction. The lock signal corresponding to the table creation transaction is the first lock signal, the lock signal corresponding to the table structure update transaction is the second lock signal, and the lock signal corresponding to the data operation transaction is the third lock signal. The first lock signal, the second lock signal, and the third lock signal are different from each other. Since the data query transaction does not require a lock signal to be established, the lock signals are divided into three categories: the first lock signal, the second lock signal, and the third lock signal. The first lock signal can be represented as lock signal a, and lock signal a is exclusive to the table creation transaction, preventing concurrent creation of tables, modification of table structures, data operations on tables, and data queries. If there is a corresponding first lock signal in the current SQL transaction being executed, then all table creation transactions, table structure update transactions, data operation transactions, and data query transactions are blocked. This locking mechanism ensures the atomicity and consistency of table creation and structure change operations, preventing problems caused by concurrent access during table creation. The second lock signal can be lock signal b, and lock signal b is exclusive to the table structure update transaction, preventing concurrent modification of the table structure and operations and queries on the data in the table. That is, if there is a second lock signal, then the table structure update transaction, data operation transaction, and data query transaction on this table are all blocked. The third lock signal can be lock signal c, and lock signal c is exclusive to the data operation transaction, preventing concurrent operations and data queries on the data in the table. That is, if there is a third lock signal, then the data operation transaction and data query transaction on this table are blocked.
[0043] In the embodiments of the present application, when the transaction type is a table creation transaction, create the first lock signal; when the transaction type is a table structure update transaction, create the second lock signal; when the transaction type is a data operation transaction, create the third lock signal.
[0044] In the embodiments of the present application, the first lock signal can be represented as: [transaction number, lock signal a]. For example, [tx2, lock signal a]. The second lock signal can be represented as: [transaction number, lock signal b, table account address]. The third lock signal can be represented as: [transaction number, lock signal c, table account address].
[0045] In the embodiments of the present application, the data query transaction does not need to create a lock signal because the data query transaction does not modify the state.
[0046] Step S104, execute the SQL transaction or block the SQL transaction based on the locking signal corresponding to the transaction type.
[0047] In the embodiment of the present application, by checking the locking signal conflict, it is determined whether the SQL transaction is executed immediately or blocked and waiting.
[0048] In the embodiment of the present application, for the blocked transaction, the transaction is put into the blocking queue and the signal it waits for is recorded. When the corresponding locking signal is released, all blocked transactions depending on the locking signal are awakened. The awakened transactions retry to execute. After the transaction execution is completed, all locking signals held by the transaction can be deleted, so as to release the locking signal. For the executed transaction, it is executed immediately.
[0049] Exemplarily, assume the transaction order within the block: tx1: delete a record of t1 (data operation transaction, requires signal c(addr1)). tx2: create table t4 (table creation transaction, requires signal a). tx3: add a column to t2 (table structure update transaction, requires signal b(addr2)). tx1 creates the locking signal c(addr1) and executes. tx2 creates the locking signal a and executes. tx3 creates the locking signal b(addr2) and executes. If tx4 (update the data of t1) is inserted at this time, it needs to create the lock c(addr1), but tx1 has not been released yet, so tx4 is blocked until tx1 is completed, and those without locking signal conflicts are executed in parallel.
[0050] In the embodiment of the present application, through the transaction type classification and the dynamic locking signal mechanism, safe parallel execution can be achieved, non-conflicting transactions are executed in a pipeline, conflicting transactions are blocked in order, avoiding the overhead of global locks or read-write sets, and making full use of multi-core CPUs.
[0051] The method provided by the embodiment of the present application can realize the efficient parallel execution of SQL transactions by obtaining the SQL transaction from the blockchain; determining the transaction type of the SQL transaction; creating the locking signal corresponding to the transaction type when the transaction type is not a data query transaction; and executing the SQL transaction or blocking the SQL transaction based on the locking signal corresponding to the transaction type.
[0052] In some embodiments, step S104 can be implemented by the following steps: Step S1041, determine whether there is at least one current SQL transaction that is being executed currently.
[0053] In the embodiments of the present application, an electronic device may maintain a global active transaction table to record the transaction numbers, lock signals, and transaction types of all currently executing SQL transactions. The current SQL transaction is an instance of an SQL transaction being processed by a blockchain node and includes a unique transaction number and an SQL statement. There may be one or more current SQL transactions. For example, when a table creation transaction and a data update transaction are being processed, this transaction is the "current SQL transaction". By determining whether such a transaction exists, it is decided whether subsequent SQL transactions can be executed or need to be blocked. Each time a new SQL transaction is received, it is checked whether there are unfinished transactions in the queue.
[0054] Step S1042, in the case where there is a currently executing current SQL transaction, execute the SQL transaction or block the SQL transaction based on the lock signal corresponding to the transaction type of at least one current SQL transaction and the lock signal corresponding to the transaction type.
[0055] In the embodiments of the present application, if the lock signal corresponding to the transaction type of the current SQL transaction is the first lock signal, then all SQL transactions are blocked. If the lock signal corresponding to the transaction type of the current SQL transaction is not the first lock signal, it is necessary to determine whether to execute or block the SQL transaction by combining the table account address of the current SQL transaction and the table account address of the SQL transaction. If the SQL transaction is to be executed, the current SQL transaction and the SQL transaction are executed in parallel.
[0056] Step S1043, in the case where there is no currently executing current SQL transaction, execute the SQL transaction.
[0057] In some embodiments, Step S1042 may be implemented by the following steps: Step S1, in the case where the lock signal corresponding to the transaction type of the target current SQL transaction in at least one current SQL transaction is the first lock signal, block the SQL transaction.
[0058] In the embodiments of the present application, if the lock signal corresponding to the transaction type of the target current SQL transaction exists and is the first lock signal, then there is a table creation transaction during the current execution. In order to exclusively occupy resources and prevent other transactions from interfering with the table structure, the SQL transaction is blocked.
[0059] Step S2, when the locking signal corresponding to the transaction type of the target current SQL transaction in at least one current SQL transaction is not the first locking signal and there is no locking signal corresponding to the transaction type of the current SQL transaction being the first locking signal, block the SQL transactions that meet the preset conditions and execute the SQL transactions that do not meet the preset conditions, where the preset conditions include that the locking signal corresponding to the transaction type is the second locking signal or the third locking signal and the table account address of the SQL transaction is the same as the table account address of the target current SQL transaction.
[0060] In the embodiment of the present application, if the locking signal corresponding to the transaction type of the target current SQL transaction is not the first locking signal and there is no locking signal corresponding to the transaction type of the current SQL transaction being the first locking signal, then the target current SQL transaction is a table structure update transaction or a data operation transaction. The table account address can be realized through the following steps: determine the table name corresponding to the transaction. Then query the status database based on the table name to obtain the table account address corresponding to the table name.
[0061] In the embodiment of the present application, the table name is the unique identifier of the target table specified in the transaction, and the table name can be extracted from the SQL transaction. The status database is a core component in the blockchain system and is used to store global status information. The status database includes: the mapping relationships between the table name and the table account address, the table structure, the data content, etc. By querying the status database with the table name, the table account address corresponding to the table name can be obtained.
[0062] In the embodiment of the present application, the table account address is the unique identifier assigned to each table in the blockchain system, which is used to distinguish different tables and avoid transaction conflicts. The table account address of the SQL transaction can be compared with the table account address of the target current SQL transaction. If the table account addresses are the same, it means that the same table is being operated on. At this time, to avoid transaction conflicts, the SQL transaction is blocked. If the table account addresses are different, it means that different tables are being operated on, then the SQL transaction is executed, and at this time, multiple SQL transactions can be executed in parallel.
[0063] The method provided in the embodiment of the present application realizes parallel execution or blocking through the locking signal and in combination with the table account address. It can efficiently and safely process table structure update transactions and data operation transactions, avoid conflicts and ensure data consistency.
[0064] In some embodiments, after step S102, the method further includes: Step S105, when the transaction type is a data query transaction, determine whether there is at least one current SQL transaction that is being executed.
[0065] In the embodiments of the present application, for a data query transaction, there is no need to create a lock signal. Instead, it is directly determined whether there is a currently executing SQL transaction.
[0066] Step S106, in the case that there is a currently executing SQL transaction, execute the SQL transaction or block the SQL transaction based on the transaction type of at least one current SQL transaction.
[0067] In the embodiments of the present application, in the case that the transaction type of at least one current SQL transaction is a data query transaction, execute the SQL transaction. Since they are all data query transactions, they can be executed in parallel.
[0068] In the embodiments of the present application, in the case that the transaction type of the target current SQL transaction in at least one current SQL transaction is not a data query transaction, determine whether the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction. In the case that the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction, block the SQL transaction. In the case that the table account address corresponding to the current SQL transaction is different from the table account address corresponding to the SQL transaction, execute the SQL transaction.
[0069] In the embodiments of the present application, it is also possible to determine whether the transaction type is a data query transaction by judging whether there is a corresponding lock signal for each current SQL transaction. If there is no lock signal, it is determined that the current SQL transaction is a data query transaction. If there is a lock signal, it is determined that the current SQL transaction is not a data query transaction.
[0070] In some embodiments, the method further includes: Step S107, in the case of blocking the SQL transaction and after the target current SQL transaction is executed, release the lock signal corresponding to the target current SQL transaction.
[0071] In the embodiments of the present application, after the current target transaction is executed, the lock signal needs to be released.
[0072] Step S108, in the case of releasing the lock signal corresponding to the target current SQL transaction, sequentially execute the blocked SQL transactions.
[0073] In the embodiments of the present application, when the lock signal corresponding to the current SQL transaction is released, the transactions in the blocking queue need to be sequentially executed. Transactions can be taken out from the blocking queue and executed until the blocking queue is empty.
[0074] The method provided in the embodiments of the present application can efficiently manage table name conflicts, ensure that transactions are executed in order, and avoid data inconsistency.
[0075] In some embodiments, executing the SQL transaction includes: Step S1, when the SQL transaction is a table creation transaction, create a table account corresponding to the SQL transaction, and write the metadata of the table under the table account corresponding to the SQL transaction.
[0076] In the embodiments of the present application, metadata describes information about the table structure, including the name of the table, column definitions, indexes, constraints, etc. The content of the metadata may include: table name, table owner, creation time, column name, data type, whether null is allowed, default value, primary key, foreign key, unique constraint, index information (index name, index type, index column), etc. In the embodiments of the present application, a new record is inserted into the TableAccounts table to initialize the table account. Write metadata: Write the metadata of the table (such as column definitions, indexes, etc.) into the metadata field of the table account, and then create the corresponding table structure in the database.
[0077] Step S2, when the SQL transaction is a table structure update transaction, update the metadata of the table for the table account corresponding to the SQL transaction, and adjust the form data of the table.
[0078] In the embodiments of the present application, the table structure update transaction may be adding columns, deleting columns, modifying column types, etc. The user modifies the form data through data operation transactions (such as insert, update, delete).
[0079] Step S3, when the SQL transaction is a data operation update transaction, operate on the table of the table account corresponding to the SQL transaction.
[0080] In the embodiments of the present application, the data update transaction may be operating on the data in the table (such as inserting, updating, deleting records).
[0081] In some embodiments, when there are multiple SQL transactions, obtaining the SQL transactions from the blockchain includes: obtaining multiple SQL transactions from the blockchain in parallel.
[0082] In the embodiments of the present application, the API of the blockchain is used to extract transaction data from blockchain nodes. Data can be extracted from multiple nodes or multiple blocks in parallel to improve efficiency.
[0083] In some embodiments, determining the transaction type of the SQL transaction includes: determining the transaction types of multiple SQL transactions in parallel.
[0084] In the embodiments of the present application, the transaction types of multiple SQL transactions can be determined in parallel through multi-threading, multi-processing, or a distributed computing framework.
[0085] In some embodiments, creating the locking signal corresponding to the transaction type includes: creating the locking signal corresponding to the transaction type in parallel.
[0086] In the embodiments of the present application, the locking signal corresponding to the transaction type can be created in parallel through multi-threading, multi-processing, or a distributed computing framework.
[0087] In some embodiments, step S102 of determining the transaction type of the SQL transaction can be implemented through the following steps: Step S1021: Convert the statement of the SQL transaction into an abstract syntax tree.
[0088] In the embodiments of the present application, an SQL parser is used to parse the SQL statement into an abstract syntax tree. The SQL parser can parse the SQL statement into a tree structure, and each node represents a part of the SQL statement (such as keywords, table names, column names, operators, etc.).
[0089] Step S1022: Determine the transaction type based on the abstract syntax tree.
[0090] In the embodiments of the present application, the abstract syntax tree is traversed using depth-first search or breadth-first search. During the traversal process, the type of each node is checked, and the transaction type is determined based on the type of each node.
[0091] The method provided by the embodiments of the present application can effectively convert the SQL transaction statement into an abstract syntax tree and determine the transaction type based on the abstract syntax tree.
[0092] In some embodiments, after step S102, the method further includes: Step S109: Record the abstract syntax tree and the transaction type into the context of the SQL transaction.
[0093] In the embodiments of the present application, the context is a data structure (such as a class or a dictionary) to store the relevant information of the SQL transaction, including the abstract syntax tree and the transaction type. After obtaining the abstract syntax tree and the transaction type, they can be recorded into the context. The abstract syntax tree and the transaction type can be recorded into the context of the SQL transaction, providing an important basis for subsequent processing.
[0094] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0095] According to the foregoing embodiments, an embodiment of the present application provides a processing device for blockchain data. Each module included in the device and each unit included in each module can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits. During implementation, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0096] An embodiment of the present application provides a processing device for blockchain data. Figure 2 FIG. [FIG. number not provided in the original] is a schematic structural diagram of a processing device for blockchain data provided by an embodiment of the present application. As Figure 2 shown, the processing device 200 for blockchain data includes: An acquisition module 201, configured to acquire SQL transactions from a blockchain; A compilation module 202, configured to determine the transaction type of the SQL transaction; A creation module 203, configured to create a locking signal corresponding to the transaction type when the transaction type is not a data query transaction; An execution module 204, configured to execute the SQL transaction or block the SQL transaction based on the locking signal corresponding to the transaction type.
[0097] In some embodiments, the execution module 204 includes: A first determination unit, configured to determine whether there is at least one current SQL transaction being executed currently; A second determination unit, configured to execute the SQL transaction or block the SQL transaction based on the locking signal corresponding to the transaction type of at least one current SQL transaction and the locking signal corresponding to the transaction type when there is at least one current SQL transaction being executed; A first execution unit, configured to execute the SQL transaction when there is no current SQL transaction being executed.
[0098] In some embodiments, the transaction type includes: a table creation transaction, a table structure update transaction, a data operation transaction, or a data query transaction. The locking signal corresponding to the table creation transaction is a first locking signal, the locking signal corresponding to the table structure update transaction is a second locking signal, and the locking signal corresponding to the data operation transaction is a third locking signal. The first locking signal, the second locking signal, and the third locking signal are different from each other.
[0099] In some embodiments, the second determination unit includes: A blocking subunit, configured to block the SQL transaction when there is a locking signal corresponding to the transaction type of the target current SQL transaction being the first locking signal in at least one current SQL transaction; An execution subunit, configured to, when there is no locking signal corresponding to the transaction type of the target current SQL transaction being the first locking signal and there is no locking signal corresponding to the transaction type of the current SQL transaction being the first locking signal in at least one current SQL transaction, block the SQL transactions that meet the preset conditions and execute the SQL transactions that do not meet the preset conditions, where the preset conditions include that the locking signal corresponding to the transaction type is the second locking signal or the third locking signal, and the table account address of the SQL transaction is the same as the table account address of the target current SQL transaction.
[0100] In some embodiments, the blockchain data processing apparatus 200 further includes: A determination module, configured to determine whether there is at least one current SQL transaction being executed currently when the transaction type is a data query transaction; A transaction processing module, configured to, when there is a current SQL transaction being executed, execute the SQL transaction or block the SQL transaction based on the transaction type of at least one current SQL transaction.
[0101] In some embodiments, the transaction processing module includes: A second execution unit, configured to execute the SQL transaction when the transaction type of at least one current SQL transaction is a data query transaction; A transaction processing unit, configured to, when the transaction type of the target current SQL transaction in at least one current SQL transaction is not a data query transaction, determine whether the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction, block the SQL transaction when the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction, and execute the SQL transaction when the table account address corresponding to the current SQL transaction is not the same as the table account address corresponding to the SQL transaction.
[0102] In some embodiments, the blockchain data processing apparatus further includes: A release module, configured to release the locking signal corresponding to the target current SQL transaction when the SQL transaction is blocked and the target current SQL transaction is executed; A sequential execution module, configured to sequentially execute the blocked SQL transactions when the locking signal corresponding to the target current SQL transaction is released.
[0103] In some embodiments, performing the SQL transaction includes: When the SQL transaction is a table creation transaction, creating a table account corresponding to the SQL transaction and writing metadata of the table under the table account corresponding to the SQL transaction; When the SQL transaction is a table structure update transaction, updating the metadata of the table for the table account corresponding to the SQL transaction and adjusting the form data of the table; When the SQL transaction is a data operation update transaction, operating on the table of the table account corresponding to the SQL transaction.
[0104] In some embodiments, when there are multiple SQL transactions, obtaining SQL transactions from the blockchain includes: obtaining multiple SQL transactions from the blockchain in parallel; Determining the transaction type of the SQL transaction includes: determining the transaction types of multiple SQL transactions in parallel; Creating a locking signal corresponding to the transaction type includes: creating a locking signal corresponding to the transaction type in parallel.
[0105] In some embodiments, the compilation module includes: A conversion unit for converting the statements of the SQL transaction into an abstract syntax tree; A third determination unit for determining the transaction type based on the abstract syntax tree.
[0106] In some embodiments, the processing device for blockchain data further includes: A recording module for recording the abstract syntax tree and the transaction type into the context of the SQL transaction.
[0107] In the embodiments of the present application, the above-mentioned respective modules are independent threads. Each module can be regarded as a node of a pipeline, and the nodes can be executed in parallel, enabling parallel execution of the pipeline.
[0108] Based on the aforementioned processing device for blockchain data, the embodiments of the present application further provide a processing device for blockchain data, as Figure 3 shown, Figure 3 is a schematic diagram of the processing flow of a processing device for blockchain data provided by the embodiments of the present application. As Figure 3 shown, the inside of the processing device for blockchain data can be divided into 5 units, and each unit is an independent thread. The 5 units include: an SQL transaction management unit, a compilation unit, a table account gap unit, a planning unit, and an execution unit.
[0109] In the embodiment of the present application, the SQL transaction management unit receives SQL transactions from the blockchain and returns the execution of the SQL transactions to the upper layer. The specific processing of the SQL transaction management unit includes: Receiving an SQL transaction from the blockchain. Initializing the transaction context, and passing the SQL transaction to the compilation unit for execution. After the corresponding SQL transaction is executed completely, the SQL execution result will be obtained from the execution unit. Releasing the lock signal corresponding to the SQL transaction. The SQL transaction has a unique number within a block, and the lock signal corresponding to the SQL transaction number is released. If there is an SQL transaction blocked by the lock signal, wake up the SQL transaction to continue its execution. Constructing the return result of the SQL transaction and returning it to the upper layer.
[0110] In the embodiment of the present application, the compilation unit is at least used to convert SQL statements into an abstract syntax tree. The specific processing of the compilation unit includes: receiving an SQL transaction from the SQL transaction management unit; converting the SQL statement into an abstract syntax tree and recording it in the transaction context. Judging the SQL transaction type based on the abstract syntax tree and recording it in the transaction context. If the SQL transaction belongs to a table creation transaction, create a lock signal a with the content [transaction number, lock signal a]. Perform synchronization coordination a. Check whether there is a lock signal a created by other transactions (that is, the transaction number of the lock signal is not equal to the current transaction number): if there is a lock signal a, block the current SQL transaction. After the lock signal a is released, sequentially pass the blocked SQL transactions to the table account pre-analysis unit; if there is no lock signal a, pass the current SQL transaction to the table account pre-analysis unit.
[0111] In the embodiment of the present application, the specific processing of the table account pre-analysis unit includes: Step 1, receiving an SQL transaction from the compilation unit.
[0112] Step 2, if the SQL transaction belongs to a table creation transaction, create a corresponding table account for the table to be created, obtain the corresponding account address, and enter step 5.
[0113] Step 3, if the SQL transaction belongs to a table structure update transaction, find the table name of the structure to be updated from the abstract syntax tree nodes, query the status database, find the table account address corresponding to the table name, and record it in the context. Create a lock signal b with the content [transaction number, lock signal b, table account address].
[0114] Step 4, if the SQL transaction belongs to a data operation transaction or a data query transaction, traverse the abstract syntax tree to identify all table nodes. The table name is recorded in the table nodes. Query the status database to find the table account addresses corresponding to these table names and record them in the context.
[0115] Step 5, perform synchronization coordination b. In this step, it is necessary to check whether there is a lock signal b created by other transactions (i.e., the transaction number of the lock signal is not equal to the current transaction number): If there is a lock signal b and there is an intersection between the table account address in the lock signal b and the table account address in the context, block the current SQL transaction. After the lock signal b corresponding to the table account address is released, sequentially pass the blocked SQL transactions to the planning unit; otherwise, pass the current SQL transaction to the planning unit.
[0116] In the embodiment of the present application, the specific processing of the planning unit includes: Step 1, receive the SQL transaction from the table account pre-analysis unit.
[0117] Step 2, if the SQL transaction belongs to a table creation transaction or a table structure update transaction, directly create a plan and create a corresponding executor, and enter Step 5.
[0118] Step 3, if the SQL transaction belongs to a data operation transaction or a data query transaction, read the account information corresponding to the table account address in the context from the status database, which includes the metadata of the table. Based on the metadata of the table and the abstract syntax tree, construct a plan and create a corresponding executor, and enter Step 4.
[0119] Step 4, if the SQL transaction belongs to a data operation transaction. Create a lock signal c for each table account address in the context, with the content [transaction number, lock signal c, table account address].
[0120] Step 5, perform synchronization coordination c. Check whether there is a lock signal c created by other transactions (i.e., the transaction number of the lock signal is not equal to the current transaction number): If there is a lock signal c and there is an intersection between the table account address in the lock signal c and the table account address in the context, block the current SQL transaction. After the lock signal c corresponding to the table account address is released, sequentially pass the blocked SQL transactions to the execution unit; otherwise, pass the current SQL transaction to the execution unit.
[0121] In the embodiment of the present application, the specific processing of the execution unit includes: Step 1, receive the SQL transaction from the planning unit.
[0122] Step 2, if the SQL transaction belongs to a table creation transaction, write the metadata of the table to the newly created table account, and enter Step 6.
[0123] Step 3, if the SQL transaction belongs to a table structure update transaction, update the metadata of the table to the target table account and adjust the corresponding form data, and enter Step 6.
[0124] Step 4, if the SQL transaction belongs to a data operation transaction, insert / update / delete the eligible form data into the target table account, and proceed to Step 6.
[0125] Step 5, if the SQL transaction belongs to a data query transaction, query the eligible form data from the target table account, and proceed to Step 6.
[0126] Step 6, record the execution result in the context, and pass the current SQL transaction to the SQL transaction management unit.
[0127] The SQL transaction management unit is responsible for releasing the lock signal corresponding to the SQL transaction, releasing the lock signal corresponding to the SQL transaction number, and waking up the blocked SQL transaction. Finally, construct the return result of the SQL transaction.
[0128] Exemplarily, there are 3 table accounts in the current state database. Table 1 is a schematic table of a table account provided by an embodiment of the present application, as shown in Table 1.
[0129] Table 1 is a schematic table of a table account provided by an embodiment of the present application
[0130] Assume that there are multiple transactions in the current block. Table 2 is a schematic table of an SQL transaction provided by an embodiment of the present application, as shown in Table 2. Table 2 is a schematic table of an SQL transaction provided by an embodiment of the present application
[0131] In the embodiment of the present application, the execution status of each unit can be observed in multiple stages. To simplify the description of the pipeline, it is assumed here that the time consumed by each unit is the same, and within the time of each stage, exactly each unit completes the current task. In an actual scenario, the time consumed by each unit is different. For example, when the compilation unit compiles the SQL of tx1, the SQL transaction management unit may have completed the context initialization of tx2, tx3, and tx4.
[0132] Table 3 is a schematic table of the execution process of an SQL transaction provided by an embodiment of the present application, as shown in Table 3. Table 3 is a schematic table of the execution process of an SQL transaction provided by an embodiment of the present application
[0133] It can be seen that according to the operation mode of the SQL transaction provided by the embodiments of the present application, it takes 14 stages to complete the execution of all transactions. If the serial mode is adopted, it takes 5 * 7 = 35 stages to complete. Based on a blockchain data processing device provided by the embodiments of the present application, the execution efficiency can be improved.
[0134] The blockchain data processing device provided by the embodiments of the present application has a definite final result during parallel execution, which is consistent with the result of serial execution. There is no need to detect read-write sets, which is efficient and secure. According to the execution characteristics of blockchain SQL and the account model of the blockchain, the execution of blockchain SQL transactions is divided into 5 units, and the units can be executed in parallel in a pipeline.
[0135] In the embodiments of the present application, parallel execution is introduced inside a single unit: For example, in the execution unit, if there are multiple data query transactions, these data query transactions can be parallel, or transactions operating on different table accounts can be parallel. In the planning unit, data operation transactions and data query transactions can be parallel. Taking the above example as an example, the compilation unit can compile tx1~tx7 concurrently, as long as the synchronization and coordination are finally carried out in the order of tx1~tx7.
[0136] In the embodiments of the present application, if parallel execution inside the unit is achieved, a certain degree of parallel execution of SQL transactions can be achieved under a more strict signal locking mechanism.
[0137] In addition, Figure 2 The shown blockchain data processing device can be a software unit, a hardware unit, or a combination of software and hardware built into an existing electronic device, can also be integrated into the electronic device as an independent pendant, or can exist as an independent terminal device.
[0138] It should be noted that for the content such as information interaction and execution process between the above-mentioned devices / units, since it is based on the same concept as the method embodiments of the present application, the specific functions and the technical effects brought by them can be specifically referred to in the method embodiment part, and will not be elaborated here.
[0139] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiment and will not be elaborated here.
[0140] Figure 4 The following is a schematic structural diagram of the electronic device provided by the embodiment of this application. As Figure 4 shown, the electronic device 3 in this embodiment may include: at least one processor 30 ( Figure 4 only one processor 30 is shown in the figure), a memory 31, and a computer program 32 stored in the memory 31 and executable on at least one processor 30. When the processor 30 executes the computer program 32, the steps in any of the foregoing method embodiments are implemented, or when the processor 30 executes the computer program 32, the functions of each module / unit in the foregoing device embodiments are implemented.
[0141] Exemplarily, the computer program 32 can be divided into one or more modules / units. One or more modules / units are stored in the memory 31 and executed by the processor 30 to complete this application. One or more modules / units can be a series of computer program 32 instruction segments capable of completing specific functions, and these instruction segments are used to describe the execution process of the computer program 32 in the electronic device 3.
[0142] The embodiment of this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program 32, and when the computer program 32 is executed by the processor 30, the steps in any of the foregoing method embodiments can be implemented.
[0143] The embodiment of this application provides a computer program product. When the computer program product runs on an electronic device, the electronic device is enabled to implement the steps in any of the foregoing method embodiments when executed.
[0144] When the integrated unit is implemented in the form of 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, to implement all or part of the processes in the above-described embodiment methods of the present application, a computer program 32 can be used to instruct relevant hardware to complete. The computer program 32 can be stored in a computer-readable storage medium. When the computer program 32 is executed by a processor 30, the steps of the above-described various method embodiments can be implemented. Among them, the computer program 32 includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the terminal, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0145] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0146] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0147] In the embodiments provided in the present application, it should be understood that the disclosed device / network device and method can be implemented in other ways. For example, the device / network device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in an electrical, mechanical, or other form.
[0148] The unit described as a separation component may or may not be physically separated. The component displayed as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0149] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
[0150] In each embodiment of the present application, the relevant user personal information that may be involved is all processed in strict accordance with the requirements of laws and regulations, following the principles of legality, legitimacy, and necessity, and for reasonable purposes based on business scenarios, the personal information actively provided by the user during the use of the product / service or generated due to the use of the product / service, as well as the personal information obtained with the user's authorization.
[0151] The user personal information processed by the applicant will vary depending on the specific product / service scenario, and it is necessary to be subject to the specific scenario of the user's use of the product / service. It may involve the user's account information, device information, driving information, vehicle information, or other relevant information. The applicant will treat the user's personal information and its processing with a high degree of diligence.
[0152] The applicant attaches great importance to the security of user personal information and has taken security protection measures that meet industry standards and are reasonable and feasible to protect the user's information and prevent personal information from being accessed, publicly disclosed, used, modified, damaged, or lost without authorization.
Claims
1. A method for processing blockchain data, characterized in that: include: Get SQL transactions from the blockchain; Determine the transaction type of the SQL transaction; When the transaction type is not a data query transaction, creating a lock signal corresponding to the transaction type; The SQL transaction is executed or blocked based on a lock signal corresponding to the transaction type.
2. The method according to claim 1, characterized in that The executing the SQL transaction or blocking the SQL transaction based on the lock signal corresponding to the transaction type includes: Determine whether there is at least one current SQL transaction currently being executed; In the case where there is at least one current SQL transaction being executed, executing the SQL transaction or blocking the SQL transaction based on a lock signal corresponding to a transaction type of the at least one current SQL transaction and a lock signal corresponding to the transaction type; In the absence of a current SQL transaction being executed, the SQL transaction is executed.
3. The method according to claim 2, characterized in that The transaction types include: table creation transaction, table structure update transaction, data operation transaction or data query transaction. The lock signal corresponding to the table creation transaction is a first lock signal, the lock signal corresponding to the table structure update transaction is a second lock signal, and the lock signal corresponding to the data operation transaction is a third lock signal. The first lock signal, the second lock signal and the third lock signal are different from each other.
4. The method according to claim 3, characterized in that The executing the SQL transaction or blocking the SQL transaction based on a lock signal corresponding to a transaction type of at least one current SQL transaction and a lock signal corresponding to the transaction type includes: When there is a lock signal corresponding to the transaction type of the target current SQL transaction in at least one current SQL transaction and the lock signal is the first lock signal, blocking the SQL transaction; In at least one current SQL transaction, there is a lock signal corresponding to the transaction type of the target current SQL transaction that is not the first lock signal and there is no lock signal corresponding to the transaction type of the current SQL transaction that is the first lock signal, blocking SQL transactions that meet preset conditions, and executing SQL transactions that do not meet the preset conditions, wherein the preset conditions include that the lock signal corresponding to the transaction type is the second lock signal or the third lock signal, and the table account address of the SQL transaction is the same as the table account address of the target current SQL transaction.
5. The method according to claim 1, characterized in that The method further comprises: In the case where the transaction type is a data query transaction, determining whether there is at least one current SQL transaction being executed; In the case that there is a current SQL transaction being executed, the SQL transaction is executed or blocked based on a transaction type of at least one current SQL transaction.
6. The method according to claim 5, characterized in that The executing the SQL transaction or blocking the SQL transaction based on the transaction type of at least one current SQL transaction comprises: When the transaction type of at least one current SQL transaction is a data query transaction, executing the SQL transaction; When the transaction type of the target current SQL transaction in at least one current SQL transaction is not a data query transaction, determine whether the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction; when the table account address corresponding to the target current SQL transaction is the same as the table account address corresponding to the SQL transaction, block the SQL transaction; when the table account address corresponding to the current SQL transaction is not the same as the table account address corresponding to the SQL transaction, execute the SQL transaction.
7. The method according to claim 4 or 6, characterized in that: The method further comprises: When the SQL transaction is blocked and the target current SQL transaction is executed, releasing the lock signal corresponding to the target current SQL transaction; When the lock signal corresponding to the target current SQL transaction is released, the blocked SQL transactions are executed in sequence.
8. The method according to claim 4, characterized in that The executing the SQL transaction includes: In the case where the SQL transaction is a table creation transaction, a table account corresponding to the SQL transaction is created, and metadata of the table is written under the table account corresponding to the SQL transaction; In the case where the SQL transaction is a table structure update transaction, updating the metadata of the table for the table account corresponding to the SQL transaction, and adjusting the form data of the table; When the SQL transaction is a data operation update transaction, the table of the table account corresponding to the SQL transaction is operated.
9. The method according to claim 4, characterized in that In the case where there are multiple SQL transactions, obtaining the SQL transactions from the blockchain includes: obtaining the multiple SQL transactions from the blockchain in parallel; The determining the transaction type of the SQL transaction comprises: determining the transaction types of multiple SQL transactions in parallel; The creating the locking signal corresponding to the transaction type includes: creating the locking signals corresponding to the transaction type in parallel.
10. The method according to claim 1, characterized in that The determining the transaction type of the SQL transaction includes: Converting the SQL transaction statement into an abstract syntax tree; The transaction type is determined based on the abstract syntax tree.
11. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 10 when executing the computer program.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
High availability data-base cluster based on message middleware
CN101183377A
Operation processing method and device
CN105573828A
Transaction execution method and device, equipment and storage medium
CN114328591A
Block chain data query method and device based on structured query language
CN115328964A