Database stored procedure conversion methods, devices, electronic equipment, and storage media
By generating a directed graph and performing code transformation, the accuracy problem of stored procedure transformation when databases are incompatible is solved, and efficient migration and execution between heterogeneous databases are achieved.
Patent Information
- Application Number
- CN202410470921.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-18
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-04-18
AI Technical Summary
In cases of database incompatibility, existing technologies struggle to accurately convert stored procedures, resulting in converted stored procedures failing to achieve the same effects as the original database.
The stored procedures are identified and loaded via the data bus to determine the execution order and dependencies, a directed graph is generated, and code transformation is performed based on the directed graph to generate a transformation program, ensuring correct execution in the target database.
It improves the accuracy and efficiency of stored procedure conversion, supports seamless migration between heterogeneous databases, and reduces the development and maintenance costs of database migration.
Smart Images

Figure CN118349597B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data technology, and in particular to a method, apparatus, electronic device and storage medium for converting database stored procedures. Background Technology
[0002] In the field of modern information technology, the use of heterogeneous databases is becoming increasingly common, especially with the increase in complex application scenarios. This trend poses a significant challenge to the seamless migration and execution of stored procedures.
[0003] When a database is incompatible with a stored procedure to be executed, the stored procedure can be parsed and transformed line by line to generate executable code that can run in the database. However, this transformation process struggles to handle complex logic, potentially resulting in a converted stored procedure that does not achieve the same effect as the original database.
[0004] Therefore, there is an urgent need for an accurate stored procedure conversion method. Summary of the Invention
[0005] This application aims to at least partially address one of the technical problems in the related art.
[0006] Therefore, the first objective of this application is to propose a method for converting database stored procedures in order to improve the accuracy of stored procedure conversion.
[0007] The second objective of this application is to provide a conversion device for database stored procedures.
[0008] The third objective of this application is to propose an electronic device.
[0009] The fourth objective of this application is to provide a computer-readable storage medium.
[0010] The fifth objective of this application is to provide a computer program product.
[0011] To achieve the above objectives, a first aspect of this application proposes a method for converting database stored procedures, comprising:
[0012] In response to receiving a data processing request from the first database, the data bus determines and loads the first stored procedure contained in the data processing request.
[0013] Determine the second stored procedure called by the first stored procedure, the execution order of the first stored procedure and the second stored procedure, and their dependencies.
[0014] The first and second stored procedures are transformed based on the execution order and dependencies to generate a directed graph;
[0015] The first and second stored procedures are transformed based on the directed graph to generate the first transformation program;
[0016] The first conversion program is executed in the second database.
[0017] To achieve the above objectives, a second aspect of this application provides a database stored procedure conversion apparatus, comprising:
[0018] The first determining module is used to determine and load the first stored procedure contained in the data processing request in response to receiving a data processing request from the first database.
[0019] The second determining module is used to determine the second stored procedure called by the first stored procedure, the execution order and dependency relationship between the first and second stored procedures;
[0020] The generation module is used to transform the first and second stored procedures based on the execution order and dependencies, generating a directed graph;
[0021] The conversion module is used to convert the first stored procedure and the second stored procedure based on the directed graph, and generate the first conversion program;
[0022] The execution module is used to execute the first conversion program in the second database.
[0023] To achieve the above objectives, a third aspect of this application provides an electronic device comprising:
[0024] At least one processor; and
[0025] A memory that is communicatively connected to at least one processor; wherein,
[0026] The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform the methods of the above embodiments.
[0027] To achieve the above objectives, a fourth aspect of this application provides a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method according to the above embodiments.
[0028] To achieve the above objectives, a fifth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the methods of the above embodiments.
[0029] The database stored procedure conversion method, apparatus, electronic device, and storage medium provided in this application, in response to a data bus receiving a data processing request from a first database, determine and load a first stored procedure contained in the data processing request, then determine a second stored procedure called by the first stored procedure, the execution order and dependencies between the first and second stored procedures, and convert the first and second stored procedures based on the execution order and dependencies to generate a directed graph, and then convert the first and second stored procedures based on the directed graph to generate a first conversion program, which is then executed in the second database. Thus, by determining a directed graph based on the execution order and dependencies of the first and second stored procedures, in-depth data flow analysis, constant propagation analysis, and execution logic analysis of the first and second stored procedures are achieved, thereby improving the accuracy of stored procedure conversion by performing code conversion based on the directed graph.
[0030] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0031] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0032] Figure 1 A flowchart illustrating a database stored procedure conversion method provided in an embodiment of this application;
[0033] Figure 2 A flowchart illustrating another method for converting a database stored procedure provided in an embodiment of this application;
[0034] Figure 3 This is a schematic diagram of the structure of a database stored procedure conversion device provided in an embodiment of this application. Detailed Implementation
[0035] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0036] The database stored procedure conversion method and apparatus of this application are described below with reference to the accompanying drawings.
[0037] A stored procedure is a set of SQL statements compiled and stored in the database to perform a specific function. Users execute it by specifying the stored procedure's name and providing parameters (if the stored procedure has parameters). A stored procedure is a process written with flow control and SQL statements, which is then compiled, optimized, and stored on the database server.
[0038] Stored procedures greatly enhance the functionality and flexibility of the SQL language, allowing users to declare variables, receive and output parameters, return status values from the execution of the stored procedure, and even nest calls. Stored procedures enable related actions to occur together, thereby maintaining database integrity.
[0039] Currently, core business systems in industries such as finance, telecommunications, and energy are all developed based on Oracle databases, resulting in a strong and tightly coupled dependency on Oracle databases. However, the localization of databases requires directly replacing existing Oracle databases with domestically produced databases, which faces a technical challenge: domestically produced databases often fail to meet compatibility standards for Oracle stored procedures.
[0040] In addition, in order to reduce time costs, there is an urgent need for a stored procedure conversion method that does not affect the normal operation of business, so as to complete the accurate and efficient migration of the database.
[0041] The database stored procedure conversion method of this application embodiment is executed by the database stored procedure conversion device (hereinafter referred to as the conversion device) provided in this application embodiment. The device can be configured in computer equipment or terminal equipment to improve the accuracy of stored procedure conversion.
[0042] Figure 1 This is a flowchart illustrating a database stored procedure conversion method provided in an embodiment of this application.
[0043] like Figure 1 As shown, the conversion method for this database stored procedure includes the following steps:
[0044] Step 101: In response to receiving a data processing request from the first database, the data bus determines and loads the first stored procedure contained in the data processing request.
[0045] In this application, a data bus is established between the application program and the heterogeneous database. The heterogeneous database includes at least two databases: a first database for outgoing data and a second database for incoming data. The first database contains stored procedures that are incompatible with those in the second database. Before the database switchover is completed, the application program sends a data processing request for the first database to the data bus. This data processing request invokes a stored procedure from the first database. Upon receiving the data processing request, the data bus parses and identifies the first stored procedure contained in the request and loads it from the first database.
[0046] Furthermore, the data bus employs metadata analysis technology to deeply mine the metadata of each database, including but not limited to database characteristics such as data structure, data constraints, and version information, enabling accurate identification of database characteristics. Subsequently, the relationships between the data structure and data constraints of the first database and the second database are manually configured. This mapping of multi-dimensional database characteristics provides a more precise direction for subsequent stored procedure conversions, thereby improving the accuracy of stored procedure conversions.
[0047] For example, suppose the first database has a date field for time-related data, and the second database has a time field for time-related data. Then date and time are related.
[0048] Understandably, the data bus can identify and adapt to various non-standard database features and configurations, ensuring high compatibility whether it is a public cloud or a private deployment, whether it is a traditional relational database or a new NoSQL database.
[0049] Optionally, before receiving a data processing request, the data bus can provide intelligent prompts to the user, such as the names of available stored procedures and commonly used parameters for each stored procedure. Furthermore, when an error occurs while loading the first stored procedure, the data bus can determine whether the first stored procedure call was correct based on the context information of the data processing request and generate error correction suggestions for the first stored procedure call. This improves the accuracy of stored procedure calls.
[0050] Step 102: Determine the second stored procedure called by the first stored procedure, the execution order of the first stored procedure and the second stored procedure, and their dependencies.
[0051] In this application, after loading the first stored procedure, the data bus performs semantic parsing on the first stored procedure to determine the second stored procedure called by the first stored procedure, and determines the contextual relationship between the first and second stored procedures in the database (such as the dependency relationship between the data tables involved in the first and second stored procedures, the execution order of each operation contained in the first and second stored procedures, and the execution order between the first and second stored procedures). This ensures that the stored procedure can be executed correctly even in heterogeneous databases. It is understood that the dependency relationship between data tables represents the flow of data. Each operation corresponds to an operation language executed on the database (such as CRUD operations), or corresponds to a function that processes the data extracted from the database.
[0052] Furthermore, the data bus can extract features from the first stored procedure to determine its structural information. Based on this structural information, multi-level semantic analysis is then performed on the first stored procedure, enabling the data bus to comprehensively understand it from macro to micro levels and determine the dependencies between the first and second stored procedures. These dependencies include, for example, nested loops, recursive calls, and parallel execution.
[0053] It should be noted that after the second stored procedure is determined, its semantics can be parsed to determine whether it calls other stored procedures. Then, a data bus can be added to the second stored procedure and all other stored procedures it calls. Thus, during the conversion of the first stored procedure, the other stored procedures it uses are simultaneously converted, ensuring the normal operation of the first stored procedure.
[0054] Step 103: Transform the first stored procedure and the second stored procedure based on the execution order and dependencies to generate a directed graph.
[0055] Based on the dependencies between the first and second stored procedures, the dependencies between data tables, the execution order between the first and second stored procedures, and the execution order of the operations contained in the first and second stored procedures, each operation contained in each stored procedure is reorganized to generate a directed graph corresponding to each stored procedure. The directed graph contains nodes and edges between each node; nodes correspond to each operation contained in the stored procedure, and edges correspond to the logical relationships between operations. This highly abstract directed graph is independent of specific database products and versions, thus improving the versatility and capability of database migration by performing stored procedure conversion based on the directed graph. It is beneficial for converting stored procedures between two completely different databases.
[0056] Furthermore, since directed graphs are generated based on graph theory principles, they possess high scalability. Whether adding new operations or modifying existing logical relationships within the first stored procedure, the original directed graph of the first stored procedure can be modified accordingly to obtain a new directed graph. Subsequently, code transformation is performed based on the new directed graph, improving the efficiency of rapid development and continuous iteration of stored procedures.
[0057] Step 104: Transform the first stored procedure and the second stored procedure based on the directed graph to generate the first transformation program.
[0058] The first conversion program can be a Java program, etc., and this application does not impose any restrictions on it.
[0059] In this application, lexical analysis is performed on the first and second stored procedures to determine the label of each element in the first and second stored procedures. Based on the directed graph and the label of each element, a mapping transformation is performed on each element to obtain the first transformation program.
[0060] One implementation involves performing lexical analysis on the first and second stored procedures, decomposing them into individual words or vocabularies. Each word or vocabulary is then treated as an element, and labels are assigned to each element within the first and second stored procedures based on the stored procedure syntax. These labels may include keywords, identifiers, operators, basic variables, user-defined variables, basic flow control statements, DML statements, DDL statements, functions, and data types. Then, for each statement in the first and second stored procedures, based on the labels of the elements contained in each statement, the relationships between elements in the first and second databases (i.e., the associations between data structures and data constraints), and the pre-defined mapping between the syntax of the first conversion program and the syntax of the first stored procedure, each element is converted to generate a converted statement. Finally, the converted statements are combined using a directed graph group to generate the first conversion program.
[0061] For example, suppose the first conversion code is a Java program. When an element's label is a basic variable, the variable's name, data type, and possible default values can be converted to Java's standard format. For instance, the INTEGER type in the database is converted to Java's int type, and VARCHAR is converted to String. When an element's label is an argument variable, the code conversion is based on the data type of that argument variable. For example, the VARRAY type is converted to a Java array or list structure, nested tables correspond to Java's nested objects or collections, and record types are converted to Java classes or objects. When an element's label is a basic flow control statement, it will be converted to the corresponding Java structure. For example, the IF...ELSE...END IF structure in the database is converted to the if...else structure in Java; the LOOP...END LOOP structure in the database is converted to a while or for loop in Java. During the conversion, logical relationships, conditional judgments, and loop boundaries are accurately preserved and implemented. When an element's label is a DML statement involving data querying, inserting, updating, and deleting operations, these statements are converted into Java's SQL execution instructions. For example, a SELECT query will be translated into code snippets that use Java's JDBC API to perform query operations. After a DDL statement is translated into its corresponding Java SQL execution instruction, metadata synchronization and backup operations can be performed before executing the SQL instruction to ensure data security. For example, a CREATE TABLE instruction might check whether the table already exists before execution and determine whether to perform a backup or issue a warning based on the check result. When an element's tag is a function, if the function is a built-in SQL function, it needs to be mapped to the corresponding function in the Java environment or JDBC API; if the function is a user-defined function, it is separately translated into a Java method or class and called in the main code.
[0062] The above process enables the loading, transformation, and management of the first stored procedure via the data bus, ensuring the security of database operations. Furthermore, if the first stored procedure subsequently changes, the data bus can reload and transform it, thereby ensuring the accuracy of database operations.
[0063] Step 105: Execute the first conversion program in the second database.
[0064] In this application, the data bus can pre-compile and optimize the first conversion program before execution in the second database. Thus, by decoupling pre-compilation and runtime, the high efficiency and stability of the first conversion program are ensured.
[0065] For example, assuming the first conversion program is a Java program, the process of executing the first conversion program in the second database is as follows:
[0066] 1. The data bus utilizes an internally embedded high-level Java compiler to compile the first transformation. This compiler, based on JIT (Just-In-Time) compilation technology, possesses deep optimization capabilities, enabling multiple checks and optimizations of the input Java code. In addition to basic syntax checking, the compiler can identify potential semantic errors, such as possible null pointer exceptions and data type mismatches. Furthermore, the compiler employs static code analysis techniques to efficiently optimize Java files, such as loop unrolling, constant propagation, and unnecessary code removal.
[0067] 2. The compiler transforms the optimized Java code (the first transformation process) into JVM bytecode. During this process, further micro-optimizations are performed on the bytecode based on known platform information. JVM characteristics and version are identified to ensure maximum bytecode compatibility and performance. Code analysis techniques are used to identify potential performance bottlenecks and specifically optimize them.
[0068] 3. The data bus dynamically launches dedicated JVM instances, ensuring isolated execution of Java code (the first conversion program) and preventing potential resource contention or security vulnerabilities. Each JVM instance has independent resource allocation, such as CPU and memory, ensuring efficient and stable execution. A secure sandbox environment is provided for each JVM instance to prevent the execution of malicious code or data leakage.
[0069] 4. During the execution of the first conversion program, the data bus supports dynamic linking of Java code to native libraries to achieve specific functionalities or performance optimizations. This allows Java code to directly call functions in native libraries, providing higher execution efficiency. The bus manages a native library caching system to ensure that frequently used libraries can be loaded and linked quickly.
[0070] 5. After the first conversion program is completed, the data bus sends the execution result back to the requester of the data processing request and handles any possible exceptions. Based on the requester's requirements, the execution result is converted into a specific format, such as JSON or XML, and then transmitted efficiently.
[0071] Optionally, the priority of the first stored procedure can be determined based on the historical call count or resource consumption of the first stored procedure, so that the first transformation program can be executed in the second database based on the priority.
[0072] In this application, a high number of historical calls to the first stored procedure indicates its importance. A high resource consumption during the execution of the first stored procedure also significantly impacts overall performance. Therefore, when the number of historical calls to the first stored procedure exceeds a preset threshold, or when its resource consumption exceeds a preset threshold, the first stored procedure can be assigned a higher priority. Subsequently, the first conversion program is executed according to the priority of the first stored procedure among all pending stored procedures to ensure faster execution. The resource consumption of the first stored procedure can be monitored and obtained during its execution.
[0073] Optionally, a scheduling strategy is determined based on the current data bus load, and resources are allocated to the first stored procedure based on the scheduling strategy, so as to utilize the resources allocated to the stored procedure to execute the first conversion program in the second database.
[0074] In this application, the data bus possesses a high degree of load awareness. It analyzes the current system load and database operation speed in real time to determine peak and off-peak periods for database operations, thereby determining the corresponding scheduling strategies for each period. Then, resources are allocated to the first stored procedure based on this scheduling strategy. For example, during peak periods, CPU, memory, and bandwidth resources are allocated to the first stored procedure based on its priority or resource usage, ensuring that each task can execute smoothly even with limited resources. Then, the resources allocated to the first stored procedure are used to execute the first transformation program in the second database, thereby ensuring the stability of the overall system.
[0075] Optionally, the data bus can not only record the execution process log of the first conversion program, but also record performance data and anomalies for each operation, providing rich data support for subsequent analysis and optimization. Furthermore, utilizing big data processing technology, the data bus can perform high-speed processing and analysis of large amounts of log data, identifying potential problems and optimization opportunities. Based on the analysis results, the bus automatically generates detailed reports, including performance bottlenecks, anomalies, and optimization suggestions. These reports are visualized, providing system administrators with clear insights and decision support.
[0076] Optionally, after the first stored procedure is successfully loaded, the data bus can register the first stored procedure internally. This dynamic registration ensures that the stored procedure can be identified and invoked immediately without any manual intervention.
[0077] In this application, the data bus responds to receiving a data processing request from a first database, determines and loads a first stored procedure contained in the data processing request, then determines a second stored procedure called by the first stored procedure, the execution order and dependencies between the first and second stored procedures, and transforms the first and second stored procedures based on the execution order and dependencies to generate a directed graph. A first transformation program is then generated based on the directed graph and executed in the second database. Thus, by determining the directed graph based on the execution order and dependencies of the first and second stored procedures, in-depth data flow analysis, constant propagation analysis, and execution logic analysis of the first and second stored procedures are achieved, thereby improving the accuracy of stored procedure transformation by performing code transformation based on the directed graph.
[0078] Figure 2 This is a flowchart illustrating a database stored procedure conversion method provided in an embodiment of this application.
[0079] like Figure 2 As shown, the conversion method for this database stored procedure includes the following steps:
[0080] Step 201: In response to receiving a data processing request from the first database, the data bus determines and loads the first stored procedure contained in the data processing request.
[0081] Step 202: Determine the second stored procedure called by the first stored procedure, the execution order of the first stored procedure and the second stored procedure, and their dependencies.
[0082] Step 203: Transform the first stored procedure and the second stored procedure based on the execution order and dependencies to generate a directed graph.
[0083] Step 204: Transform the first stored procedure and the second stored procedure based on the directed graph to generate the first transformation program.
[0084] Step 205: Execute the first conversion program in the second database.
[0085] The specific implementation process of steps 201-205 in this application can be found in the detailed description of any embodiment of this application, and will not be repeated here.
[0086] Step 206: Perform performance monitoring on the second database to obtain performance data during each operation in the first conversion program.
[0087] The performance data may include CPU utilization, memory utilization, time consumption, etc., and this application does not impose any restrictions on this.
[0088] In this application, when each operation in the first conversion program is executed, the performance of the second database can be monitored to obtain performance data when each operation in the first conversion program is executed.
[0089] Optionally, a performance prediction model can be pre-trained using performance data from historical moments when each operation is performed in the second database. Then, the performance prediction model can be used to predict the performance data of each operation before each operation is performed.
[0090] Step 207: If the performance data corresponding to any operation does not meet the preset conditions, rewrite any operation in the first conversion program to obtain the second conversion program.
[0091] In this application, preset conditions can be pre-set in the system. Preset conditions may include reference values corresponding to each performance indicator. Then, the performance data obtained when executing each operation can be compared with its corresponding reference value to determine whether the performance data corresponding to each operation meets the preset conditions. If the performance data corresponding to a certain operation does not meet the preset conditions, the statements corresponding to that operation in the first conversion program can be rewritten to obtain a second conversion program.
[0092] For example, if the performance degrades when performing a join operation in the first conversion program, the data bus can rewrite the join statement based on the preset replacement statement of the join statement to obtain the second conversion program.
[0093] Step 208: Execute the second conversion program in the second database.
[0094] In this application, the execution of the first conversion program in the second database can be stopped directly, and the second conversion program can be compiled and executed. This improves the efficiency of data operations.
[0095] Alternatively, the second conversion program can be stored in the system, so that when the first stored procedure is called again, the second conversion program can be used directly to operate on the second database, thereby improving the efficiency of data operations.
[0096] In this application, the data bus responds to a data processing request received from a first database by identifying and loading a first stored procedure contained in the request. Then, it determines a second stored procedure called by the first stored procedure, the execution order and dependencies between the first and second stored procedures, and transforms the first and second stored procedures based on the execution order and dependencies to generate a directed graph. A first transformation program is then generated based on this graph. The first transformation program is executed in the second database while simultaneously monitoring its performance. Performance data for each operation in the first transformation program is obtained. If the performance data for any operation does not meet preset conditions, that operation in the first transformation program is rewritten, a second transformation program is obtained, and executed in the second database. Thus, by accurately transforming the first stored relationship and monitoring the performance of the second database during the execution of the first transformation program, the first transformation program can be rewritten based on the performance data. This improves the accuracy and efficiency of data operations.
[0097] The embodiments in this application also meet the need for seamless migration and execution of stored procedures (i.e., database migration without affecting the normal operation of the database). We can not only greatly improve the portability and reusability of stored procedures, but also avoid the huge development and maintenance costs associated with database migration or switching. This has high application value for large application systems that need to switch between multiple database products.
[0098] In the scenario of database migration, based on the method of the embodiments of this application, the data bus can adopt multi-threading technology to load and transform multiple first stored procedures simultaneously, thereby improving the efficiency of database migration.
[0099] To implement the above embodiments, this application also proposes a database stored procedure conversion device.
[0100] Figure 3 This is a schematic diagram of the structure of a database stored procedure conversion device provided in an embodiment of this application.
[0101] like Figure 3 As shown, the database stored procedure conversion device includes a first determining module 310, a second determining module 320, a generating module 330, a conversion module 340, and an execution module 350.
[0102] The first determining module 310 is used to determine and load the first stored procedure contained in the data processing request in response to receiving a data processing request from the first database.
[0103] The second determining module 320 is used to determine the second stored procedure called by the first stored procedure, the execution order and dependency relationship between the first stored procedure and the second stored procedure;
[0104] The generation module 330 is used to transform the first stored procedure and the second stored procedure based on the execution order and dependencies to generate a directed graph;
[0105] The conversion module 340 is used to convert the first stored procedure and the second stored procedure based on the directed graph to generate the first conversion program;
[0106] Execution module 350 is used to execute the first conversion program in the second database.
[0107] Furthermore, in one possible implementation of this application embodiment, an optimization module is also included, used for:
[0108] The performance of the second database is monitored to obtain performance data during each operation in the first transformation program.
[0109] If the performance data corresponding to any operation does not meet the preset conditions, rewrite any operation in the first conversion program to obtain the second conversion program;
[0110] Execute the second conversion program in the second database.
[0111] Furthermore, in one possible implementation of this application embodiment, the execution module 340 is used for:
[0112] The priority of the first stored procedure is determined based on its historical call count or resource consumption.
[0113] Based on priority, the first transformation procedure is executed in the second database.
[0114] Furthermore, in one possible implementation of this application embodiment, the execution module 340 is used for:
[0115] Determine the scheduling strategy based on the current load on the data bus;
[0116] Resources are allocated to the first stored procedure based on the scheduling policy, so that the resources allocated to the first stored procedure can be used to execute the first transformation program in the database.
[0117] Furthermore, in one possible implementation of this application embodiment, the conversion module 330 is used for:
[0118] Lexical analysis is performed on the first and second stored procedures to determine the tags of each element in the first and second stored procedures;
[0119] Based on the directed graph and the label of each element, a mapping transformation is performed on each element to obtain the first transformation program.
[0120] Furthermore, in one possible implementation of this application embodiment, a registration module is also included, used for:
[0121] After successfully loading the first stored procedure, register the first stored procedure.
[0122] It should be noted that the foregoing explanation of the database stored procedure conversion method embodiment also applies to the database stored procedure conversion device of this embodiment, and will not be repeated here.
[0123] In this application, the data bus responds to receiving a data processing request from a first database, determines and loads a first stored procedure contained in the data processing request, then determines a second stored procedure called by the first stored procedure, the execution order and dependencies between the first and second stored procedures, and transforms the first and second stored procedures based on the execution order and dependencies to generate a directed graph. A first transformation program is then generated based on the directed graph and executed in the second database. Thus, by determining the directed graph based on the execution order and dependencies of the first and second stored procedures, in-depth data flow analysis, constant propagation analysis, and execution logic analysis of the first and second stored procedures are achieved, thereby improving the accuracy of stored procedure transformation by performing code transformation based on the directed graph.
[0124] To implement the above embodiments, this application also proposes an electronic device, including: a processor and a memory communicatively connected to the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0125] To implement the above embodiments, this application also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.
[0126] To implement the above embodiments, this application also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.
[0127] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0128] It should be noted that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. Furthermore, such collection / sharing should only be conducted after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes authorization of relevant user information before the user uses the function. In addition, any necessary steps must be taken to protect and safeguard access to such personal information data and ensure that others with access to personal information data comply with their privacy policies and procedures.
[0129] This application is intended to provide an implementation scheme for users to selectively prevent the use or access to their personal information data. Specifically, this application is intended to provide hardware and / or software to prevent or block access to such personal information data. Once personal information data is no longer needed, risks can be minimized by restricting data collection and deleting data. Furthermore, where applicable, such personal information is de-identified to protect user privacy.
[0130] In the foregoing descriptions of the embodiments, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0131] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0132] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0133] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0134] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0135] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0136] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0137] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for converting database stored procedures, characterized in that, The method includes: In response to receiving a data processing request from the first database, the data bus determines and loads a first stored procedure contained in the data processing request. Determine the second stored procedure called by the first stored procedure, the execution order of the first stored procedure and the second stored procedure, and their dependencies. Based on the execution order and the dependencies, the first stored procedure and the second stored procedure are transformed to generate a directed graph; Lexical analysis is performed on the first stored procedure and the second stored procedure to determine the tag of each element in the first stored procedure and the second stored procedure; Based on the directed graph and the label of each element, a mapping transformation is performed on each element to obtain a first transformation program; Execute the first conversion program in the second database; The method further includes: The performance of the second database is monitored to obtain performance data during each operation in the first conversion program. If the performance data corresponding to any operation does not meet the preset conditions, the operation in the first conversion program is rewritten to obtain the second conversion program. The second conversion program is executed in the second database.
2. The method as described in claim 1, characterized in that, Executing the first conversion program in the second database includes: The priority of the first stored procedure is determined based on its historical call count or resource consumption. Based on the priority, the first conversion procedure is executed in the second database.
3. The method as described in claim 1, characterized in that, Executing the first conversion program in the second database includes: Determine the scheduling strategy based on the current load of the data bus; Based on the scheduling policy, resources are allocated to the first stored procedure so that the resources allocated to the first stored procedure can be used to execute the first conversion program in the second database.
4. The method as described in claim 1, characterized in that, Also includes: After the first stored procedure is successfully loaded, the first stored procedure is registered.
5. A database stored procedure conversion device, characterized in that, The device includes: The first determining module is used to determine and load a first stored procedure contained in the data processing request in response to receiving a data processing request from the first database. The second determining module is used to determine the second stored procedure called by the first stored procedure, the execution order and dependency relationship between the first stored procedure and the second stored procedure; A generation module is used to transform the first stored procedure and the second stored procedure based on the execution order and the dependency relationship to generate a directed graph; A conversion module is used to perform lexical analysis on the first stored procedure and the second stored procedure to determine the label of each element in the first stored procedure and the second stored procedure; based on the directed graph and the label of each element, a mapping conversion is performed on each element to obtain a first conversion program; An execution module is used to execute the first conversion program in the second database; The device is further configured to: perform performance monitoring on the second database and obtain performance data when executing each operation in the first conversion program; if the performance data corresponding to any operation does not meet the preset conditions, rewrite any operation in the first conversion program to obtain a second conversion program; and execute the second conversion program in the second database.
6. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-4.
8. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1-4.
Citation Information
Patent Citations
Computer-readable recording medium storing conversion program and conversion method
US20230176851A1