Structured text processing method and device and related product
By introducing a target compatibility plugin into the database management system, structured text from different database management systems can be processed. Hook functions are used to perform syntax and semantic analysis, which solves the problem of deep coupling of kernel code, reduces development difficulty, and ensures the correctness of processing results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2026-04-03
AI Technical Summary
Compatibility issues between different database management systems lead to deep coupling of the kernel code, increasing development difficulty and the risk of code conflicts, and making it difficult to keep up with community updates.
By deploying a target compatibility plugin in the first database management system, structured text created based on the syntax of the second database management system is parsed and processed. Hook functions are used to perform syntax parsing, semantic analysis, rewriting and optimization to obtain processing results that conform to the syntax of the first database management system.
This decouples the kernel from compatibility code, reduces development difficulty, ensures the correctness and reliability of processing results, and avoids the risk of conflicts caused by kernel code modifications.
Smart Images

Figure CN121785671A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus and related products for processing structured text. Background Technology
[0002] Currently, different platforms may use different database management systems (DBMS) to process data (such as structured text), and these DBMSs have different syntaxes and features. However, when different DBMSs need to interact and process data composed of the syntax and features of another DBMS, it may lead to processing failures.
[0003] To address the issue of cross-platform data processing incompatibility, related technologies employ database management systems (DBMSs) that ensure compatibility with other DBMSs. For example, if DBMS A needs to process data from DBMS B, DBMS A must be compatible with DBMS B. This compatibility can be achieved by modifying the kernel code of DBMS A to support the processing of data composed of the syntax and features of DBMS B.
[0004] However, since the modification involves the code in the kernel of the database management system, the compatibility features are deeply coupled with the kernel code. As a result, when the community corresponding to the database management system releases new features or fixes, the new features or fixes may conflict with the code corresponding to the compatibility features, making it difficult for the database management system to synchronize its code with the community and increasing the development difficulty of the database management system. Summary of the Invention
[0005] This application provides a method, apparatus, and related products for processing structured text, aiming to decouple the code and compatibility features in the kernel of a database management system, thereby reducing the development difficulty of the database management system.
[0006] The first aspect of this application provides a method for processing structured text, applied to a first server, the first server having a first database management system deployed thereon, comprising:
[0007] The target structured text to be processed is obtained; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server;
[0008] The target structured text is parsed to determine the target text, and then the target text is sent to the target compatibility plugin. The target compatibility plugin is used to process the structured text created based on the syntax of the second database management system. The target compatibility plugin is deployed in the first database management system.
[0009] The target text is processed using the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the First Database Management System.
[0010] A second aspect of this application provides a structured text processing apparatus applied to a first server, the first server having a first database management system deployed thereon, comprising:
[0011] The acquisition module is used to acquire the target structured text to be processed; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server;
[0012] The sending module is used to parse the target structured text, determine the target text of the target structured text, and send the target text to the target compatibility plugin; the target compatibility plugin is used to process the structured text created based on the syntax of the second database management system; the target compatibility plugin is deployed in the first database management system;
[0013] The processing module is used to process the target text through the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the first database management system.
[0014] As an optional implementation, the processing module is used for:
[0015] The target text is parsed using a target compatibility plugin to obtain the parsing results;
[0016] The processing function of the target compatibility plugin is invoked through a hook function to process the syntax parsing results and obtain the processing result corresponding to the target structured text.
[0017] As an optional implementation, the processing module is specifically used for:
[0018] The semantic analysis function of the target compatibility plugin is called through the first hook function to perform semantic analysis on the syntax parsing results and obtain the semantic analysis results.
[0019] The second hook function calls the rewrite and optimization function of the target compatibility plugin to rewrite and optimize the semantic analysis results, thus obtaining the optimized processing results.
[0020] The third hook function calls the execution function of the target compatibility plugin to perform the optimization processing and obtain the processing result corresponding to the target structured text.
[0021] As an optional implementation, the device also includes:
[0022] The first processing module is used to obtain the first structured text to be processed; the first structured text is obtained based on the syntax of the first database management system; the first structured text is processed to obtain the first processing result corresponding to the first structured text; the syntax of the first processing result is the syntax of the first database management system.
[0023] As an optional implementation, the acquisition module is used for:
[0024] Retrieve multiple structured texts to be processed; each structured text includes syntax markers;
[0025] The target plugin function determines whether the syntax identifier of each structured text is the target syntax identifier, and the structured text whose syntax identifier is the target syntax identifier is taken as the target structured text. The target plugin function is the entry function corresponding to the target compatibility plugin, and the plugin function is used to identify the structured text that includes the target syntax identifier.
[0026] As an optional implementation, the sending module is specifically used for:
[0027] The target structured text is parsed using the target plugin function to obtain the target text of the target structured text;
[0028] The target text is sent to the target compatibility plugin via the target plugin function.
[0029] As an optional implementation, a storage module is also included after the processing module to store the processing results.
[0030] A third aspect of this application provides an electronic device, the device comprising a processor and a memory:
[0031] The memory is used to store program code and transmit the program code to the processor;
[0032] The processor is configured to execute the steps of the structured text processing method provided in the first aspect according to the instructions in the program code.
[0033] A fourth aspect of this application provides a computer-readable storage medium for storing program code for performing the steps of the structured text processing method provided in the first aspect.
[0034] The fifth aspect of this application provides a computer program product, including a computer program or instructions that, when executed, implement the steps of the structured text processing method provided in the first aspect.
[0035] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0036] In this application's technical solution, a target structured text is obtained by creating a structured text based on the syntax of a second database management system. This second database management system is deployed on a second server. The target structured text is then parsed to determine its target text, which is then sent to a target compatibility plugin. The target compatibility plugin processes the structured text created based on the syntax of the second database management system. The target compatibility plugin is deployed within a first database management system. Further processing of the target text by the target compatibility plugin yields a processing result corresponding to the target structured text. The syntax of the processing result is the syntax of the first database management system.
[0037] Thus, by parsing the target structured text created using the syntax of the second database management system, the target text is determined. This target text is then sent to the target compatibility plugin, which processes the structured text created using the syntax of the second database management system. The target compatibility plugin then processes the target text to obtain the processing result, which is the syntax of the first database management system. Without modifying the kernel code of the first database management system, the compatibility plugin processes the target structured text created using the syntax of the second database management system. This ensures that the target structured text can be processed successfully, thereby decoupling the kernel and compatibility code and reducing development difficulty. Attached Figure Description
[0038] Figure 1 A schematic diagram illustrating a scenario for a structured text processing method provided in an embodiment of this application;
[0039] Figure 2 A flowchart illustrating a structured text processing method provided in this application embodiment;
[0040] Figure 3 A schematic diagram illustrating a structured text processing method provided in an embodiment of this application;
[0041] Figure 4 A schematic diagram of the structure of a structured text processing device provided in an embodiment of this application;
[0042] Figure 5 This is a schematic diagram of the server structure in an embodiment of this application;
[0043] Figure 6 This is a schematic diagram of the structure of a terminal device in an embodiment of this application. Detailed Implementation
[0044] In related technologies, in order to achieve compatibility between database management systems on different platforms, it is necessary to make extensive modifications to the kernel code of the database management system used to process data from another database management system, to the point that the kernel of the database management system is deeply coupled with the compatibility code.
[0045] As an example, suppose database management system A needs to process data from database management system B. Database management system A needs to be compatible with database management system B. This compatibility can be achieved by modifying the kernel code of database management system A to support processing data composed of the syntax and features of database management system B. Further assuming the database management system includes a syntax layer, a semantic layer, and an executor, then support for the syntax rules of database management system B needs to be added to the syntax layer of database management system A to ensure the syntax parsing process completes correctly. In the semantic layer of database management system A, a semantic analysis process for object names within packages needs to be added. In the executor of database management system A, the creation of packages, functions, types, and other objects needs to be completed, and metadata needs to be written. That is, the modifications to the syntax layer, semantic layer, and executor share a set of code with the ordinary structured text processing flow, resulting in the functionality used for compatibility with database management system B being tightly coupled to the kernel code of database management system A.
[0046] When the community of a database management system releases new policies (such as new features, new fixes, new versions, etc.), these new policies may conflict with compatibility code (compatibility code refers to code used to achieve compatibility with another database management system), that is, the new policies cannot be integrated into the kernel code of the database management system.
[0047] Integrating new strategies into the database management system requires significant manpower and time to resolve conflicts between the new strategies and compatibility code, further increasing code complexity. This makes it difficult for the database management system to synchronize its code with subsequent community updates when new strategies are introduced, further complicating its development.
[0048] In view of the above problems, this application provides a method, apparatus, and related product for processing structured text. The method includes: acquiring target structured text to be processed, created based on the syntax of a second database management system; deploying the second database management system on a second server, then parsing the target structured text to determine the target text, and sending the target text to a target compatibility plugin; wherein the target compatibility plugin is used to process the structured text created based on the syntax of the second database management system; the target compatibility plugin is deployed in a first database management system; further processing the target text through the target compatibility plugin to obtain a processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the first database management system.
[0049] Thus, by parsing the target structured text created using the syntax of the second database management system, the target text is determined. This target text is then sent to the target compatibility plugin, which processes the structured text created using the syntax of the second database management system. The target compatibility plugin then processes the target text to obtain the processing result, which is the syntax of the first database management system. Without modifying the kernel code of the first database management system, the compatibility plugin processes the target structured text created using the syntax of the second database management system. This ensures that the target structured text can be processed successfully, thereby decoupling the kernel and compatibility code and reducing development difficulty.
[0050] Figure 1 An exemplary scenario architecture diagram of a structured text processing method is shown. Figure 1 It includes the first server 101 and the second server 102. Figure 1 The first and second servers shown can both be independent physical servers, or server clusters or distributed systems composed of multiple physical servers. Additionally, servers can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Figure 3 The terminal device 302 shown is a device with a display screen, including but not limited to mobile phones, tablets, computers, smart voice interaction devices, and vehicle terminals, but not limited to these. The terminal device and the server can be connected directly or indirectly through wired or wireless communication, and this application does not impose any restrictions.
[0051] The second server 102 receives the target query request sent by the client, creates the target structured text according to the syntax of the deployed second database management system, and then sends the target structured text to the first server 101.
[0052] The first database management system deployed on the first server 101 acquires the target structured text to be processed. It should be understood that since the first server 101 and the second server 102 are different servers, the syntax rules and some characteristics of the first database management system are different from those of the second database management system. Therefore, the first server 101 cannot directly process the target structured text and needs to execute subsequent processes to achieve the processing of the target structured text.
[0053] The first server 101 parses the target structured text, determines the target text of the target structured text, and sends the target text to the target compatibility plugin. It should be understood that, in this embodiment, the target compatibility plugin can be deployed in the first database management system. This plugin can process the target structured text created using the syntax of the second database management system. Since this plugin is a relatively independent functional component with extensibility relative to the first database management system, processing functions for target structured text can be developed within it without setting or modifying kernel code in the first database management system, thus decoupling the kernel from the compatibility code.
[0054] The first server 101 processes the target text using a target compatibility plugin to obtain a processing result corresponding to the target structured text. The syntax of this processing result conforms to the syntax of the first database management system. It should be understood that, in this embodiment, the target compatibility plugin is deployed in the first database management system; therefore, the processing result corresponding to the target structured text must conform to the syntax of the first database management system so that the first database management system can read the processing result.
[0055] In this embodiment, the target structured text created by the syntax of the second database management system is parsed to determine the target text. The target text is then sent to a target compatibility plugin for processing the structured text created by the syntax of the second database management system. The target compatibility plugin then processes the target text to obtain a processing result, which is the syntax of the first database management system. Without modifying the kernel code of the first database management system, the compatibility plugin processes the target structured text created by the syntax of the second database management system. This ensures that the target structured text can be processed successfully, thereby decoupling the kernel and compatibility code and reducing development difficulty.
[0056] In practice, the collection and processing of relevant data in this application should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the subject of personal information, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0057] See Figure 2 The figure is a flowchart illustrating a structured text processing method provided in an embodiment of this application.
[0058] Combination Figure 2 As shown, this application provides a method for processing structured text, which can be applied to a first server. The first server is equipped with a first database management system, which may include:
[0059] S201: Obtain the target structured text to be processed.
[0060] The first database management system refers to a system deployed on the first server that has data processing capabilities.
[0061] The target structured text refers to SQL text. SQL (Structured Query Language) is a language specifically designed for communicating with databases (also known as database management systems). SQL allows various operations to be performed using objects, such as querying, updating, inserting, and deleting data in the database. SQL is the standard language for database management systems.
[0062] SQL statements include Data Manipulation Language (DML), Data Definition Language (DDL), Data Control Language (DCL), and Transaction Control Language (TCL). DML is used to query (SELECT) and modify (INSERT, UPDATE, DELETE) data. DDL is used to define and modify the structure of database objects, such as tables and indexes. DCL is used to define access permissions and security levels for databases, tables, and fields. TCL manages database transactions, ensuring data integrity and consistency.
[0063] In this embodiment, the target structured text is created based on the syntax of a second database management system. The second database management system refers to a system deployed on a second server that has data processing capabilities.
[0064] It should be noted that, in one possible implementation, when the structured text received by the first database management system is a first structured text, which is obtained based on the syntax of the first database management system, then the first structured text can be processed to obtain a first processing result corresponding to the first structured text, and the syntax of the first processing result is the syntax of the first database management system.
[0065] It should be understood that, in the embodiments of this application, if the first database management system receives structured text created by its own syntax, then the first structured text conforms to the syntax rules of the first database management system, and the first structured text can be directly processed to obtain the corresponding first processing result, without affecting the processing logic of the first database management system's own structured text (i.e., the first structured text), thus ensuring the reliability of the first database management system.
[0066] S202: Parse the target structured text, determine the target text of the target structured text, and send the target text to the target compatibility plugin.
[0067] The target text refers to the SQL statement created according to the syntax of the second database management system.
[0068] A plugin is a software component that can extend the functionality of an existing database management system or add new features without modifying the core code of the original database management system. This modular design makes the database management system more flexible and scalable. In this application embodiment, a compatibility plugin refers to a plugin used to achieve compatibility with other database management systems.
[0069] In this embodiment of the application, the directory of the target compatibility plugin may include, but is not limited to, the following functions:
[0070] Catalog: System table management;
[0071] Commands: The entry function provided by the plugin (indicating the target plugin function);
[0072] Executor: The executor of the First Database Management System sets hook functions on key logic (such as semantic analysis, rewriting and optimization, etc.), defines the hook functions to be executed (that is, to let the executor enter the execution logic of the target compatibility plugin) and completes the compatibility function;
[0073] Parser: After receiving the target text, the target plugin function uses the syntax parser (i.e., syntax parsing function) built into the target compatibility plugin to process it, without affecting the syntax parsing logic of the First Database Management System itself.
[0074] In this embodiment of the application, the first server can interact with multiple servers. Therefore, the first database management system may need to be compatible with multiple other database management systems. Thus, the first database management system in this embodiment of the application can deploy multiple compatibility plugins, each of which implements the processing functions of the corresponding database management system.
[0075] It should be understood that, in the embodiments of this application, the target structured text is obtained based on the syntax of the second database management system, and therefore needs to be processed by the target compatibility plugin in the first database management system for processing the structured text created based on the syntax of the second database management system.
[0076] It should be understood that, since this target compatibility plugin is a relatively independent functional component with extensibility relative to the first database management system, processing functions for target structured text can be developed in this target compatibility plugin without setting up or modifying the kernel code in the first database management system, thus achieving decoupling between the kernel and compatibility code.
[0077] S203: Process the target text using the target compatibility plugin to obtain the processing result corresponding to the target structured text.
[0078] The syntax of the processing result is the syntax of the first database management system. It should be understood that, in order to ensure that the first database management system can read the processing result, in this embodiment, the syntax of the processing result obtained by the target compatibility plugin from processing the target text should be the syntax of the first database management system.
[0079] In one possible implementation, after step S203, the process may further include storing the processing result. It should be understood that saving the processing result facilitates subsequent reading, forwarding, and reprocessing of the result by the first database management system.
[0080] In this embodiment of the application, without modifying the kernel code of the first database management system, a compatibility plugin is used to process the target structured text created by the syntax of the second database management system. While ensuring that the target structured text can be processed successfully, the kernel and compatibility code are decoupled, reducing the development difficulty.
[0081] Based on the structured text processing method provided in the above embodiments, in one possible implementation, step S201 may include:
[0082] A1: Retrieves multiple structured texts to be processed.
[0083] The first database management system can obtain multiple structured texts to be processed. The source of these multiple structured texts can be itself or other database management systems, without any specific limitations.
[0084] Each structured text includes a syntax identifier. A syntax identifier refers to an identifier used to indicate the syntax of the corresponding structured text.
[0085] A2: Determine whether the syntax identifier of each structured text is the target syntax identifier through the target plugin function, and take the structured text whose syntax identifier is the target syntax identifier as the target structured text.
[0086] The term "plugin function" refers to the entry point function corresponding to a compatibility plugin. The first database management system can include multiple compatibility plugins, each of which can have its own corresponding plugin function, without specific limitations here. The "target plugin function" is the entry point function corresponding to the target compatibility plugin. The entry point function refers to the interface function that sends the target structured text to the target compatibility plugin.
[0087] In one possible implementation, the target plugin function can be provided by the plugin mechanism of the first database management system. Plugins are a kernel capability that is completely decoupled from the kernel and are generally used to provide some kernel auxiliary functions. Here, they are used to implement the syntax acceptance entry point of the second data management system.
[0088] It should be understood that since the first database processing system cannot directly process the target structured text, it needs to be processed through the target compatibility plugin. That is, the target compatibility plugin needs to identify the target structured text to be processed in multiple structured texts, and pass the target text of the target structured text to the target compatibility plugin.
[0089] Therefore, in this embodiment, a target plugin function can be set to recognize the target structured text. By determining a target plugin function, the target plugin function can judge the syntax identifier of each structured text. When the syntax identifier is the target syntax identifier (i.e., the syntax identifier corresponding to the syntax rules of the second database management system), the structured text is taken as the target structured text, so that the target structured text can be processed subsequently without modifying the kernel code of the first database management system, thus achieving decoupling between the kernel and compatibility code.
[0090] Based on the above implementation, step S202 may include:
[0091] B1: Use the target plugin function to parse the target structured text and obtain the target text of the target structured text.
[0092] It should be understood that after the target structured text is determined, it is also necessary to parse the target structured text to extract the SQL statements in the target structured text so that the target compatibility component can process the SQL statements.
[0093] In one possible implementation, the target plugin function can include two parameters. The first parameter is the text language type, such as DDL, DCL, etc. This first parameter indicates the type of SQL statement corresponding to the target structured text. For example, if the text language type is DDL, then the current operation (the operation corresponding to the target structured text) is a data definition statement. The second parameter is the target text, which can also be understood as the specific syntax text within the target structured text.
[0094] As an example, see the following code:
[0095] SELECT ORACLE('DDL',$$
[0096] CREATE PACKAGE emp_bonus AS
[0097] PROCEDURE calc_bonus(date_hired employees.hire_date%TYPE);
[0098] END emp_bonus;
[0099] $$);
[0100] Here, “SELECT ORACLE” represents the syntax identifier of the target structured text, “DDL” represents the text language type of the target structured text, and the text between the two “$$” represents the target text of the target structured text.
[0101] B2: Send the target text to the target compatibility plugin via the target plugin function.
[0102] It should be understood that after the target plugin function recognizes the target structured text corresponding to the target syntax identifier, it will send the target text of the target structured text to the target compatibility plugin through its own function mechanism, so that the target compatibility plugin can process the target text without modifying the kernel code of the first database management system, thus achieving decoupling between the kernel and compatibility code.
[0103] Based on the structured text processing method provided in the above embodiments, in one possible implementation, step S303 may include:
[0104] C1: The target text is parsed using the target compatibility plugin to obtain the parsing results.
[0105] Syntax parsing refers to the validation of the syntax of the target text, checking whether it conforms to the syntax rules of the SQL language corresponding to the second database management system. In one possible implementation, the lexical units of the target text can be combined and validated according to the SQL language's syntax rules to ensure the correctness of the target text's syntactic structure. For example, checking whether the target text specifies the queried table and whether the correct SQL keywords are used, etc.
[0106] It should be understood that after the target compatibility plugin receives the target text, it can first perform syntax parsing on the target text to ensure that the syntax structure of the target text is correct, thereby further ensuring the accuracy of the processing results.
[0107] If the parsing result indicates that the target text has a correct grammatical structure, then step C2 is executed; if the parsing result indicates that the target text has an incorrect grammatical structure, then the processing flow can be terminated and a parsing failure message can be returned.
[0108] C2: By calling the processing function of the target compatibility plugin through the hook function, the syntax parsing result is processed to obtain the processing result corresponding to the target structured text.
[0109] A hook function is a special type of function whose main purpose is to insert custom code or logic at specific points in the program's execution to modify or extend the program's behavior. Hook functions are an interface or mechanism provided by database management systems that allow user-defined code to be inserted when specific events or function calls occur.
[0110] It should be understood that, since hook functions can insert custom code or logic at specific points, they can be inserted at locations corresponding to critical execution steps in the first database management system. This allows the hook functions to trigger and call the processing functions of the target compatibility plugin after the syntax parsing results are obtained. This approach avoids modifying the code of the first database management system while enabling the target compatibility plugin to process the syntax parsing results and obtain the corresponding target structured text.
[0111] In one possible implementation, the first database management system, in addition to syntax parsing functionality, may also include semantic analysis functionality, rewriting and optimization functionality, and execution functionality. Therefore, step C2 may include:
[0112] D1: The semantic analysis function of the target compatibility plugin is called through the first hook function to perform semantic analysis on the syntax parsing results and obtain the semantic analysis results.
[0113] Semantic analysis refers to checking whether the access objects (such as tables and columns) in the target text exist, and whether the objects using the target text have the corresponding permissions to execute the target text. Specifically, based on syntax parsing, it further checks whether the database objects (such as table names and column names) in the target text exist in the database, and whether the objects using the target text have sufficient permissions, thus obtaining the semantic analysis results. In addition, type checking can be performed to ensure data type matching and consistency.
[0114] D2: The second hook function calls the rewrite and optimization function of the target compatibility plugin to rewrite and optimize the semantic analysis results, and obtain the optimized processing results.
[0115] It should be understood that, assuming the syntax and semantics are correct, optimizing the target text can improve subsequent execution efficiency. In one possible implementation, an optimizer can be used to rewrite and optimize the target text, selecting the optimal execution plan as the result. The optimizer considers various factors, such as the use of indexes, the order of table joins, and the distribution of data, to generate an efficient execution plan.
[0116] D3: The third hook function calls the execution function of the target compatibility plugin to perform the optimization processing and obtain the processing result corresponding to the target structured text.
[0117] It should be understood that after determining the optimized execution plan, the storage engine can be invoked to execute the optimized processing results based on the optimized execution plan, and the results will be returned. As one possible implementation, the executor, based on the execution plan (i.e., the optimized processing results) generated by the optimizer, invokes the underlying storage engine of the database (such as InnoDB, MyISAM, etc.) to perform actual database operations, such as adding, deleting, modifying, and querying data.
[0118] In this embodiment, to ensure that the target structured text can be processed according to the processing flow of the first database processing system without modifying the kernel code of the first database processing system, a target compatibility plugin can be set up to process the target structured text. For each key processing node in the first database management system, the corresponding function in the target compatibility component can be executed through a hook function. This achieves the processing of the target structured text without modifying the kernel code of the first database management system, ensuring the correctness and reliability of the processing. Since hook functions allow developers to insert custom functions or logic without modifying the original code structure, hook functions can be considered as "plugin" points in the code. That is, the target compatibility component can be called through hook functions without directly modifying the kernel code, thereby improving the modularity and maintainability of the code.
[0119] Based on the structured text processing method provided in the above embodiments, see [link to relevant documentation]. Figure 3 This figure is a schematic diagram of a structured text processing method provided in an embodiment of this application. Combined with... Figure 3 As shown, Figure 3 The interaction process between a first database management system and a target compatibility plugin is demonstrated. The first database management system includes syntax parsing, semantic analysis, rewriting and optimization, and executor functions. Correspondingly, the target compatibility plugin for this first database management system has the ability to process target structured text created by the syntax of a second database management system, including syntax parsing, semantic analysis, rewriting and optimization, and executor functions.
[0120] The structured text processing method provided in this application embodiment may include:
[0121] Step 1: When the SQL text is received, it first enters the main parser of the first database management system.
[0122] Here, SQL text refers to the target structured text in this application.
[0123] If the main parser interprets the received function as a normal function call (representing the function corresponding to the SQL text) and does not contain any syntax from a second database management system, the main parser will execute the function normally.
[0124] Step 2: If the main parser executes the target plugin function defined in the target compatibility plugin, it passes the parameters to the target compatibility plugin, which contains the target text.
[0125] As an example, suppose the SQL text is:
[0126]
[0127] The target plugin function will then recognize "SELECT ORACLE" and pass the text between the two "$$" as the target text to the target compatibility plugin.
[0128] Step 3: The target compatibility plugin performs syntactic parsing on the target text and passes the parsing results to the semantic analysis function in the first database management system. It then calls the first hook function to analyze the parsing results through the semantic analysis function in the target compatibility plugin, thus obtaining the semantic analysis results.
[0129] Step 4: The target compatibility plugin passes the semantic analysis results to the rewrite and optimization function in the first database management system. It then calls the second hook function to process the semantic analysis results through the rewrite and optimization function in the target compatibility plugin, thus obtaining the optimized result.
[0130] Step 5: The target compatibility plugin passes the optimization processing result to the execution function in the first database management system, which then calls the third hook function. The target compatibility plugin executes the syntax business logic corresponding to the optimization processing result through the third hook function to obtain the processing result.
[0131] Step 6: After execution, the processing results are stored in the storage of the first data management system.
[0132] Based on the structured text processing method provided in the above embodiments, see [link to relevant documentation]. Figure 4 This application also provides a structured text processing apparatus, applied to a first server, the first server having a first database management system deployed thereon, which may include:
[0133] The acquisition module 401 is used to acquire the target structured text to be processed; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server;
[0134] The sending module 402 is used to parse the target structured text, determine the target text of the target structured text, and send the target text to the target compatibility plugin; the target compatibility plugin is used to process the structured text created based on the syntax of the second database management system; the target compatibility plugin is deployed in the first database management system;
[0135] Processing module 403 is used to process the target text through the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the first database management system.
[0136] In one possible implementation, the processing module 403 is configured to:
[0137] The target text is parsed using a target compatibility plugin to obtain the parsing results;
[0138] The processing function of the target compatibility plugin is invoked through a hook function to process the syntax parsing results and obtain the processing result corresponding to the target structured text.
[0139] In one possible implementation, the processing module 403 is specifically used for:
[0140] The semantic analysis function of the target compatibility plugin is called through the first hook function to perform semantic analysis on the syntax parsing results and obtain the semantic analysis results.
[0141] The second hook function calls the rewrite and optimization function of the target compatibility plugin to rewrite and optimize the semantic analysis results, thus obtaining the optimized processing results.
[0142] The third hook function calls the execution function of the target compatibility plugin to perform the optimization processing and obtain the processing result corresponding to the target structured text.
[0143] In one possible implementation, the apparatus further includes:
[0144] The first processing module is used to obtain the first structured text to be processed; the first structured text is obtained based on the syntax of the first database management system; the first structured text is processed to obtain the first processing result corresponding to the first structured text; the syntax of the first processing result is the syntax of the first database management system.
[0145] In one possible implementation, the acquisition module 401 is used for:
[0146] Retrieve multiple structured texts to be processed; each structured text includes syntax markers;
[0147] The target plugin function determines whether the syntax identifier of each structured text is the target syntax identifier, and the structured text whose syntax identifier is the target syntax identifier is taken as the target structured text. The target plugin function is the entry function corresponding to the target compatibility plugin, and the plugin function is used to identify the structured text that includes the target syntax identifier.
[0148] In one possible implementation, the sending module 402 is specifically used for:
[0149] The target structured text is parsed using the target plugin function to obtain the target text of the target structured text;
[0150] The target text is sent to the target compatibility plugin via the target plugin function.
[0151] In one possible implementation, a storage module is included after the processing module for storing the processing results.
[0152] The structured text processing apparatus provided in this application embodiment has the same beneficial effects as the structured text processing method provided in the above embodiments, and therefore will not be described again.
[0153] The following sections will describe the structures for server-based and terminal-based configurations.
[0154] Figure 5 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 900 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 922 (e.g., one or more processors) and memory 932, and one or more storage media 930 (e.g., one or more mass storage devices) for storing application programs 942 or data 944. The memory 932 and storage media 930 can be temporary or persistent storage. The program stored in the storage media 930 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 922 may be configured to communicate with the storage media 930 and execute the series of instruction operations in the storage media 930 on the server 900.
[0155] Server 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input / output interfaces 958, and / or one or more operating systems 941, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0156] CPU 922 is used to perform the following steps:
[0157] The target structured text to be processed is obtained; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server;
[0158] The target structured text is parsed to determine the target text, and then the target text is sent to the target compatibility plugin. The target compatibility plugin is used to process the structured text created based on the syntax of the second database management system. The target compatibility plugin is deployed in the first database management system.
[0159] The target text is processed using the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the First Database Management System.
[0160] This application also provides another electronic device, such as... Figure 6 As shown, for ease of explanation, only the parts related to the embodiments of this application are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of this application. The terminal can be any terminal device including mobile phones, tablets, personal digital assistants (PDAs), point-of-sale (POS) terminals, in-vehicle computers, etc. Taking a mobile phone as an example:
[0161] Figure 6 This is a block diagram illustrating a portion of the structure of a mobile phone related to the terminal provided in the embodiments of this application. (Reference) Figure 6 The mobile phone includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090, etc. Those skilled in the art will understand that... Figure 6 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0162] The following is combined with Figure 6 A detailed introduction to each component of a mobile phone:
[0163] The RF circuit 1010 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with the processor 1080; additionally, it transmits uplink data to the base station. Typically, the RF circuit 1010 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the RF circuit 1010 can also communicate wirelessly with networks and other devices. The aforementioned wireless communications may use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).
[0164] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various mobile phone functions and data processing by running the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 1020 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0165] The input unit 1030 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the mobile phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 1031), and drive the corresponding connection devices according to a pre-set program. Optionally, the touch panel 1031 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 1080, and can also receive and execute commands sent by the processor 1080. In addition, the touch panel 1031 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 1031, the input unit 1030 may also include other input devices 1032. Specifically, other input devices 1032 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0166] The display unit 1040 can be used to display information input by the user or information provided to the user, as well as various menus of the mobile phone. The display unit 1040 may include a display panel 1041, which may optionally be configured as a Liquid Crystal Display (LCD), Organic Light-Emitting Diode (OLED), or similar display panel 1041. Further, a touch panel 1031 may cover the display panel 1041. When the touch panel 1031 detects a touch operation on or near it, it transmits the information to the processor 1080 to determine the type of touch event. Subsequently, the processor 1080 provides corresponding visual output on the display panel 1041 according to the type of touch event. Although in Figure 6 In this embodiment, the touch panel 1031 and the display panel 1041 are two separate components to realize the input and output functions of the mobile phone. However, in some embodiments, the touch panel 1031 and the display panel 1041 can be integrated to realize the input and output functions of the mobile phone.
[0167] The mobile phone may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1041 according to the ambient light level, and the proximity sensor can turn off the display panel 1041 and / or the backlight when the phone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, taps), etc. Other sensors that may be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0168] The audio circuit 1060, speaker 1061, and microphone 1062 provide an audio interface between the user and the mobile phone. The audio circuit 1060 converts the received audio data into electrical signals and transmits them to the speaker 1061, where the speaker 1061 converts them into sound signals for output. On the other hand, the microphone 1062 converts the collected sound signals into electrical signals, which are then received by the audio circuit 1060, converted into audio data, and then processed by the processor 1080 before being transmitted via the RF circuit 1010 to, for example, another mobile phone, or the audio data can be output to the memory 1020 for further processing.
[0169] WiFi is a short-range wireless transmission technology. Through the WiFi module 1070, mobile phones can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 6 The WiFi module 1070 is shown, but it is understood that it is not an essential component of a mobile phone and can be omitted as needed without changing the essence of the invention.
[0170] The processor 1080 is the control center of the mobile phone, connecting various parts of the phone through various interfaces and lines. It executes software programs and / or modules stored in the memory 1020 and calls data stored in the memory 1020 to perform various functions and process data, thereby collecting overall data and information from the phone. Optionally, the processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1080.
[0171] The mobile phone also includes a power supply 1090 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0172] Although not shown, mobile phones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0173] In this embodiment of the application, the processor 1080 included in the terminal also has the following functions:
[0174] The target structured text to be processed is obtained; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server;
[0175] The target structured text is parsed to determine the target text, and then the target text is sent to the target compatibility plugin. The target compatibility plugin is used to process the structured text created based on the syntax of the second database management system. The target compatibility plugin is deployed in the first database management system.
[0176] The target text is processed using the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the First Database Management System.
[0177] This application also provides a computer-readable storage medium for storing program code that executes any one of the implementation methods for processing structured text described in the foregoing embodiments.
[0178] This application also provides a computer program product including instructions that, when run on a computer, cause the computer to execute any one of the implementation methods of a structured text processing method described in the foregoing embodiments.
[0179] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system and equipment described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the division of the system is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple systems may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0181] The system described as separate components may or may not be physically separate. Components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0182] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0183] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0184] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for processing structured text, characterized in that, Applied to a first server, the first server having a first database management system deployed thereon, including: The target structured text to be processed is obtained; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server; The target structured text is parsed to determine the target text, and the target text is sent to the target compatibility plugin; the target compatibility plugin is used to process the structured text created based on the syntax of the second database management system; the target compatibility plugin is deployed in the first database management system; The target text is processed by the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the first database management system.
2. The method according to claim 1, characterized in that, The process of processing the target text using the target compatibility plugin to obtain the processing result corresponding to the target structured text includes: The target text is parsed using the target compatibility plugin to obtain the parsing result. The processing function of the target compatibility plugin is invoked through a hook function to process the syntax parsing result and obtain the processing result corresponding to the target structured text.
3. The method according to claim 2, characterized in that, The process of calling the target compatibility plugin's processing function via a hook function to process the syntax parsing result includes: The semantic analysis function of the target compatibility plugin is invoked through the first hook function to perform semantic analysis on the syntax parsing result and obtain the semantic analysis result. The second hook function calls the rewrite and optimization function of the target compatibility plugin to rewrite and optimize the semantic analysis results, thereby obtaining the optimized processing results. The third hook function calls the execution function of the target compatibility plugin to execute the optimization processing result, thereby obtaining the processing result corresponding to the target structured text.
4. The method according to claim 1, characterized in that, The method further includes: Obtain the first structured text to be processed; the first structured text is obtained based on the syntax of the first database management system; The first structured text is processed to obtain a first processing result corresponding to the first structured text; the syntax of the first processing result is the syntax of the first database management system.
5. The method according to claim 1, characterized in that, The process of obtaining the target structured text to be processed includes: Obtain multiple structured texts to be processed; each structured text includes a syntax identifier; The target plugin function determines whether the syntax identifier of each structured text is a target syntax identifier, and the structured text whose syntax identifier is a target syntax identifier is taken as the target structured text; wherein, the target plugin function is the entry function corresponding to the target compatibility plugin, and the plugin function is used to identify the structured text including the target syntax identifier.
6. The method according to claim 5, characterized in that, The step of parsing the target structured text, determining the target text of the target structured text, and sending the target text to the target compatibility plugin includes: The target structured text is parsed using the target plugin function to obtain the target text of the target structured text; The target text is sent to the target compatibility plugin via the target plugin function.
7. The method according to any one of claims 1-6, characterized in that, After obtaining the processing result corresponding to the target structured text, the method further includes: storing the processing result.
8. A structured text processing apparatus, characterized in that, Applied to a first server, the first server having a first database management system deployed thereon, including: The acquisition module is used to acquire the target structured text to be processed; the target structured text is created based on the syntax of the second database management system; the second database management system is deployed on the second server; The sending module is used to parse the target structured text, determine the target text of the target structured text, and send the target text to the target compatibility plugin; the target compatibility plugin is used to process the structured text created based on the syntax of the second database management system; the target compatibility plugin is deployed in the first database management system; The processing module is used to process the target text through the target compatibility plugin to obtain the processing result corresponding to the target structured text; the syntax of the processing result is the syntax of the first database management system.
9. An electronic device, characterized in that, The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of the structured text processing method according to any one of claims 1 to 9, based on instructions in the program code.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for performing the steps of the structured text processing method according to any one of claims 1 to 9.
11. A computer program product, characterized in that, Includes a computer program or instructions that, when executed, implement the steps of the method for processing structured text as described in any one of claims 1 to 9.