Method, device and equipment for extracting error text of database and storage medium
By dividing the error file into three areas to store the total number of error messages, index information and text data, and using three small-scale data reading operations, the problem of long database error text extraction time in the existing technology is solved, and the client response speed is improved.
Patent Information
- Application Number
- CN202511120393.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-08-12
AI Technical Summary
The existing database error text extraction method takes too long, resulting in slow client response speed.
The index and text data are stored in separate areas, and the error file is divided into three areas for storage: the first area stores the total number of error messages, the second area stores the index information of the error messages, and the third area stores the error text data. The target error text is obtained through three small data reading operations.
The time spent on extracting error text has been greatly shortened, and the client response speed has been improved.
Smart Images

Figure CN120632012A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database text extraction, and in particular to a method, device, equipment and storage medium for extracting erroneous text from a database. Background Art
[0002] The client-server architecture is a network architecture model that divides computers on a network into two categories: clients and servers. Clients accessing server databases are widely used in applications such as enterprise resource planning (ERP) systems and customer relationship management (CRM) systems. For example, clients access databases using the CSDK provided by the database vendor.
[0003] When a database client accesses a database, errors occasionally occur. Error information typically includes an error number and error text. The error number is generated by the server or client. The error text is a description of the error and is generally stored in a file on the client. When the error text needs to be extracted, file operations need to be performed on the client file, involving system calls. The traditional method of extracting error text can be to read each error message into memory one by one, compare the error number, and extract the target error text. This method requires multiple file reads, which is time-consuming and affects the client's response speed. Another traditional method of extracting error text is to read all error messages in the file into memory at once, and then compare and extract them one by one. Although this method has fewer reads, it occupies more memory resources and takes a long time to read large amounts of data in batches. As a result, the existing database error text extraction method takes too long, resulting in a low client response speed. Summary of the Invention
[0004] The embodiments of the present invention provide a method, apparatus, device and storage medium for extracting database error text, so as to solve the problem that the existing database error text extraction method consumes too long a time and results in a low client response speed.
[0005] In a first aspect, an embodiment of the present invention provides a method for extracting error text from a database, wherein an error file stores multiple error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; the second area stores the error number of each error message and the storage range of the corresponding error text; and the third area stores multiple error texts of non-fixed length. The method comprises: Get the target error number of the target error information; read the first area to get the total number of error messages; Based on the total number of error messages, a storage range of the second area is obtained; Based on the storage range of the second area, the second area is read to obtain the error number of each error message and the storage range of the corresponding error text; Based on the target error number, query and obtain the storage range of the error text corresponding to the target error number in the storage range of the error number and the corresponding error text of each error message; Read the target error text according to the storage range of the error text corresponding to the target error number.
[0006] In one possible implementation, the storage space of the first area is a first fixed length; the storage space of each error message in the second area is a second fixed length; and based on the total number of error messages, the storage range of the second area includes: A storage range of the second area is obtained based on the first fixed length, the total number of error messages, and the second fixed length of each error message.
[0007] In a possible implementation, the storage range of the error text includes an offset and an error text length; the offset indicates a starting storage position of the error text in the error file.
[0008] In a possible implementation, the offset of any error text is equal to the sum of the lengths of the first area and the second area, plus the sum of the lengths of all error texts before the error text.
[0009] In a possible implementation, there are multiple error files; each error file stores the same type of error information; and reading the first area to obtain the total number of error information includes: According to the target error number, determine the type of error information corresponding to the target error number; According to the type of the error information, determining a target error file corresponding to the type; The first area of the target error file is read to obtain the total number of error messages in the target error file.
[0010] In a possible implementation, the types of the error information include: database connection error, database operation syntax error, or database data error.
[0011] In one possible implementation, the error numbers and corresponding error text storage ranges of the error messages are stored in the second area in order of the error numbers; based on the target error number, the storage range of the error text corresponding to the target error number is obtained by querying the error numbers and corresponding error text storage ranges of the error messages, including: Based on the target error number, a binary search method is used to determine the position of the target error number in the storage range of the error number and the corresponding error text of each error message; Based on the position of the target error number, the storage range of the error text corresponding to the target error number is obtained.
[0012] In a second aspect, an embodiment of the present invention provides a device for extracting error text from a database, wherein an error file stores multiple error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; the second area stores the error number of each error message and the storage range of the corresponding error text; and the third area stores multiple error texts of non-fixed length. The device includes: An acquisition module is used to obtain a target error number of target error information; The first zone reading module is used to read the first zone and obtain the total number of error messages; A second zone range determination module, configured to obtain a storage range of the second zone based on the total number of error messages; A second area reading module is used to read the second area based on the storage range of the second area to obtain the error number of each error message and the storage range of the corresponding error text; a target text range determination module, configured to query and obtain a storage range of the error text corresponding to the target error number from the storage range of the error number and the corresponding error text of each error message based on the target error number; The target text reading module is used to read the target error text according to the storage range of the error text corresponding to the target error number.
[0013] In a third aspect, an embodiment of the present invention provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method in the first aspect or any possible implementation of the first aspect is implemented.
[0014] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method in the first aspect or any possible implementation of the first aspect.
[0015] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the method in the first aspect or any possible implementation of the first aspect.
[0016] In an embodiment of the present invention, an error file uses a storage method in which indexes and text data are stored in separate areas to store multiple error messages. The first area of the error file stores the total number of error messages; the second area stores the index information of each error message, and the index information includes the error number and the storage range of the corresponding error text; the third area stores error text data of non-fixed length. The index and text data in the same file are stored in separate areas. Based on the above storage method, when extracting error text, the total number of error messages stored in the first area is first read out, thereby determining the storage range of the second area. Thus, the index information of each error message stored in the second area that occupies less space is read out, that is, the error number and the storage range of the corresponding error text. In the index information, the storage range of the error text corresponding to the target error number is determined, and the target error text is further read out. According to the above extraction method, no matter how many error texts are contained in the error file, only three small data reading operations are required to obtain the error text corresponding to the target error number, which greatly shortens the time consumed in error text extraction and improves the client response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is an application scenario diagram of the method for extracting error text from a database provided by an embodiment of the present invention; Figure 2 Schematic diagram of the storage structure of the error file provided by the embodiment of the present invention; Figure 3 This is a flowchart of a method for extracting error text from a database provided by an embodiment of the present invention; Figure 4 1 is a schematic structural diagram of an apparatus for extracting error text from a database provided by an embodiment of the present invention; Figure 5 is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0019] Figure 1 This is an application scenario diagram of the method for extracting error text from a database provided by an embodiment of the present invention. Figure 1As shown, errors that occur when a client accesses a database can be stored in the client. For example, error information is stored in an error file. Database error text is a text prompt containing error information returned to the user when the database system encounters an exception or error during operation. This text typically indicates the type of problem, possible cause, and solution, and is an important basis for locating and repairing database failures. When performing error analysis and error handling, the client needs to read the error information in the error file, especially the error text. However, existing methods for extracting database error text are time-consuming, resulting in slow client response speed. Reducing the number of file reads, and thereby reducing system calls, is the key to improving client response speed.
[0020] The present invention utilizes separate storage areas for index and text data to store multiple error messages. Furthermore, by performing three small-scale data read operations, the error text corresponding to the target error number can be obtained, thereby improving client response speed. The following first describes the storage structure of the error file.
[0021] Figure 2 This is a schematic diagram of the storage structure of the error file provided by the embodiment of the present invention; Figure 2 The error file stores multiple error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; the second area stores the error number of each error message and the storage range of the corresponding error text; the third area stores multiple error texts of non-fixed length; It should be noted that the error file pre-stores multiple error messages when accessing the database. Exemplarily, each error message includes at least an error number and an error text. For example, the error number is generated by the server or the client. The error number is a unique identifier for each error message. Furthermore, the error number may also include error type information, user information, or time information. The specific encoding rules for the error number are not limited here. It should be further noted that the multiple error messages are not stored one by one in the error file, but each error message is split into different parts and stored in different areas of the error file.
[0022] Figure 3 This is a flowchart of the method for extracting error text from a database provided by an embodiment of the present invention. Figure 3 , the method for extracting database error text includes: Step 301, obtaining the target error number of the target error information; For example, a specific application scenario of an embodiment of the present invention is to extract target error text based on a target error number. The error number can not only uniquely identify the error text, but can also represent more information. For example, a certain digit in the error number represents a certain type of error. When a client needs to analyze a certain type of error, it can filter out the target error number. Furthermore, the target error text is extracted based on the target error number. The specific scenario in which the error text needs to be extracted is not limited here.
[0023] Step 302: Based on the total number of error messages, obtain the storage range of the second area; In one possible implementation, the storage space of the first area is a first fixed length; the storage space of each error message in the second area is a second fixed length; and obtaining the storage range of the second area based on the total number of error messages includes: obtaining the storage range of the second area based on the first fixed length, the total number of error messages, and the second fixed length of each error message.
[0024] In one possible implementation, the error file is used to store multiple error messages when accessing the database; the error file includes three consecutive storage areas; a first area of fixed length stores the total number of error messages; a third area stores multiple error texts of non-fixed length; and a second area stores the error number of each error message and the storage range of the corresponding error text; Exemplarily, the storage range of the error text includes an offset and an error text length. The offset indicates the starting storage position of the error text in the error file; and the length of each error message in the second area is a second fixed length.
[0025] In some embodiments, the error file includes three consecutive storage areas. Consecutive storage means that, in physical storage, the three areas are continuous, without any gaps in the storage space. For example, the first, second, and third areas are stored consecutively. The functions of the three areas are described below.
[0026] In some embodiments, the first fixed length of the first area stores the total number of error messages. For example, the first fixed length of the first area is 2 bytes. Figure 2 , exemplarily, the total number of error messages stored in the first area is 3.
[0027] In some embodiments, the third area stores multiple error texts of non-fixed length. The error text is used to describe the error content. Figure 2, text 1, text 2 and text 3 represent error texts. Exemplarily, in the third area, text 1 can be "database service does not exist", text 2 can be "user name does not exist", and text 3 can be "password error". The length of the error text is non-fixed. Compared with the method of allocating the same storage space to each text according to the maximum length, multiple texts of non-fixed length stored continuously can save storage space. However, the continuous storage of multiple texts of non-fixed length also results in multiple texts having no fixed storage pattern in the storage space. The second area can be used to record the storage location of each error text. The details are explained below. It should be noted that in the storage space, the second area is located between the first area and the third area.
[0028] In some embodiments, the second area stores the error number, offset and error text length of each error message; each offset represents the starting storage position of each error text in the error file; the length of each error message in the second area is a second fixed length.
[0029] For example, refer to Figure 2 The second area contains the error numbers, offsets, and error text lengths of three error messages. The first error message has an error number of 101, an offset of 20, and an error text length of 24. The second error message has an error number of 102, an offset of 40, and an error text length of 17. The third error message has an error number of 103, an offset of 61, and an error text length of 15.
[0030] Regarding the second fixed length, illustratively, the total length of the storage space occupied by the error number, offset, and error text length of each error message is the second fixed length. For example, the error number, offset, and error text length each occupy 2 bytes of storage space, meaning that each error message occupies 6 bytes of storage space in the second area. Therefore, since the storage space occupied by each error message in the second area is fixed, the total length of the storage space in the second area can be determined based on the total number of error messages in the first area.
[0031] It should be noted that each offset represents the starting storage position of each error text in the error file. For example, the offset of text 1 is 20, which means that the starting storage position of text 1 in the error file is 20, which is equivalent to the starting storage position of text 1 being the sum of the lengths of the first area and the second area. Furthermore, the target error text can be read based on the offset and the length of the error text. It should be further noted that the offset is determined when the error information is stored. The offset can specifically use absolute coordinates to represent the starting storage position, or it can use relative coordinates to represent the starting storage position.
[0032] It should also be noted that the error numbers stored in the second area correspond one-to-one with the error texts stored in the third area, and are stored in the same order. For example, error number 101 corresponds to text 1, error number 102 corresponds to text 2, and error number 103 corresponds to text 3.
[0033] It should be noted that the error file is stored in a storage medium, such as a hard disk of the client. Reading here can be reading certain data of the error file in the hard disk into the memory of the client, and executing the method of the embodiment of the present invention with the processor of the client as the execution body.
[0034] In one possible implementation, after obtaining the target error number of the target error information, it also includes: obtaining the starting storage position of the error file; correspondingly, based on the first fixed length, reading the first area, and obtaining the total number of error information includes: based on the starting storage position of the error file and the first fixed length, reading the first area, and obtaining the total number of error information.
[0035] In order to further improve the efficiency of error text extraction, the error information can also be classified according to the error type, and the error information of the same category can be stored in the same file, and the error information of different categories can be stored in different error files. The following embodiment will illustrate this.
[0036] In one possible implementation, there are multiple error files; each error file stores error information of the same type; accordingly, reading the first area to obtain the total number of error messages includes: determining the type of error information corresponding to the target error number according to the target error number; determining the target error file corresponding to the type according to the type of the error information; and reading the first area of the target error file to obtain the total number of error messages in the target error file.
[0037] It should be noted that after the target error file is determined, all subsequent steps involving read operations will read the target error file.
[0038] In some embodiments, the types of error information include: database connection error, database operation syntax error, or database data error.
[0039] For example, database connection errors include the database service not existing, the username not existing, or the password being incorrect. Database operation syntax errors include syntax format errors or illegal characters in the statement. Database data errors include data being truncated on the right.
[0040] The above steps obtain the total number of error messages in the first area of the error file. The following describes how to obtain the storage range of the second area.
[0041] Step 303: Based on the total number of error messages, obtain the storage range of the second area; In some embodiments, the starting position and length of the second area are obtained based on the first fixed length, the total number of error messages, and the second fixed length of each error message; It should be noted that since the first and second areas are stored consecutively, the starting position of the second area can be determined based on the first fixed length of the first area. For example, if the starting position of the error file content is represented as 0 and the first fixed length is 2 bytes, the starting position of the second area can be represented as 2, which means starting from and including the second byte.
[0042] It should be further noted that, since the length of each error message in the second area is fixed, namely the second fixed length, and since the relevant fields of each error message in the second area are stored consecutively, the length of the second area can be obtained based on the total number of error messages and the second fixed length. Therefore, based on the starting position and length of the second area, the second area can be directly read from the storage space.
[0043] In an embodiment of the present invention, the error file uses a fixed-length index and independent area storage method to store multiple error messages. The first area of the error file stores the total number of error messages; the second area stores the index information of each error message, and the index information includes the error number, offset and error text length; the index information of the first and second areas is fixed length; the third area stores error text data of non-fixed length. The index and text data in the same file are stored in separate areas. The fixed-length index area and the non-fixed-length text area are physically stored continuously but logically independent. Based on the above storage method, when extracting the error text, the storage range of the second area can be quickly determined, which reduces the time consumed in error text extraction and improves the client response speed.
[0044] Step 304: Based on the storage range of the second area, read the second area to obtain the error number of each error message and the storage range of the corresponding error text; In some embodiments, based on the starting position and length of the second area, the second area is read to obtain the error number, offset and error text length of each error message; In some embodiments, based on the starting position and length of the second area, the second area of the error file is read to obtain the error number, offset and error text length of each error message stored in the second area.
[0045] For example, in the error file, the offset of any error text is equal to the sum of the lengths of the first and second areas, plus the sum of the lengths of all error texts before the error text. Figure 2, the offset of text 2 is 44, which is the sum of the length of the first area (2 bytes), the length of the second area (18 bytes), and the length of text 1 (24 bytes).
[0046] In some embodiments, the storage range of the error text includes an offset and an error text length; the offset indicates the starting storage position of the error text in the error file.
[0047] Exemplarily, the offset of any error text is equal to the sum of the lengths of the first area and the second area, plus the sum of the lengths of all error texts before the error text.
[0048] Step 305: Based on the target error number, query the storage range of the error text corresponding to the target error number in the storage range of the error number and the corresponding error text of each error message; In some embodiments, based on the target error number, the offset and error text length corresponding to the target error number are queried among the error number, offset and error text length of each error message.
[0049] For example, the target error number can be compared with each error number one by one in the order in which they are stored. The computational efficiency of this method is uncertain. Another possible implementation is provided below.
[0050] In one possible implementation, the error numbers and corresponding error text storage ranges of the error messages are stored in the second area in order of the error numbers; based on the target error number, the storage range of the error text corresponding to the target error number is obtained by querying the error numbers and corresponding error text storage ranges of the error messages, including: Based on the target error number, a binary search method is used to determine the position of the target error number in the storage range of the error number and the corresponding error text of each error message; Based on the position of the target error number, the storage range of the error text corresponding to the target error number is obtained.
[0051] The embodiment of the present invention stores index information of each error message based on the error number sequence, and adopts a binary search method to quickly match and determine the position of the target error number, thereby quickly obtaining the storage range of the error text corresponding to the target error number.
[0052] Step 306: Read the target error text according to the storage range of the error text corresponding to the target error number.
[0053] In some embodiments, the target error text is read out according to the offset corresponding to the target error number and the error text length.
[0054] Exemplarily, the target error text is read out from the third area of the error text according to the offset corresponding to the target error number and the error text length.
[0055] For example, in the third area, the starting position of the first error text = the starting position of the third area = the length of the first area + the length of the second area. The starting position of the nth error text = the starting position of the n-1th error text + the length of the n-1th error text.
[0056] It should be noted that after obtaining the offset corresponding to the target error number and the error text length, the target error text can be directly read from the error file.
[0057] In a possible implementation, after reading the target error text, the method further includes: obtaining multiple target error texts based on multiple target error numbers; and performing statistical analysis on error causes when accessing the database based on the multiple target error texts.
[0058] For example, according to each target error number, the target error text corresponding to the target error number is obtained based on steps 301 to 306. After obtaining multiple target error texts, the error causes when accessing the database can be statistically analyzed based on the multiple target error texts.
[0059] In an embodiment of the present invention, an error file uses a storage method in which indexes and text data are stored in separate areas to store multiple error messages. The first area of the error file stores the total number of error messages; the second area stores the index information of each error message, and the index information includes the error number and the storage range of the corresponding error text; the third area stores error text data of non-fixed length. The index and text data in the same file are stored in separate areas. Based on the above storage method, when extracting error text, the total number of error messages stored in the first area is first read out, thereby determining the storage range of the second area. Thus, the index information of each error message stored in the second area that occupies less space is read out, that is, the error number and the storage range of the corresponding error text. In the index information, the storage range of the error text corresponding to the target error number is determined, and the target error text is further read out. According to the above extraction method, no matter how many error texts are contained in the error file, only three small data reading operations are required to obtain the error text corresponding to the target error number, which greatly shortens the time consumed in error text extraction and improves the client response speed.
[0060] It should be noted that step 302 is the first data read, in which only the total number of error messages is read. Step 304 is the second data read, in which only the second area is read. Step 306 is the third data read, in which the target error text is directly read.
[0061] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0062] The following are device embodiments of the present invention. For details not fully described therein, reference may be made to the corresponding method embodiments described above.
[0063] Figure 4 A schematic diagram of the structure of an apparatus for extracting error text from a database provided by an embodiment of the present invention is shown. For ease of explanation, only the portion related to the embodiment of the present invention is shown, which is described in detail as follows: like Figure 4 As shown, the error file stores multiple error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; the second area stores the error number of each error message and the storage range of the corresponding error text; the third area stores multiple error texts of non-fixed length; a device 4 for extracting database error texts includes: An acquisition module 41 is used to acquire a target error number of target error information; The first zone reading module 42 is used to read the first zone and obtain the total number of error messages; A second zone range determination module 43 is configured to obtain a storage range of the second zone based on the total number of error messages; The second area reading module 44 is configured to read the second area based on the storage range of the second area to obtain the error number of each error message and the storage range of the corresponding error text; A target text range determining module 45 is configured to query the storage range of the error text corresponding to the target error number from the storage range of the error number and the corresponding error text of each error message based on the target error number; The target text reading module 46 is used to read the target error text according to the storage range of the error text corresponding to the target error number.
[0064] In an embodiment of the present invention, an error file uses a storage method in which indexes and text data are stored in separate areas to store multiple error messages. The first area of the error file stores the total number of error messages; the second area stores the index information of each error message, and the index information includes the error number and the storage range of the corresponding error text; the third area stores error text data of non-fixed length. The index and text data in the same file are stored in separate areas. Based on the above storage method, when extracting error text, the total number of error messages stored in the first area is first read out, thereby determining the storage range of the second area. Thus, the index information of each error message stored in the second area that occupies less space is read out, that is, the error number and the storage range of the corresponding error text. In the index information, the storage range of the error text corresponding to the target error number is determined, and the target error text is further read out. According to the above extraction method, no matter how many error texts are contained in the error file, only three small data reading operations are required to obtain the error text corresponding to the target error number, which greatly shortens the time consumed in error text extraction and improves the client response speed.
[0065] Figure 5 Schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 5 As shown, the electronic device 5 of this embodiment includes: a processor 50 and a memory 51. The memory 51 stores a computer program 52. When the processor 50 executes the computer program 52, the steps of the above-mentioned method embodiments are implemented. Alternatively, when the processor 50 executes the computer program 52, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0066] For example, the computer program 52 may be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program 52 in the electronic device 5.
[0067] The electronic device 5 may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that Figure 5 It is only an example of the electronic device 5 and does not constitute a limitation of the electronic device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 5 may also include input and output devices, network access devices, buses, etc.
[0068] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0069] The memory 51 can be an internal storage unit of the electronic device 5, such as the hard drive or memory of the electronic device 5. The memory 51 can also be an external storage device of the electronic device 5, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on the electronic device 5. Furthermore, the memory 51 can include both the internal storage unit of the electronic device 5 and an external storage device. The memory 51 is used to store the computer program 52 and other programs and data required by the electronic device 5. The memory 51 can also be used to temporarily store data that has been output or is about to be output.
[0070] For the sake of convenience and brevity, the division of the above functional modules / units is only used as an example. In actual applications, the above functions can be assigned to different functional modules / units as needed. The above modules / units can be implemented in the form of hardware, software, or a combination of hardware and software.
[0071] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods in the above-mentioned method embodiments.
[0072] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the methods in the above-mentioned method embodiments.
[0073] The term "computer program" includes computer program code, which may be in source code form, object code form, executable file, or some intermediate form. Computer-readable media may include any entity or device capable of carrying computer program code, recording media, USB flash drives, removable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media.
[0074] In the above embodiments, the descriptions of each embodiment have their own focus. For parts not described or recorded in detail in one embodiment, please refer to the relevant descriptions of other embodiments. Unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other. The technical features of different embodiments can be combined to form new embodiments based on their inherent logical relationships.
[0075] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for extracting error text from a database, characterized in that: The error file stores a plurality of error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; The second area stores the error number of each error message and the storage range of the corresponding error text; The third area stores a plurality of error texts of non-fixed length; the method includes: Get the target error number of the target error information; read the first area to get the total number of error messages; Based on the total number of error messages, a storage range of the second area is obtained; Based on the storage range of the second area, the second area is read to obtain the error number of each error message and the storage range of the corresponding error text; Based on the target error number, query and obtain the storage range of the error text corresponding to the target error number in the storage range of the error number and the corresponding error text of each error message; Read the target error text according to the storage range of the error text corresponding to the target error number.
2. The method for extracting error text from a database according to claim 1, characterized in that: The storage space of the first area is a first fixed length; the storage space of each error message in the second area is a second fixed length; Based on the total number of error messages, the storage range of the second area includes: A storage range of the second area is obtained based on the first fixed length, the total number of error messages, and the second fixed length of each error message.
3. The method for extracting error text from a database according to claim 1, characterized in that: The storage range of the error text includes an offset and an error text length; the offset indicates the starting storage position of the error text in the error file.
4. The method for extracting error text from a database according to claim 3, characterized in that: The offset of any error text is equal to the sum of the lengths of the first and second areas, plus the sum of the lengths of all error texts before the error text.
5. The method for extracting error text from a database according to claim 1, characterized in that: There are multiple error files; each error file stores the same type of error information; the total number of error information obtained by reading the first area includes: According to the target error number, determine the type of error information corresponding to the target error number; According to the type of the error information, determining a target error file corresponding to the type; The first area of the target error file is read to obtain the total number of error messages in the target error file.
6. The method for extracting error text from a database according to claim 5, characterized in that: The types of error information include: database connection error, database operation syntax error or database data error.
7. The method for extracting error text from a database according to claim 1, characterized in that: The error number of each error message and the storage range of the corresponding error text are stored in the second area in the order of the error number; Based on the target error number, in the storage range of the error number and the corresponding error text of each error message, the storage range of the error text corresponding to the target error number is queried and includes: Based on the target error number, a binary search method is used to determine the position of the target error number in the storage range of the error number and the corresponding error text of each error message; Based on the position of the target error number, the storage range of the error text corresponding to the target error number is obtained.
8. A device for extracting error text from a database, characterized in that: The error file stores a plurality of error messages when accessing the database; the error file includes three consecutive storage areas; the first area stores the total number of error messages; The second area stores the error number of each error message and the storage range of the corresponding error text; The third area stores a plurality of error texts of non-fixed length; the device comprises: An acquisition module is used to obtain a target error number of target error information; The first zone reading module is used to read the first zone and obtain the total number of error messages; A second zone range determination module, configured to obtain a storage range of the second zone based on the total number of error messages; A second area reading module is used to read the second area based on the storage range of the second area to obtain the error number of each error message and the storage range of the corresponding error text; a target text range determination module, configured to query and obtain a storage range of the error text corresponding to the target error number from the storage range of the error number and the corresponding error text of each error message based on the target error number; The target text reading module is used to read the target error text according to the storage range of the error text corresponding to the target error number.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method for extracting database error text according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for extracting database error text according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data processing method and device in distributed file storage system
CN104272274A
Method and device for generating index file
CN106326397A
Evaluation method and device for text error detection model
CN112686045A
Database error processing method and device, equipment and medium
CN116467109A
Method for generating index of document retrieving device and document retrieving device
JP1996314966A