A method, device and equipment for extracting error text from a database and a storage medium

By dividing the error file into three areas to store error information and using a method of separating the index and text data for storage, the problem of excessively long error text extraction time in existing technologies is solved, enabling rapid acquisition of error text and improving client response speed.

CN120632012BActive Publication Date: 2025-11-25TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511120393.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-12
Publication Date
2025-11-25
Estimated Expiration
2045-08-12

AI Technical Summary

Technical Problem

The existing method for extracting error text from the database takes too long, resulting in slow client response times.

Method used

The system uses a separate storage method for index and text data. The error file is stored in three areas: the first area stores the total number of error messages, the second area stores the error number and the storage range of the corresponding error text, and the third area stores error text data of variable length. The target error text is obtained through three small data read operations.

Benefits of technology

It significantly reduces the time required to extract error text and improves client response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632012B_ABST
    Figure CN120632012B_ABST
Patent Text Reader

Abstract

The application provides a method, device and equipment for extracting error text from a database and a storage medium, and relates to the technical field of database text extraction. When error text is extracted, the application first reads the total number of error information stored in a first part, thereby determining the storage range of a second part. Index information of each piece of error information stored in the second part is read, and the index information occupies less space. 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. According to the above extraction method, no matter how many pieces of error text are contained in the error file, only three reading operations of a small amount of data are required to obtain the error text corresponding to the target error number, thereby greatly shortening the time consumption of error text extraction and improving the response speed of the client.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database text extraction, and in particular to a method and device for extracting database error text, an apparatus and a storage medium. BACKGROUND

[0002] Client-server architecture is a network architecture model that divides computers in a network into two categories: clients and servers. The application scenarios of client accessing server database are very wide, such as enterprise resource planning (ERP) system, customer relationship management (CRM) system, etc. For example, the client accesses the database through the CSDK provided by the database vendor.

[0003] When the database client accesses the database, errors may occasionally occur. The error information usually includes error number and error text, etc. The error number is generated by the server side or the client side. The error text is the description information of the error, which is generally saved in the file of the client. When the error text needs to be extracted, file operations need to be performed on the client file, which involves system calls. The traditional way of extracting error text can be to read each error information into memory one by one, compare the error number, and extract the target error text until the target error text is extracted. This way, the file needs to be read multiple times, which takes a long time and affects the client response speed. The traditional way of extracting error text can also be to read all error information in the file into memory at one time, and then compare and extract one by one. Although this way reads the file less frequently, it occupies more memory resources and takes a long time to read a large amount of data in batches. Therefore, the existing database error text extraction method consumes too much time, resulting in low client response speed. SUMMARY

[0004] The embodiments of the present application provide a method, device, apparatus and storage medium for extracting database error text, to solve the problem of low client response speed caused by the existing database error text extraction method consuming too much time.

[0005] In a first aspect, the embodiments of the present application provide a method for extracting database error text. An error file stores a plurality of error information when accessing the database. The error file includes three continuously stored areas. The first area stores the total number of error information. The second area stores the error number of each error information and the storage range of the corresponding error text. The third area stores a plurality of error texts of non-fixed length. The method comprises:

[0006] obtaining the target error number of the target error information; reading the first area to obtain the total number of error information;

[0007] obtaining the storage range of the second area based on the total number of error information;

[0008] reading the second area based on the storage range of the second area to obtain the error number of each piece of error information and the storage range of the corresponding error text;

[0009] querying the storage range of the error text corresponding to the target error number based on the target error number from the error number of each piece of error information and the storage range of the corresponding error text;

[0010] reading the target error text according to the storage range of the error text corresponding to the target error number.

[0011] In a possible implementation, the storage space of the first area is of a first fixed length; the storage space of each piece of error information in the second area is of a second fixed length; and the storage range of the second area is obtained based on the total number of pieces of error information, including:

[0012] the storage range of the second area is obtained based on the first fixed length, the total number of pieces of error information, and the second fixed length of each piece of error information.

[0013] In a possible implementation, the storage range of the error text includes an offset and an error text length; and the offset represents the starting storage position of the error text in the error file.

[0014] 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.

[0015] In a possible implementation, the error file is a plurality of error files; each error file stores error information of the same type; and the reading of the first area to obtain the total number of pieces of error information includes:

[0016] determining the type of error information corresponding to the target error number according to the target error number;

[0017] determining the target error file corresponding to the type according to the type of error information;

[0018] reading the first area of the target error file to obtain the total number of pieces of error information in the target error file.

[0019] In a possible implementation, the type of error information includes a database connection error, a database operation syntax error, or a database data error.

[0020] In a possible implementation, the error numbers of the error information and the storage ranges of the corresponding error texts are stored in the second area in the 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 from the error numbers of the error information and the storage ranges of the corresponding error texts by querying.

[0021] Based on the target error number, the position of the target error number is determined by using a binary search method from the error numbers of the error information and the storage ranges of the corresponding error texts.

[0022] Based on the position of the target error number, the storage range of the error text corresponding to the target error number is obtained.

[0023] In a second aspect, an embodiment of the present application provides a device for extracting error texts of a database. An error file stores a plurality of error information when the database is accessed. The error file includes three areas stored continuously. A first area stores a total number of error information. A second area stores error numbers of the error information and storage ranges of corresponding error texts. A third area stores a plurality of error texts with non-fixed lengths. The device includes:

[0024] An obtaining module is configured to obtain a target error number of target error information.

[0025] A first area reading module is configured to read the first area to obtain the total number of error information.

[0026] A second area range determining module is configured to obtain a storage range of the second area based on the total number of error information.

[0027] A second area reading module is configured to read the second area based on the storage range of the second area to obtain the error numbers of the error information and the storage ranges of the corresponding error texts.

[0028] A target text range determining module is configured to obtain the storage range of the error text corresponding to the target error number from the error numbers of the error information and the storage ranges of the corresponding error texts based on the target error number.

[0029] A target text reading module is configured to read the target error text according to the storage range of the error text corresponding to the target error number.

[0030] In a third aspect, an embodiment of the present application provides an electronic device including a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the method in the first aspect or any possible implementation of the first aspect is implemented.

[0031] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the method in the first aspect or any possible implementation of the first aspect.

[0032] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computer program, the computer program being executed by a processor to implement the method in the first aspect or any possible implementation of the first aspect.

[0033] In the embodiment of the present application, the error file stores multiple pieces of error information in the form of index and text data separation area. The first area of the error file stores the total number of error information; the second area stores the index information of each piece of error information, the index information including error number and storage range of corresponding error text; and the third area stores error text data of non-fixed length. The index and text data are stored in the separation area in the same file. Based on the above storage mode, when the error text is extracted, the total number of error information stored in the first area is read first, so as to determine the storage range of the second area. The index information of each piece of error information with less occupied space in the second area, i.e., error number and storage range of corresponding error text, is read. In the index information, the storage range of the target error text corresponding to the target error number is determined, and the target error text is further read. According to the above extraction method, no matter how many pieces of error text are contained in the error file, only three times of reading operation of small amount of data is required, so as to obtain the error text corresponding to the target error number, greatly shorten the time consumption of error text extraction, and improve the response speed of the client. BRIEF DESCRIPTION OF DRAWINGS

[0034] Figure 1 is an application scenario diagram of the method for extracting error text of a database provided by the embodiment of the present application;

[0035] Figure 2 is a storage structure diagram of an error file provided by the embodiment of the present application;

[0036] Figure 3 is a flowchart of the method for extracting error text of a database provided by the embodiment of the present application;

[0037] Figure 4 is a structure diagram of the device for extracting error text of a database provided by the embodiment of the present application;

[0038] Figure 5 is a schematic diagram of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0039] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0040] Figure 1 The application scenario diagram of the method for extracting database error text provided by the embodiment of the present application is shown in FIG. 1. Figure 1 As shown in FIG. 1, 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 returned by a database system to a user when the database system encounters an exception or an error during operation, and the text prompt contains error information. These texts are usually used to indicate the problem type, possible causes and solution direction, and are important basis for locating and repairing database faults. The client needs to read error information in the error file, especially error text in the error information, when performing error analysis and error processing. However, the existing database error text extraction method consumes too much time, resulting in a relatively low response speed of the client. How to reduce the number of times of reading a file and thus reduce system calls is the key to improving the response speed of the client.

[0041] The embodiment of the present application stores multiple pieces of error information by adopting an index and a text data separation area storage mode. Further, the target error text corresponding to the target error number can be obtained by adopting three times of reading a small amount of data, thereby improving the response speed of the client. The storage structure of the error file is first described below.

[0042] Figure 2 FIG. 1 is a schematic diagram of the storage structure of an error file provided by the embodiment of the present application; referring to FIG. 1, Figure 2 the error file stores multiple pieces of error information when accessing the database; the error file includes three continuously stored areas; the first area stores the total number of pieces of error information; the second area stores the error number of each piece of error information and the storage range of the corresponding error text; and the third area stores multiple error texts of non-fixed length;

[0043] It should be noted that the error file pre-stores multiple pieces of error information when accessing the database. For example, each piece of error information at least includes an error number and error text. For example, the error number is generated by a server side or a client side. The error number is the unique identifier of each piece of error information. Further, the error number can further include error type information, user information or time information, etc. The specific coding rule of the error number is not limited here. It should be further noted that the multiple pieces of error information are not stored one by one in the error file, but each piece of error information is split into different parts and stored in different areas of the error file.

[0044] Figure 3 FIG. 2 is a flowchart of the implementation process of the method for extracting database error text provided by the embodiment of the present application. Referring to FIG. 2, Figure 3 the method for extracting database error text includes:

[0045] Step 301, obtaining a target error number of target error information;

[0046] For example, the application scenario of the embodiment of the present application is extracting target error text based on target error number. The error number can not only be the unique identifier of the error text, but also can represent more information. For example, a bit of the error number represents a type of error. When the client needs to analyze a type of error, the target error number can be filtered out. Further, the target error text is extracted based on the target error number. The specific scenario of extracting error text is not limited here.

[0047] In step 302, the first area is read to obtain the total number of error information;

[0048] In one possible implementation, the error file is used to store a plurality of error information when accessing the database; the error file includes three areas stored continuously; the first area of the first fixed length stores the total number of error information; the third area stores a plurality of error texts of non-fixed length; the second area stores the error number of each piece of error information and the storage range of the corresponding error text;

[0049] For example, the storage range of the error text includes an offset and an error text length. The offset represents the starting storage position of the error text in the error file; the length of each piece of error information in the second area is the second fixed length.

[0050] In some embodiments, the error file includes three areas stored continuously. Continuous storage means that in physical storage, the three areas are stored continuously without interval space. For example, the first area, the second area, and the third area are stored continuously. The functions of the three areas are described below respectively.

[0051] In some embodiments, the first area of the first fixed length stores the total number of error information. For example, the first fixed length of the first area is 2 bytes. Referring to Figure 2 , for example, the total number of error information stored in the first area is 3.

[0052] In some embodiments, the third area stores a plurality of error texts of non-fixed length. The error text is used to describe the error content. Referring to Figure 2Text 1, Text 2 and Text 3 represent error texts. For example, Text 1 in the third area 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. In comparison with the way of allocating the same storage space for each text according to the maximum length, the plurality of non-fixed length texts stored continuously can save storage space. However, the plurality of non-fixed length texts stored continuously also leads to no fixed storage rule of the plurality of texts in the storage space. The second area can be used to record the storage location of each error text. The following will be specifically explained. It should be noted that in the storage space, the second area is located between the first area and the third area.

[0053] In some embodiments, the second area stores the error number, offset and error text length of each error information; each offset represents the starting storage location of each error text in the error file; and the length of each error information in the second area is a second fixed length.

[0054] For example, referring to Figure 2 The second area contains the error number, offset and error text length of three error information. The first error information has an error number of 101, an offset of 20 and an error text length of 24. The second error information has an error number of 102, an offset of 40 and an error text length of 17. The third error information has an error number of 103, an offset of 61 and an error text length of 15.

[0055] Regarding the second fixed length, for example, the total length of the storage space occupied by the error number, offset and error text length of each error information is the second fixed length. For example, the error number, offset and error text length each occupy 2 bytes of storage space, i.e. each error information occupies 6 bytes of storage space in the second area. Thus, since the length of the storage space occupied by each error information in the second area is fixed, the total length of the storage space of the second area can be determined based on the total number of error information in the first area.

[0056] It should be noted that each offset represents the starting storage location of each error text in the error file. For example, the offset of Text 1 is 20, which means that the starting storage location of Text 1 in the error file is 20, which is equivalent to the starting storage location of Text 1 being the sum of the length of the first area and the second area. Further, based on the offset and the error text length, the target error text can be read. It should be further noted that the offset is determined when the error information is stored. The offset can specifically represent the starting storage location in the form of absolute coordinates or in the form of relative coordinates.

[0057] It should be noted that the error number stored in the second area and the error text stored in the third area are in one-to-one correspondence, 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.

[0058] It should be noted that the error file is stored in a storage medium, for example, in the hard disk of the client. Here, reading can be reading some data of the error file in the hard disk to the memory of the client, and the processor of the client is the execution subject to execute the method of the embodiment of the application.

[0059] In a possible implementation, after obtaining the target error number of the target error information, the method further includes: obtaining a starting storage position of the error file; and correspondingly, based on the first fixed length, reading the first area to obtain 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 to obtain the total number of error information.

[0060] In order to further improve the extraction efficiency of the error text, the error information can also be classified according to the error type, and the error information of the same category is stored in the same file, and the error information of different categories is stored in different error files. The following embodiments are described.

[0061] In a possible implementation, the error file is a plurality of error files; each error file stores error information of the same type; and correspondingly, reading the first area to obtain the total number of error information 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 of error information according to the type of error information; and reading the first area of the target error file to obtain the total number of error information in the target error file.

[0062] It should be noted that after the target error file is determined, the reading operation in the subsequent steps is all reading the target error file.

[0063] In some embodiments, the type of error information includes: a database connection error, a database operation syntax error, or a database data error.

[0064] For example, the database connection error includes a database service that does not exist, a user name that does not exist, or a password error. The database operation syntax error includes a syntax format error or a statement containing an illegal character. The database data error includes data right truncation.

[0065] The above steps obtain the total number of error information in the first area of the error file. The following describes how to obtain the storage range of the second area.

[0066] In step 303, a storage range of the second area is obtained based on the total number of error information.

[0067] In a possible implementation, the storage space of the first area is of a first fixed length; the storage space of each piece of error information in the second area is of a second fixed length; and obtaining the storage range of the second area based on the total number of error information includes: obtaining the storage range of the second area based on the first fixed length, the total number of error information, and the second fixed length of each piece of error information.

[0068] In some embodiments, the start position and the length of the second area are obtained based on the first fixed length, the total number of error information, and the second fixed length of each piece of error information.

[0069] It should be noted that, since the first area and the second area are stored continuously, the start position of the second area can be obtained based on the first fixed length of the first area. For example, the start position of the error file content is represented as 0, the first fixed length is 2 bytes, and the start position of the second area can be represented as 2, that is, starting from the second byte and including the second byte.

[0070] It should be further noted that, since the length of each piece of error information in the second area is fixed and is of a second fixed length, and since the related fields of each piece of error information in the second area are also stored continuously, the length of the second area can be obtained based on the total number of error information and the second fixed length. Thus, based on the start position and the length of the second area, the second area can be directly read in the storage space.

[0071] In the embodiment of the application, the error file adopts a fixed-length index and an independent area storage manner to store a plurality of pieces of error information. The first area of the error file stores the total number of error information; the second area stores index information of each piece of error information, the index information including an error number, an offset, and an error text length; the index information of the first area and the second area is of a fixed length; and the third area stores error text data of a non-fixed length. The index and the 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 independently. Based on the above storage manner, when the error text is extracted, the storage range of the second area can be quickly determined, the time consumption for extracting the error text is reduced, and the response speed of the client is improved.

[0072] In step 304, the second area is read based on the storage range of the second area to obtain the error number of each piece of error information and the storage range of the corresponding error text.

[0073] In some embodiments, the second area is read based on the start position and the length of the second area to obtain the error number, the offset, and the error text length of each piece of error information.

[0074] In some embodiments, the second zone of the error file is read based on the start position and the length of the second zone, to obtain the error number, the offset and the error text length of each piece of error information stored in the second zone.

[0075] For example, the offset of any error text is equal to the sum of the length of the first zone and the length of the second zone, plus the sum of the length of all error texts before the error text. Figure 2 For example, the offset of text 2 is 44, which is the sum of the length of the first zone 2 bytes, the length of the second zone 18 bytes and the length of text 1 24 bytes.

[0076] In some embodiments, the storage range of the error text includes the offset and the error text length, and the offset indicates the start storage position of the error text in the error file.

[0077] For example, the offset of any error text is equal to the sum of the length of the first zone and the length of the second zone, plus the sum of the length of all error texts before the error text.

[0078] In step 305, based on the target error number, the storage range of the error text corresponding to the target error number is obtained from the error number and the storage range of the corresponding error text of each piece of error information.

[0079] In some embodiments, based on the target error number, the offset and the error text length corresponding to the target error number are obtained from the error number, the offset and the error text length of each piece of error information.

[0080] For example, the target error number can be compared with each error number one by one in the order of storage. The calculation efficiency of this way is uncertain. Another possible implementation is provided below.

[0081] In one possible implementation, the error number and the storage range of the corresponding error text of each piece of error information are stored in the second zone in the order of error number; based on the target error number, the storage range of the error text corresponding to the target error number is obtained from the error number and the storage range of the corresponding error text of each piece of error information, including:

[0082] Based on the target error number, the position of the target error number is determined from the error number and the storage range of the corresponding error text of each piece of error information by using binary search.

[0083] Based on the position of the target error number, the storage range of the error text corresponding to the target error number is obtained.

[0084] The embodiment of the present application stores index information of each error information based on error number sequence, adopts binary method to quickly match and determine the position of target error number, and thereby quickly obtains the storage range of error text corresponding to the target error number.

[0085] In step 306, the target error text is read according to the storage range of error text corresponding to the target error number.

[0086] In some embodiments, the target error text is read according to the offset and error text length corresponding to the target error number.

[0087] For example, the target error text is read in the third area of error text according to the offset and error text length corresponding to the target error number.

[0088] 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-1)th error text + the length of the (n-1)th error text.

[0089] It should be noted that after obtaining the offset and error text length corresponding to the target error number, the target error text can be directly read in the error file.

[0090] In a possible implementation, after reading the target error text, the method further includes: obtaining a plurality of target error texts based on a plurality of target error numbers; and performing statistical analysis on error causes during database access according to the plurality of target error texts.

[0091] For example, the target error text corresponding to each target error number is obtained based on steps 301-306 according to each target error number. After obtaining a plurality of target error texts, statistical analysis can be performed on error causes during database access according to the plurality of target error texts.

[0092] In the embodiment of the present application, the error file stores multiple error information in the form of index and text data separation area. The first area of the error file stores the total number of error information; the second area stores the index information of each piece of error information, which includes error number and the storage range of corresponding error text; and the third area stores error text data of non-fixed length. The index and text data are stored in the separation area in the same file. Based on the above storage method, when extracting error text, the total number of error information stored in the first area is read first, thereby determining the storage range of the second area. The index information of each piece of error information stored in the second area, i.e. error number and the storage range of corresponding error text, is read. 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. According to the above extraction method, no matter how many pieces of error text are contained in the error file, only three times of reading operation of small amount of data is required to obtain the error text corresponding to the target error number, thereby greatly shortening the time consumption of error text extraction and improving the response speed of the client.

[0093] It should be noted that the data is read for the first time in step 302, and only the total number of error information is read. In step 304, the data is read for the second time, and only the second area is read. In step 306, the data is read for the third time, and the target error text is directly read.

[0094] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0095] The following is the device embodiment of the present application. For details not described in detail, please refer to the corresponding method embodiments described above.

[0096] Figure 4 The structure of the device for extracting error text of the database provided by the embodiment of the present application is shown. For the convenience of description, only the part related to the embodiment of the present application is shown, and the details are as follows:

[0097] As shown in Figure 4 , the error file stores multiple error information when accessing the database; the error file includes three areas stored continuously; the first area stores the total number of error information; the second area stores the error number of each piece of error information and the storage range of corresponding error text; and the third area stores multiple error texts of non-fixed length; a device 4 for extracting error text of the database includes:

[0098] The acquisition module 41 is configured to acquire the target error number of the target error information.

[0099] The first area reading module 42 is configured to read the first area to obtain a total number of error information;

[0100] The second area range determining module 43 is configured to obtain a storage range of the second area based on the total number of error information.

[0101] The second area reading module 44 is configured to read the second area based on the storage range of the second area to obtain an error number of each piece of error information and a storage range of corresponding error text.

[0102] The target text range determining module 45 is configured to query the storage range of the error text corresponding to the target error number in the error number of each piece of error information and the storage range of corresponding error text based on the target error number.

[0103] The target text reading module 46 is configured to read the target error text according to the storage range of the error text corresponding to the target error number.

[0104] In the embodiment of the present application, the error file adopts an index and text data separation area storage mode to store a plurality of pieces of error information. The first area of the error file stores a total number of error information; the second area stores index information of each piece of error information, the index information including an error number and a storage range of corresponding error text; and the third area stores error text data of non-fixed length. The index and text data are stored in the separation area in the same file. Based on the above storage mode, when the error text is extracted, the total number of error information stored in the first area is first read to determine the storage range of the second area. The index information of each piece of error information stored in the second area, i.e., the error number and the storage range of the corresponding error text, is read. 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. According to the above extraction method, no matter how many pieces of error text are contained in the error file, the error text corresponding to the target error number can be obtained only by three times of reading a small amount of data, which greatly shortens the time consumption of error text extraction and improves the response speed of the client.

[0105] Figure 5 is a schematic diagram of an electronic device provided by the embodiment of the present application. As shown in Figure 5 The electronic device 5 of the embodiment includes a processor 50 and a memory 51. The memory 51 stores a computer program 52. The processor 50 implements the steps in each of the method embodiments described above when executing the computer program 52. Alternatively, the processor 50 implements the functions of each module / unit in each of the device embodiments described above when executing the computer program 52.

[0106] For example, the computer program 52 can be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program 52 in the electronic device 5.

[0107] The electronic device 5 can include, but is not limited to, the processor 50, the memory 51. Those skilled in the art can understand that, Figure 5 The electronic device 5 is only an example and does not constitute a limitation on the electronic device 5, and can include more or fewer components than the illustration, or combine certain components, or different components, for example, the electronic device 5 can also include an input / output device, a network access device, a bus, etc.

[0108] The processor 50 can be a central processing unit (CPU), and can also be 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 can be a microprocessor or the processor can also be any conventional processor.

[0109] The memory 51 can be an internal storage unit of the electronic device 5, such as a hard disk 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 disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 5. Further, the memory 51 can include both the internal storage unit and the external storage device of the electronic device 5. 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 will be output.

[0110] For the convenience and brevity of description, only the division of the above functional modules / units is exemplified, and in actual application, the above functions can be completed by different functional modules / units according to needs. The above modules / units can be realized in the form of hardware, software or a combination of hardware and software.

[0111] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the method in each method embodiment.

[0112] The embodiment of the present application further provides a computer program product, which comprises a computer program. The computer program is executed by a processor to implement the method in each method embodiment.

[0113] The computer program comprises computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium can comprise any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, Read-Only Memory (ROM), Random Access Memory (RAM), electric carrier wave signal, telecommunication signal and software distribution medium, etc.

[0114] In the above embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in a certain embodiment can be referred to the relevant description of other embodiments. If there is no special description and no logical conflict, the terms and / or descriptions of different embodiments are consistent and can be mutually referred to, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationship.

[0115] The above embodiments are only used to illustrate the technical solutions of the present application, rather than limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method of extracting error text from a database, characterized by, The error file stores a plurality of error information when a client accesses the database; the error file is stored in a storage medium of the client; the error file comprises three continuously stored areas; the first area stores a total number of error information; The second area stores error numbers of each piece of error information and storage ranges of corresponding error texts; The third area stores a plurality of error texts with non-fixed lengths; the method comprises: Obtaining a target error number of target error information; reading the first area to obtain a total number of error information; Based on the total number of error information, obtaining a storage range of the second area; Based on the storage range of the second area, reading the second area to obtain error numbers of each piece of error information and storage ranges of corresponding error texts; Based on the target error number, querying a storage range of an error text corresponding to the target error number in the error numbers of each piece of error information and the storage ranges of corresponding error texts; Reading the target error text according to the storage range of the error text corresponding to the target error number.

2. The method of claim 1, wherein, The storage space of the first area is a first fixed length; the storage space of each piece of error information in the second area is a second fixed length; Based on the total number of error information, obtaining a storage range of the second area comprises: Based on the first fixed length, the total number of error information and the second fixed length of each piece of error information, obtaining the storage range of the second area.

3. The method of claim 1, wherein the error text is extracted from the database. The storage range of the error text comprises an offset and an error text length; the offset represents a starting storage position of the error text in the error file.

4. The method of claim 3, wherein, 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.

5. The method of claim 1, wherein the error text is extracted from the database. The error file is a plurality of error files; each error file stores error information of the same type; the reading of the first area to obtain the total number of error information comprises: According to the target error number, determining the type of error information corresponding to the target error number; According to the type of error information, determining a target error file corresponding to the type; Reading the first area of the target error file to obtain the total number of error information in the target error file.

6. The method of claim 5, wherein the error text is extracted from the database by, The type of error information comprises: a database connection error, a database operation syntax error or a database data error.

7. The method of claim 1, wherein, The error numbers of each piece of error information and the storage ranges of corresponding error texts are stored in the second area in order of error numbers; Based on the target error number, querying a storage range of an error text corresponding to the target error number in the error numbers of each piece of error information and the storage ranges of corresponding error texts comprises: Based on the target error number, determining the position of the target error number in the error numbers of each piece of error information and the storage ranges of corresponding error texts by using a binary search method; Based on the position of the target error number, obtaining the storage range of the error text corresponding to the target error number.

8. An apparatus for extracting error text from a database, characterized by The error file stores a plurality of error information when a client accesses the database; the error file is stored in a storage medium of the client; the error file comprises three continuously stored areas; the first area stores a total number of error information; The second area stores error numbers of each piece of error information and storage ranges of corresponding error texts; The third area stores a plurality of error texts with non-fixed lengths; the device comprises: an acquisition module, configured to acquire a target error number of target error information; a first area reading module, configured to read the first area to obtain a total number of pieces of error information; a second area range determination module, configured to obtain a storage range of the second area based on the total number of pieces of error information; a second area reading module, configured to read the second area based on the storage range of the second area to obtain error numbers of each piece of error information and storage ranges of corresponding error texts; a target text range determination module, configured to query a storage range of an error text corresponding to the target error number from the error numbers of each piece of error information and the storage ranges of corresponding error texts based on the target error number; a target text reading module, configured to read a target error text according to the storage range of the error text corresponding to the target error number.

9. An electronic device, comprising: The device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method for extracting error texts of a database according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method for extracting error texts of a database according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • 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