Method and equipment for rapidly detecting and repairing non-released EC program cursor and storage medium

By enabling multi-process scanning in the EC program and integrating the ‘OPEN’, ‘return’ and ‘CLOSE’ statements, unreleased cursors are detected and repaired, and resource waste and performance problems caused by unreleased cursors are solved, which significantly improves program stability and database performance.

CN119645724APending Publication Date: 2025-03-18FUJIAN LUOYUAN COUNTY SENIOR VOCATIONAL HIGH SCHOOL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411700326.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In EC programs or database interaction applications, cursors are not released correctly, resulting in increased resource consumption, affecting database performance and transaction execution, and may cause hidden errors.

Method used

Detect and repair unreleased cursors by enabling multiple processes to scan multiple systems simultaneously. The specific steps include scanning and classifying the 'OPEN', 'return' and 'CLOSE' statements, integrating them into an ordered set, serializing the cursor release status, and recording the unreleased cursor information for repair.

Benefits of technology

Effectively detect and repair unreleased cursors, prevent resource waste, improve database performance and program stability, and reduce the risk of crashes caused by resource exhaustion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645724A_ABST
    Figure CN119645724A_ABST
Patent Text Reader

Abstract

The invention discloses a method for rapidly detecting and repairing non-released verniers in EC programs. The method comprises the steps that the EC programs in multiple systems are scanned at the same time through multiple processes; scanning 'OPEN', 'turn' and 'CLOSE' statements in the EC program, and recording the line number and the content of the statements; performing insertion sorting on the contents of the three sets according to the line number to obtain an ordered set; sequentially taking out the verniers from the ordered set, carrying out sequence processing on the verniers, replacing 'CLOSE' with '0', replacing'turn 'with' 1 ', and replacing the last' CLOSE 'with' 01 '; judging whether the vernier is normally released or not according to the obtained logic sequence; recording a cursor which is not normally released and a file name of a program where the cursor is located; the program file is backed up, and a CLOSE statement is supplemented to the position where the vernier needs to be closed. According to the method, through insertion sorting, sequence processing and logic sequence comparison, the non-released vernier is effectively detected and repaired, the stability of the program is improved, and collapse or performance reduction caused by resource exhaustion is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of databases, and in particular to a method, a device and a storage medium for quickly detecting and repairing an unreleased EC program cursor. Background Art

[0002] In EC programs or any database-interactive applications, cursors are used to process query results row by row. In business systems based on EC coding, there are a large number of scenarios where cursors are used. However, due to irregular coding and failure to properly handle exceptions, cursors are not released correctly, resulting in additional resource consumption in the production system, affecting database performance and normal transaction execution, and causing hidden errors, such as transaction consistency issues. If the system uses a large number of cursors, the maximum cursor limit may also be triggered, and new cursors will not be able to be opened, causing application errors.

[0003] Therefore, detecting that the cursor is not released is an important step to ensure stable and efficient system operation. By detecting whether the cursor is released, the stability of the program can be improved and crashes or performance degradation caused by resource exhaustion can be reduced. This not only helps maintain code quality, but also improves the robustness of the application. Summary of the invention

[0004] The purpose of the present invention is to provide a method for quickly detecting and repairing an unreleased EC program cursor, so as to solve the problem that system resources are occupied, performance is degraded, and program errors occur due to unreleased cursors.

[0005] The method for quickly detecting and repairing EC program cursor not being released is characterized in that multiple processes are started to scan EC program codes of multiple systems at the same time, and each EC program is detected and repaired, including the following steps:

[0006] S1. The system scans all the lines of "OPEN", "return", and "CLOSE" in the EC program respectively, and classifies the scan results to obtain three classification sets: OPEN set, return set, and CLOSE set. The elements in each set are two-dimensional elements containing the line number and the code statement of this line number;

[0007] S2. Take one of the three classification sets as the base set, and insert the elements of the other two classification sets into the base set according to the number of rows to obtain an ordered set;

[0008] S3. Serialize the ordered set to obtain a sequence set;

[0009] S4. Take out elements from the sequence set in sequence, reconstruct the taken out elements to obtain a logical sequence, and use the obtained logical sequence to judge the cursor release state. If the cursor release state is normal, take out the next element. If the cursor state is not normal, go to S5;

[0010] S5. Record the name of the cursor and the name of the program file where the cursor is not released normally;

[0011] S6. Find the EC program file according to the recorded EC program file name, back it up and get the target file, find the cursor in the target file according to the recorded cursor name, and complete the repair of the current cursor.

[0012] Furthermore, the serialization process is specifically as follows:

[0013] The "CLOSE" inside the removed element is replaced with "0", but when the "CLOSE" is the last "CLOSE" in the last cursor, it is replaced with "01" and "return" is replaced with "1".

[0014] Furthermore, the cursor state release judgment is specifically as follows:

[0015] According to the obtained logical sequence, its length is obtained to determine whether the value of its length is an even number. If it is an even number, the system forms a comparison sequence composed of "01" according to the length of the logical sequence, and compares the comparison sequence with the logical sequence. If the comparison result is "1", the cursor is released normally and the next element is taken.

[0016] If it is not an even number or the comparison result is "0", the cursor is not released normally, so the cursor name and the name of the program file are recorded.

[0017] Furthermore,

[0018] The specific steps of extracting elements and reconstructing elements are as follows:

[0019] The elements are taken out from "OPNE" to the next adjacent "OPEN", so multiple numbers are obtained by reading the taken out elements, and they are arranged in sequence to form a logical sequence to complete the element reconstruction.

[0020] Furthermore, the backup and cursor repair are specifically as follows:

[0021] The system finds the file according to the recorded program file name and backs it up to obtain the target file, and obtains the content before the position to be supplemented from the original program file and writes it into the target file;

[0022] In the target file, add the corresponding CLOSE statement before the return that needs to be supplemented with the cursor closing operation. In order to ensure alignment, get the position of the return in its line number, add the corresponding number of spaces before the supplementary CLOSE operation, and synchronize the remaining content from the original program file to the target file.

[0023] Furthermore, a computer device comprises

[0024] A memory for storing instructions;

[0025] The processor is used to execute the instructions, so as to realize a method for quickly detecting and repairing the EC program cursor not being released.

[0026] Furthermore, a computer-readable storage medium stores a computer program, which, when executed, can implement a method for quickly detecting and repairing an unreleased EC program cursor.

[0027] The present invention has the beneficial effects:

[0028] 1. Integrate "OPEN", "return" and "CLOSE" statements into an ordered set through scanning and insertion sorting, and convert the key statements inside the cursor into a logical sequence by replacing them with "0", "1" and "01" through specific sequence processing. This method not only improves the processing flexibility, but also makes the judgment of cursor release more accurate.

[0029] 2. The present invention can not only detect cursors that are not released normally, but also accurately record the names of these cursors and the names of the program files in which they are located, which provides detailed information for subsequent repair work and facilitates the tracking and positioning of problems.

[0030] 3. This invention significantly enhances the stability of the program by accurately detecting and confirming the release status of the cursor, effectively avoiding the risk of crash and performance degradation that may be caused by improper release of resources. This not only provides a solid guarantee for the continuous optimization of code quality, but also greatly improves the overall robustness and reliability of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of the steps of the present invention;

[0032] Figure 2 This is a schematic diagram of the logic judgment of the present invention;

[0033] Figure 3 It is a schematic diagram of the "OPNE" assembly of the present invention;

[0034] Figure 4 This is a schematic diagram of the "CLOSE" collection of the present invention;

[0035] Figure 5 This is a schematic diagram of the "return" set of the present invention;

[0036] Figure 6 The present invention sequentially extracts and obtains a logical sequence schematic diagram from an ordered set. DETAILED DESCRIPTION

[0037] The present invention will be further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.

[0038] Example

[0039] See also Figures 1 to 6 As shown,

[0040] The method for quickly detecting and repairing EC program cursors that are not released is to start multiple processes to scan the EC program codes of multiple systems at the same time, and detect and repair each EC program, including the following steps:

[0041] S1. The system scans all the lines of "OPEN", "return", and "CLOSE" in the EC program respectively, and classifies the scan results to obtain three classification sets: OPEN set, return set, and CLOSE set. The elements in each set are two-dimensional elements containing the line number and the code statement of this line number;

[0042] S2. Take one of the three classification sets as the base set, and insert the elements of the other two classification sets into the base set according to the number of rows to obtain an ordered set;

[0043] S3. Serialize the ordered set to obtain a sequence set;

[0044] S4. Take out elements from the sequence set in sequence, reconstruct the taken out elements to obtain a logical sequence, and use the obtained logical sequence to judge the cursor release state. If the cursor release state is normal, take out the next element. If the cursor state is not normal, go to S5;

[0045] S5. Record the name of the cursor and the name of the program file where the cursor is not released normally;

[0046] S6. Find the EC program file according to the recorded EC program file name, back it up and get the target file, find the cursor in the target file according to the recorded cursor name, and complete the repair of the current cursor.

[0047] EC, the full name of NFORMIX-ESQL / C, is a programming language that allows SQL statements to be embedded in C language code. This embedded SQL C language enables developers to directly execute SQL commands in C programs to access and operate databases.

[0048] In EC program, database cursor can be used to operate database data. Cursor mainly includes "OPEN" statement, "CLOSE" statement and "return" statement. The function of "OPEN" statement is to open cursor, "CLOSE" statement is to close cursor, and "return" statement is to exit cursor. A cursor has only one "OPEN" statement, one or more "CLOSE" statements, and there is no limit to "return" statement. There is only one situation in which cursor is closed normally: there is a "CLOSE" statement before each "return" statement. When there is no "CLOSE" statement before a "return" statement inside the cursor, the cursor is not closed normally.

[0049] The present invention starts multiple processes to scan "OPEN", "return" and "CLOSE" in the codes of EC programs in multiple systems respectively, so that all "OPEN", "return" and "CLOSE" can be obtained without omission, and because it is a scan of the codes in the EC programs, the number of lines where the codes are located can be obtained, and the elements in the three classification sets OPEN set, return set and CLOSE set obtained are two-bit elements including line numbers and code statements, and the line numbers in the three classification sets are sorted from small to large, and the line numbers can also provide a basis for subsequent set integration;

[0050] Then, one of the OPEN set, return set, and CLOSE set is set as the base set, and the other two sets are compared with the number of rows of elements in the base set according to the number of rows in the elements, and inserted into the appropriate position, so as to integrate the three sets together to obtain an ordered set in which the number of rows of elements is arranged in ascending order. The purpose of integrating the three sets into an ordered set according to the number of rows is to obtain all the cursor statements in the EC program code and arrange them in order, which is equivalent to extracting the statements about "OPEN", "return", and "CLOSE" from the EC program code and removing the irrelevant parts, which is convenient for the subsequent processing and judgment of the cursor;

[0051] Take out elements from the ordered set in order and perform sequence processing to obtain a sequence set. Take out elements from the sequence set in order and combine them to obtain a logical sequence. Use the obtained logical sequence to judge the release of the cursor and record the name of the cursor that was not released normally. Then back up the program file where the cursor is located and add the "CLOSE" statement to the corresponding position of the recorded cursor.

[0052] The present invention can obtain all "OPEN", "return", and "CLOSE", and obtain the row number of each "OPEN", "return", and "CLOSE", accurately locate "OPEN", "return", and "CLOSE", and then obtain a logical sequence by serializing and combining "return" and "CLOSE". The logical sequence is used for judgment. Compared with the method of judging the cursor state by the continuity of "OPEN", "return", and "CLOSE", the present invention can judge the continuous and discontinuous cursor states of "OPEN", "return", and "CLOSE", and has more extensiveness and applicability;

[0053] The OPEN set, return set, and CLOSE set are as follows: Figures 3 to 5 The schematic diagrams are shown in sequence.

[0054] The process of obtaining an ordered set is:

[0055] Any one of the three sets is identified as an ordered set, and the remaining two sets are identified as unordered sets. The two unordered sets are inserted into the ordered set in ascending order according to the number of rows.

[0056] For example, consider the OPEN set as an ordered permutation set, where the data is:

[0057] 836: EXEC SQL OPENN favo_curl; - Cursor name: [favo_curl]

[0058] 960: EXEC SQL OPENN curl; - Cursor name: [curl]

[0059] Consider the return set and the CLOSE set as two unordered sets, where the data are:

[0060] return collection:

[0061] 875: return

[0062] 1100: return

[0063] CLOSE collection:

[0064] 846: EXEC SQL CLOSE favo_curl

[0065] 900: EXEC SQL CLOSE favo_curl

[0066] 1054: EXEC SQL CLOSE curl

[0067] 1132: EXEC SQL CLOSE curl

[0068] First, insert the OPEN set and the return set into sort order, inserting them in order according to their number of rows. The result is a new ordered set:

[0069] 836: EXEC SQL OPENN favo_curl; - Cursor name: [favo_curl]

[0070] 875: return

[0071] 960: EXEC SQL OPENN curl; - Cursor name: [curl]

[0072] 1100: return

[0073] Then insert and sort the new ordered set and the CLOSE set to get the final ordered set, as follows:

[0074] 836: EXEC SQL OPENN favo_curl; - Cursor name: [favo_curl]

[0075] 846: EXEC SQL CLOSE favo_curl

[0076] 875: return

[0077] 900: EXEC SQL CLOSE favo_curl

[0078] 960: EXEC SQL OPENN curl; - Cursor name: [curl]

[0079] 1054: EXEC SQL CLOSE curl

[0080] 1100: return

[0081] 1132: EXEC SQL CLOSE curl

[0082] Furthermore, the serialization process is specifically as follows:

[0083] The "CLOSE" inside the removed element is replaced with "0", but when the "CLOSE" is the last "CLOSE" in the last cursor, it is replaced with "01" and "return" is replaced with "1".

[0084] Using the idea of ​​substitution, "0" is used to represent the "COLSE" inside the cursor, "01" is used to represent the last "CLOSE" in the cursor, and "1" is used to represent the "return" inside the element. The keywords "COLSE" and "return" in the element are read in the order of code execution, thereby obtaining a logical sequence.

[0085] For example, to retrieve elements from an ordered set by cursor name, as follows:

[0086] 836: EXEC SQL OPENN favo_curl; - Cursor name: [favo_curl]

[0087] 858: EXEC SQL CLOSE favo_curl;

[0088] 861: return;

[0089] 874: EXEC SQL CLOSE favo_curl;

[0090] Reading the element from top to bottom, the numbers obtained in order are 0, 1, 01, so the resulting logical sequence is 0101;

[0091] The above elements are as follows after obtaining the logical sequence number:

[0092] 836: EXEC SQL OPENN favo_curl; - Cursor name: [favo_curl]

[0093] 858: EXEC SQL CLOSE favo_curl;

[0094] 861: return;

[0095] 874: EXEC SQL CLOSE favo_curl; 0101

[0097] Furthermore, the cursor state release judgment is specifically as follows:

[0098] According to the obtained logical sequence, its length is obtained to determine whether the value of its length is an even number. If it is an even number, the system forms a comparison sequence composed of "01" according to the length of the logical sequence, and compares the comparison sequence with the logical sequence. If the comparison result is "1", the cursor is released normally and the next cursor is removed.

[0099] If it is not an even number or the comparison result is "0", the cursor is not released normally, so the cursor name and the name of the program file are recorded;

[0100] According to the normal closing state of the cursor, there should be a "CLOSE" statement before each "return" in the cursor, so the sequence number of a group of "CLOSE" and "return" is "01". Because the last "CLOSE" is represented by "01", the logical sequence of the normal closing of the cursor should be composed of "01";

[0101] Therefore, the value of the logic sequence length corresponding to the normally closed cursor should be an even number. Therefore, first determine whether the value of the logic sequence length is an even number to obtain the cursors whose logic sequence length values ​​are not even numbers, thereby obtaining some cursors that are not normally closed;

[0102] Since there is no limit on the number of "returns" in a cursor, it may happen that even if the length of the obtained logical sequence is an even number, the logical sequence is not composed of "01", such as the following cursor:

[0103] 1836: EXEC SQL OPENN cur_dk; - cursor name: [cur_dk]

[0104] 1845: return;

[0105] 1858: EXEC SQL CLOSE cur_dk;

[0106] 1861: return;

[0107] 1870: return;

[0108] 1874: EXEC SQL CLOSE cur_dk;

[0109] The logic sequence of this cursor is: 101101. Although it is an even number, it is not composed of "01". Therefore, it is necessary to form a comparison sequence composed of "01" according to the length of the logic sequence. The comparison sequence of this cursor is 010101. The comparison sequence and the logic sequence of this cursor are numerically judged to determine whether they are equal. If they are the same, "1" is output, and if they are not equal, "0" is output.

[0110] Outputting "1" means that the cursor is closed normally, and outputting "0" means that the cursor is not closed normally.

[0111] Furthermore,

[0112] The specific steps of extracting elements and reconstructing elements are as follows:

[0113] The elements are taken out from "OPNE" to the next adjacent "OPEN", so multiple numbers are obtained by reading the taken out elements, and they are arranged in sequence to form a logical sequence to complete the element reconstruction.

[0114] Furthermore, the backup and cursor repair are specifically as follows:

[0115] The system finds the file according to the recorded program file name and backs it up to obtain the target file, and obtains the content before the position to be supplemented from the original program file and writes it into the target file;

[0116] In the target file, add the corresponding CLOSE statement before the return that needs to be supplemented with the cursor closing operation. In order to ensure alignment, get the position of the return in its line number, add the corresponding number of spaces before the supplementary CLOSE operation, and synchronize the remaining content from the original program file to the target file.

[0117] Furthermore, a computer device comprises

[0118] A memory for storing instructions;

[0119] The processor is used to execute the instructions, so as to realize a method for quickly detecting and repairing the EC program cursor not being released.

[0120] Furthermore, a computer-readable storage medium stores a computer program, which, when executed, can implement a method for quickly detecting and repairing an unreleased EC program cursor.

[0121] It is understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present invention, but the present invention is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also considered to be within the scope of protection of the present invention.

Claims

1. A method for quickly detecting and repairing EC program cursors that are not released, characterized in that: Start multiple processes to scan EC program codes of multiple systems at the same time, and detect and repair each EC program, including the following steps: S1. The system scans all the lines of "OPEN", "return", and "CLOSE" in the EC program respectively, and classifies the scan results to obtain three classification sets: OPEN set, return set, and CLOSE set. The elements in each set are two-dimensional elements containing the line number and the code statement of this line number; S2. Take one of the three classification sets as the base set, and insert the elements of the other two classification sets into the base set according to the number of rows to obtain an ordered set; S3. Serialize the ordered set to obtain a sequence set; S4. Take out elements from the sequence set in sequence, reconstruct the taken out elements to obtain a logical sequence, and use the obtained logical sequence to judge the cursor release state. If the cursor release state is normal, take out the next element. If the cursor state is not normal, go to S5; S5. Record the name of the cursor and the name of the program file where the cursor is not released normally; S6. Find the EC program file according to the recorded EC program file name, back it up and get the target file, find the cursor in the target file according to the recorded cursor name, and complete the repair of the current cursor.

2. The method for quickly detecting and repairing EC program cursor not being released according to claim 1 is characterized in that: The serialization process is specifically as follows: The "CLOSE" inside the element is replaced with "0", but when the "CLOSE" is the last "CLOSE" in the last element, it is replaced with "01", and "return" is replaced with "1".

3. The method for quickly detecting and repairing EC program cursor not being released according to claim 1, characterized in that: The cursor state release judgment is specifically as follows: According to the obtained logical sequence, its length is obtained to determine whether the value of its length is an even number. If it is an even number, the system forms a comparison sequence composed of "01" according to the length of the logical sequence, and compares the comparison sequence with the logical sequence. If the comparison result is "1", the cursor is released normally and the next cursor is removed. If it is not an even number or the comparison result is "0", the cursor is not released normally, so the cursor name and the name of the program file are recorded.

4. The method for quickly detecting and repairing EC program cursor not being released according to claim 1, characterized in that: The specific steps of extracting elements and reconstructing elements are as follows: The elements are taken out from "OPNE" to the next "OPEN". Then, multiple numbers are obtained by reading the taken out elements. The numbers are arranged in sequence to form a logical sequence, thus completing the element reconstruction.

5. The method for quickly detecting and repairing EC program cursor not being released according to claim 1, characterized in that: The EC program file backup and cursor repair are specifically as follows: The system finds the file according to the recorded EC program file name and backs it up to obtain the target file. The content before the position to be supplemented is obtained from the original program file and written into the target file. In the target file, add the corresponding CLOSE statement before the return that needs to be supplemented with the cursor closing operation. In order to ensure alignment, get the position of the return in its line number, add the corresponding number of spaces before the supplementary CLOSE operation, and synchronize the remaining content from the original program file to the target file.

6. A computer device, characterized in that: include A memory for storing instructions; The processor is used to execute the instructions so as to implement the method for quickly detecting and repairing the non-release of the EC program cursor as claimed in any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, it can implement a method for quickly detecting and repairing EC program cursor not being released as claimed in any one of claims 1 to 5.