Method, apparatus and medium for implementing a multi-tenant service system

By determining the isolation method and generating a second query statement in the service system, the problem of high modification costs when switching from a single-tenant architecture to a multi-tenant architecture is solved, and efficient automatic conversion of query statements is achieved.

CN117971876BActive Publication Date: 2025-12-19BEIJING LANYUN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410167963.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-06
Publication Date
2025-12-19
Estimated Expiration
2044-02-06

AI Technical Summary

Technical Problem

When a service system switches from a single-tenant architecture to a multi-tenant architecture, existing technologies require a significant amount of time and cost to modify structured query statements.

Method used

By determining the isolation method for tenant data and permissions, the system receives the first query statement input by the tenant, and generates a second query statement suitable for the multi-tenant architecture based on the isolation method and the tenant's identification information. The system then modifies the second query statement using an abstract syntax tree to automatically generate the second query statement.

Benefits of technology

This reduces the workload and cost of modifying structured query statements when switching service systems to a multi-tenant architecture, and improves response speed and modification efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117971876B_ABST
    Figure CN117971876B_ABST
Patent Text Reader

Abstract

The embodiment of the disclosure provides an implementation method, device and medium of a multi-tenant service system, and relates to the technical field of computers, wherein the method comprises: when the service system is switched from a single-tenant architecture to a multi-tenant architecture, determining an isolation mode of tenant data and permissions in the service system, and receiving a first query statement input by a tenant, the first query statement being a structured query statement of the service system under the single-tenant architecture; generating a second query statement according to the isolation mode, the identification information of the tenant and the first query statement, so that the service system executes the second query statement, the second query statement being a structured query statement of the service system under the multi-tenant architecture. The second query statement suitable for the multi-tenant architecture can be automatically generated, thereby reducing the workload, time and cost of modifying the structured query statement when the service system is switched to the multi-tenant architecture.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the computer technology, and in particular to an implementation method, device and medium of a multi-tenant service system. BACKGROUND

[0002] Multi-tenant technology is the core capability of SAAS (Software as a Service). When a WEB service system adopts a multi-tenant architecture, it can allow a WEB service software to serve multiple tenants simultaneously, and the data and permissions of each tenant do not interfere with each other.

[0003] Generally, according to the way of isolating the data and permissions of tenants by the service system, the multi-tenant architecture can include the following types: database isolation (i.e., per Database), that is, each tenant uses a separate database to store its own data and permissions; schema isolation (i.e., per Schema), that is, the data and permissions of multiple tenants share the same database, but each tenant uses its own schema; column isolation, that is, shared table, the data and permissions of multiple tenants share the database and table, and each row of data is marked with a tenant identifier.

[0004] The same business query logic has different implementation ways under different isolation modes, and the writing of the corresponding Structured Query Language (SQL) is also different. Therefore, after the service system selects the implementation way of the multi-tenant architecture, the Structured Query Language needs to be modified adaptively. A complete WEB service system usually contains a large number of Structured Query Languages, which results in a large workload of modifying the Structured Query Language, and requires a lot of time and cost. SUMMARY

[0005] The present disclosure provides an implementation method, device and medium of a multi-tenant service system.

[0006] In a first aspect, the present disclosure provides an implementation method of a multi-tenant service system, comprising: when the service system is switched from a single-tenant architecture to a multi-tenant architecture, determining the isolation mode of tenant data and permissions in the service system, and receiving a first query statement input by a tenant, the first query statement being a Structured Query Language of the service system under the single-tenant architecture; generating a second query statement according to the isolation mode, the identifier information of the tenant and the first query statement, so as to execute the second query statement by the service system, the second query statement being a Structured Query Language of the service system under the multi-tenant architecture.

[0007] In a second aspect, the embodiments of the present disclosure provide an implementation device of a multi-tenant service system, comprising a processor and a memory storing a computer program, and the computer program is executable by the processor to implement the implementation method of the multi-tenant service system in the above embodiments.

[0008] In a third aspect, the embodiments of the present disclosure provide a computer storage medium for storing computer-readable instructions, and the instructions are executable to implement the implementation method of the multi-tenant service system in the above embodiments.

[0009] Compared with the related art, the implementation method, device and medium of the multi-tenant service system provided by the embodiments of the present disclosure can modify the first query statement input by the tenant, automatically generate a second query statement suitable for the multi-tenant architecture, and reduce the workload, time and cost of modifying the structured query statement when the service system is switched to the multi-tenant architecture.

[0010] Other features and advantages of the present disclosure will be described in the following description, and some will become apparent from the description, or will be learned through practice of the present disclosure. Other advantages of the present disclosure can be achieved and obtained through the solutions described in the specification and the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0011] The accompanying drawings are used to provide an understanding of the technical solutions of the present disclosure, and constitute a part of the specification, and are used to explain the technical solutions of the present disclosure together with the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions of the present disclosure.

[0012] Figure 1 A flowchart of one embodiment of the implementation method of the multi-tenant service system of the present disclosure;

[0013] Figure 2 A scenario diagram of the implementation method of the multi-tenant service system of the present disclosure;

[0014] Figure 3 A flowchart of another embodiment of the implementation method of the multi-tenant service system of the present disclosure;

[0015] Figure 4 A flowchart of modifying an abstract syntax tree in one embodiment of the implementation method of the multi-tenant service system of the present disclosure;

[0016] Figure 5 A structural diagram of one embodiment of the implementation device of the multi-tenant service system of the present disclosure. DETAILED DESCRIPTION

[0017] The present disclosure describes a number of embodiments, but the description is illustrative rather than limiting and many additions, deletions, and modifications can be made to the described embodiments by those skilled in the art without departing from the scope of the described embodiments. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Any feature of any embodiment can be used with any other feature or element from any other embodiment, or in combination with any other feature or element of any other embodiment, or in the place of any other feature or element in any other embodiment, as would be understood by one of ordinary skill in the art. Unless specifically intended otherwise, the order of steps in which the described processes are carried out is immaterial.

[0018] The present disclosure includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The presently disclosed embodiments, features and elements can also be combined with any conventional feature or element to form a unique application defined by the claims. Any feature or element of any embodiment can also be combined with features or elements from other application to form another unique application defined by the claims. Therefore, it is to be understood that any feature shown and / or discussed in the present disclosure can be implemented alone or in any suitable combination. Embodiments are, therefore, not to be limited by other than as would be claimed in any appended claims and equivalents thereof. Further, various modifications and changes can be made thereto within the scope and spirit of the claims.

[0019] Further, in describing representative embodiments, the specification can have presented the method and / or process as a particular sequence of steps. However, to the extent that the method or process depends on more than one step, the method or process should not be limited to the particular sequence of steps described. Other sequences of steps can be possible, and are within the spirit and scope of the embodiments. Therefore, the particular order of the steps set forth in the specification is not an limitation. Further, the claims should not be limited to the steps of the method and / or process in the order in which they are written, as other sequences of steps can be possible and are within the spirit and scope of the embodiments.

[0020] As shown in Figure 1 The present embodiments propose an implementation method of a multi-tenant service system, which can include the following steps.

[0021] Step 110, when the service system is switched from a single-tenant architecture to a multi-tenant architecture, determining the isolation mode of tenant data and permissions in the service system, and receiving a first query statement input by a tenant.

[0022] The first query statement is a structured query statement of the service system under the single-tenant architecture.

[0023] Generally, the service system can be a Web (webpage) service system, which can run on a server. A tenant with permission can access the service system after logging in on a client, and then obtain services by inputting a structured query language (SQL) statement, for example, the tenant can click an operation button or a page in the client, the server can read the structured query language corresponding to the operation button or the page, and in response, the server can obtain corresponding data from a database in the back end according to the structured query language and feed back to the tenant.

[0024] The service system can be divided into a single-tenant architecture and a multi-tenant architecture, the former can serve a single tenant, and the latter can serve multiple tenants at the same time. When the service system adopts the single-tenant architecture, the isolation of tenant data and permissions does not need to be considered, so the structured query language (i.e., the first query statement in this embodiment) is irrelevant to the information of the tenant and the isolation mode. When the service system adopts the multi-tenant architecture, the data and permissions of multiple tenants need to be isolated, at this time, the tenant information needs to be carried in the structured query language (i.e., the second query statement in this embodiment) input by different tenants, and the writing of the structured query language under different isolation modes is also different. It can be seen that when the service system is switched from the single-tenant architecture to the multi-tenant architecture, the structured query language needs to be adjusted accordingly to adapt to the multi-tenant architecture.

[0025] In this embodiment, when the service system is switched from the single-tenant architecture to the multi-tenant architecture, the execution subject (for example, a server running the service system) can determine the isolation mode of tenant data and permissions under the multi-tenant architecture, which can be database isolation, schema isolation, or column isolation.

[0026] Step 120, generating a second query statement according to the isolation mode, the identification information of the tenant, and the first query statement, so that the service system executes the second query statement.

[0027] Among them, the second query statement is the structured query language of the service system under the multi-tenant architecture.

[0028] In this embodiment, the identification information of the tenant is used to represent the identity of the tenant inputting the first query statement, which can be the ID of the tenant, and the identification information of the tenant can generally be obtained when the tenant logs in the service system.

[0029] When the server running the service system receives the first query statement input by the tenant, the information of the tenant can be added in the first query statement according to the modification strategy corresponding to the isolation mode, so as to generate a second query statement. Here, the processing mode corresponding to different isolation modes is also different. For example, when the service system adopts schema isolation, the multi-tenant data table in the first query statement can be replaced with the data table of the tenant. When the service system adopts column isolation, a filter condition corresponding to the tenant can be generated according to the isolation mode and the identification information of the tenant, and then the filter condition is added to the first query statement. When the service system adopts database isolation, the first query statement can be directly used as the second query statement.

[0030] In an optional example, after the server running the service system generates the second query statement, the second query statement can be executed, and the processing result is returned to the client as the response of the first query statement, so that after the service system switches to the multi-tenant architecture, the structured query statement can be replaced from the single-tenant architecture to the multi-tenant architecture without feeling.

[0031] Figure 2 One scenario diagram of the implementation method of the multi-tenant service system of the present disclosure is shown, as shown in Figure 2 The service system runs in the server 220, and the client of the service system is loaded in the terminal device 210. The tenant can send a first query statement to the server 220 through the terminal device 210. The server 220 can modify the first query statement according to the isolation mode and the identification information of the tenant, generate a second query statement adapted to the multi-tenant architecture, then obtain the corresponding data from the data according to the second query statement as the execution result, and return the execution result to the terminal device 210 as the response of the first query statement. In this way, when the service system switches from the single-tenant architecture to the multi-tenant architecture, the first query statement can be automatically converted into an executable second query statement.

[0032] The implementation method, device and medium of the multi-tenant service system in the embodiment can modify the first query statement input by the tenant according to the identification information of the tenant and the isolation mode of the tenant data and the authority of the service system under the multi-tenant architecture when the service system switches from the single-tenant architecture to the multi-tenant architecture, automatically generate a second query statement suitable for the multi-tenant architecture, and reduce the workload, time and cost of modifying the structured query statement when the service system switches to the multi-tenant architecture.

[0033] The following refers to Figure 3 , Figure 3 Another embodiment of the implementation method of the multi-tenant service system of the present disclosure is shown in a flow diagram, as shown in Figure 3 The flow includes the following steps.

[0034] Step 310, when the service system is switched from a single-tenant architecture to a multi-tenant architecture, determining the isolation manner of tenant data and permissions in the service system, and receiving a first query statement input by a tenant.

[0035] Step 320, obtaining the identification information of the tenant and the configuration file of the database in the service system for storing tenant data.

[0036] Here, the identification information of the tenant is used to represent the identity information of the tenant inputting the first query statement, which can usually be the ID of the tenant. The configuration file includes parameter information of the database, which can include, for example, the database name, the data table name, and the column name in the database for storing tenant information, wherein the column name in the database for storing tenant information refers to the name of the column where the identification information of all tenants is located, which can usually be specified by the developer in advance.

[0037] As an example, the configuration file can be generated in advance according to the parameters of the database and stored in a preset location (which can be a server where the service system is located or other locations). After the service system is switched to a multi-tenant architecture, the server where the service system is located can obtain the configuration file from the location.

[0038] Step 330, loading the parameter information of the database from the configuration file, which includes the database name, the data table name, and the column name in the database for storing tenant information.

[0039] In this embodiment, after the server where the service system is located obtains the configuration file, it can load the parameter information of the database therefrom to obtain the information required for modifying the first query statement, which helps to improve the generation efficiency of the second query statement and further improve the response speed of the service system.

[0040] Step 340, parsing the first query statement to generate an abstract syntax tree.

[0041] The abstract syntax tree (AST) is a tree representation of the abstract syntax structure of the source code, and each node on the tree represents a structure in the source code.

[0042] In this embodiment, the server where the service system is located can be pre-loaded with a compiler for parsing the first query statement into an abstract syntax tree. Alternatively, the server can also call a function for processing the abstract syntax tree to process the first query statement, to generate the abstract syntax tree and view the definition of the abstract syntax tree, the category of the nodes, and the like.

[0043] Step 350, modifying the abstract syntax tree based on the parameter information, the identification information of the tenant, and the isolation manner, so that the modified abstract syntax tree contains the identification information of the tenant.

[0044] In the embodiment, the server where the service system is located can traverse the nodes (for example, nodes of types such as SELECT, JOIN, etc.) related to the query condition in the abstract syntax tree, and then modify the attributes of the related nodes by combining the parameter information and the identification information of the tenant according to the corresponding strategy in the isolation mode, so that the modified nodes contain the identification information of the tenant.

[0045] Step 360, generating a second query statement based on the modified abstract syntax tree.

[0046] In the embodiment, the server where the service system is located can traverse each node of the modified abstract syntax tree, and generate a corresponding statement according to the type and attribute of the node.

[0047] Figure 3 The embodiments shown can parse the first query statement into an abstract syntax tree, and then modify the abstract syntax tree according to the parameter information of the database, the isolation mode, and the identification information of the tenant. Thanks to the concise code representation form of the abstract syntax tree, the modification efficiency can be improved. Then, the second query statement generated according to the modified abstract syntax tree can be applicable to various development languages and their development tools and libraries, so that the second query statement has stronger universality.

[0048] In some optional implementations of the embodiment, the above step 350 can adopt Figure 4 The flow shown as Figure 4 The flow includes the following steps.

[0049] Step 410, traversing each Select subquery in the abstract syntax tree, and identifying the data table name included in the FROM clause of each Select subquery.

[0050] Step 420, comparing the data table name included in each FROM clause with the data table name in the parameter information to determine whether the data table name included in each FROM clause is a multi-tenant table.

[0051] Step 430, in the case where the data table name included in the FROM clause is a multi-tenant table, modifying each Select subquery according to the isolation mode and the identification information of the tenant, so that the identification information of the tenant is included in each Select subquery.

[0052] Generally, the Select subquery in the abstract syntax tree includes a query condition, and the content in the FROM clause is used to limit the source of data.

[0053] In the embodiment, the query condition of the first query statement can be obtained by traversing each select subquery in the abstract syntax tree, and when the data table name in the FROM clause is a multi-tenant table, the tenant information is added to each select subquery according to the isolation mode and the identification information of the tenant, so that the modification of the abstract syntax tree is completed. With the aid of the abstract syntax tree, the query condition in the first query statement can be more accurately identified, and the efficiency and flexibility of the modification process can be improved.

[0054] Since the writing of the structured query statement is related to the isolation mode, the modification method of the select subquery is different under different isolation modes.

[0055] In some optional embodiments of the embodiment, when the isolation mode is schema isolation, the modification method in the step 430 can include: replacing the data table name included in each FROM clause in the abstract syntax tree with the data table name corresponding to the tenant according to the identification information of the tenant.

[0056] As an example, assuming that the identification information of the tenant is "tenant1", the first query statement is: SELECT Name, Title FROM evt_threat WHERE Time >= 160012300 AND Time <= 160012500, and the data table name corresponding to the tenant is tenant1.evt_threat. The information of the database table evt_threat is shown in Table 1.

[0057] Table 1

[0058]

[0059] Replacing "evt_threat" with "tenant1.evt_threat" can add the tenant information to the select subquery, so as to obtain the modified abstract syntax tree. The second query statement generated by the step 360 is: SELECT Name, Title FROM tenant1.evt_threat WHERE Time >= 160012300 AND Time <= 160012500.

[0060] In the embodiment, for schema isolation, the multi-tenant table in the select subquery can be modified by the replacement method, so as to add the tenant information to the select subquery.

[0061] In an optional example in the embodiment, when the select subquery further includes a JOIN clause, the data table name in each JOIN clause can be replaced with the data table name corresponding to the tenant.

[0062] Continuing to illustrate in conjunction with the above example, assume that the first query statement is:

[0063] SELECT evt_threat.Name, evt_threat.Title, data_source.Addr FROM evt_threat LEFT JOIN data_source ON evt_threat.DSID = data_source.ID WHERE evt_threat.Time >= 160012300 AND evt_threat.Time <= 160012500.

[0064] The information of the database table data_source can be referred to Table 2.

[0065] Table 2

[0066] Column Name Type ID String Name String Addr String tenant_id String

[0067] Replace “evt_threat” with “tenant1.evt_threat”, and replace the data table name in the JOIN clause with the tenant corresponding data table name “data_source” with the tenant corresponding data table name “tenant1.data_source”, and the modification of the abstract syntax tree is completed. The second query statement obtained through the above step 260 is: SELECT evt_threat.Name, evt_threat.Title, data_source.Addr FROM tenant1.evt_threat LEFT JOIN tenant1.data_source ON evt_threat.DSID = data_source.ID WHERE evt_threat.Time >= 160012300 AND evt_threat.Time <= 160012500.

[0068] In some other embodiments of the present embodiment, when the isolation mode is column isolation, the modification of the select subquery in the above step 430 can include: generating a filter condition of the multi-tenant table based on the identification information of the tenant; and adding the filter condition of the multi-tenant table to the WHERE clause of the select subquery.

[0069] As an example, assuming the identification information of the tenant is "tenantl", the filter condition of the multi-tenant table can be expressed as: tenant_id = 'tenantl'. Assuming the first query statement is: SELECT Name, Title FROM evt_threat WHERE Time >= 160012300 AND Time <= 160012500. After adding the filter condition to the selected subquery, the second query statement generated by step 360 is: SELECT Name, Title FROM evt_threat WHERE Time >= 160012300 AND Time <= 160012500 AND tenant_id = 'tenantl'.

[0070] In the embodiment, when the service system adopts the isolation mode of column isolation, the filter condition generated based on the identification information of the tenant can be added to the selected subquery of the abstract syntax tree, so as to realize the modification of the abstract syntax tree.

[0071] In an optional example of the embodiment, when the selected subquery also includes a JOIN clause, the above modification process can further include: traversing the data table names included in each JOIN clause, and generating a filter condition of each data table based on the identification information of the tenant; and adding the filter condition of each data table to the WHERE clause of the selected subquery.

[0072] As an example, assuming the first query statement is: SELECT evt_threat.Name, evt_threat.Title, data_source.Addr FROM evt_threat LEFT JOIN data_source ON evt_threat.DSID = data_source.ID WHERE evt_threat.Time >= 160012300 AND evt_threat.Time <= 160012500. The two data table names "evt_threat" and "data_source" are included, and the generated filter conditions are: evt_threat.tenant_id = 'tenantl' and data_source.tenant_id = 'tenantl' respectively. After adding the two filter conditions to the WHERE clause, the second query statement obtained by step 260 is:

[0073] SELECT evt threat.Name, evt threat.Title, data source.Addr FROM evt threat LEFT JOIN data source ON evt threat.DSID = data source.ID WHERE evt threat.tenant_id = 'tenantl'AND data source.tenant_id = 'tenantl'AND evt threat.Time >= 160012300 AND evt threat.Time <= 160012500.

[0074] The embodiment of the present disclosure further provides an implementation device of a multi-tenant service system, which comprises a processor 510 and a memory 520 storing a computer program, and the computer program is executed by the processor to implement the implementation method of the multi-tenant service system in any of the above embodiments. Figure 5 As shown in the figure, the implementation device comprises a processor 510 and a memory 520 storing a computer program, and the computer program is executed by the processor to implement the implementation method of the multi-tenant service system in any of the above embodiments.

[0075] The processor 510 in the embodiment can be a general processor, including a central processing unit (CPU), a microprocessor, etc., and can also be other conventional processors, etc.; the processor 510 can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC); or a combination of the above devices. That is, the processor 510 in the above embodiment can be any processing device or combination of devices that implement the methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure. If the embodiments of the present disclosure are implemented partially in software, instructions for the software can be stored in a suitable nonvolatile computer readable storage medium, and one or more processors can be used to execute the instructions in hardware to implement the methods of the embodiments of the present disclosure.

[0076] The embodiment of the present disclosure further provides a computer storage medium for storing computer instructions, which are executed to implement the implementation method of the multi-tenant service system in any of the above embodiments.

[0077] Those of ordinary skill in the art will realize and understand that all or some of the steps in the methods disclosed above and the functional modules / units in the systems and devices can be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be performed by several physical components in cooperation. Some or all of the components can be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on computer-readable media, which can include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those of ordinary skill in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, it is common and well understood by those of ordinary skill in the art that communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and can include any information delivery media.

Claims

1. A method of implementing a multi-tenant service system, the method comprising: Comprising: When a service system is switched from a single-tenant architecture to a multi-tenant architecture, determining an isolation manner of tenant data and permissions in the service system, and receiving a first query statement input by a tenant, the first query statement being a structured query statement of the service system under the single-tenant architecture; According to the isolation manner, the identification information of the tenant, and the first query statement, generating a second query statement, so that the service system executes the second query statement, the second query statement being a structured query statement of the service system under the multi-tenant architecture.

2. The method of claim 1, wherein, Before generating the second query statement, the method further comprises: Obtaining the identification information of the tenant and a configuration file of a database in the service system for storing tenant data; Loading parameter information of the database from the configuration file, the parameter information including a database name, a data table name, and a column name in the database for storing tenant information.

3. The method of claim 2, wherein, According to the isolation manner, the identification information of the tenant, and the first query statement, generating a second query statement, comprises: Parsing the first query statement to generate an abstract syntax tree; Based on the parameter information, the identification information of the tenant, and the isolation manner, modifying the abstract syntax tree so that the modified abstract syntax tree contains the identification information of the tenant; Based on the modified abstract syntax tree, generating the second query statement.

4. The method of claim 3, wherein, Based on the parameter information, the identification information of the tenant, and the isolation manner, modifying the abstract syntax tree so that the modified abstract syntax tree contains the identification information of the current tenant, comprises: Traversing each select subquery in the abstract syntax tree to identify the data table name included in the FROM clause of each select subquery; Comparing the data table name included in each FROM clause with the data table name in the parameter information to determine whether the data table name included in each FROM clause is a multi-tenant table; In the case where the data table name included in the FROM clause is a multi-tenant table, modifying each select subquery according to the isolation manner and the identification information of the tenant so that the identification information of the tenant is included in each select subquery.

5. The method of claim 4, wherein, According to the isolation manner and the tenant information, modifying each select subquery so that the identification information of the tenant is included in each select subquery, comprises: In the case where the isolation manner is schema isolation, replacing the data table name included in each FROM clause in the abstract syntax tree with the data table name corresponding to the tenant according to the identification information of the tenant.

6. The method of claim 5, wherein, In the case where the select subquery further includes a JOIN clause, the method further comprises: Replacing the data table name in each JOIN clause with the data table name corresponding to the tenant.

7. The method of claim 4, wherein, According to the isolation manner and the tenant information, modifying each select subquery so that the identification information of the tenant is included in each select subquery, comprises: In the case where the isolation manner is column isolation, generating a filter condition of the multi-tenant table based on the identification information of the tenant; adding the filter condition of the multi-tenant table to the WHERE clause of the select subquery.

8. The method of claim 7, wherein, In the case that the select subquery further comprises a JOIN clause, the method further comprises: traversing the data table names included in each JOIN clause, and generating a filter condition of each data table based on the identification information of the tenant; adding the filter condition of each data table to the WHERE clause of the select subquery.

9. An apparatus for implementing a multi-tenant service system, comprising a processor and a memory having stored thereon a computer program, wherein, The computer program, when executed by the processor, implements the implementation method of the multi-tenant service system of any one of claims 1 to 8.

10. A computer storage medium storing computer-readable instructions, characterized in that, The instructions, when executed, implement the implementation method of the multi-tenant service system of any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data query method and device, electronic equipment and computer readable storage medium

    CN114328574A