Method and device for detecting foreign key constraint, electronic equipment and storage medium

By constructing a key-value query task at the executor level and utilizing the read uncommitted isolation level and whitelist filtering, the problem of high system overhead in foreign key constraint detection is solved, detection performance is improved, lock conflicts are avoided, and efficient foreign key constraint detection is achieved.

CN117216098BActive Publication Date: 2026-01-09BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311134376.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-04
Publication Date
2026-01-09
Estimated Expiration
2043-09-04

AI Technical Summary

Technical Problem

Existing technologies require parsing and executing SQL statements when performing foreign key constraint detection, resulting in high system overhead. Furthermore, locking is required in concurrent transaction scenarios, impacting performance.

Method used

By constructing key-value query tasks at the executor level, using key-value sets for foreign key constraint detection, and employing read uncommitted isolation level and whitelist filtering, the SQL statement parsing and locking operations are reduced.

Benefits of technology

It reduces system overhead, improves the performance of foreign key constraint detection, avoids lock conflict issues, and reduces the detection overhead of multi-row operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117216098B_ABST
    Figure CN117216098B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of detection, and particularly provides a foreign key constraint detection method and device, electronic equipment and a storage medium. The foreign key constraint detection method comprises the following steps: determining a target key value of a to-be-inquired foreign key in a to-be-inquired row according to a received target query instruction, and obtaining a key value set; at an executor level, a key value query task is constructed based on the key value set; the key value query task is executed by the executor, and a target query result is obtained. In this way, the system overhead is reduced, and the system performance is improved without SQL statement analysis and execution.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of detection, and particularly relates to a foreign key constraint detection method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the development of computer technology, people's requirements for the performance of a database are also getting higher and higher. In a database application scenario, the consistency of cross-table data is usually ensured through foreign key constraints. The foreign key constraint is a constraint between tables in a database system, which is defined as all values in the column of the foreign key constraint should exist in the column it refers to. The foreign key is a column name in a first table (i.e., a child table) that refers to a column (i.e., a parent key) in a second table (i.e., a parent table).

[0003] In the prior art, the detection of foreign key constraints is usually implemented by selecting a structured query language (SQL) statement. Specifically, a select query statement is constructed according to the value of the foreign key in each inserted row, and the select query statement is executed to perform foreign key constraint detection. If all foreign key constraint detections pass, it means that the cross-table data has consistency, otherwise, it does not have consistency.

[0004] However, in this way, the select statement needs to be parsed and executed, which will consume a lot of system overhead. SUMMARY

[0005] The purpose of the embodiments of the present application is to provide a foreign key constraint detection method, device, electronic equipment and storage medium, which can reduce the system overhead consumed when performing foreign key constraint detection.

[0006] In one aspect, the present application provides a foreign key constraint detection method, comprising:

[0007] According to the received target query instruction, determining the target key value of the to-be-queried foreign key in the to-be-queried row, and obtaining a key value set;

[0008] At the executor level, constructing a key value query task based on the key value set;

[0009] Executing the key value query task through the executor to obtain a target query result.

[0010] In one embodiment, before the key value query task is executed through the executor to obtain the target query result, the method further comprises:

[0011] Setting the isolation level of the query task related to the to-be-queried foreign key to read uncommitted.

[0012] In an implementation, before constructing the key-value query task based on the key-value set at the executor level, the method further includes:

[0013] If it is determined that the target key values are multiple, the target key values in the key-value set are deduplicated to obtain a deduplicated key-value set.

[0014] In an implementation, before constructing the key-value query task based on the key-value set at the executor level, the method further includes:

[0015] Removing the target key values contained in the whitelist from the key-value set;

[0016] Determining that the target query result corresponding to the removed target key values is a detection success.

[0017] In an implementation, after executing the key-value query task by the executor to obtain the target query result, the method further includes:

[0018] Adding the target key values whose target query results are detection successes to the whitelist.

[0019] In an aspect, an embodiment of the present application provides a device for foreign key constraint detection, including:

[0020] An obtaining unit is configured to determine target key values of a to-be-queried foreign key in a to-be-queried row according to a received target query instruction, and obtain a key-value set;

[0021] A constructing unit is configured to construct a key-value query task based on the key-value set at an executor level;

[0022] An executing unit is configured to execute the key-value query task by the executor to obtain a target query result.

[0023] In an implementation, the executing unit is further configured to:

[0024] Set an isolation level of a query task related to the to-be-queried foreign key to read uncommitted.

[0025] In an implementation, the constructing unit is further configured to:

[0026] If it is determined that the target key values are multiple, the target key values in the key-value set are deduplicated to obtain a deduplicated key-value set.

[0027] In an implementation, the constructing unit is further configured to:

[0028] Removing the target key values contained in the whitelist from the key-value set;

[0029] Determining that the target query result corresponding to the removed target key values is a detection success.

[0030] In an implementation, the execution unit is further configured to:

[0031] add the target key value for which the target query result is a detection success into a whitelist.

[0032] In an aspect, an embodiment of the present application provides an electronic device, comprising:

[0033] a processor; and a memory storing computer instructions for causing the processor to perform steps of a method provided in any of the various optional implementation manners of the foreign key constraint detection.

[0034]

[0035] In an aspect, an embodiment of the present application provides a storage medium storing computer instructions for causing a computer to perform steps of a method provided in any of the various optional implementation manners of the foreign key constraint detection.

[0036] In the foreign key constraint detection method, device, electronic device and storage medium provided by the embodiments of the present application, according to the received target query instruction, the target key value of the to-be-queried foreign key in the to-be-queried row is determined, and a key value set is obtained; at the executor level, the key value set is used to construct a key value query task; the key value query task is executed by the executor to obtain a target query result. In this way, the parsing and execution of the SQL statement are not required, the system overhead is reduced, and the system performance is improved. BRIEF DESCRIPTION OF DRAWINGS

[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed in the description of the embodiments or the prior art will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0038] Figure 1 A flowchart of a foreign key constraint detection method in an embodiment of the present application.

[0039] Figure 2 A detailed implementation flowchart of a foreign key constraint detection method in an embodiment of the present application.

[0040] Figure 3 A structural block diagram of a foreign key constraint detection device in an embodiment of the present application.

[0041] Figure 4 A structural schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The technical solutions of the present application will be described clearly and completely in connection with the drawings. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application. In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.

[0043] First, some terms involved in the embodiments of the present application are described to facilitate understanding by those skilled in the art.

[0044] Terminal device: It can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a station, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system device, a personal navigation device, a personal digital assistant, an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an electronic book device, a game device, or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is also foreseeable that the terminal device can support any type of interface for the user (such as wearable devices) and the like.

[0045] Server: It can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and basic cloud computing services such as big data and artificial intelligence platforms.

[0046] The technical idea of the present application is described below.

[0047] In the database application scenario, the consistency of cross-table data is usually guaranteed by foreign key constraints. If the foreign key constraint detection passes, if the foreign key constraint detection passes, it means that the cross-table data has consistency, otherwise, it does not have consistency.

[0048] Under the traditional technology, a select query statement is constructed according to the value of the foreign key in each inserted row, and the select query statement is executed to perform foreign key constraint detection. However, the foreign key constraint detection through the select query statement needs to go through the complete SQL parsing and execution process, and the system overhead is large.

[0049] Further, in order to ensure the consistency of data in a concurrent transaction scenario, when performing the foreign key constraint check, the corresponding row on the parent table / sub-table is often also locked to ensure that the referenced row is not modified by other concurrent transactions, thereby causing data inconsistency problems. However, locking the checked row when performing foreign key constraint detection introduces additional performance overhead.

[0050] Further, when simultaneously performing operations such as insertion or update on multiple rows, foreign key constraint detection needs to be performed on each row, which further leads to low system performance. In addition, for a distributed scenario, if the sub-table and the parent table are located on different devices, when performing foreign key constraint detection on each row of data, remote procedure call (RPC) needs to be frequently sent across devices or even across regions, which reduces the system performance by one to two orders of magnitude.

[0051] Based on the defects of the above related technologies, the embodiments of the present application provide a foreign key constraint detection method and device, electronic equipment and storage medium, which can reduce the system overhead consumed when performing foreign key constraint detection.

[0052] The embodiments of the present application provide a foreign key constraint detection method, which can be applied to electronic equipment. The type of the electronic equipment is not limited in the present application, which can be any suitable device type, such as terminal equipment and servers, etc. The present application will not be repeated here.

[0053] Referring to Figure 1 FIG. 1 is a flowchart of a foreign key constraint detection method according to an embodiment of the present application. The method will be described below in conjunction with Figure 1 The specific implementation process of the method is as follows:

[0054] Step 100: According to the received target query instruction, determine the target key value of the to-be-queried foreign key in the to-be-queried row, and obtain a key value set.

[0055] In practical applications, the target query instruction is usually received in a data manipulation language (DML) scenario of a row update operation on one or more rows of a data table of a database.

[0056] Optionally, the row update operation can be any one of an insertion (inert), a deletion (delete), and an update (update) operation on one or more rows. The key value set contains at least one target key value.

[0057] Further, if the key-value set contains multiple target key values, the key-value set can contain the same target key value. Therefore, to improve the key-value query efficiency, the target key values in the key-value set can be deduplicated.

[0058] In an implementation, if it is determined that the target key value is multiple, the target key values in the key-value set are deduplicated to obtain a deduplicated key-value set.

[0059] In this way, the target key values corresponding to the batch processing to-be-queried rows can be deduplicated to obtain a key-value set containing at least one target key value to be queried, so that the data processing amount of subsequent foreign key constraint detection can be reduced, and system overhead can be reduced.

[0060] Further, if the number of to-be-queried rows is large, multiple to-be-queried rows can be processed in batches to obtain multiple to-be-queried row sets, and multiple key-value sets corresponding to the multiple to-be-queried row sets can be generated.

[0061] In an implementation, when generating multiple key-value sets, the following steps can be used:

[0062] S1001: According to the target query instruction, the total number of to-be-queried rows is determined.

[0063] It should be noted that when performing key-value query, the key-value query is usually performed on multiple to-be-queried rows in the same to-be-queried table in the database, and therefore the number of to-be-queried rows can be counted to obtain the total number of to-be-queried rows.

[0064] S1002: If it is determined that the total number of rows is higher than the grouping threshold, the multiple to-be-queried rows are divided to obtain multiple to-be-queried row sets.

[0065] In actual application, the grouping threshold can be set according to the actual application scenario, for example, the grouping threshold can be 5, which is not limited herein.

[0066] S1003: The target key values of the to-be-queried foreign key corresponding to each row in each to-be-queried row set are determined to obtain a key-value set corresponding to each to-be-queried row set.

[0067] Further, a white list can also be set. The white list is a set of exempted key values, that is, a set of key values that are currently not subject to foreign key constraint detection and have been determined to pass the detection. Optionally, the white list key value can be pre-set, and can also be a set of key values that have passed the detection. In actual application, the white list can be set according to the actual application scenario, which is not limited herein.

[0068] In an implementation, the target key values contained in the white list are removed from the key-value set, and it is determined that the target query result corresponding to the removed target key value is a detection success.

[0069] In this way, a large number of key-value query operations are reduced, detection efficiency is improved, and detection overhead is reduced.

[0070] Step 101: At the executor level, a key-value query task is constructed based on the key-value set.

[0071] Specifically, at the executor level, a key-value query task is constructed for each target key value in the key-value set.

[0072] It should be noted that the key-value query task described above is constructed at the executor level, and is a task that can be directly executed by the executor, and does not need to be compiled and executed.

[0073] In an embodiment, the parent table of the foreign key to be queried and the corresponding parent key in the parent table can be obtained, and a key-value query task can be constructed according to the foreign key to be queried, a target key value, the parent table, and the parent key.

[0074] In this way, the foreign key to be queried, a target key value, a parent table, and a parent key can be used as parameters to construct a query task for the parent table at the executor level of the database.

[0075] Optionally, the database can be any one of the following: a SQL relational database, a database middleware (MySQL), an Oracle database, a cloud database (Cloud DataBase, CDB), and a database (Ti Data Base, TiDB).

[0076] Step 102: The executor executes the key-value query task to obtain a target query result.

[0077] Specifically, the executor executes the key-value query task corresponding to each target key value to obtain a target query result corresponding to each target key value.

[0078] In an embodiment, the key-value query task is executed, and the result returned by the task is checked. If the target key value is in the result set returned by the task, it is determined that the detection is successful, otherwise, it is determined that the detection fails.

[0079] Further, if the key-value set is a plurality of key-value sets, the executor executes the key-value query task corresponding to the key-value set to be detected in each key-value set to obtain a target query result corresponding to each target key value in the key-value set to be detected.

[0080] The key-value set to be detected is a set of key values that have not been detected in the key-value set.

[0081] Further, the whitelist can also be constructed based on the target key value that has passed the detection.

[0082] In one embodiment, if the target key value set contains multiple target key values, the target key value whose query result is detection success can be added to the white list. In this way, if the target key value is not deduplicated, the white list can be established based on the target key value whose query result is detection success, so that the repeated detection of the target key value which is the same as the key value whose detection is successful can be reduced through the white list, thereby reducing the system computing overhead.

[0083] In one embodiment, if there are multiple key value sets, the target key value whose query result is detection success can also be filtered from the detected key value set, and the filtered target key value can be added to the white list. In this way, when detection is performed in batches according to multiple key value sets, the white list can be established according to the detection result of the key value set that has been detected, thereby reducing the detection processing amount of subsequent other key value sets.

[0084] In one embodiment, the white list is stored in the cache. Specifically, a statement-level hash-set can be maintained as a cache, and the above white list (i.e., the set of all target key values that have been checked and whose detection is successful) can be stored in the cache. For any target key value that has not been subjected to key value query, it is first checked whether the target key value exists in the hash-set. If it is determined that the target key value exists, it means that the target key value has been checked in the to-be-queried row and exists in the parent table in the past, so the detection is directly returned as success, and no subsequent operation is needed.

[0085] In this way, the repeated detection of the same target key value is reduced, and the detection efficiency is further improved.

[0086] Further, before step 102 is performed, in order to ensure the data consistency in the concurrent transaction scenario, the isolation level of the query task related to the to-be-queried foreign key can also be set as read uncommited. The read uncommited can enable the key value query task to see whether other concurrent transactions are modifying the checked row when the key value query task is performed, and can ensure the consistency of the execution results of the to-be-executed and executed key value query tasks.

[0087] In this way, the consistency of the execution results of the to-be-executed and executed key value query tasks is ensured through the read uncommited, and no locking operation is needed, thereby reducing the overhead caused by locking.

[0088] Under the traditional technology, the parsing, planning and execution of the SQL statement are usually needed, and the system overhead is large. In the embodiment of the present application, the key value query task that can be directly executed by the executor is constructed at the executor level, and the parsing and planning process of the SQL statement are not needed, thereby reducing the overhead of the SQL statement parsing and execution.

[0089] Further, in the prior art, in order to ensure the consistency of data in a concurrent transaction scenario, the corresponding rows on the parent table / sub-table are often locked when the foreign key constraint check is performed. However, locking the rows to be checked when performing the foreign key constraint check introduces additional performance overhead. In the embodiment of the present application, the read uncommitted mode is used to ensure data consistency, which reduces the performance overhead caused by the key value check after locking the parent table and the sub-table in the prior art, and avoids the lock conflict problem in the concurrent transaction scenario.

[0090] Further, in the prior art, when inserting or updating multiple rows simultaneously, foreign key constraint detection needs to be performed on each row, which results in low system performance. In addition, for a distributed scenario, if the sub-table and the parent table are located in different devices, when performing foreign key constraint detection on each row of data, RPC needs to be frequently sent across devices or even across regions, which reduces the system performance by one to two orders of magnitude.

[0091] In the embodiment of the present application, through key value batch processing, key value deduplication, foreign key caching, and whitelist screening, the number of foreign key constraint detection is reduced, thereby greatly reducing the overhead of foreign key constraint detection in the multi-row DML statement processing process, reducing the number of RPCs, reducing the system overhead of foreign key constraint detection, and improving the performance of foreign key constraint detection.

[0092] Referring to FIG. 8, which is a detailed implementation flowchart of a method for foreign key constraint detection. The method for foreign key constraint detection in the embodiment of the present application will be described below with reference to FIG. 8. Figure 2 Figure 2 Figure 1

[0093] Step 200: According to the target query instruction, the target key values of the foreign keys in the rows to be queried are determined.

[0094] Step 201: If the total number of rows to be queried is greater than the grouping threshold, the rows to be queried are divided to obtain the key value sets corresponding to the row sets to be queried.

[0095] Step 202: For the target key value set to be detected in each key value set, the target key values contained in the whitelist are removed from the target key value set, and the target query result of the removed target key values is determined to be detection success. The target key value set is any key value set in the key value set.

[0096] Step 203: The target key values in the target key value set are deduplicated to obtain the deduplicated target key value set.

[0097] Step 204: Based on each target key value in the target key value set, a corresponding key value query task is constructed. ​​​

[0098] Step 205: obtaining the target query result corresponding to each target key value by executing the key value query task of each target key value by the executor.

[0099] Step 206: adding the target key value whose target query result is detection success to the white list.

[0100] Step 207: judging whether there is a set of key values that have not been detected, if yes, executing step 202, otherwise, executing step 208.

[0101] Step 208: determining that the key value query is ended.

[0102] Specifically, when steps 200-208 are executed, the specific steps are described above in steps 100-102, which will not be repeated here.

[0103] In the embodiment of the application, at the level of the executor, the key value query task that can be directly executed by the executor is constructed, without the need for SQL statement parsing and execution process, thereby reducing the overhead of SQL statement parsing and execution. Furthermore, the readuncommited mode is adopted to ensure data consistency, thereby reducing the performance overhead caused by the key value checking after the parent table and the child table are locked in the traditional mode, and avoiding the locking conflict problem. Further, through the key value batch processing, key value deduplication and white list screening operation, the system overhead of the foreign key constraint detection is greatly reduced, and the performance of the foreign key constraint detection is improved.

[0104] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0105] Based on the same inventive concept, the embodiment of the application also provides a device for foreign key constraint detection. Since the above device and equipment solve the problem in the same principle as the method of foreign key constraint detection, the implementation of the above device can be referred to the implementation of the method, and the repeated parts will not be repeated. The device can be applied to electronic devices, and the type of the electronic device is not limited in the application, which can be any suitable device type, such as smart phones, tablet computers, etc., which will not be repeated here.

[0106] Referring to Figure 3 Fig. 1 shows a structural block diagram of a device for foreign key constraint detection in the embodiment of the application. In some embodiments, the device for foreign key constraint detection of the example of the application comprises:

[0107] The obtaining unit 301 is configured to determine target key values of the to-be-queried foreign keys in the to-be-queried row according to the received target query instruction, and obtain a key value set.

[0108] The constructing unit 302 is configured to construct a key value query task based on the key value set at an executor level.

[0109] The executing unit 303 is configured to execute the key value query task by using the executor to obtain a target query result.

[0110] In an implementation manner, the executing unit 303 is further configured to:

[0111] Set an isolation level of the query task related to the to-be-queried foreign key to read uncommitted.

[0112] In an implementation manner, the constructing unit 302 is further configured to:

[0113] If it is determined that the target key values are multiple, the target key values in the key value set are de-duplicated to obtain a de-duplicated key value set.

[0114] In an implementation manner, the constructing unit 302 is further configured to:

[0115] Remove the target key values contained in the whitelist from the key value set.

[0116] Determine that a target query result corresponding to the removed target key value is detection success.

[0117] In an implementation manner, the executing unit 303 is further configured to:

[0118] Add the target key value, for which the target query result is detection success, to the whitelist.

[0119] In the method and device for foreign key constraint detection, the electronic device and the storage medium provided by the embodiments of the present application, the target key values of the to-be-queried foreign keys in the to-be-queried row are determined according to the received target query instruction, and a key value set is obtained. A key value query task is constructed based on the key value set at an executor level. The key value query task is executed by using the executor to obtain a target query result. In this way, the parsing and execution of the SQL statement are not required, the system overhead is reduced, and the system performance is improved.

[0120] The electronic device provided by the embodiments of the present application comprises:

[0121] A processor; and

[0122] A memory storing computer instructions, the computer instructions being used to cause the processor to execute the method of any of the embodiments.

[0123] The embodiment of the present application provides a storage medium, which stores computer instructions, and the computer instructions are used for enabling a computer to execute the method of any of the above embodiments.

[0124] Figure 4 A structural schematic diagram of an electronic device 4000 is shown. Referring to Figure 4 As shown, the electronic device 4000 comprises a processor 4010 and a memory 4020, and optionally, can further comprise a power supply 4030, a display unit 4040, and an input unit 4050.

[0125] The processor 4010 is a control center of the electronic device 4000, connects various components by using various interfaces and lines, and executes various functions of the electronic device 4000 by running or executing software programs and / or data stored in the memory 4020.

[0126] In the embodiment of the present application, the processor 4010 executes various steps in the above embodiment when calling the computer program stored in the memory 4020.

[0127] Optionally, the processor 4010 can comprise one or more processing units; preferably, the processor 4010 can integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and an application, and the modem processor mainly processes wireless communication. It can be understood that the above modem processor can also not be integrated into the processor 4010. In some embodiments, the processor, the memory, and the like can be realized on a single chip, and in some embodiments, they can also be realized on independent chips respectively.

[0128] The memory 4020 can mainly comprise a storage program area and a storage data area, wherein the storage program area can store an operating system, various applications, and the like; and the storage data area can store data created according to the use of the electronic device 4000 and the like. In addition, the memory 4020 can comprise a high-speed random access memory, and can also comprise a nonvolatile memory, for example, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device, and the like.

[0129] The electronic device 4000 further comprises a power supply 4030 (such as a battery) for supplying power to various components, and the power supply can be logically connected with the processor 4010 through a power management system, so as to realize the functions of managing charging, discharging, and power consumption, and the like through the power management system.

[0130] The display unit 4040 can be used to display information input by a user or information provided to the user, as well as various menus of the electronic device 4000, and in embodiments of the present application is mainly used to display a display interface of each application in the electronic device 4000 and objects such as text and pictures displayed in the display interface. The display unit 4040 can include a display panel 4041. The display panel 4041 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0131] The input unit 4050 can be used to receive information such as numbers or characters input by a user. The input unit 4050 can include a touch panel 4051 and other input devices 4052. The touch panel 4051, also known as a touch screen, can collect touch operations of a user thereon or adjacent thereto, such as operations of a user using a finger, a stylus, or any suitable object or accessory on or adjacent to the touch panel 4051.

[0132] Specifically, the touch panel 4051 can detect touch operations of a user and detect signals resulting from the touch operations, convert the signals into touch coordinates, send the touch coordinates to the processor 4010, and receive commands from the processor 4010 and execute the commands. In addition, the touch panel 4051 can be implemented in various types such as a resistive type, a capacitive type, an infrared type, and a surface acoustic wave type. The other input devices 4052 can include one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, and the like), a trackball, a mouse, a joystick, and the like, but are not limited thereto.

[0133] Of course, the touch panel 4051 can cover the display panel 4041, and when the touch panel 4051 detects a touch operation thereon or adjacent thereto, the touch panel 4051 transmits the touch operation to the processor 4010 to determine a type of the touch event, and then the processor 4010 provides corresponding visual output on the display panel 4041 according to the type of the touch event. Although in Figure 4 In some embodiments, the touch panel 4051 and the display panel 4041 can be integrated to implement the input and output functions of the electronic device 4000.

[0134] The electronic device 4000 can further include one or more sensors, such as a pressure sensor, a gravity acceleration sensor, a proximity light sensor, and the like. Of course, the electronic device 4000 can further include a camera and other components as needed in a specific application, and since these components are not the main components used in embodiments of the present application, they will not be described in detail. Figure 4are not shown and will not be described in detail.

[0135] Those skilled in the art can understand that Figure 4 The electronic device is merely an example and is not intended to limit the electronic device, and can include more or fewer components than illustrated, or combine certain components, or different components.

[0136] For the convenience of description, the above parts are divided into modules (or units) according to functions and are described respectively. Of course, the functions of the modules (or units) can be implemented in the same or multiple software or hardware in implementing the present application.

[0137] Obviously, the above embodiments are only examples for clearly illustrating, rather than limiting the embodiments. Based on the above description, other different forms of changes or variations can be made by those skilled in the art. Here, all the embodiments do not need to be exhausted, and the obvious changes or variations derived therefrom are still within the protection scope of the present application.

Claims

1. A method for foreign key constraint detection, the method comprising: determining target key values of a to-be-queried foreign key in a to-be-queried row according to a received target query instruction, and obtaining a key value set; constructing, at an executor level, a key value query task based on the key value set, the key value query task being used to check whether the target key values exist in a parent table; executing, by an executor, the key value query task to obtain a target query result, wherein if the target key values are in a result set returned by the key value query task, it is determined that the detection is successful, otherwise, it is determined that the detection fails. 2.The method of claim 1, before the executing, by an executor, the key value query task to obtain a target query result, the method further comprises: setting an isolation level of a query task related to the to-be-queried foreign key to read uncommitted. 3.The method of claim 1, before the constructing, at an executor level, a key value query task based on the key value set, the method further comprises: if it is determined that the target key values are multiple, performing deduplication on the target key values in the key value set to obtain a deduplicated key value set. 4.The method of any one of claims 1-3, before the constructing, at an executor level, a key value query task based on the key value set, the method further comprises: removing target key values contained in a whitelist from the key value set; determining that a target query result corresponding to the removed target key values is detection success. 5.The method of claim 4, after the executing, by an executor, the key value query task to obtain a target query result, the method further comprises: adding the target key values for which the target query result is detection success to the whitelist. 6.An apparatus for foreign key constraint detection, the apparatus comprising: an obtaining unit configured to determine target key values of a to-be-queried foreign key in a to-be-queried row according to a received target query instruction, and obtain a key value set; a constructing unit configured to construct, at an executor level, a key value query task based on the key value set, the key value query task being used to check whether the target key values exist in a parent table; an executing unit configured to execute, by an executor, the key value query task to obtain a target query result, wherein if the target key values are in a result set returned by the key value query task, it is determined that the detection is successful, otherwise, it is determined that the detection fails. 7.The apparatus of claim 6, the executing unit is further configured to: set an isolation level of a query task related to the to-be-queried foreign key to read uncommitted. 8.The apparatus of claim 6, the constructing unit is further configured to: if it is determined that the target key values are multiple, perform deduplication on the target key values in the key value set to obtain a deduplicated key value set. 9.The apparatus of any one of claims 6-8, the constructing unit is further configured to: remove target key values contained in a whitelist from the key value set; determine that a target query result corresponding to the removed target key values is detection success. 10.The apparatus of claim 9, the executing unit is further configured to: add the target key values for which the target query result is detection success to the whitelist.

11. An electronic device comprising: a processor; and a memory storing computer instructions for causing the processor to perform the method of any one of claims 1-5.

12. A storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-5. ​

Citation Information

Patent Citations

  • Data processing method and device, program product and storage medium

    CN113448969A