Patent ID: 11880367
Assignee: XI'AN ZHONGXING NEW SOFTWARE CO., LTD.
Field: Computer technology (Electrical engineering)
Classification: CPC G | IPC G

Claim 4:
5. An apparatus for realizing a globally unique index, applicable to a distributed database, wherein the apparatus comprises a memory, a processor and a computer program stored on the memory and executable on the processor, and the computer program, when executed, causes the processor to implement a method for realizing a globally unique index, and the method comprises:
receiving a structured query language (SQL) request;
obtaining a conflict detection SQL statement corresponding to the SQL request;
calculating an expected value;
issuing the conflict detection SQL statement to each database node for execution;
obtaining an execution result of the conflict detection SQL statement;
comparing the execution result of the conflict detection SQL statement with the expected value; and
in response to the execution result of the conflict detection SQL statement being less than or equal to the expected value, processing an original SQL statement of the SQL request, and issuing the original SQL statement to the each database node for execution,
wherein obtaining the conflict detection SQL statement corresponding to the SQL request comprises:
in response to the SQL request being an insert request, determining whether an insert field of the insert request includes the globally unique index, and in response to the insert field including the globally unique index, splicing a globally unique index field and an insert field value to form the conflict detection SQL statement; wherein a where condition of the conflict detection SQL statement is that the globally unique index field is equal to the insert field value; and
in response to the SQL request being an update request, determining whether an update field of the update request includes the globally unique index, and in response to the update field including the globally unique index, splicing the globally unique index field and an update field value to form the conflict detection SQL statement; wherein the where condition of the conflict detection SQL statement is that the globally unique index field is equal to the update field value;
wherein one globally unique index is spliced with one conflict detection SQL statement.