Database routine reloading decision method and device, electronic equipment and storage medium

By implementing routine overload resolution methods in the database, obtaining and preprocessing the calling routine information, and using routine weight algorithms for iterative matching, the call matching problem of existing databases under multiple expressions is solved, and the readability and reusability of the code is improved.

CN119759460AActive Publication Date: 2025-04-04TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510260116.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-06
Publication Date
2025-04-04
Estimated Expiration
2045-03-06

AI Technical Summary

Technical Problem

Existing databases such as gbase 8s only handle traditional position expressions when function overload resolutions, and cannot adapt to other expressions, resulting in reduced stability of routine overloading and unable to meet the call matching requirements of multiple parameter expressions.

Method used

A database routine overload resolution method is proposed. By obtaining the calling routine information, preprocessing is performed to initialize the priority list of passed parameters, and iteratively matches through the routine weighting algorithm to determine the unique target routine to execute the call.

Benefits of technology

This method is suitable for multiple parameter expression methods, and can call different routines according to different parameters passed in, improving the readability and reusability of the code, and enhancing the stability of routine overloading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759460A_ABST
    Figure CN119759460A_ABST
Patent Text Reader

Abstract

The invention provides a database routine reloading decision method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining calling routine information which at least comprises a transmission parameter type, a transmission parameter number, a transmission parameter expression mode, a routine name, a routine parameter type and a routine parameter number; preprocessing the routine information to initialize a priority list of each transmission parameter; and searching all homonymous routines according to the routine names, performing iterative matching on all searched homonymous routines through a routine weight algorithm to determine a unique target routine, and executing calling according to the target routine. The method is suitable for various parameter transmission expression methods, the final routine is selected to execute calling by calculating the weight of the parameter transmission type, and the readability and reusability of codes are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of database technology, and in particular, relates to a database routine overload resolution method, device, electronic device and storage medium. Background Art

[0002] Routine overloading in the database means defining routines with the same name but different parameter lists in the same scope. In this way, when calling this routine, it will automatically match the corresponding routine to execute according to the type and number of parameters passed in. By using routine overloading, different operations can be performed according to different input parameter types, making the code more flexible and easy to understand.

[0003] The complex data types of the database cannot be matched by a single type like simple data types. Especially for complex types that can have inheritance relationships, the type matching step must be specially handled during function overloading resolution, otherwise the credibility of routine overloading will be reduced. Currently, gbase 8s database function overloading only handles the case where the input parameter is the traditional positional expression, and is not applicable to other expressions. If other expressions are introduced, the stability of routine overloading will be reduced and routine call matching cannot be satisfied. Summary of the invention

[0004] In view of this, the present application aims to propose a database routine overload resolution method, device, electronic device and storage medium to solve the shortcomings of the above-mentioned problems.

[0005] To achieve the above purpose, the technical solution of this application is implemented as follows: In a first aspect, the present application provides a database routine overload resolution method, characterized by comprising: Obtaining calling routine information, wherein the routine information at least includes parameter type, number of parameters, expression of parameter, routine name, routine parameter type, and number of routine parameters; Preprocessing the routine information to initialize a priority list for each parameter passed; All routines with the same name are searched according to the routine name, and all the searched routines with the same name are iteratively matched through a routine weight algorithm to determine a unique target routine, and a call is performed according to the target routine.

[0006] In a second aspect, based on the same inventive concept, the present application also provides a database routine overload resolution device, comprising: An information acquisition module is configured to acquire calling routine information, wherein the routine information at least includes a parameter type, a number of parameters, a parameter expression method, a routine name, a routine parameter type, and a number of routine parameters; A preprocessing module, configured to preprocess the routine information to initialize a priority list of each parameter; The routine calling module is configured to search for all routines with the same name according to the routine name, and iteratively match all the searched routines with the same name through a routine weight algorithm to determine a unique target routine, and perform a call according to the target routine.

[0007] In a third aspect, based on the same inventive concept, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.

[0008] In a fourth aspect, based on the same inventive concept, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in the first aspect.

[0009] Compared with the prior art, the database routine overload resolution method, device, electronic device and storage medium described in this application have the following beneficial effects: The database routine overloading resolution method, device, electronic device and storage medium described in the present application are applicable to a variety of parameter passing expressions, and different routines can be called according to different incoming parameters. Through routine overloading, the readability and reusability of the code are effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A flowchart of a database routine overload resolution method according to an embodiment of the present application; Figure 2 A schematic diagram of the structure of a database routine overload resolution device according to an embodiment of the present application; Figure 3 This is a schematic diagram of the hardware structure of the electronic device described in the embodiment of the present application. DETAILED DESCRIPTION

[0011] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0012] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0013] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0014] See also Figure 1 As shown, this embodiment provides a database routine overload resolution method, which is characterized by specifically comprising the following steps: Step S101, obtaining calling routine information, wherein the routine information at least includes parameter type, parameter number, parameter expression method, routine name, routine parameter type, and routine parameter number.

[0015] Specifically, in this embodiment, when a routine is called and there are multiple candidate routines with the same name, routine resolution is required to obtain a final routine.

[0016] When a routine is called, the calling routine information is collected, that is, the parameter (incoming parameter) structure, including the parameter type (recording the data type of each parameter passed during the call), the number of parameters passed (the actual number of parameters passed in the call), the expression method of the parameter (including named expression, positional expression and mixed expression), the routine name (recording the name of the target routine called), the routine parameter type (recording the parameter type declared in the routine definition), and the number of routine parameters (the number of actual routine parameters in the call) and other information.

[0017] Furthermore, there are three ways to express the parameters when calling a routine: named expression, positional expression, and mixed expression. They are as follows: Positional notation: parameters must be listed in the order in which they are declared; Named notation: If you specify parameters using named notation, the order of the parameters does not matter; Mixed expression: that is, the naming expression and the positional expression are mixed; Named and positional notation (legacy calling style) can be mixed, but positional notation is not allowed after the first named parameter.

[0018] Example: procedure pr1(c1 int, c2 varchar2, c3 int); Positional expression: pr1(1,'a',2); Nomenclature representation: pr1(c2=>'a', c3=>2, c1=>1); Mixed expression: pr1(1, c3=>2, c2=>'a').

[0019] Step S102: pre-process the routine information to initialize the priority list of each parameter.

[0020] Specifically, in this embodiment, the collected calling routine information is preprocessed, mainly for some complex data types, a priority list is initialized, and for the case of named expressions, the parameters are reordered.

[0021] Specifically, if the argument type is a subtype of the routine parameter type (which is the case when the argument is a row type), matching is achieved by adding the supertype of the argument type to its priority list, and then checking whether the routine parameter type is in the argument extension list on subsequent iterations.

[0022] If the passed argument type is a distinct type of the routine parameter type, matching is done by adding the source type of the passed argument type to its precedence list and then checking to see if the routine parameter type is in the expanded list.

[0023] For example: create distinct type ty1 as int; create distinct type ty2 as ty1; create distinct type ty3 as ty2; / Three routines are overloaded, only the parameter types are different / create or replace package pkg2 as procedure f1(a in ty1); procedure f1(a in ty2); procedure f1(a in int); end; / create or replace package body pkg2 as procedure f1(a in ty1) as begin Execute block 1; end; procedure f1(a in ty2) as begin Execute block 2; end; procedure f1(a in int) as begin Execute block 3; end; end; / Declare var ty3; begin pkg2.f1(var); end; / In the priority list of parameter var, ty2, ty1, int, the type weights (distances) are 1, 2, and 3 respectively. Therefore, ty2 will be matched first, and the second routine will be selected and execution block 2 will be executed.

[0024] Step S103: Search all routines with the same name according to the routine name, and iteratively match all the searched routines with the same name through the routine weight algorithm to determine a unique target routine, and execute the call according to the target routine.

[0025] Specifically, in this embodiment, all routines with the same name are searched according to the routine name, and all searched routines are iteratively matched by weight calculation to obtain a final routine. After matching the only final routine, the routine can be executed according to the passed parameters.

[0026] To explain further, all the routines with the same name that are searched are iterated, and the specific steps include the following: S301, first check the basic information: Routine type matches, whether it is procedure or function; Routine name matching; The number of passed parameters cannot be greater than the number of routine parameters; The number of passed parameters + the number of default values ​​cannot be less than the number of routine parameters; If any check fails, the current routine is eliminated and the next routine is checked.

[0027] S302. After the basic information check is passed, a special check is performed on the case where there is a naming expression.

[0028] Check the routine parameter names and parameter names, and eliminate routines with redundant or missing parameters.

[0029] Then a step of parameter reordering is performed (only for cases with named notation) to make the parameters correspond to the corresponding routine parameters one by one.

[0030] S303: After all the above checks are passed, weights of all routines that meet the above conditions are calculated according to the following rules to select the final routine.

[0031] The weight of a single parameter is defined as the "distance" between the passed parameter type and the routine parameter type.

[0032] In the simplest case, if the types match exactly, that is, the type of the passed parameter is the same as the corresponding routine parameter type, the distance is zero, that is, the weight is set to 0.

[0033] If null is passed in the parameter, it is defined to match any type in the parameter, with a weight of 1.

[0034] If the types do not match completely, check whether the routine parameter type is in the parameter passing priority list and calculate the distance to the parameter passing type, and get the weight based on the distance.

[0035] If there is no match in the priority list, the parameter matching fails and the current routine is eliminated.

[0036] The calculation process is as follows: If a routine can be found whose all parameter types match the corresponding routine parameter types (ie, it belongs to one of the above three cases a, b, and c), the best routine is selected by calculating the weight.

[0037] The weight of each parameter is w[0] w[1] w[n], where w[0] is the weight of the first parameter and w[n] is the weight of the last specified parameter. It should be noted that the weight can only be calculated after the two types match. The weight refers to the distance between the parameter type and the corresponding routine parameter type.

[0038] Assume that best_w[] represents the routine with the smallest total weight and w[] represents the weights of all other routines with matching types, but not the smallest total weight. best_w[] must satisfy the following conditions: For each non-minimum weight routine, there are some values of k, where k <= n - 1; such that for i = 0 to k, best_w[i] <= w[i], and best_w[k + 1] < w[k + 1].

[0039] For ease of understanding, the following example is given: Match the first routine r1; w[0] <= best_w[0], w[1] <= best_w[1], w[2] > best_w[2]. At this time, the above conditions are not met, and r1 is eliminated.

[0040] Start matching the second routine r2; w[0] <= best_w[0], w[1] <= best_w[1], w[2] < best_w[2]. At this time, reassign the value of best_w. The current best routine is r2, and start matching the next routine.

[0041] Match the second routine r3; w[0] = best_w[0], w[1] = best_w[1], w[2] = best_w[2]. At this time, record the conflict. If there is a subsequent routine that can satisfy w[0] <= best_w[0], w[1] <= best_w[1], w[2] < best_w[2], then clear the conflict record and update the best routine; if it is already the last routine, report an error for the conflict.

[0042] The method described in this embodiment is applicable to various parameter passing expression methods, and different routines can be called according to different input parameters. Through routine overloading resolution, the readability and reusability of the code are effectively provided.

[0043] It should be noted that some embodiments of the present application are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the above embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0044] Based on the same inventive concept, corresponding to the method of any of the above embodiments, an embodiment of the present application also provides a database routine overloading resolution device.

[0045] As Figure 2 shown, the database routine overloading resolution device includes: The information acquisition module 11 is configured to acquire the calling routine information, wherein the routine information at least includes the parameter type, the number of parameters, the expression method of the parameter, the routine name, the routine parameter type, and the number of routine parameters; A preprocessing module 12 is configured to preprocess the routine information to initialize a priority list of each parameter transmission; The routine calling module 13 is configured to search for all routines with the same name according to the routine name, and iteratively match all the searched routines with the same name through a routine weight algorithm to determine a unique target routine, and perform a call according to the target routine.

[0046] For the convenience of description, the above devices are described in terms of functions and are divided into various modules. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0047] The device of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0048] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any of the above embodiments is implemented.

[0049] Figure 3 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0050] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0051] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0052] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0053] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0054] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).

[0055] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0056] The electronic device of the above embodiment is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0057] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in any of the above embodiments.

[0058] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0059] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute the method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0060] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0061] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device may be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0062] Although the present application has been described in conjunction with specific embodiments of the present application, many alternatives, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the discussed embodiments.

[0063] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.

Claims

1. A database routine overload resolution method, characterized in that: include: Obtaining calling routine information, wherein the routine information at least includes parameter type, number of parameters, expression of parameter, routine name, routine parameter type, and number of routine parameters; Preprocessing the routine information to initialize a priority list for each parameter passed; All routines with the same name are searched according to the routine name, and all the searched routines with the same name are iteratively matched through a routine weight algorithm to determine a unique target routine, and a call is performed according to the target routine.

2. The method according to claim 1, characterized in that: The expression methods of parameter passing include named expression, positional expression and mixed expression.

3. The method according to claim 1, characterized in that The preprocessing of the routine information includes: In response to the parameter type being a subtype of the routine parameter type, adding all supertypes of the parameter type to its priority list; In response to the parameter type being one of the distinct types of the routine parameter type, all source types of the parameter type are added to its priority list.

4. The method according to claim 1, characterized in that: The step of searching for all routines with the same name according to the routine name, iteratively matching all the searched routines with the same name by using a routine weight algorithm to determine a unique target routine, and executing a call according to the target routine includes: Performing basic information check on all searched routines with the same name, wherein the check includes routine parameter type matching, routine name matching, and comparison of the number of passed parameters with the number of routine parameters; The weight calculation is performed on each parameter passed through the check according to the preset weight rules, wherein the weight rules include: If the parameter type matches the routine parameter type completely, the definition weight is zero; In response to passing null in the routine parameter, the weight is defined as 1; In response to the parameter type not completely matching the routine parameter type, checking whether the routine parameter type is in a parameter priority list, and calculating the distance to the parameter type to obtain a corresponding weight; The routine with the best weight is selected as the final matching target routine to perform the routine call.

5. The method according to claim 4, characterized in that The comparison between the number of passed parameters and the number of routine parameters includes: The number of passed parameters is less than or equal to the number of routine parameters; The number of passed parameters + the number of default values ​​is greater than or equal to the number of routine parameters.

6. The method according to claim 4, characterized in that It also includes special checks on parameters passed with named expressions after the basic information check has passed: Check the names of routine parameters and passed parameters, eliminate routines with redundant parameters and missing parameters, and reorder the passed parameters so that the passed parameters correspond to the corresponding routine parameters one by one.

7. The method according to claim 4, characterized in that: In response to the routine parameter type not being in the parameter passing priority list, the parameter passing match fails and the current routine is eliminated.

8. A database routine overload resolution device, characterized in that: include: An information acquisition module is configured to acquire calling routine information, wherein the routine information at least includes a parameter type, a number of parameters, a parameter expression method, a routine name, a routine parameter type, and a number of routine parameters; A preprocessing module, configured to preprocess the routine information to initialize a priority list of each parameter; The routine calling module is configured to search for all routines with the same name according to the routine name, and iteratively match all the searched routines with the same name through a routine weight algorithm to determine a unique target routine, and perform a call according to the target routine.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium, characterized in that: in, The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Distributed system generating rule compiler engine apparatuses, methods, systems and media

    CN113574517A

  • Object reloading method, device and equipment and storage medium

    CN113703879A

  • Object type-declaration prefix syntax

    US20050278697A1