Data processing method and device based on long transaction, electronic equipment and storage medium
By introducing long transaction views and trigger mechanisms into the database, the problem of short transaction lifecycles in traditional RDBMS is solved, data isolation and undo/edit operations are achieved, and network planning and design flexibility and persistent storage are supported.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA COMM SERVICE APPL & SOLUTION TECH CO LTD
- Filing Date
- 2021-11-17
- Publication Date
- 2026-06-12
AI Technical Summary
In existing technologies, database transactions based on RDBMS have short lifecycles, and data isolation is lost after the transaction is committed, which cannot meet the needs of undoing or partial undoing and redesign. In particular, it is difficult to achieve effective data isolation and editing operations in network planning and design.
By introducing long transaction views and trigger mechanisms into the database, the system determines the type of user operation, calls the corresponding trigger to perform data operations, updates the long transaction status during the operation, uses temporary tables to store data, supports deletion and update operations, and provides the ability to undo editing.
It ensures data isolation while providing the ability to undo edits, facilitating network planning and design, and ensuring persistent storage of data when the design is partially or completely scrapped.
Smart Images

Figure CN114090599B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of long transaction data processing technology, and in particular to a data processing method, apparatus, electronic device and storage medium based on long transactions. Background Technology
[0002] In databases, long transactions are logical units of work. A long transaction consists of one or more short transactions that complete a set of related actions, and it is often used in network planning and design.
[0003] Currently, network planning and design often adopts database transaction implementation based on Relational Database Management System (RDBMS) technology. However, traditional database transactions based on RDBMS technology have a short lifespan. Once a transaction is committed, data isolation immediately disappears. Furthermore, due to the persistence characteristic, transactions cannot be rolled back after completion, which cannot meet the needs of some schemes that require reversal or partial redesign.
[0004] Therefore, how to provide an effective solution that ensures data isolation while providing the ability to undo editing operations has become a pressing problem to be solved in existing technologies. Summary of the Invention
[0005] In a first aspect, embodiments of this application provide a data processing method based on long transactions, including:
[0006] Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0007] Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0008] Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered;
[0009] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0010] In one possible design, the method further includes:
[0011] The fourth trigger in the base table is invoked to obtain the operation log of the operation, which includes the log type, long transaction number, and sequence number of the operation object data.
[0012] In one possible design, calling the first trigger in the long transaction view corresponding to the user ID and the operation type includes:
[0013] If the operation type is an insert operation, then the first insert trigger in the long transaction view is invoked;
[0014] If the operation type is a delete operation, then the first delete trigger in the long transaction view is invoked;
[0015] If the operation type is an update operation, then the first update trigger in the long transaction view is invoked;
[0016] The internal processing logic of the first trigger is as follows: when inserting data into the base table under the long transaction view, the user number is first obtained and assigned to the session-level global variable V_USERID used to record the current user number, and then the data is inserted into the base table under the long transaction view.
[0017] The internal processing logic of the first deletion trigger is as follows: when deleting data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then delete the data in the base table under the long transaction view.
[0018] The internal processing logic of the first update trigger is as follows: when updating the data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then update the data in the base table under the long transaction view.
[0019] In one possible design, a second trigger in the base table corresponding to the operation type is invoked to update the long-transaction state of the operation object data when the operation is triggered, including:
[0020] If the operation type is an insert operation, then the second insert trigger in the base table is invoked to update the long transaction state of the operation object data when the insert operation is triggered;
[0021] If the operation type is a delete operation, then the second delete trigger in the base table is invoked to update the long transaction state of the data of the operation object when the delete operation is triggered;
[0022] If the operation type is an update operation, then the second update trigger in the base table is invoked to update the long transaction state of the operation object data when the update operation is triggered;
[0023] The internal processing logic of the second insertion trigger is as follows:
[0024] When the long transaction state of the inserted data is LTTOLD (backup state), change the long transaction state of the data to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary deletion state), change the long transaction state of the data to DELETE (deletion state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary addition state), change the long transaction state of the data to IADD (delete uncommitted addition state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary editing state), change the long transaction state of the data to IEDIT (intermediate editing version state) before insertion.
[0025] The internal processing logic of the second deletion trigger is as follows:
[0026] Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion (LTTDEL) and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition (LTTIAD) and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary editing (LTTIED) and store it in the temporary table corresponding to the base table.
[0027] The internal processing logic of the second update trigger is as follows:
[0028] Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
[0029] In one possible design, the re-updating of the long-transaction state of the operation object data includes:
[0030] The second insert trigger is invoked to update the long transaction state of the operation object data again.
[0031] In one possible design, the operation types include the delete operation, the update operation, and the insert operation.
[0032] In one possible design, before determining the type of user operation on the base table, the method further includes:
[0033] Create the second trigger and the third trigger on the base table, and define the internal processing logic of the second trigger and the third trigger;
[0034] Create the first trigger in the long transaction view and define the internal processing logic of the first trigger.
[0035] Secondly, embodiments of this application provide a data processing apparatus based on long transactions, including:
[0036] The judgment unit is used to determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0037] The calling unit is used to call the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0038] Invoke the second trigger in the base table corresponding to the operation type, so as to update the long transaction state of the operation object data when the operation is triggered; and
[0039] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data from the temporary table corresponding to the base table into the base table;
[0040] The update unit is used to update the long transaction status of the operation object data again after the calling unit calls the third trigger in the base table to insert the data in the temporary table corresponding to the base table into the base table.
[0041] Thirdly, embodiments of this application provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the bus;
[0042] Memory, used to store computer programs;
[0043] The processor executes programs stored in memory, implementing the following process:
[0044] Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0045] Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0046] Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered;
[0047] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0048] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the following process:
[0049] Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0050] Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0051] Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered;
[0052] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0053] The above-described technical solutions employed in one or more embodiments of this application can achieve the following beneficial effects:
[0054] By determining the type of user operation on the base table, the system invokes the first trigger in the long transaction view corresponding to the user's ID, which executes the operation corresponding to the operation type on the base table under the long transaction view. It then invokes the second trigger in the base table corresponding to the operation type to update the long transaction state of the data being operated on when the operation is triggered. When the operation type is a delete or update operation, the system invokes the third trigger in the base table to insert data from the corresponding temporary table into the base table, and updates the long transaction state of the data being operated on again. During this process, the triggers in the long transaction view can be invoked based on the user's ID, ensuring data isolation. Furthermore, when the operation type is a delete or update operation, the system can invoke the third trigger in the base table to insert data from the corresponding temporary table into the base table. This provides the ability to undo edits when the design scheme is partially or completely invalidated, and the system can persistently store data in the database during the planning and design process, further facilitating network planning and design. Attached Figure Description
[0055] The accompanying drawings, which are included to provide a further understanding of this document and form part of this document, illustrate exemplary embodiments and their descriptions, serving to explain this document and do not constitute an undue limitation thereof. In the drawings:
[0056] Figure 1 A flowchart of a data processing method based on long transactions provided in one embodiment of this application.
[0057] Figure 2 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application.
[0058] Figure 3 This is a schematic diagram of the structure of a data processing device based on long transactions provided in one embodiment of this application. Detailed Implementation
[0059] To facilitate network planning and design, embodiments of this application provide a data processing method, apparatus, electronic device, and storage medium based on long transactions. This data processing method, apparatus, electronic device, and storage medium based on long transactions can provide the ability to undo edit operations while ensuring data isolation, thus facilitating network planning and design.
[0060] The data processing method based on long transactions provided in this application can be applied to user terminals or servers. The user terminal may be, but is not limited to, personal computers, smartphones, tablets, personal digital assistants (PDAs), etc.
[0061] It is understood that the execution entity described does not constitute a limitation on the embodiments of this application.
[0062] The data processing method based on long transactions provided in the embodiments of this application will be described in detail below.
[0063] like Figure 1 As shown in the embodiments of this application, the data processing method based on long transactions may include the following steps:
[0064] Step S101: Determine the type of operation the user is performing on the base table.
[0065] The operation involves a user ID.
[0066] In network planning and design, when a user needs to edit, update, or delete a long transaction, they can initiate an operation on the base table of the long transaction. This operation type can be edit, update, or delete, and it carries the user's ID. At this point, the database determines the type of operation the user is performing on the base table.
[0067] Step S102: In the long transaction view corresponding to the user number, the first trigger corresponding to the operation type is invoked to perform the operation corresponding to the operation type on the base table under the long transaction view.
[0068] In this embodiment of the application, a long transaction view corresponding to the base table is created. Its main function is to associate the base table and the user table. When querying the view, the user ID can be used as a query condition to query the long transaction number of the current user (the long transaction number is recorded in the user table), thereby finding the long transaction view corresponding to the user ID.
[0069] In this embodiment of the application, a first trigger is created in the long transaction view on the base table. The trigger type of the first trigger is "INSTEAD OF". The internal processing logic of the first trigger is: to obtain the user number and assign it to the session-level global variable V_USERID used to record the current user number, and then perform related operations on the base table under the long transaction view.
[0070] When a long transaction view corresponding to a user ID is found, the first trigger in the long transaction view corresponding to the operation type can be called so that the operation corresponding to the operation type can be executed on the base table under the long transaction view through the first trigger.
[0071] In this embodiment, the operation type can be an edit operation, an update operation, or a delete operation. The first trigger corresponding to the operation type can be a first insert trigger, a first delete trigger, or a first update trigger.
[0072] Specifically, if the operation type is an insert operation, the first insert trigger in the long transaction view is invoked. If the operation type is a delete operation, the first delete trigger in the long transaction view is invoked. If the operation type is an update operation, the first update trigger in the long transaction view is invoked.
[0073] The internal processing logic of the first trigger inserter is as follows: when inserting data into the base table under the long transaction view, the user number is first obtained and assigned to the session-level global variable V_USERID used to record the current user number, and then the data is inserted into the base table under the long transaction view.
[0074] The internal processing logic of the first deletion trigger is as follows: when deleting data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then delete the data in the base table under the long transaction view.
[0075] The internal processing logic of the first update trigger is as follows: when updating the data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then update the data in the base table under the long transaction view.
[0076] Step S103: Call the second trigger in the base table corresponding to the operation type so as to update the long transaction state of the operation object data when the operation is triggered.
[0077] In this embodiment, a second trigger is created in the base table. The trigger type of the second trigger is "BEFORE EACH ROW". The second trigger includes a second insert trigger, a second delete trigger, and a second update trigger. After determining the type of operation performed by the user on the base table, the second trigger in the base table corresponding to the operation type can be invoked to update the long transaction state of the data of the operation object when the operation is triggered.
[0078] Specifically, if the operation type is an insert operation, the second insert trigger in the base table is invoked to update the long-transaction state of the data being operated on when the insert operation is triggered. If the operation type is a delete operation, the second delete trigger in the base table is invoked to update the long-transaction state of the data being operated on when the delete operation is triggered. If the operation type is an update operation, the second update trigger in the base table is invoked to update the long-transaction state of the data being operated on when the update operation is triggered.
[0079] The internal processing logic of the second insertion trigger is as follows:
[0080] When the long transaction state of the inserted data is LTTOLD (backup state), the long transaction state is changed to LOCKED before insertion. When the long transaction state of the inserted data is LTTDEL (temporary deletion state), the long transaction state is changed to DELETE before insertion. When the long transaction state of the inserted data is LTTIAD (temporary addition state), the long transaction state is changed to IADD (delete uncommitted addition state) before insertion. When the long transaction state of the inserted data is LTTIED (temporary editing state), the long transaction state is changed to IEDIT (intermediate edit version state) before insertion. IEDIT refers to the state of data that has undergone multiple edits; the intermediate edit version state is IEDIT. IADD (delete uncommitted addition state) refers to the state when deleting data that was previously in the ADD (uncommitted addition state).
[0081] The internal processing logic of the second deletion trigger is as follows:
[0082] Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion status LTTDEL and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition status LTTIAD and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
[0083] The internal processing logic of the second update trigger is as follows:
[0084] Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
[0085] Step S104: When the operation type is a delete operation or an update operation, the third trigger in the base table is called to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0086] A third trigger is also created in the base table. The trigger type of the third trigger is "AFTER STATEMENT". The internal processing logic when the third trigger is triggered is as follows: insert the data in the temporary table into the base table. When the operation type is a delete operation or an update operation, the third trigger in the base table is called to insert the data in the corresponding temporary table into the base table. At the same time, the second insert trigger under the second trigger in the base table is called again to update the long transaction status of the operation object data. For the specific update process, please refer to the internal processing logic of the second insert trigger, which will not be elaborated here.
[0087] Furthermore, in this embodiment, a fourth trigger is also established in the base table. The trigger type of the fourth trigger is "BEFORE EACH ROW". The fourth trigger is mainly used to collect operation logs when inserting, updating, and deleting data into the base table. The operation logs include log type, long transaction number, and sequence number of the operation object data. After calling the second trigger in the base table corresponding to the operation type, the fourth trigger in the base table can also be called to obtain the operation logs of the operation.
[0088] It should be noted that for long transaction rollbacks, steps S101-S104 above can be skipped; instead, the triggers in the base table can be directly invoked to update data parameters and status. The specific process of long transaction rollbacks will be explained in detail below.
[0089] In this embodiment of the application, long transaction rollback includes two cases: single-step rollback and full rollback.
[0090] For single-step undo, when a user clicks "Undo Job Editing," the base tables involved in the job changes can be found through the long transaction log and long transaction base tables. Then, the data involving long transactions in these tables for the current job can be found by long transaction number and processed as follows:
[0091] 1) Delete data in the long transaction state of ADD (Added).
[0092] 2) Delete the data with the long transaction status of EDIT. Among the remaining data, if the data with the largest session identifier (i.e. the most recently edited data) has a long transaction status of IEDIT (intermediate edit version), then update the intermediate edit version status of IEDIT to EDIT. If the data with the largest session identifier has a long transaction status of LOCKED (locked), then update the LOCKED status to NULL (committed).
[0093] 3) Delete the data whose long transaction status is DELETE. If the long transaction status of the data with the largest session identifier is IEDIT, then update the IEDIT status to EDIT. If the long transaction status of the data with the largest session identifier is LOCKED, then update the LOCKED status to NULL.
[0094] 4) Update the status of data in the long transaction state of Delete Uncommitted New Item (IADD) to New Item (ADD).
[0095] 5) Finally, clear the corresponding records in the long transaction log.
[0096] In the case of a complete reversal, when a user clicks "Reverse All Job Editing," the system first locates the base tables involved in the job changes through the long transaction log and long transaction base tables. Then, it searches for the data in these tables related to long transactions using the long transaction number. Data with long transaction status of IADD (new), EDIT (edit), DELETE (delete uncommitted new), IADD (intermediate edit version), and IEDIT (intermediate edit version) are deleted. The status of data with long transaction status of LOCKED is updated to NULL (committed). Finally, the corresponding records in the long transaction log are cleared.
[0097] In summary, the data processing method based on long transactions provided in this application determines the operation type of a user's operation on a base table, calls the first trigger in the long transaction view corresponding to the operation type for the user's ID, executes the operation corresponding to the operation type on the base table under the long transaction view, calls the second trigger in the base table corresponding to the operation type to update the long transaction state of the operation object data when the operation is triggered, and calls the third trigger in the base table to insert data from the temporary table corresponding to the base table into the base table when the operation type is deleted or updated, and updates the long transaction state of the operation object data again. During this process, the triggers in the long transaction view can be called according to the user ID, thus ensuring data isolation. Furthermore, when the operation type is deleted or updated, the third trigger in the base table can be called to insert data from the temporary table corresponding to the base table into the base table. This provides the ability to undo edits when a design scheme is partially or completely invalidated, and it can persistently store data in a database during the planning and design process, further facilitating network planning and design.
[0098] Furthermore, embodiments of this application also provide a possible design for creating a trigger for long transaction data processing. This may include, but is not limited to, the following steps S201-S204.
[0099] Step S201: Create a fourth trigger on the base table and define the internal processing logic of the fourth trigger.
[0100] The trigger type of the fourth trigger is "BEFORE EACH ROW". The fourth trigger is mainly used to collect operation logs when inserting, updating and deleting data into the base table. The operation logs include log type, long transaction number and sequence number of the operation object data.
[0101] Step S202: Create a second trigger and a third trigger on the base table, and define the internal processing logic of the second trigger and the third trigger.
[0102] The second trigger is of type "BEFORE EACH ROW" and includes a second insert trigger, a second delete trigger, and a second update trigger. The third trigger is of type "BEFORE EACHROW," and its internal processing logic is as follows: insert data from the temporary table into the base table. When the operation type is a delete or update operation, the third trigger in the base table is invoked to insert data from the corresponding temporary table into the base table.
[0103] Specifically, a second delete trigger can be created on the base table, with the trigger type "BEFORE EACHROW". The internal processing logic of the second delete trigger is defined as follows: determine whether the data to be deleted is in the current long transaction. If the data to be deleted is not in the current long transaction, mark the status of the deleted data as temporary delete status LTTDEL and store it in the temporary table corresponding to the base table; if the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary add status LTTIAD and store it in the temporary table corresponding to the base table; if the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
[0104] After creating the second delete trigger, a second insert trigger can be created on the base table. The trigger type is "BEFORE EACH ROW", and the internal processing logic of the second insert trigger is defined as follows: When the long transaction state of the inserted data is LTTOLD (backup state), the long transaction state of the data is changed to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary delete state), the long transaction state of the data is changed to DELETE (delete state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary add state), the long transaction state of the data is changed to IADD (delete uncommitted add state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary edit state), the long transaction state of the data is changed to IEDIT (intermediate edit version state) before insertion.
[0105] After creating the second insert trigger, a second update trigger can be created on the base table. The trigger type is "BEFORE EACH ROW". The internal processing logic of the second update trigger is defined as follows: determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
[0106] Finally, a third trigger is created on the base table, with the trigger type being "AFTER STATEMENT", and the internal processing logic of the third trigger is defined as: inserting the data from the temporary table into the base table.
[0107] Step S203: Create a long transaction view corresponding to the base table.
[0108] The main function is to link the base table and the user table. When querying the view, the user ID is used as the query condition to find the current user's long transaction number (recorded in the user table). Data in three states is then filtered out for the user to view, update, or delete. The first type is data outside the long transaction, i.e., data with a long transaction number of 0 and a committed state (NULL). The second type is data in the final state of the user's current long transaction, i.e., data with a long transaction number equal to the current user's long transaction number and a long transaction state of "added" or "edited". The third type is data within the long transaction but not in the user's current long transaction, i.e., data with a long transaction number of 0 and a long transaction state of "locked".
[0109] Step S204: Create a first trigger in the long transaction view and define the internal processing logic of the first trigger.
[0110] The first trigger includes a first insert trigger, a first delete trigger, and a first update trigger. The trigger type of the first trigger is "INSTEAD OF". The internal processing logic of the first trigger is as follows: obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then perform related operations on the base table under the long transaction view.
[0111] Specifically, a first insert trigger can be created in the long transaction view, with the trigger type being "INSTEADOF". The internal processing logic of the first insert trigger is defined as follows: when inserting data into the base table under the long transaction view, the user ID is first obtained and assigned to the session-level global variable V_USERID used to record the current user ID, and then the data is inserted into the base table under the long transaction view.
[0112] Then, create a first update trigger in the long transaction view. The trigger type is "INSTEAD OF". The internal processing logic of the first update trigger is defined as follows: when updating the data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then update the data in the base table under the long transaction view.
[0113] Finally, a first delete trigger is created in the long transaction view, with the trigger type being "INSTEAD OF". The internal processing logic of the first delete trigger is defined as follows: when deleting data in the base table under the long transaction view, the user ID is first obtained and assigned to the session-level global variable V_USERID used to record the current user ID, and then the data in the base table under the long transaction view is deleted.
[0114] Figure 2 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Please refer to it. Figure 2 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.
[0115] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 2 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0116] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.
[0117] The processor reads the corresponding computer program from non-volatile memory into main memory and then executes it, forming a data processing device based on long transactions at the logical level. The processor executes the program stored in memory and specifically performs the following operations:
[0118] Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0119] Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0120] Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered;
[0121] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0122] The above is as stated in this application. Figure 2The method executed by the data processing device based on long transactions disclosed in the illustrated embodiments can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in one or more embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in one or more embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0123] The electronic device can also perform Figure 1 The method, and implements a data processing device based on long transactions in Figure 2 The functions of the embodiments shown are not described in detail here.
[0124] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0125] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by a portable electronic device including multiple applications, enable the portable electronic device to perform... Figure 1 The method of the illustrated embodiment is specifically used to perform the following operations:
[0126] Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0127] Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0128] Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered;
[0129] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again.
[0130] Figure 3 This is a schematic diagram of the structure of a data processing apparatus based on long transactions provided in one embodiment of this application. Please refer to... Figure 3 In one software implementation, the data processing apparatus based on long transactions includes:
[0131] The judgment unit is used to determine the type of operation performed by the user on the base table, wherein the operation carries the user ID;
[0132] The calling unit is used to call the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view;
[0133] Invoke the second trigger in the base table corresponding to the operation type, so as to update the long transaction state of the operation object data when the operation is triggered; and
[0134] When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data from the temporary table corresponding to the base table into the base table;
[0135] The update unit is used to update the long transaction status of the operation object data again after the calling unit calls the third trigger in the base table to insert the data in the temporary table corresponding to the base table into the base table.
[0136] In summary, the above description is merely a preferred embodiment of this document and is not intended to limit the scope of protection of this document. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of protection of this document.
[0137] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0138] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0139] The various embodiments in this document are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
Claims
1. A data processing method based on long transactions, characterized in that, include: Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID; Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view; Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered; When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again. Invoking the second trigger in the base table corresponding to the operation type to update the long transaction state of the operation object data when the operation is triggered includes: If the operation type is an insert operation, then the second insert trigger in the base table is invoked to update the long transaction state of the operation object data when the insert operation is triggered; If the operation type is a delete operation, then the second delete trigger in the base table is invoked to update the long transaction state of the data of the operation object when the delete operation is triggered; If the operation type is an update operation, then the second update trigger in the base table is invoked to update the long transaction state of the operation object data when the update operation is triggered; The internal processing logic of the second insertion trigger is as follows: When the long transaction state of the inserted data is LTTOLD (backup state), change the long transaction state of the data to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary deletion state), change the long transaction state of the data to DELETE (deletion state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary addition state), change the long transaction state of the data to IADD (delete uncommitted addition state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary editing state), change the long transaction state of the data to IEDIT (intermediate editing version state) before insertion. The internal processing logic of the second deletion trigger is as follows: Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion (LTTDEL) and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition (LTTIAD) and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary editing (LTTIED) and store it in the temporary table corresponding to the base table. The internal processing logic of the second update trigger is as follows: Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
2. The method of claim 1, wherein, The method further includes: The fourth trigger in the base table is invoked to obtain the operation log of the operation, which includes the log type, long transaction number, and sequence number of the operation object data.
3. The method of claim 1, wherein, Calling the first trigger in the long transaction view corresponding to the user ID, which corresponds to the operation type, includes: If the operation type is an insert operation, then the first insert trigger in the long transaction view is invoked; If the operation type is a delete operation, then the first delete trigger in the long transaction view is invoked; If the operation type is an update operation, then the first update trigger in the long transaction view is invoked; The internal processing logic of the first trigger is as follows: when inserting data into the base table under the long transaction view, the user number is first obtained and assigned to the session-level global variable V_USERID used to record the current user number, and then the data is inserted into the base table under the long transaction view. The internal processing logic of the first deletion trigger is as follows: when deleting data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then delete the data in the base table under the long transaction view. The internal processing logic of the first update trigger is as follows: when updating the data in the base table under the long transaction view, first obtain the user ID and assign it to the session-level global variable V_USERID used to record the current user ID, and then update the data in the base table under the long transaction view.
4. The method according to claim 1, characterized in that, The process of updating the long-term transaction status of the operation object data again includes: The second insert trigger is invoked to update the long transaction state of the operation object data again.
5. The method according to claim 1, characterized in that, The operation types include the deletion operation, the update operation, and the insert operation.
6. The method according to claim 1, characterized in that, Before determining the type of user operation on the base table, the method further includes: Create the second trigger and the third trigger on the base table, and define the internal processing logic of the second trigger and the third trigger; Create the first trigger in the long transaction view and define the internal processing logic of the first trigger.
7. A data processing device based on long transactions, characterized in that, include: The judgment unit is used to determine the type of operation performed by the user on the base table, wherein the operation carries the user ID; The calling unit is used to call the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view; Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered; as well as When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data from the temporary table corresponding to the base table into the base table; The update unit is used to update the long transaction status of the operation object data again after the calling unit calls the third trigger in the base table to insert the data in the temporary table corresponding to the base table into the base table; When the calling unit invokes the second trigger in the base table corresponding to the operation type, so as to update the long transaction state of the operation object data when the operation is triggered, it is specifically used for: If the operation type is an insert operation, then the second insert trigger in the base table is invoked to update the long transaction state of the operation object data when the insert operation is triggered; If the operation type is a delete operation, then the second delete trigger in the base table is invoked to update the long transaction state of the data of the operation object when the delete operation is triggered; If the operation type is an update operation, then the second update trigger in the base table is invoked to update the long transaction state of the operation object data when the update operation is triggered; The internal processing logic of the second insertion trigger is as follows: When the long transaction state of the inserted data is LTTOLD (backup state), change the long transaction state of the data to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary deletion state), change the long transaction state of the data to DELETE (deletion state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary addition state), change the long transaction state of the data to IADD (delete uncommitted addition state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary editing state), change the long transaction state of the data to IEDIT (intermediate editing version state) before insertion. The internal processing logic of the second deletion trigger is as follows: Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion (LTTDEL) and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition (LTTIAD) and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary editing (LTTIED) and store it in the temporary table corresponding to the base table. The internal processing logic of the second update trigger is as follows: Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the bus; Memory, used to store computer programs; The processor executes programs stored in memory, implementing the following process: Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID; Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view; Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered; When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again. Invoking the second trigger in the base table corresponding to the operation type to update the long transaction state of the operation object data when the operation is triggered includes: If the operation type is an insert operation, then the second insert trigger in the base table is invoked to update the long transaction state of the operation object data when the insert operation is triggered; If the operation type is a delete operation, then the second delete trigger in the base table is invoked to update the long transaction state of the data of the operation object when the delete operation is triggered; If the operation type is an update operation, then the second update trigger in the base table is invoked to update the long transaction state of the operation object data when the update operation is triggered; The internal processing logic of the second insertion trigger is as follows: When the long transaction state of the inserted data is LTTOLD (backup state), change the long transaction state of the data to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary deletion state), change the long transaction state of the data to DELETE (deletion state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary addition state), change the long transaction state of the data to IADD (delete uncommitted addition state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary editing state), change the long transaction state of the data to IEDIT (intermediate editing version state) before insertion. The internal processing logic of the second deletion trigger is as follows: Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion (LTTDEL) and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition (LTTIAD) and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary editing (LTTIED) and store it in the temporary table corresponding to the base table. The internal processing logic of the second update trigger is as follows: Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, performs the following process: Determine the type of operation performed by the user on the base table, wherein the operation carries the user ID; Invoke the first trigger in the long transaction view corresponding to the operation type, so as to perform the operation corresponding to the operation type on the base table under the long transaction view; Call the second trigger in the base table corresponding to the operation type so that the long transaction state of the operation object data is updated when the operation is triggered; When the operation type is a delete operation or an update operation, the third trigger in the base table is invoked to insert the data in the temporary table corresponding to the base table into the base table, and the long transaction status of the operation object data is updated again. Invoking the second trigger in the base table corresponding to the operation type to update the long transaction state of the operation object data when the operation is triggered includes: If the operation type is an insert operation, then the second insert trigger in the base table is invoked to update the long transaction state of the operation object data when the insert operation is triggered; If the operation type is a delete operation, then the second delete trigger in the base table is invoked to update the long transaction state of the data of the operation object when the delete operation is triggered; If the operation type is an update operation, then the second update trigger in the base table is invoked to update the long transaction state of the operation object data when the update operation is triggered; The internal processing logic of the second insertion trigger is as follows: When the long transaction state of the inserted data is LTTOLD (backup state), change the long transaction state of the data to LOCKED (locked state) before insertion; when the long transaction state of the inserted data is LTTDEL (temporary deletion state), change the long transaction state of the data to DELETE (deletion state) before insertion; when the long transaction state of the inserted data is LTTIAD (temporary addition state), change the long transaction state of the data to IADD (delete uncommitted addition state) before insertion; when the long transaction state of the inserted data is LTTIED (temporary editing state), change the long transaction state of the data to IEDIT (intermediate editing version state) before insertion. The internal processing logic of the second deletion trigger is as follows: Determine whether the data to be deleted is within the current long transaction. If the data is not within the current long transaction, mark the status of the deleted data as temporary deletion (LTTDEL) and store it in the temporary table corresponding to the base table. If the data to be deleted was added under the current long transaction, mark the status of the deleted data as temporary addition (LTTIAD) and store it in the temporary table corresponding to the base table. If the data to be deleted was edited under the current long transaction, mark the status of the deleted data as temporary editing (LTTIED) and store it in the temporary table corresponding to the base table. The internal processing logic of the second update trigger is as follows: Determine whether the data before the update is in the current long transaction. If the data before the update is not in the current long transaction, mark the status of the data before the update as backup status LTTOLD and store it in the temporary table corresponding to the base table. If the data before the update has been edited under the current long transaction, mark the status of the data before the update as temporary edit status LTTIED and store it in the temporary table corresponding to the base table.