Disclosure of Invention
In order to solve the problems in the prior art, the invention provides a method and a device for restoring and synchronizing full-text search sentences of an Oracle database. The technical problems to be solved by the invention are realized by the following technical scheme:
the first aspect of the embodiment of the invention provides a method for restoring and synchronizing full-text search sentences of an Oracle database, which comprises the following steps:
The Oracle database full-text retrieval statement reduction synchronization method is applied to a source end and comprises the following steps of:
invoking a search configuration object to execute full-text search aiming at a preset search target on a database in a synchronous manager mode;
responding to the full text retrieval completion instruction, and acquiring a system table operation statement;
Analyzing the system table operation statement to determine the name of an operation object to be operated when a search configuration object is called in the system table operation statement, wherein the name of the operation object is created based on the user name of the synchronous manager;
When the DML operation information in the modification log is updated, searching a system table operation statement in the tracking log file;
when a system table operation statement is found, acquiring the name of an operation object based on the user name of the current user;
Determining an operation sentence to be synchronized when the full text retrieval is executed based on the retrieval configuration object called by the current user according to the operation type in the system table operation sentence corresponding to the name of the operation object based on the user name of the current user;
And sending the operation statement to be synchronized to a target end.
In one embodiment of the present invention, the acquiring the system table operation sentence in response to the full text search completion instruction includes:
Responding to a full text retrieval completion instruction, and acquiring a current tracking log file;
And analyzing the current tracking log file to obtain a system table operation statement.
In one embodiment of the present invention, when the DML operation information in the modification log is updated, the searching the trace log file for the system table operation statement includes:
And when the DML operation information is added in the modification log, searching a system table operation statement in the tracking log file.
In one embodiment of the present invention, the determining, according to the operation type in the system table operation sentence corresponding to the name of the operation object based on the user name of the current user, the operation sentence to be synchronized when the full text search is performed based on the current user invoking the search configuration object includes:
Determining the operation type when the target call retrieval configuration object executes full-text retrieval according to the operation type in the system table operation statement corresponding to the name of the operation object based on the user name of the current user;
And generating an operation statement to be synchronized when the current user calls the search configuration object to execute the full text search according to the operation type when the target calls the search configuration object to execute the full text search.
A second aspect of the present invention provides an Oracle database full-text retrieval statement restoration synchronization device, including:
The execution module is used for calling the search configuration object to execute full-text search aiming at a preset search target on the database in a synchronous manager mode;
The first acquisition module is used for responding to the full text retrieval completion instruction and acquiring a system table operation statement;
The first determining module is used for analyzing the system table operation statement to determine the name of an operation object to be operated when the retrieval of the configuration object is called in the system table operation statement, wherein the name of the operation object is created based on the user name of the synchronous manager;
the searching module is used for searching the system table operation statement in the tracking log file when the DML operation information in the modification log is updated;
The second acquisition module is used for acquiring the name of the operation object based on the user name of the current user when the system table operation statement is found;
The second determining module is used for determining an operation sentence to be synchronized when the full text retrieval is executed based on the retrieval configuration object called by the current user according to the operation type in the system table operation sentence corresponding to the name of the operation object based on the user name of the current user;
And the sending module is used for sending the operation statement to be synchronized to a target end.
In one embodiment of the present invention, the acquiring the system table operation sentence in response to the full text search completion instruction includes:
Responding to a full text retrieval completion instruction, and acquiring a current tracking log file;
And analyzing the current tracking log file to obtain a system table operation statement.
In one embodiment of the present invention, when the DML operation information in the modification log is updated, the searching the trace log file for the system table operation statement includes:
And when the DML operation information is added in the modification log, searching a system table operation statement in the tracking log file.
In one embodiment of the present invention, the determining, according to the operation type in the system table operation sentence corresponding to the name of the operation object based on the user name of the current user, the operation sentence to be synchronized when the full text search is performed based on the current user invoking the search configuration object includes:
Determining the operation type when the target call retrieval configuration object executes full-text retrieval according to the operation type in the system table operation statement corresponding to the name of the operation object based on the user name of the current user;
And generating an operation statement to be synchronized when the current user calls the search configuration object to execute the full text search according to the operation type when the target calls the search configuration object to execute the full text search.
A third aspect of the embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements the method for restoring and synchronizing full-text search sentences in an Oracle database provided in the first aspect of the embodiment of the present invention when executing the program.
A fourth aspect of the embodiments of the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method for recovering and synchronizing full-text search sentences of an Oracle database provided in the first aspect of the embodiments of the present invention.
The invention has the beneficial effects that:
The invention analyzes the operation statement of the system table to determine the name of the operation object of the operation executed when the retrieval configuration object is called in the operation statement of the system table, further obtains the operation type in the operation statement of the system table corresponding to the name of the operation object based on the user name of the current user from the operation statement of the system table when the operation statement of the full text retrieval is required to be synchronously called in the operation statement of the system table, and further can restore the operation statement of the operation object of the retrieval configuration object which is required to be synchronously called in order to synchronize the operation statement, thereby completing the data synchronization of the full text retrieval operation statement and ensuring the integrity of backup data.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
The technical scheme of the invention is further described in detail through the drawings and the embodiments.
Detailed Description
The present invention will be described in further detail with reference to specific examples, but embodiments of the present invention are not limited thereto.
As shown in fig. 1, a first aspect of the embodiment of the present invention provides a method for restoring and synchronizing full-text search sentences of an Oracle database, which is applied to a source end, and includes the following steps:
And step 11, invoking a search configuration object to execute full-text search aiming at a preset search target on the database in a synchronous manager mode.
And step 12, responding to the full text retrieval completion instruction, and acquiring a system table operation statement.
And step 13, analyzing the system table operation statement to determine the name of the operation object to be operated when the retrieval configuration object is called in the system table operation statement.
Wherein the name of the operation object is created based on the user name of the synchronization manager.
And 14, when the DML operation information in the modification log is updated, searching the operation statement of the system table in the trace log file.
And step 15, when the system table operation statement is found, acquiring the name of the operation object based on the user name of the current user.
And step 16, determining the operation statement to be synchronized when the full text retrieval is executed based on the retrieval configuration object called by the current user according to the operation type in the operation statement of the system table corresponding to the name of the operation object based on the user name of the current user.
And step 17, sending the operation statement to be synchronized to the target end.
In this embodiment, by analyzing the system table operation statement, the name of the operation object of the operation executed when the search configuration object is called is determined to exist in the system table operation statement, and further, when the operation statement of the full text search is required to be synchronously called and executed by the search configuration object, the operation type in the system table operation statement corresponding to the name of the operation object based on the user name of the current user can be obtained from the system table operation statement, so that the operation statement of the full text search required to be synchronously called and executed by the search configuration object can be restored, and the operation statement can be synchronized, so that the data synchronization of the full text search operation statement is completed, and the integrity of backup data is ensured.
On the basis of the first aspect of the embodiment of the invention, a second aspect of the embodiment of the invention further provides a method for restoring and synchronizing full-text search sentences of an Oracle database, and the second aspect of the embodiment of the invention provides a method for restoring and synchronizing full-text search sentences of an Oracle database, which is applied to a source end and comprises the following steps:
Step 21, invoking the search configuration object ctx_ddl to execute full-text search for a preset search target on the database in the synchronous manager mode.
In this step, the user name is associated in some of the operation sentences of the operations performed by the Oracle database executing the full text search function, and the full text search is performed in the synchronous manager mode, wherein the operation sentences are associated with the user name of the synchronous manager, so that the operation sentences associated with the user names can be conveniently identified.
The exec ctx_ddl.create_reference (' ctfs _ lexer ', ' chinese _ vgram _ lexer ') is an operation statement for full text retrieval that invokes ctx_ddl, where ctfs in ' ctfs _ lexer ' indicates the user's user name, but the operation statement cannot be directly obtained from a redox log, which is a log for recording the DML operation of data changes such as database insertion, modification, deletion, etc., and the information of the operation statement needs to be restored by the method of the present embodiment.
Step 22, in response to the full text retrieval completion instruction, a system table operation statement is acquired.
The method comprises the steps of responding to a full text retrieval completion instruction, obtaining a current tracking log file, and then analyzing the current tracking log file to obtain a system table operation statement. The trace log file is a trace file. the trace file records DML operation statements of ctxsys.drxxx system table (ctxsys.dr$ index_set, ctxsys.dr$ index_object, ctxsys.dr$ PREFERENCE, etc.), and the system table operation statement can be obtained by parsing the trace file.
By way of example, a system table operation statement is obtained:
SQL>select * from ctxsys.DR$PREFERENCE where rowid='AAANh4AACAAACVPAAD';
PRE_ID PRE_OWNER# PRE_NAMEPRE_OBJ_ID PRE_CLA_ID PRE_VALID
1064293 CTFS_LEXER46N
This operation indicates that the database inserted a piece of data into the dr$ PREFERENCE table at the time ctx ddl. Create _ reference was performed, it follows that the database will operate on the system table when performing full text searches.
Step 23, analyzing the system table operation statement to determine that the name of the operation object to be operated when the retrieval configuration object is called exists in the system table operation statement.
Wherein the name of the operation object is created based on the user name of the synchronization manager.
In this step, the system table operation sentence is searched and analyzed, and there is a name in the system table sentence, the name includes the user name of the synchronization manager and the operation object to be operated when the search configuration object is called, and the name is related to the full text search operation. Therefore, when the retrieval configuration object is called for full-text retrieval, the system table operation statement can be determined to generate information related to full-text retrieval, and the full-text retrieval operation statement calling ctx_ddl can be restored by using the information.
By way of example, in the statement of step 22,
SQL>select * from ctxsys.DR$PREFERENCE where rowid='AAANh4AACAAACVPAAD';
PRE_ID PRE_OWNER# PRE_NAMEPRE_OBJ_ID PRE_CLA_ID PRE_VALID
1064293 CTFS_LEXER46N
CTFS _ LEXER is the name of the operation object to be operated when the search configuration object is called, wherein CTFS is the user name of the synchronization manager, LEXER is the operation object to be operated when the search configuration object is called, which is the same as ctfs _ lexer in the example in step 21.
And step 24, when the DML operation information in the modification log is updated, searching the operation statement of the system table in the trace log file.
Specifically, when DML operation information is added to the modification log, a system table operation statement is looked up in the trace log file. When the DML operation statement in the modification log redox is increased, it indicates that a change operation is performed on the database, for example, a data change operation such as insertion, modification, deletion, etc., and at this time, a database synchronization program needs to be started to synchronize the modified content of the database to the database at the target end, where the database may also perform a full-text search operation, and if so, the related operation of the full-text search operation may also be synchronized to the target end.
Step 25, when the system table operation sentence is found, it is determined whether the name of the operation object based on the user name of the current user exists in the system table operation sentence.
After the system table operation statement is obtained in the trace file, the name of the operation object based on the user name of the current user is searched in the system table operation statement, namely, when the current user uses the Oracle database to execute the full text retrieval function, the name of the operation object to be operated when the configuration object is retrieved is called, and the name is related to the user name of the current user as described in the steps.
If the name is not found, the fact that the database does not exist does not execute full text search is indicated, synchronization of the data is not needed, and synchronization of newly added DML operation information is needed. If the name is found, step 26 is performed.
And step 26, if the name is found, determining the operation type when the target call retrieval configuration object executes full-text retrieval according to the operation type in the system table operation statement corresponding to the name of the operation object based on the user name of the current user.
In this step, if the name is found, a system table operation sentence where the name is located may be obtained according to the name, and then, according to a correspondence between an operation type in the system table operation sentence and an operation type when the full text search is executed by the call search configuration object, an operation type when the full text search is executed by the target call search configuration object corresponding to the system table operation sentence where the name is located is obtained.
The corresponding relationship between the operation type in the operation statement of the system table and the operation type when the retrieval configuration object is called to execute full text retrieval can be a relationship mapping table.
And step 27, generating an operation statement to be synchronized when the current user calls the search configuration object to execute the full text search according to the operation type when the target calls the search configuration object to execute the full text search.
In this step, after the operation type is obtained, a corresponding operation sentence may be generated, that is, the operation sentence when the retrieval configuration object is invoked to perform full text retrieval is restored. For example, in the above example, the target calls the operation type create_reference when the search configuration object performs full-text search, and the operation statement to be synchronized obtained by restoration is ctx_ddl. For example, if other operation types can be restored to obtain operation statements to be synchronized, such as ctx_ddl.create_index_set、ctx_ddl.drop_index_set、begin ctx_ddl.add_index、ctx_ddl.remove_index、ctx_ddl.drop_shadow_index、ctx_ddl.drop_policy, the statements indicate corresponding operations when the retrieval configuration object is called to execute full-text retrieval.
And step 28, sending the operation statement to be synchronized to the target end to complete synchronization.
As shown in fig. 2, a third aspect of the embodiment of the present invention provides an Oracle database full-text retrieval statement restoration synchronization device, including:
An execution module 31, configured to invoke a search configuration object to execute full-text search for a preset search target on a database in a synchronization manager mode;
A first obtaining module 32, configured to obtain a system table operation sentence in response to the full text retrieval completion instruction;
A first determining module 33, configured to analyze the system table operation statement to determine that a name of an operation object to be operated when the search configuration object is called exists in the system table operation statement, where the name of the operation object is created based on a user name of the synchronization manager;
A searching module 34, configured to search the trace log file for a system table operation statement when the DML operation information in the modification log is updated;
a second obtaining module 35, configured to obtain, when the system table operation sentence is found, a name of an operation object based on a user name of a current user;
a second determining module 36, configured to determine, according to an operation type in the system table operation sentence corresponding to the name of the operation object based on the user name of the current user, an operation sentence to be synchronized when the full text search is performed based on the current user invoking the search configuration object;
And the sending module 37 is used for sending the operation statement to be synchronized to the target end.
In one embodiment of the present invention, in response to a full text retrieval completion instruction, obtaining a system table operation statement includes:
Responding to a full text retrieval completion instruction, and acquiring a current tracking log file;
And analyzing the current tracking log file to obtain the operation statement of the system table.
In one embodiment of the present invention, when the DML operation information in the modification log is updated, the system table operation statement is looked up in the trace log file, including:
When DML operation information is added in the modification log, the operation statement of the system table is searched in the trace log file.
In one embodiment of the present invention, determining an operation sentence to be synchronized when performing full text retrieval based on a retrieval configuration object called by a current user according to an operation type in a system table operation sentence corresponding to a name of the operation object based on a user name of the current user includes:
determining the operation type of the target call retrieval configuration object when the full text retrieval is executed according to the operation type in the system table operation statement corresponding to the name of the operation object based on the user name of the current user;
and generating an operation statement to be synchronized when the current user calls the search configuration object to execute the full text search according to the operation type when the target calls the search configuration object to execute the full text search.
A fourth aspect of the embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the above-mentioned method for restoring and synchronizing full-text search sentences in an Oracle database according to the embodiment of the present invention when executing the program.
The fifth aspect of the embodiment of the present invention further provides a computer readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements the steps of the method for restoring and synchronizing full-text search sentences in an Oracle database provided by the embodiment of the present invention.
The Memory may include random access Memory (Random Access Memory, RAM) or Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor including a central Processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc., or may be a digital signal processor (DIGITAL SIGNAL Processing, DSP), application Specific Integrated Circuit (ASIC), field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware system.
The method provided by the embodiment of the invention can be applied to electronic equipment. Specifically, the electronic device may be a desktop computer, a portable computer, an intelligent mobile terminal, a server, or the like. Any electronic device capable of implementing the present invention is not limited herein, and falls within the scope of the present invention.
For the apparatus/electronics embodiments, the description is relatively simple as it is substantially similar to the method embodiments, with reference to the description of the method embodiments in part.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.