Home
Log Analyzer User`s Manual - ALTIBASE Customer Support
Contents
1.
2. The movement of XLogs and meta data within the XLog Collector is as follows 1 2 4 Memory for XLogs is obtained from the XLog Pool The XLog Collector receives the data that constitute XLogs from the XLog Sender and uses the data to create XLogs The XLogs are added to the XLog Queue where they are accessed and used via the Log Analy sis API When it is desired to obtain the XLogs for transactions in the order in which the transactions are committed the XLogs are temporarily stored in the Transaction Table before they are added to the XLog Queue After the XLogs are used the memory that was assigned to them is returned to the XLog Pool The following illustration shows the movement of meta data and XLogs within the XLog Collector LogAnalyzer User s Manual 4 1 1 ALTIBASE HDB Log Analyzer Figure 1 2 The Structure of the XLog Collector XLog Collector 1 1 3 Features of the Log Analyzer 1 1 3 1 The XLog Sender uses the Replication module The SQL statements that are used to manage the XLog Sender are almost the same as those that are used to manage Replication Additionally the Replication related properties also apply to the Log Analyzer For more information on Replication please refer to the Replication Manual 1 1 3 2 Transaction XLogs can be obtained in the order in which transactions are committed When creating the XLog Collector it is possible to specify that transaction XLogs are to be obtained
3. include alaAPI h void testAltibaseSQL ALA Table aTable ALA XLog aXLog ALA Column sColumn SChar sBuffer 1024 UInt sPKColumnPos UInt sColumnPos Process the primary key column for sPKColumnPos 0 sPKColumnPos lt aXLog mPrimaryKey mPKColCnt sPKColumnPos The primary key sequence for the XLog and the primary key sequence for the table are the same sColumn aTable gt mPKColumnArray sPKColumnPos Obtain the Altibase text void ALA GetAltibaseText sColumn amp aXLog gt mPrimaryKey mPKColArray sPKColumnPos 1024 sBuffer NULL Process the column for sColumnPos 0 sColumnPos lt aXLog mColumn mColCnt sColumnPos Obtain the column information void ALA GetColumnInfo aTable aXLog mColumn mCIDArray sColumnPos amp sColumn NULL Obtain the Altibase text for the Before Image void ALA GetAltibaseText sColumn amp aXLog mColumn mBColArray sColumnPos 1024 sBuffer NULL Obtain the Altibase text for the After Image void ALA GetAltibaseText sColumn 8 aXLog gt mColumn mAColArray sColumnPos 1024 sBuffer NULL 95 Log Analysis API 4 31 ALA GetODBCCValue 4 31 ALA GetODBCCValue 4 31 1 Syntax ALA RC ALA GetODBCCValue ALA Column aColumn ALA Value aAltibaseValue SInt aODBCCTypeID UInt aODBCCValueBufferSize void aOutODBCCValueBuffer ALA BOO
4. 2 n incre e ias 88 427A DESCripti ON E 88 4 27 5 ConsideratiOTis ee telae iio 88 427 6 Related FUN CS rtr e P Pe be EU o o dede Ue te eo ager 89 4 27 7 Example eite eri ree reete re eere eee ATA A ree eee e Rc dre eee deest 89 4 28 ALA GetlInternalNumeericlInfo cccccccsscssssscsessessessesssssssssssessscssssssssssesssssssscssesssssessessssssssessssssssssssssssssessssssssessesssssssssesssssseess 90 4 28 1 Syntax 2 90 4 28 2 Arguments 90 4 28 3 Possible Result Values 4 28 4 Description 4 28 5 Example 90 4 29 ALA GetAltibaseText 2 92 4 29 1 Syntax 92 4292 Argumerits sin A i 92 4 29 3 Possible Result Values cc cc sosssssssoosscssosessessnscsuscosscosasuecosaccsannsstsacnssccssenosssuavorrsasisacnudseasevecsucosaassscosesisanesaesisnsesdceoons 92 p Ao EDI ragleiio pe 92 4529 5 Considetatiofis 5 c aec t eie ep in ee ER PR td d tee e Re ced e eR teu 92 4 29 6 Related Function n eerte eso ei eto e pes e ir uet Ec tete ER dod nerd 93 A RT 93 430 ALA Getaria 94 AOT SYNIR NOAA 94 4 302 Arguments scie ertet eee roa e TAA eee beet EAA eee ee eet 94 430 3 POSSE Result Values da RO a 94 4 30 4 Descriptio PEE 94 430 5 Consideration CHRONO O A 94 4 30 6 REE FUN Nilo 95 vii 4 30 7 EXaMple inscrit ista riada iria dai 95 4 3TAEA GABBA 96 4 31 Syntax soe tte s ble entis a NN 96 4 31 2 A NA 96 4731 3 Possible Result Va
5. Once ALA FreeXLog has been called the corresponding XLog and related data can no longer be used 11 Introduction 1 3 Summary of the Log Analysis API 1 3 Summary of the Log Analysis API 1 3 1 Log Analysis API Environment Management Function Type Log Analysis API Function Name Description Creating and Destroying the Log Analysis API Environment ALA InitializeAPI Creates an environment in which the Log Analysis API can be invoked ALA DestroyAPI Terminates an environment which was created to invoke the Log Analysis API Logging ALA EnableLogging Enables logging for problem tracking ALA DisableLogging Disables logging 1 3 2 XLog Collector Management Function Type Log Analysis API Function Name Description Creating and Preparing the XLog Collector ALA CreateXLogCollect or Creates an XLog Collector that corre sponds to an XLog Sender ALA AddAuthlnfo Adds XLog Sender authentication infor mation ALA RemoveAuthlnfo Removes XLog Sender authentication information ALA SetHandshakeTim eout Specifies the handshake timeout ALA SetReceiveXLogTi meout Specifies the XLog reception timeout Receiving Meta Data and XLogs ALA Handshake Waits for a connection with an XLog Sender and performs handshaking ALA ReceiveXLog Receives XLogs and adds them to the XLog Oueue ALA GetXLog Obtains an XLog
6. i tert eerie toe y ehe n etes to acc 2 1 9 Setting a neri 21 10 FIUSPINgG XLO9S ee 2 2 Meta Tables etes 2 2 1 SYSTEM SYS REPLICATIONS 2 2 2 SYSTEM SYS REPL HOSTS A 2 2 3 S YSTEM S YS REPL ITEMS siete aaa eiii 2 3 Peiformarnice NOTA 2 3 1 VSREPEXEC IN erede 2 3 2 VSREPSENDER M iia 2 3 3 VSREPSENDER TRANSTBL 2 3 4 VSREPGAP 3 Analyzing XLogs vs O CRP RO OC AUT OSO DS AN O 3 1 3 Configuration Based on XLog TyPe n ssssccsssecsssessecssecsessseccssecsesutecssucessuccesnsecessseesssssecssnecsesueeccsuseseeuseessnecesenseessnees 32 Meta Data A NN 3 2 1 Meta Data Usos 3 3 ALTIBASE HDB Data Types and Internal Structure 3 3 1 FLOAT NUMERIC esee 3 3 2 DOUBLE REAL BIGINT INTEGER SMALLINT eere tenente ttnnnntttnnntttnnntttnntttnnnittnnnitttnnnis 35 33 3 DATE vires ettet sU t DN Pd M T M OL E I MI ME 35 3 3 4 CHAR VARCHAR NCHAR NVARCHAR BYTE NIBBLE BIT VARBIT BLOB CLOB sss 36 3 3 5 GEOMETRY 5 eth oe ROT tette eee diet ede di bc e trs e 37 FA SAVEPOINT ec 38 E RR 38 CAPE NICHIL csarcasin 41 ZA PF nitialize AP E E 42 LS PI BOT A l 42 412 ree n 42
7. typedef struct ALA Replication SChar mXLogSenderName ALA NAME LEN XLog Sender Name UInt mTableCount Table Count ALA Table mTableArray Table Array ALA Replication typedef struct ALA Table ULong mTableOID Table OID SChar mFromUserName ALA NAME LEN From User Name SChar mFromTableName ALA NAME LEN From Table Name SChar mToUserName ALA NAME LEN To User Name SChar mToTableName ALA NAME LEN To Table Name UInt mPKIndexID Index ID of Primary Key UInt mPKColumnCount Primary Key Column Count ALA Column mPKColumnArray Primary Key Column Array UInt mColumnCount Column Count ALA Column mColumnArray Column Array UInt mIndexCount Index Count ALA Index mIndexArray Index Array ALA Table typedef struct ALA Column UInt mColumnID Column ID SChar mColumnName ALA NAME LEN Column Name UInt mDataType Column information Type UInt mLanguageID Column Language ID UInt mSize Column Size SInt mPrecision Column Precision SInt mScale Column Scale ALA BOOL mNotNull Column Not Null ALA Column typedef struct ALA Index UInt mIndexID Index ID SChar mIndexName ALA NAME LEN Index Name ALA BOOL mUnique Index Unique UInt mColumnCount Index Column Count UInt mColumnIDArray Index Column ID Array ALA I
8. ALA SUCCESS ALA FAILURE 4 28 4 Description This function is used to determine the sign and exponent of a FLOAT or NUMERIC type number An aOutSign value of 1 represents a positive number whereas an aOutSign value of 0 represents a negative number aOutExponent is a base 10 exponent 4 28 5 Example include lt alaAPI h gt void testInternalNumeric ALA Column aColumn ALA Value aAltibaseValue LogAnalyzer User s Manual 90 4 28 ALA GetlnternalNumericlnfo SInt sNumericSign SInt sNumericExponent Obtain the internal numeric information void ALA GetInternalNumericInfo aColumn aAltibaseValue amp sNumericSign amp sNumericExponent NULL 91 Log Analysis API 4 29 ALA GetAltibaseText 4 29 ALA GetAltibaseText 4 29 1 Syntax ALA RC ALA GetAltibaseText ALA Column aColumn ALA Value aValue UInt aBufferSize SChar aOutBuffer ALA ErrorMgr aOutErrorMgr 4 29 2 Arguments Argument Description aColumn This is the meta information about the column in which aValue is stored aValue This is the actual data of ALTIBASE HDB to convert to a string aBufferSize This is the size of the buffer in which the output string will be stored aOutBuffer This is the buffer containing the actual output string aOutErrorMgr This is an Error Manager structure 4 29 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 29 4 Description This function
9. ULong Unsigned Big Integer 64 bits Every Log Analysis API function takes the so called Error Manager as an argument If the result of a call to the Log Analysis API is ALA FAILURE it will be necessary to determine the cause of the error and take appropriate measures The error information that is provided via the API consists of the Error Code Error Level and Error Message The structure of the Error Manager is as follows typedef struct ALA ErrorMgr UInt mErrorCode SChar mErrorState 6 CODE STATE SChar mErrorMessage ALA MAX ERROR MSG LEN 256 ALA ErrorMgr The following should be kept in mind when using the Error Manager The entity e g process or thread that calls the Log Analysis API is responsible for creating and storing the Error Manager The Error Manager only contains information about the most recent error The functions provided in the Log Analysis API for handling errors cannot accept a NULL value for the Error Manager argument If NULL is passed as the Error Manager argument to a Log Analysis API function other than an error handling function then any errors that occur will not be logged by the Log Manager Because mErrorCode element of the Error Manager structure contains internal data the error code must be obtained using ALA GetErrorCode The ALA GetErrorLevel function is used to retrieve the value of ALA ErrorLevel which indicates the error level
10. sExitFlag ALA TRUE Send ACK to XLog Sender void ALA SendACK aHandle NULL Return XLog to XLog Pool void ALA FreeXLog aHandle sXLog NULL Obtain the Status of XLog Collector void ALA GetXLogCollectorStatus aHandle amp sXLogCollectorStatus NULL LogAnalyzer User s Manual 60 4 11 ALA ReceiveXLog 4 11 ALA ReceiveXLog 4 11 1 Syntax ALA RC ALA ReceiveXLog ALA Handle aHandle ALA BOOL aOutInsertXLogInQueue ALA ErrorMgr aOutErrorMgr 4 11 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutlnsertXLoglnOueue This indicates whether the received XLog was added to the XLog Oueue aOutErrorMgr This is an Error Manager structure 4 11 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 11 4 Description This function is used to receive an XLog and add it to the XLog Oueue The memory for an XLog is obtained from the XLog Pool When transaction XLogs are obtained in the order in which transactions are committed all of the XLogs pertaining to a given transaction are stored in the transaction table until the corresponding COMMIT XLog is received This function can be called at the same time as ALA_GetXLog 4 11 5 Considerations ALA Handshake must be called before this function If a network error occurs after a success ful call to ALA Handshake the call to this function will fail If no XLogs are
11. void ALA RemoveAuthInfo sHandle PEER IP 127 0 0 2 NULL Invoke Log Analysis API Remove XLog Collector void ALA DestroyXLogCollector sHandle NULL id testXLogCollectorUNIX ALA Handle sHandle Create XLog Collector that uses a UNIX domain XLog Sender Name log analysis The max size of XLog Pool 20000 Obtain transaction XLog in the order of commit Enabled The reference number of XLog for which ACK will be sent out void ALA CreateXLogCollector log analysis SOCKET UNIX 20000 ALA TRUE 50 amp sHandle LogAnalyzer User s Manual 50 30300 10000 Disabled 100 50 4 5 ALA CreateXLogCollector NULL Invoke Log Analysis API Remove XLog Collector void ALA DestroyXLogCollector sHandle NULL 51 Log Analysis API 4 6 ALA AddAuthlnfo 4 6 ALA AddAuthinfo 4 6 1 Syntax ALA RC ALA AddAuthInfo ALA Handle aHandle const SChar aAuthInfo ALA ErrorMgr aOutErrorMgr 4 6 2 Arguments Arguments Description aHandle This is the handle of the XLog Collector aAuthlnfo This is the XLog Sender authentication information aOutErrorMgr This is an Error Manager structure 4 6 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 6 4 Description This function adds authentication information for the XLog Sender When the connection type is TCP aAuthinfo is a string having the format PEER IP xlog sender ip The valid length of xlog sende
12. 0x52035 Log Analysis API Environment Remove ALA DestroyAPI Failed 0x52000 Log Manager Initialization Failure ALA EnableLogging 0x52001 Log File Open Failure ALA EnableLogging 0x52004 Log Manager Lock Failure All Log Analysis API functions 0x52005 Log Manager Unlock Failure All Log Analysis API functions 0x52003 Log Manager Remove Failure ALA DisableLogging 0x52002 Log File Close Failure ALA DisableLogging 0x52009 Not an active transaction ALA GetXLog 0x5200E The linked list is not empty ALA Handshake ALA DestroyXLogCollector 0x52033 XLog Pool is empty ALA ReceiveXLog 0x5200F NULL Parameter All Log Analysis API functions 0x5201D Invalid Parameter All Log Analysis API functions 0x52014 Network Timeout can be retried ALA ReceiveXLog 0x52026 A socket type that is not supported ALA Handshake 0x52025 A socket type is not selected ALA Handshake 0x5202F The socket type does not support the ALA AddAuthinfo corresponding Log Analysis API ALA RemoveAuthlnfo 0x5202D The XLog Sender name is different ALA Handshake 0x52030 There is only one piece of authentication ALA RemoveAuthlnfo information available 0x52031 No more authentication information can ALA AddAuthInfo be added 0x52032 There is no authentication information ALA Handshake available for a peer 0x52010 Invalid Role ALA Handshake 0x52011 Invalid Replication Flags ALA Handshake 0x52007 Geometry Endian Conversion Failure ALA GetXLog 109 Error Codes Error Code Table
13. ALA FAILURE 4 32 4 Description This function initializes the Error Manager 4 32 5 Consideration Before an Error Manager is used for the first time it must be initialized using this function 4 32 6 Related Functions ALA GetErrorCode ALA GetErrorLevel ALA GetErrorMessage 4 32 7 Example include lt alaAPI h gt void testErrorHandling ALA ErrorMgr sErrorMgr UInt sErrorCode ALA ErrorLevel sErrorLevel 99 Log Analysis API 4 32 ALA ClearErrorMgr SChar sErrorMessage Initialize Error Manager void ALA ClearErrorMgr amp sErrorMgr Invoking of Log Analysis API fails Obtain the error code void ALA GetErrorCode amp sErrorMgr amp sErrorCode Obtain the error level void ALA GetErrorLevel amp sErrorMgr amp sErrorLevel Obtain the error message void ALA GetErrorMessage amp sErrorMgr amp sErrorMessage LogAnalyzer User s Manual 100 4 33 ALA GetErrorCode 4 33 ALA GetErrorCode 4 33 1 Syntax ALA RC ALA GetErrorCode const ALA ErrorMgr aErrorMgr UInt aOutErrorCode 4 33 2 Arguments Argument Description aErrorMgr This is an Error Manager structure aOutErrorCode This is the Error Code 4 33 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 33 4 Description This function is used to obtain an error code An error code is a unique numerical value that identifies the kind of error that has occurred
14. Retrieves information about an index in a table using the index ID Reading internal data types of ALTIBASE HDB ALA GetInternalNumericl nfo Obtains the sign and exponent of FLOAT or NUMERIC type data ALA GetAltibaseText Converts internal data of ALTIBASE HDB into string form ALA GetAltibaseSOL Converts an XLog related to a transaction into an SOL string of ALTIBASE HDB Type Conversion ALA GetODBCCValue Converts internal data of ALTIBASE HDB into an ODBC C data type 13 Introduction 1 3 Summary of the Log Analysis API Function Type Log Analysis API Function Name Description Error Handling ALA ClearErrorMgr Initializes the Error Manager ALA GetErrorCode Obtains an error code ALA GetErrorLevel Obtains the error level ALA GetErrorMessage Obtains a specific error message LogAnalyzer User s Manual 14 2 The XLog Sender This chapter explains how to use the XLog Sender which is one of the components of the ALTIBASE HDB Log Analyzer The XLog Sender combines log records together to create XLogs and sends the XLogs to the XLog Collector The XLog Sender is an internal ALTIBASE HDB module and is managed in almost exactly the same way that Replication is managed i e using the same SQL interface 15 The XLog Sender 2 1 SQL Statements Used to Manage the XLog Sender 2 1 SQL Statements Used to Manage the XLog S
15. Structure Member Description mMyPort TCP This is the port number being used on the XLog Collector mPeerlP TCP This is the IP address of the XLog Sender mPeerPort TCP This is the port number being used on the XLog Sender mSocketFile UNIX Domain This is the name of the socket file mXLogCountInPool This is the number of XLogs remaining in the XLog Pool mLastArrivedSN This is the SN of the most recently received XLog mLastProcessedSN This is the SN of the most recently processed XLog mNetworkValid This indicates whether the network connection is valid These status values are maintained internally by the Log Analyzer and the values are returned in the structure when this function is called The internal values corresponding to mMylP mMyPort mPeerlP mPeerPort and mSocketFile are updated when ALA Handshake is called When ALA_ReceiveXLog is called the value that is returned in mXLogCountInPool is incremented if a ROLLBACK XLog is received and decremented when other kinds of XLogs are received It is incre mented when ALA FreeXLog is called mLastArrivedsN is the SN of the XLog that was most recently received by calling ALA ReceiveXLog nLast ProcessedSN is the SN of the XLog that was most recently obtained by calling ALA GetXLog The status value corresponding to mNetworkValid might change when ALA Handshake ALA ReceiveXLog or ALA SendACK is called Memory for aOutXLogCollectorStatus must
16. aXLog This is the XLog for which to retrieve the column aOutXLogColumn The XLog column of aXLog is returned in this argument aOutErrorMgr This is an Error Manager structure 4 19 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 19 4 Description This function is used to obtain the XLog column for the specified XLog 4 19 5 Related Functions ALA GetXLog ALA GetXLogHeader ALA GetXLogPrimaryKey ALA GetXLogSavepoint ALA GetXLogLOB 4 19 6 Example Please refer to ALA GetXLogHeader 75 Log Analysis API 4 20 ALA GetXLogSavepoint 4 20 ALA GetXLogSavepoint 4 20 1 Syntax ALA RC ALA GetXLogSavepoint const ALA XLog aXLog const ALA XLogSavepoint aOutXLogSavepoint ALA ErrorMgr 4 20 2 Argume nts aOutErrorMgr Argument Description aXLog This is the XLog for which to retrieve the savepoint aOutXLogSavepoint The XLog savepoint information of aXLog is returned in this argument aOutErrorMgr This is an Error Manager structure 4 20 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 20 4 Description This function is used to obtain the XLog savepoint information for the specified XLog 4 20 5 Related Functions ALA GetXLog ALA GetXLogH eader ALA GetXLogPrimarykey ALA GetXLogColumn ALA GetXLogLOB 4 20 6 Example Please refer to ALA GetXLogHeader LogAnalyzer User s Manual 76 4 21 ALA GetXLogLOB 4 21 A
17. in the order in which transactions are committed When the XLog Collector is set in this way the fol lowing circumstances apply The XLogs pertaining to a given transaction can be obtained after the COMMIT XLog for the transaction has been received Because savepoint related XLogs are not necessary they are thus not provided 5 Introduction 1 1 ALTIBASE HDB Log Analyzer XLogs for transactions that were rolled back cannot be obtained 1 1 3 3 The TCP and UNIX Domain sockets are supported for use in transmitting XLogs The UNIX Domain socket can be used only when the XLog Sender and XLog Collector reside on the same machine and the OS is UNIX or Linux A single XLog Sender can use only one type of socket 1 1 3 4 Conversion to ODBC C data types is supported Internal data of ALTIBASE HDB can be converted to corresponding ODBC C data types 1 1 4 Limitations Because the XLog Sender uses the Replication module the following limitations apply Only the SYS user can run the XLog Sender The basic unit of analysis is the database table Atable to be analyzed must have a primary key The values in the columns that constitute the primary key of a table to be analyzed cannot be updated However INSERT and DELETE operations can be performed on the columns that constitute the primary key DDL statements cannot be executed on a table to be analyzed The combined total of XLog Senders and Replication Send
18. it is first necessary to allocated memory to hold the aOutProto colVersion structure 4 22 6 Example include lt alaAPI h gt void testProtocolVersion ALA ProtocolVersion sProtocolVersion Obtain Protocol Version void ALA GetProtocolVersion amp sProtocolVersion NULL LogAnalyzer User s Manual 78 4 23 ALA GetReplicationlnfo 4 23 ALA GetReplicationlnfo 4 23 1 Syntax ALA RC ALA GetReplicationInfo ALA Handle const ALA Replication aOutReplication ALA ErrorMgr 4 23 2 Arguments aHandle aOutErrorMgr Argument Description aHandle This is the handle of the XLog Collector aOutReplication This is information about Replication aOutErrorMgr This is an Error Manager structure 4 23 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 23 4 Description This function is used to obtain information about Replication 4 23 5 Considerations If there are no meta data pertaining to replication this function returns NULL for the aOutRep lication argument Any meta data that were obtained using this function before handshaking was performed should not be used again after handshaking as the information might be out of date 4 23 6 Related Functions ALA Handshake ALA GetTablelnfo ALA GetTablelnfoByName 79 Log Analysis API 4 23 ALA GetReplicationInfo ALA GetColumnlInfo ALA GetIndexInfo 4 23 7 Example include lt alaAPI h gt
19. ters Keywords and all elements pro vided by the system appear in upper case DESC SYSTEM SYS INDICES For additional technical information please refer to the following manuals ALTIBASE HDB Getting Started Guide ALTIBASE HDB Administrator s Manual ALTIBASE HDB Replication Manual ALTIBASE HDB SOL Reference ALTIBASE HDB ODBC Reference ALTIBASE HDB Spatial SOL Reference ALTIBASE HDB Application Program Interface User s Manual ALTIBASE HDB iSQL User s Manual ALTIBASE HDB Error Message Reference Preface About This Manual Online Manuals Online versions of our manuals PDF or HTML are available from the Altibase Download Center http atc altibase com Altibase Welcomes Your Comments Please feel free to send us your comments and suggestions regarding this manual Your comments and suggestions are important to us and may be used to improve future versions of the manual When you send your feedback please make sure to include the following information The name and version of the manual that you are using Any comments that you have about the manual Your full name address and phone number Write to us at the following e mail address support altibase com For immediate assistance with technical issues please contact the Altibase Customer Support Cen ter We always appreciate your comments and suggestions Log Analyzer User s Manual vi 1 Introduction This
20. void testMetaInformation ALA Handle aHandle ALA Replication sReplication NULL ALA Table sTable NULL ALA Table sTableByTableOID NULL ALA Table sTableByName NULL ALA Column sPKColumn NULL ALA Column sColumn NULL ALA Index sIndex NULL UInt sTablePos UInt sPKColumnPos UInt sColumnPos UInt sIndexPos Obtain replication information void ALA GetReplicationInfo aHandle amp sReplication NULL for sTablePos 0 sTablePos amp lt sReplication mTableCount sTablePos sTable amp sReplication gt mTableArray sTablePos Obtain table information by table OID void ALA GetTableInfo aHandle sTable gt mTableOID amp sTableByTableOID NULL if sTableByTableOID sTable Fatal Error Error in Log Analysis API break Obtain table information by name void ALA GetTableInfoByName aHandle sTable gt mFromUserName sTable gt mFromTableName amp sTableByName NULL if sTableByName sTable Fatal Error Error in Log Analysis API break Process primary key column for sPKColumnPos 0 sPKColumnPos lt sTable gt mPKColumnCount sPKColumnPos Obtain the primary key column information by primary key column ID void ALA GetColumnInfo sTable sTable gt mPKColumnArray sPKColumnPos gt mColumnID amp sPKColumn LogAnalyzer User s Manual 80 4 23 ALA GetReplicationlnfo NULL if
21. 4 1 3 Possible Result Valles seite eer entities erri ete eee eee eese enel 42 4 1 4 DOSCrIPtlOM e 42 ANC incas 42 4 1 6 Related FO ea 42 4 17 EXAMI PIC uccide A 42 AZALA Destroy AP Pec 44 4 2 1 Syntax a 44 4 2 2 Arguments 44 4 2 3 Possible Result Values 44 4 2 4 Description 1 44 4 2 5 Considerations 2 44 4 2 6 Related Function 4 2 7 Example 2 44 4 3 ALA EnableLoggifig ii iaa ii 45 LM A O 45 ADA TU MN Si AA A A A o A AAR 45 4 3 3 Possible Result Valles rte cin oie ta rre tun eee eei re inicien 45 2 34 Description dee DRAIN ipd RE Nat xen 45 4 3 5 Considerations lei te os o eoi ea e esten oe Ren re ele ertet ore iee 46 4 3 6 Related F nctlOn zie tei or e LR eR RR Un dee RA PEE RERNA eden 46 4 3 7 EXIM Plnenia LU EE 46 4 4 ALA Disableboggitig oit ettari a LAETI rette 47 AAV SYNTAX au 47 AAD A E TA 47 4 4 3 Possible Result Vals dee e e RERO RE E EA RU REA HEAR ARE HERE BEER ARDEN EN ddd 47 4AA Descriptio Nissisen 47 BAS COMSIGELACIONS dida 47 4 4 6 Related Function o ertet diee e e Eo d dee AE do iA 47 AAT Examples ET 47 4 5 ALA CreateXLogCollector 48 4 5 1 Syntax 2 48 4 5 2 Arguments 148 4 5 3 Possible Result Values 2
22. 4 3 Example Stop an XLog Sender named log analysis iSOL gt ALTER REPLICATION log analysis STOP 2 1 5 Adding a Table to a Log Analysis Task This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 5 1 Syntax ALTER REPLICATION replication name ADD TABLE FROM user name table name TO user name table name LogAnalyzer User s Manual 18 2 1 SQL Statements Used to Manage the XLog Sender 2 1 5 2 Description This statement is used to add a table to an analysis task It is acceptable to specify a table with a foreign key in the FROM clause With the above exception the use of this statement with an XLog Sender is the same as in Replica tion 2 1 5 3 Example Add table t2 which belongs to the sys user to the list of tables to be processed by the XLog Sender named og analysis iSOL gt ALTER REPLICATION log analysis ADD TABLE FROM sys t2 TO sys t2 2 1 6 Removing a Table from a Log Analysis Task This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 6 1 Syntax ALTER REPLICATION replication name DROP TABLE FROM user name table name TO user name table name 2 1 6 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 6 3 Example Remove table t2 which belongs to the sys user from the list of tables to be processed by the XLog Sender named log analysis iSOL gt ALTER REPLICATION log analysis DROP TABLE FROM sys
23. 48 4 5 4 Description 148 4 5 5 Considerations 4 5 6 Related Functions 2 50 4 5 Example nt RA s 50 NN A verba pride 52 A c 52 AN A RON NON 52 4 6 3 Possible Res lt Values aia iii 52 46 4 Description ii A ds e ASE a Ed 52 A cc 52 4 6 6 Related Fulctions sce A ERE C ERE ERE ie re sec ERR Do coque eg 52 467 EXAM SEE E m 53 AT ALA Remover c 54 4 71 SYNAR TAO 54 472 rere Ed 54 47 3 Possible Result Values Pei eee a ted deest eei eee a RU a Ede naria siii 54 4 7 4 Descriptio N e e 54 ETICO NS da 54 A AAA A AN 54 RR 55 ASALA SetHan dsShake iMac 56 4 8 lS Vntax A once O O DUREE AER HM area cision eet o P O o l n nh 56 4 8 2 Arguments e RN 56 4 8 3 Possible Result Valles ini ia 56 A A ET ROA 56 4 38 Related FUNCION arar did 56 O 56 CEA Wr ire Ro INInIeuuqu 57 ADDS ACA or P RODM 57 RN A te rte oe eren ro eet emet essor eet photo ea de eee ge eee o epa 57 4 9 3 Possible Res lt Values enana ence ve oett e debct a a PU e 57 4 94 Descriptio een NO 57 4 9 5 Related Function 57 4 9 6 Example 57 4 10 ALA Handshake 4 58 4 10 1 Syntax 2 58 4 10 2 Arguments 2 58 4 10 3 Possible Result Values 58 4 10 4 Description 58 4 10 5 Consideratioris 3
24. 7 ALA RemoveAuthlnfo 4 7 7 Example Please refer to ALA CreateXLogCollector 55 Log Analysis API 4 8 ALA SetHandshakeTimeout 4 8 ALA SetHandshakeTimeout 4 8 1 Syntax ALA RC ALA SetHandshakeTimeout ALA Handle aHandle UInt aSecond ALA ErrorMgr aOutErrorMgr 4 8 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aSecond This is the handshake timeout unit seconds range 1 OxFFFFFFFE aOutErrorMgr This is an Error Manager structure 4 8 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 8 4 Description This function sets the handshake timeout The handshake timeout is used when ALA Handshake is called The default handshake timeout is 600 seconds 4 8 5 Related Function ALA Handshake 4 8 6 Example Please refer to ALA Handshake LogAnalyzer User s Manual 56 4 9 ALA SetReceiveXLogTimeout 4 9 ALA SetReceiveXLogTimeout 4 9 1 Syntax ALA RC ALA SetReceiveXLogTimeout ALA Handle aHandle UInt aSecond ALA ErrorMgr aOutErrorMgr 4 9 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aSecond This is the reception timeout unit seconds range 1 OxFFFFFFFE aOutErrorMgr This is an Error Manager structure 4 9 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 9 4 Description This function sets the XLog reception timeout The XLog reception timeout
25. AA RR RESO A 104 4 35 ALA GetErrorMessage rectos ridere cie e oA atado Ene eMe eee ARARA OAS ETADI e ideado dano eddie 105 435 1 apr e 105 4 35 2 Arguments ceci 105 4 35 3 PossibleRes lt Val UGS ste itte il 105 O 105 4 35 5 Consideration ced idet cett o e doe S eee oon eae te aodann 105 4 356 Related F rictions cte tr E ERE T e tu EROR RENE ADR re E etnia oe EUER bna ciunt 105 43357 Example OO 105 AppendixA Error Codes 107 Error Code Table e Rad 107 FATAL Jie rP 107 ABORT ETTOL A T noove ds 107 hogzi tf H 109 AppendixB Sample Code 111 Sample Code Replication to Altibase DBMS cccsssssssssssssesssssssssssssscssscssscssnecssussessessnssesscssuscessessssesssscsssssensecssscessecsssecsseesseeees 111 XLog Sender Creatin deret betrieben ooo fora eben redis 111 XLog Collector EXecUtiON ricino 111 XLog Sender O Lo 111 MO e ad 111 viii Preface About This Manual About This Manual This manual describes the concept of the ALTIBASE HDB Log Analyzer and explains how to use it Audience This manual has been prepared for the following users of ALTIBASE HDB Database administrators Performance managers Database users Application developers Programmers Technical support workers It
26. LogAnalyzer User s Manual 1 2 How to Use the Log Analysis API typedef enum ALA ERROR FATAL 0 Need to Destroy ALA ERROR ABORT Need to Handshake ALA ERROR INFO Information ALA ErrorLevel The appropriate action to take in response to an error at each of the supported error levels is as fol lows ALA ERROR FATAL indicates a fatal error and thus ALA DestroyXLogCollector must be called to terminate the corresponding XLog Collector ALA ERROR ABORT indicates that the status of the corresponding XLog Collector is abnormal so ALA Handshake must be called to perform handshaking again for the XLog Collector ALA ERROR INFO indicates that the call to the Log Analysis API failed The action that is appropriate in response to this kind of error depends on the error code Errors that have already occurred can be checked via the log files written by the Log Manager For information on the use of the Log Manager please refer to the descriptions of the ALA EnableLogging and ALA DisableLogging 1 2 4 Basic Use The following diagram illustrates the steps involved when using the Log Analysis API 9 Introduction 1 2 How to Use the Log Analysis API STEP 1 Create Environment in which the Log Analysis API can be invoked and Start Logging ALA InitializeAPI ALA EnableLogging STEP 2 Create and Set Xlog Collector ALA CreateXLogCollector ALA AddAuthInfo ALA RemoveAuthInfo ALA SetHandshakeTimeou
27. O O O ALTIBASEHDB Data ODBCC Value FLOAT NUMERIC DOUBLE REAL BIGINT INTEGER SMALLINT DATE CHAR VARCHAR NCHAR NVARCHAR BYTE NIBBLE BIT VARBIT The BLOB CLOB and GEOMETRY types cannot be converted using this function This function supports ODBC 3 0 and subsequent versions Hinclude lt alaAPI h gt Log Analysis API 97 4 31 ALA GetODBCCValue void testODBCCConversion ALA Table aTable ALA XLog aXLog ALA Column sColumn SChar sBuffer 1024 ALA BOOL sIsNull UInt sODBCCValueSize UInt sPKColumnPos Convert the primary key to SQL C CHAR for sPKColumnPos 0 sPKColumnPos lt aXLog mPrimaryKey mPKColCnt sPKColumnPos The primary key seguence for XLog and the primary key seguence for the table are the same sColumn aTable gt mPKColumnArray sPKColumnPos Convert the internal data to SOL C CHAR void ALA GetODBCCValue sColumn amp aXLog mPrimaryKey mPKColArray sPKColumnPos SOL C CHAR 1024 sBuffer amp sIsNull amp sODBCCValueSize NULL LogAnalyzer User s Manual 98 4 32 ALA ClearErrorMgr 4 32 ALA ClearErrorMgr 4 32 1 Syntax ALA RC ALA ClearErrorMgr ALA ErrorMgr aOutErrorMgr 4 32 2 Arguments Argument Description aOutErrorMgr This is an Error Manager structure 4 32 3 Possible Result Values ALA SUCCESS
28. Result Values ALA SUCCESS ALA FAILURE 4 24 4 Description This function retrieves information about the table identified by the specified table OID 4 24 5 Considerations If there are no meta data corresponding to the specified table or if the specified table could not be found this function returns NULL for the aOutTable argument Any meta data that were obtained using this function before handshaking was performed should not be used again after handshaking as the information might be out of date 4 24 6 Related Functions ALA_Handshake LogAnalyzer User s Manual 82 4 24 ALA GetTablelnfo ALA GetReplicationInfo ALA GetTablelnfoByName ALA GetColumnlnfo ALA GetIndexInfo 4 24 7 Example Please refer to ALA GetReplicationlnfo 83 Log Analysis API 4 25 ALA GetTablelnfoByName 4 25 ALA GetTablelnfoByName 4 25 1 Syntax ALA RC ALA GetTableInfoByName ALA Handle aHandle const SChar aFromUserName const SChar aFromTableName const ALA Table aOutTable ALA ErrorMgr aOutErrorMgr 4 25 2 Arguments Arguments Description aHandle This is the handle of the XLog Collector aFromUserName This is the name of the owner of the table for which to retrieve the information aFromTableName This is the name of the table for which to retrieve the information aOutTable The table information is returned in this argument aOutErrorMgr This is an Error Manager
29. checked at the time point at which ALA GetXLog was most recently called If there are no active transactions the SN of the last XLog that was obtained using ALA GetXLog When transaction XLogs are obtained in the order in which transactions are committed the lowest XLog SN for uncommitted transactions that are currently stored in the transaction table 65 Log Analysis API 4 13 ALA SendACK 4 13 5 Considerations ACK has an influence on the XLog Sender s meta table and on flushing If ACK is not sent within the time period specified in the REPLICATION RECEIVE TIMEOUT property on the XLog Sender the XLog Sender drops the network connection Moreover if ACK is not sent for a long time the XLog Sender may stop sending XLogs update the Restart SN with the SN for the most recently recorded log and resume attempting to send XLogs Because the restart SN on the XLog Sender can be updated after the XLog Sender receives ACK it is necessary to process all of the XLogs obtained by calling ALA GetXLog before call ing ALA SendACK If a network error occurs the XLog Sender will periodically attempt handshaking When hand shaking succeeds the XLog Sender will resume sending XLogs beginning with the XLog hav ing the Restart SN 4 13 6 Related Functions ALA Handshake ALA ReceiveXLog 4 13 7 Example Please refer to ALA Handshake LogAnalyzer User s Manual 66 4 14 ALA FreeXLog 4 14 1 Syntax ALA RC ALA Free
30. from the XLog Oueue ALA SendACK Sends ACK to the XLog Sender ALA FreeXLog Returns an XLog to the XLog Pool Terminating an XLog Collector LogAnalyzer User s Manual ALA DestroyXLogCollec tor 12 Terminates an XLog Collector 1 3 Summary of the Log Analysis API Function Type Log Analysis API Function Name Description Monitoring an XLog Col lector ALA GetXLogCollectorS tatus Queries the status of an XLog Collector Function Type Log Analysis API Function Name Description Reading XLogs ALA GetXLogHeader ALA GetXLogPrimaryKey Obtains the header information from an XLog Obtains the data in the primary key col umn s from an XLog ALA GetXLogColumn Obtains the column data before and after from an XLog ALA GetXLogSavepoint ALA GetXLogLOB Obtains the savepoint information from an XLog Obtains the LOB data from an XLog Reading meta data ALA GetProtocolVersion Obtains the Replication protocol version of the Log Analysis API ALA GetReplicationInfo Obtains Replication information ALA GetTablelnfo Retrieves information about a table using the table OID ALA GetTablelnfoByNam e Retrieves information about a table using the table name and the table owner name ALA GetColumnlnfo Retrieves information about a column in a table using the column ID ALA GetIndexInfo
31. in rela tion to the corresponding XLog Collector will fail 4 15 6 Related Function ALA CreateXLogCollector 4 15 7 Example Please refer to ALA CreateXLogCollector LogAnalyzer User s Manual 68 4 16 ALA GetXLogCollectorStatus 4 16 ALA GetXLogCollectorStatus 4 16 1 Syntax ALA RC ALA GetXLogCollectorStatus ALA Handle aHandle ALA XLogCollectorStatus aOutXLogCollectorStatus ALA ErrorMgr aOutErrorMgr 4 16 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutXLogCollectorStatus This is a structure in which information about the status of the XLog Collector is stored aOutErrorMgr This is an Error Manager structure 4 16 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 16 4 Description This function is used to check the status of the XLog Collector The structure for storing information about the status of the XLog Collector is defined as follows typedef struct ALA XLogCollectorStatus SChar mMyIP ALA IP LEN SInt mMyPort SChar mPeerIP ALA IP LEN SInt mPeerPort SChar mSocketFile ALA SOCKET FILENAME LEN UInt mXLogCountInPool ALA SN mLastArrivedSN ALA SN mLastProcessedSN ALA BOOL mNetworkValid ALA XLogCollectorStatus Structure Member Description mMyIP TCP This is the IP address of the XLog Collector 69 Log Analysis API 4 16 ALA GetXLogCollectorStatus
32. obtain XLogs and meta data that are used to interpret the XLogs 1 1 1 5 Handshaking Handshaking is the task of checking the protocol version meta data etc before the XLogs are sent from the XLog Sender to the XLog Collector 1 1 1 6 XLog Queue The XLog Queue is the place where available XLogs are stored before they are accessed by users LogAnalyzer User s Manual 2 1 1 ALTIBASE HDB Log Analyzer 1 1 1 7 XLog Pool The XLog Pool is memory that has been allocated for the storage of XLogs The purpose of the XLog Pool is to reuse the memory that has been allocated to XLogs in order to prevent excessive memory usage 1 1 1 8 Transaction Table The transaction table is the place where information about transactions including the status of transactions is stored 1 1 1 9 Restart SN The Restart SN is the SN of the active log from which reading will resume when the XLog Sender is restarted 1 1 1 10 SN The SN Sequence Number is the serial number of an individual log record 1 1 1 11 Replication Replication is a module that is used to synchronize data between two Altibase databases For more information please refer to the Replication Manual 1 1 1 12 Replication SYNC Replication SYNC is a replication function whereby all of the records in the replication target tables on the local server are sent to the remote server This feature is used to synchronize replication target tables on two databases before active log based
33. of XLogs range from 1 upwards aUseCommittedTxBuffer This indicates whether to obtain transaction XLogs in the order in which they were committed aACKPerXLogCount This is the actual number of XLogs for which ACK will be sent range from 1 upwards aOutHandle This is the handle for the XLog Collector aOutErrorMgr This is an Error Manager structure 4 5 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 5 4 Description This function creates an XLog Collector that corresponds to the specified XLog Sender The name of the XLog Sender can be a duplicate name that is it can be the same name specified when another XLog collector was created aSocketInfo is a string having the format LogAnalyzer User s Manual 48 4 5 ALA CreateXLogCollector SOCKET socket typejlP STACK xlog ip stack PEER IP xlog sender ip MY PORT listen port whereby socket type can only be set to one of TCP or UNIX If it is set to UNIX a socket file having the path and name SALTIBASE HOME trc rp replication name is automatically created xlog sender ip must be specified when socket type is set to TCP The valid length is in the range from 1 to 39 bytes This is the IP address of the XLog Sender This information is required in order to authenticate the XLog Sender listen port must be specified when socket type is set to TCP The valid range is from 1024 to 65535 OxFFFF This is the port number via which the XLog S
34. printAlaErr amp sErrorMgr goto FINALYZE sStep 4 Initialize ALA Logging if ALA EnableLogging const signed char Current Directory const signed char ALA LOG FILE Log File Name 10 1024 1024 Log File Size 20 Maximum Previous Log File Count amp sErrorMgr ALA SUCCESS printAlaErr amp sErrorMgr goto FINALYZE sStep 5 Create XLogCollector memset sSocketInfo 0x00 128 sprintf sSocketInfo SOCKET s PEER IP s MY PORT d SOCKET TYPE PEER IP MY PORT if ALA CreateXLogCollector const signed char ALA NAME const signed char sSocketInfo 10000 XLog Pool Size ALA TRUE Use Committed Transaction Buffer 100 ACK Per XLog Count amp sHandle amp sErrorMgr ALA SUCCESS printAlaErr amp sErrorMgr goto FINALYZE sStep 6 Set Timeouts if ALA SetHandshakeTimeout sHandle 600 amp sErrorMgr ALA SUCCESS printAlaErr amp sErrorMgr goto FINALYZE if ALA SetReceiveXLogTimeout sHandle 10 amp sErrorMgr ALA SUCCESS 113 printAlaErr amp sErrorMgr goto FINALYZE BRR RR RK RR RR RR RR RR RK RR KR RK RR RR RR k RRR RR RR RRR AAA RK KK RR e ke ke ke ke ke Using XLog Collector SSA void runXLogCollector sHandle amp sErrorMgr FINALYZE BRR KR KR KR RK RR AAA RARA KR KK RARA Sk RR AA RARA Sk ke e AA RARA RK RK KR RR RR ke ke ke ke Finalization SSA switch s
35. received within the XLog reception timeout period a timeout event will occur If there are no XLogs available in the XLog Pool the call to this function will fail 61 Log Analysis API 4 11 ALA ReceiveXLog When transaction XLogs are obtained in the order in which transactions are committed XLogs that are received are not necessarily added to the XLog Queue If a network error occurs or a REPL STOP XLog is received it will be necessary to roll back any uncommitted transactions for which XLogs have been obtained and in connection with which the database contents have been changed Memory for aOutlnsertXLoglnOueue must be allocated in advance 4 11 6 Related Functions ALA SetReceiveXLogTimeout ALA Handshake ALA GetXLog ALA SendACK ALA FreeXLog 4 11 7 Example Please refer to ALA Handshake LogAnalyzer User s Manual 62 4 12 ALA GetXLog 4 12 1 Syntax ALA RC ALA GetXLog ALA Handle aHandle const ALA XLog aOutXLog 4 12 ALA GetXLog ALA ErrorMgr aOutErrorMgr 4 12 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutXLog This is an XLog obtained from the XLog Queue aOutErrorMgr This is an Error Manager structure 4 12 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 12 4 Description This function is used to obtain an XLog from the XLog Queue It can be called at the same time as ALA_ReceiveXLog If there are no XLogs i
36. structure 4 25 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 25 4 Description This function retrieves information about the table identified by the specified user table owner name and table name 4 25 5 Considerations If there are no meta data corresponding to the specified table or if no table corresponding to the specified user name and table name could be found this function returns NULL for the aOutTable argument Any meta data that were obtained using this function before handshaking was performed should not be used again after handshaking as the information might be out of date LogAnalyzer User s Manual 84 4 25 ALA GetTablelnfoByName 4 25 6 Related Functions ALA Handshake ALA GetReplicationInfo ALA GetTablelnfo ALA GetColumnlnfo ALA GetIndexInfo 4 25 7 Example Please refer to ALA GetReplicationInfo 85 Log Analysis API 4 26 ALA GetColumnlInfo 4 26 ALA GetColumninfo 4 26 1 Syntax ALA RC ALA GetColumnInfo const ALA Table aTable UInt aColumnID const ALA Column aOutColumn ALA ErrorMgr aOutErrorMgr 4 26 2 Arguments Argument Description aTable This is the meta information aboutthe table containing the column for which to retrieve the information aColumnID This is the ID of the column for which to retrieve the information aOutColumn The column information is returned in this argument aOutErrorMgr This is an Error Manager
37. to ensure that the XLog Pool is not depleted LogAnalyzer User s Manual 58 4 10 ALA Handshake 4 10 6 Related Functions ALA AddAuthlnfo ALA RemoveAuthlnfo ALA SetHandshakeTimeout ALA ReceiveXLog ALA SendACK ALA GetReplicationInfo ALA GetTablelnfo ALA GetColumnlnfo ALA GetIndexInfo 4 10 7 Example include alaAPI h void testXLogCollector ALA Handle aHandle ALA XLog sXLog NULL ALA XLogHeader sXLogHeader NULL ALA XLogCollectorStatus sXLogCollectorStatus ALA BOOL sInsertXLogInQueue ALA FALSE ALA BOOL sExitFlag ALA FALSE Set Handshake Timeout 600 seconds void ALA A dandis 600 NULL Set XLog Receive Timeout 10 seconds void ALA SetReceiveXLogTimeout aHandle 10 NULL Listen for XLog Sender and Handshake void ALA Handshake aHandle NULL Receive XLog until XLog Sender ends while sExitFlag ALA TRUE Receive XLog and add it to XLog Queue sInsertXLogInOueue ALA FALSE while sInsertXLogInQueue ALA TRUE void ALA ReceiveXLog aHandle amp sInsertXLogInQueue NULL Obtain XLog from XLog Queue Assuming that transaction XLog is obtained in the order in which records are logged void ALA GetXLog aHandle amp sXLog NULL Analyze and Process XLog void ALA GetXLogHeader sXLog amp sXLogHeader NULL 59 Log Analysis API 4 10 ALA Handshake if sXLogHeader gt mType XLOG TYPE REPL STOP
38. 14 6 Related Functloris tecto A tei rta ot A aA st 67 4 14 7 Example sei ere O a 67 AAS ALA DestroyXLogCollector i nidad 68 E ESI or 68 A A T 68 4 153 Possible RESult Values rra itan lee Rege 68 A154 ABI ieilejioe eU 68 4 15 5 Considerations cac ate oc e teen ri a tenda e s d Ode Ee hec 68 415 6 Related FUN NO 68 4 157 Example see Ri A esee E e este bee EE or Re 68 4 16 ALA GetXLogCollectorStatus 5 3 etienne diciendo ricas 69 E T6 V SYNTAX p PEN 69 4 16 2 Arguments zeit ert A 69 4 16 3 Possible Result Value S ccccssssssssesssessssssesssesssessssssesssecessssssssesssesesssssssosssssssscssecasscesssessesecssecasseasesessesssenssoessoeseseesees 69 4 16 4 Descriptio pe 69 4 16 5 Consideratiornic eRe sa de tesa i ed SS Diag e Gee Ba 70 416 6 Related FUNCIONS ei 70 4 16 7 Example ein 71 4 17 ALA GetXLogHeadef eee fs 72 4 17 1 Syntax red 2 4 17 2 Arguments 72 4 17 3 Possible Result Values 0 72 4 17 4 Description 242 4 17 5 Related Functions 72 4 17 6 Example 72 4 18 ALA GetXLogPrimaryKey wane 74 418 1 SYNTA A M 74 ATS 2 ANG umts 2er a A ETE tke EET eine dada a A ERREUR 74 4 183 Possible Result Val es a 74 ALIADOS PUN ii a aii 74 448 5 Related FU stas 74 4 18 6
39. 4 33 5 Considerations It is necessary to allocate memory in which to store aOutErrorCode before calling this function Because the mErrorCode element of the ALA ErrorMgr structure contains information that is internally used and thus not easy to parse or understand it is necessary to use the ALA GetErrorCode function in order to obtain the error code 4 33 6 Related Functions ALA ClearErrorMgr ALA GetErrorLevel ALA GetErrorMessage 101 Log Analysis API 4 33 ALA GetErrorCode 4 33 7 Example Please refer to ALA ClearErrorMgr LogAnalyzer User s Manual 102 4 34 ALA GetErrorLevel 4 34 ALA GetErrorLevel 4 34 1 Syntax ALA RC ALA GetErrorLevel const ALA ErrorMgr aErrorMgr ALA ErrorLevel aOutErrorLevel 4 34 2 Arguments Argument Description aErrorMgr This is an Error Manager structure aOutErrorLevel This is the error level 4 34 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 34 4 Description This function is used to determine the error level from aErrorMgr Because the ALA ERROR FATAL error level indicates a fatal error if this error level is returned the corresponding XLog Collector must be terminated This is accomplished using the ALA DestroyXLogCollector function The ALA ERROR ABORT error level indicates that the state of the XLog Collector is abnormal If this error level is returned it will be necessary to call ALA Handshake for the corresponding
40. Altibase Application Development Log Analyzer User s Manual Release 5 5 1 January 15 2013 a ALTIBASE PERFORMANCE SOLUTIONS Altibase Application Development Log Analyzer User s Manual Release 5 5 1 Copyright 2001 2010 Altibase Corporation All rights reserved This manual contains proprietary information of Altibase amp Corporation it is provided under a license agreement containing restric tions on use and disclosure and is also protected by copyright patent and other intellectual property law Reverse engineering of the Software is prohibited All trademarks registered or otherwise are the property of their respective owners Altibase Corporation 10F Daerung PostTower II 182 13 Guro dong Guro gu Seoul 152 847 Korea Telephone 82 2 2082 1000 Fax 82 2 2082 1099 E mail support altibase com www http www altibase com Contents Preface ie deiecit NA i About This Manual Audience a Software Environment siet tree e aen pede cesa inerat ed ect res alise epi ped obo tea uae ii OrganizatioDi Scd UPPER essa dta D S E DIE ii Documentation Conventions ceci cidcid iii Relata HR REESE HAAS nter ne ote v Online Manuals sees vi Altibase Welcomes Your Comments vi 1 Introd ction reeso eee ere oso ta nose ena cono ansa rohs 1 T T AETIBASE HDB Log Analy Ze tscscsssssssssavcssiatssaessssacssconsusostasavcsesetssavaussensussosiagssuassasataedeanecstbeisloaiandaaesvss
41. E 4 27 4 Description This function retrieves the information about the index identified by the specified Index ID in the specified table 4 27 5 Considerations If there are no meta data corresponding to the specified index or if the specified table or index could not be found this function returns NULL for the aOutlndex argument Any meta data that were obtained using this function before handshaking was performed should not be used again after handshaking as the information might be out of date LogAnalyzer User s Manual 88 4 27 ALA Getlndexlnfo 4 27 6 Related Functions ALA Handshake ALA GetReplicationlnfo ALA GetTablelnfo ALA GetTablelnfoByName ALA GetColumnlInfo 4 27 7 Example Please refer to ALA GetReplicationlnfo 89 Log Analysis API 4 28 ALA GetlnternalNumericlnfo 4 28 ALA GetinternalNumericinfo 4 28 1 Syntax ALA RC ALA GetInternalNumericInfo ALA Column aColumn ALA Value aAltibaseValue SInt aOutSign SInt aOutExponent ALA ErrorMgr aOutErrorMgr 4 28 2 Arguments Argument Description aColumn This is the meta information about the column in which aAltibaseValue is stored aAltibaseValue This is the actual ALTIBASE HDB numeric data for which to return the information aOutSign This is the sign of the numeric data aOutExponent This is the exponent of the numeric data aOutErrorMgr This is an Error Manager structure 4 28 3 Possible Result Values
42. Error Code Description Can be returned by 0x52036 Unable to obtain the MTD module ALA GetXLog ALA GetAltibaseText ALA GetAltibaseSOL 0x52037 Failed to create text with the MTD mod ALA GetAltibaseText ule 0x52038 CMT Initialization Failure ALA GetODBCCValue 0x52039 CMT End Failure ALA GetODBCCValue 0x5203A Analysis Header Create Failed ODBC ALA GetODBCCValue Conversion 0x5203B Analysis Header Remove Failure ODBC ALA GetODBCCValue Conversion 0x5203C Failed to convert from MT to CMT ALA GetODBCCValue 0x5203D Failed to convert from CMT to ulnCol ALA GetODBCCValue umn 0x5203E Failed to convert from ulnColumn to ALA GetODBCCValue ODBC C LogAnalyzer User s Manual 110 Appendix B Sample Code Sample Code Replication to Altibase DBMS This sample code is available at SALTIBASE HOME sample ALA Altibase ReplToAltiSample c The following is a brief description of the use of the Log Analyzer with reference to sample code For complete information please refer to Chapter2 The XLog Sender for details XLog Sender Creation CREATE REPLICATION ALA1 FOR ANALYSIS WITH 127 0 0 1 47146 FROM ala ala t1 TO ala ala tl XLog Collector Execution ReplToAltiSample XLog Sender Startup ALTER REPLICATION ALA1 START Sample Code This sample code is available at SALTIBASE HOME sample ALA Altibase ReplToAltiSample c kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
43. Example dore 74 419 AEA GetXLogCol lmh s c ttt tee ee ERREUR RUE etre S DEUM RAS eth 75 4 19 T Syntax sucio teo ete e e e n re RR A e E to OL A EA a dee ut de rea RR pee e Dee Ae 75 419 2 ALUMNES hpna T 75 A1 9 3 POSSIDIG RESUIE Values eit cote ie te obere ees doter EUN d regm opea ra 75 CAI EEDIragleiio pP isesi 75 4 19 5 Rel t d Functions ad 75 4 19 6 Example reet I e RR CERRAR dai 75 4 20ALA GEA OS AVEO ui H 76 IS X niia RN RN 76 ALO O a acia 76 4 20 3 Possible Result Values 76 4 20 4 Description 76 4 20 5 Related Functions 2 76 4 20 6 Example 76 4 21 ALA GetXLogLOB 277 4 21 1 Syntax 17 4 21 2 Arguments uL 4 21 3 Possible Result Values tetto iii 77 421 4DesScriptOM roD 77 4 21 5 R lated FUNCIONS ccce iodo dida 77 4 21 6 EXaiTiple e pr ERA NN 77 4 22 ALA Gettin ete e Re ote eee pepe epos eto eo e Eee n ARANA qet 78 422 rpm H1 78 4 22 2 Argumente sse eet td di dee sene rere ree eR 78 422 3 Possible Result Val US in EE E ER cb E EE ER RE Do re se RT E Cae 78 A D2 A Descriptio t ree ree iaa 78 4 22 5 Considerato Nissinen ioiii Naa ARN 78 4226 Example O ARI 78 4 23 AEA GetReplicationltifo ensinanzas aana EEN ATRE EAA ETNE 79 LP rr TISPE TOPA AE EEE T O A 79 vi A 79 4 23 3 Po
44. L aOutIsNull UInt aOutODBCCValueSize ALA ErrorMgr 4 31 2 Arguments aOutErrorMgr Argument Description aColumn This is meta information about the column in which aAltibaseValue is stored aAltibaseValue This is the data in the internal format of ALTIBASE HDB aODBCCTypelD This is the ODBC C type into which the data are to be converted aODBCCValueBufferSize This is the size of the buffer in which to store the results aOutODBCCValueBuffer This is the buffer in which to store the results aOutlsNul aOutODBCCValueSize This indicates whether the data to be converted are NULL This is the size of the ODBC C value resulting from the conversion aOutErrorMgr This is an Error Manager structure 4 31 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 31 4 Description This function is used to convert a value in an internal format of ALTIBASE HDB to an ODBC C type The type conversions that are supported are shown in the following table LogAnalyzer User s Manual 96 4 31 ALA GetODBCCValue Table 4 1 ODBC C Conversion dWVLSAWIL 3dAL D 10S 3WIL 3dAL D 1OS Alva 3dAL D 10S AYVNIg D 1OS q118nod gt 10s 1VO14 D 10S ANIDIGN D TOS 1NIDI8S D 10S DNOIN D 10S SNOIS D 10S LYOHSN D 10S 1HOHSS D TOS ANIANILA D 10S ANIANILS D TOS 118 gt 1OS DIYAWAN D 10S YYHD gt 10S O O O
45. LA GetXLogLOB 4 21 1 Syntax ALA RC ALA GetXLogLOB const ALA XLog aXLog const ALA XLogLOB aOutXLogLOB ALA ErrorMgr aOutErrorMgr 4 21 2 Arguments Argument Description aXLog This is the XLog for which to retrieve the XLog LOB information aOutXLogLOB The XLog LOB information of aXLog is returned in this argument aOutErrorMgr This is an Error Manager structure 4 21 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 21 4 Description This function is used to obtain the XLog LOB information for the specified XLog 4 21 5 Related Functions ALA GetXLog ALA GetXLogHeader ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogSavepoint 4 21 6 Example Please refer to ALA GetXLogHeader 77 Log Analysis API 4 22 ALA GetProtocolVersion 4 22 ALA GetProtocolVersion 4 22 1 Syntax ALA RC ALA GetProtocolVersion const ALA ProtocolVersion aOutProtocolVersion ALA ErrorMgr aOutErrorMgr 4 22 2 Arguments Argument Description aOutProtocolVersion This is a Protocol Version structure aOutErrorMgr This is an Error Manager structure 4 22 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 22 4 Description This function is used to check the protocol version that is being used by the Log Analysis API The protocol version can be checked regardless of whether handshaking has been performed 4 22 5 Consideration Before this function is executed
46. OB 77 ALA GetXLogPrimarykey 74 ALA GetXLogSavepoint 76 ALA Handshake 58 ALA InitializeAPI 42 ALA ReceiveXLog 61 ALA RemoveAuthlnfo 54 ALA SendACK 65 ALA SetHandshakeTimeout 56 ALA SetReceiveXLogTimeout 57 Altibase Log Analyzer 2 B Basic Use 9 BIGINT 35 BIT 36 BLOB 36 BYTE 36 C CHAR 36 CLOB 36 Creating XLog Sender 16 D Data Types 7 33 Internal Structure 33 DATE 35 DOUBLE 35 E Error Code Table 107 Error Handling 8 Error Handling API 14 F FATAL Errors 107 FLOAT 34 Flushing XLogs 21 G GEOMETRY 37 H Handshaking 2 I INFO Errors 109 INTEGER 35 L Log Analysis API 2 Log Analysis API Environment Management 12 M Meta Data 31 Meta Data Structure 31 Meta Tables 22 N NCHAR 36 NIBBLE 36 NUMERIC 34 NVARCHAR 36 P Performance Views 23 Index R REAL 35 Remove XLog Sender 17 Removing a Host 20 Removing a Table for Analysis 19 Replication 3 Replication SYNC 3 Restart SN 3 S SAVEPOINT 38 Setting a Host 20 SMALLINT 35 SN 3 SQL Statements for XLog Sender 16 Starting XLog Sender 17 Stopping XLog Sender 18 SYSTEM SYS REPL HOSTS 22 SYSTEM SYS REPLICATIONS 22 SYSTEM SYS REPL ITEMS 22 T Transaction Table 3 V VSREPEXEC 23 VSREPGAP 23 VSREPSENDER 23 VSREPSENDER TRANSTBL 23 VARBIT 36 VARCHAR 36 X XLog 2 26 Types 26 XLog Analysis APIs 13 XLog Collector 2 XLog Collector Management API 12 XLog Pool 3 XLog Queue 2 XLog Sender 2 Index 120
47. Step Case 6 Destroy XLog Collector void ALA DestroyXLogCollector sHandle amp sErrorMgr case 5 Finalize Logging void ALA DisableLogging amp sErrorMgr Case 4 Destroy ALA API environment void ALA DestroyAPI ALA TRUE amp sErrorMgr Case 3 void SOLDisconnect gDbc case 2 void SOLFreeConnect gDbc Case 1 void SQLFreeEnv gEnv default break return 0 ALA RC runXLog Collector ALA Handle aHandle ALA ErrorMgr aErrorMgr ALA XLog sXLog NULL ALA XLogHeader sXLogHeader NULL UInt sErrorCode ALA ErrorLevel sErrorLevel A A A LA BOOL sReplStopFlag ALA FALSE LA BOOL sDummyFlag ALA FALSE LA BOOL sAckFlag Run until ALA ERROR FATAL Error occurs or REPL STOP XLog arrives while sReplStopFlag ALA TRUE Wait and Handshake with XLog Sender if ALA Handshake aHandle aErrorMgr ALA SUCCESS printAlaErr aErrorMgr void ALA GetErrorLevel aErrorMgr amp sErrorLevel if sErrorLevel ALA ERROR FATAL return ALA FAILURE LogAnlyzer User s Manual 114 Wait and Handshake with XLog Sender continue while sReplStopFlag ALA TRUE Get XLog from XLog Queue if ALA GetXLog aHandle const ALA XLog amp sXLog aErrorMgr ALA SUCCESS printAlaErr aErrorMgr void ALA GetErrorLevel aErrorMgr amp sErrorLevel if sErrorLevel ALA ERROR FATAL Wait and Handshake
48. T XLog Header mType mTID mSN mSyncSN Savepoint mSPNameLen mSPName If mSPName begins with SSIMPLICIT it is an implicit savepoint If mSPName is SSPSM SVP it isa PSM Savepoint 3 1 3 9 LOB CURSOR OPEN XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray LOB mLobLocator mLobColumnID 3 1 3 10 LOB CURSOR CLOSE XLog Header mType mTID mSN mSyncSN LOB mLobLocator 3 1 3 11 LOB PREPAREAWRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator mLobOffset mLobOldSize mLobNewsSize 3 1 3 12 LOB PARTIAL WRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator mLobOffset mLobPieceLen mLobPiece mLobOffset is the position relative to the value of mLoboffset in the 29 Analyzing XLogs 3 1 XLogs LOB PREPAREAWRITE XLog 3 1 3 13 LOB FINISH2WRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator 3 1 3 14 KEEP ALIVE XLog Header mType mTID mSN mSyncSN 3 1 3 15 REPL STOP XLog Header mType mTID mSN mSyncSN LogAnalyzer User s Manual 30 3 2 Meta Data 3 2 Meta Data This section describes how to access the meta data that are used to interpret XLogs Before the meta data can be accessed it is necessary to call ALA Handshake 3 2 1 Meta Data Structure typedef struct ALA ProtocolVersion UShort mMajor Major Version UShort mMinor Minor Version UShort mFix Fix Version ALA ProtocolVersion
49. Types and Internal Structure MantissaStr mantissa 0 else MantissaStr mantissa 0 10 MantissaStr MantissaStr mantissa 0 10 mantissa 1 mantissa mLength 1 for Index 1 Index lt mLength 1 Index MantissaStr MantissaStr mantissa Index 10 MantissaStr MantissaStr mantissa Index 10 else if Sign is Example 98 76 54 32 10 0 123456789 09 87 65 43 21 0 9012345678 mantissa 0 if mantissa 0 MantissaStr MantissaStr else MantissaStr MantissaStr MantissaStr MantissaStr gt 90 99 mantissa 0 99 mantissa 0 99 mantissa 0 BO 10 1 mantissa 1 mantissa mLength 1 for Index 1 Index lt mLength 1 Index MantissaStr MantissaStr 99 mantissa Index 10 MantissaStr MantissaStr 99 mantissa Index 10 3 3 2 DOUBLE REAL BIGINT INTEGER SMALLINT 3 3 2 1 Internal Structure Each type is mapped to a primitive data type typedef SDouble mtdDoubleType DOUBLE typedef SFloat mtdRealType REAL typedef SLong mtdBigintType BIGINT typedef SInt mtdIntegerType INTEGER typedef SShort mtdSmallintType SMALLINT 3 3 3 DATE 3 3 3 1 Internal Structure There is only one internal data type available for handling dates and times 35 Analyzing XLogs 3 3 ALTIBASE HDB Data Types and Internal Structure typedef struct mtdDateType SShort year
50. UShort mon day hour UInt min sec mic mtdDateType Year 16bit Not Used 2bit Month 4bit Day 5bit Hour 5bit Minute 6bit Second 6bit MicroSec 20bit 3 3 4 CHAR VARCHAR NCHAR NVARCHAR BYTE NIBBLE BIT VARBIT BLOB CLOB 3 3 4 1 Internal Structure These data types have similar structures typedef struct mtdCharType UShort length UChar value 1 mtdCharType typedef struct mtdNcharType UShort length UChar value 1 mtdNcharType typedef struct mtdByteType UShort length UChar value 1 mtdByteType typedef struct mtdNibbleType UChar length UChar value 1 mtdNibbleType typedef struct mtdBitType UInt length UChar value 1 mtdBitType typedef struct mtdLobType UInt length UChar value 1 mtdLobType typedef mtdLobType mtdBlobType typedef mtdLobType mtdClobType CHAR VARCHAR Length of value UChar Array NCHAR NVARCHAR Length of value UChar Array BYTE Length of value UChar Array NIBBLE Length of Nibbles UChar Array BIT VARBIT Length of Bits UChar Array Length of value UChar Array BLOB CLOB The ALA GetAltibaseText ALA GetAltibaseSOL and ALA GetODBCCValue functions cannot be used with BLOB or CLOB type values Valid values for the length element of the NIBBLE t
51. XLOG TYPE KEEP ALIVE SAckFlag ALA TRUE break case I case XLOG TYPE LOB CURSOR OPEN XLOG TYPE BEGIN X case XLOG TYPE LOB CURSOR CLOSE X X case XLOG TYPE LOB PREPAREAWRITE case XLOG TYPE LOB PARTIAL WRITE case XLOG TYPE LOB FINISH2WRITE default break Free XLog if ALA FreeXLog aHandle sXLog aErrorMgr ALA SUCCESS printAlaErr aErrorMgr void ALA GetErrorLevel aErrorMgr amp sErrorLevel if sErrorLevel ALA ERROR FATAL return ALA FAILURE Wait and Handshake with XLog Sender break Send ACK to XLog Sender if sAckFlag ALA FALSE if ALA SendACK aHandle aErrorMgr ALA SUCCESS printAlaErr aErrorMgr void ALA GetErrorLevel aErrorMgr amp sErrorLevel if sErrorLevel ALA ERROR FATAL Wait and Handshake with XLog Sender break return ALA FAILURE else while LogAnlyzer User s Manual 116 Rollback Current Transaction void SQLEndTran SQL HANDLE DBC gDbc SQL ROLLBACK while return ALA SUCCESS ALA RC applyXLogToAltibase ALA Handle aHandle ALA XLog aXLog ALA ErrorMgr aErrorMgr ALA Table sTable NULL ALA XLogHeader sXLogHeader NULL char sQuery QUERY SIZE char sImplictSPPos Get XLog Header void ALA GetXLogHeader aXLog const ALA XLogHeader amp SXLogHeader aErrorMgr if COMMIT XLog then Commit Current Transactio
52. XLog ALA Handle ALA XLog aXLog 4 14 ALA FreeXLog ALA ErrorMgr aOutErrorMgr 4 14 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aXLog This is an XLog that will be returned to the XLog Pool aOutErrorMgr This is an Error Manager structure 4 14 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 14 4 Description This function returns an XLog to the XLog Pool 4 14 5 Conside ration If XLogs obtained using ALA GetXLog are not returned to the XLog Pool for an excessively long period of time the XLog Pool may become depleted 4 14 6 Related Functions ALA ReceiveXLog ALA GetXLog 4 14 7 Example Please refer to ALA Handshake 67 Log Analysis API 4 15 ALA DestroyXLogCollector 4 15 ALA DestroyXLogCollector 4 15 1 Syntax ALA RC ALA DestroyXLogCollector ALA Handle aHandle ALA ErrorMgr aOutErrorMgr 4 15 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutErrorMgr This is an Error Manager structure 4 15 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 15 4 Description This function terminates an XLog Collector 4 15 5 Considerations Before this function is called ALA FreeXLog must be executed for all XLogs that were obtained by calling ALA GetXLog Regardless of the result value any subsequent calls to the Log Analysis API functions
53. XLog Col lector in order to perform handshaking with the XLog Sender again An error level of ALA ERROR INFO indicates failure to invoke the Log Analysis API The action that is appropriate to take in response to this error level is determined based on the error code 4 34 5 Consideration It will be necessary to allocate memory in which to store aOutErrorLevel before calling this function 4 34 6 Related Functions ALA ClearErrorMgr 103 Log Analysis API 4 34 ALA GetErrorLevel ALA GetErrorCode ALA GetErrorMessage 4 34 7 Example Please refer to ALA ClearErrorMgr LogAnalyzer User s Manual 104 4 35 ALA GetErrorMessage 4 35 ALA GetErrorMessage 4 35 1 Syntax ALA RC ALA GetErrorMessage const ALA ErrorMgr aErrorMgr const SChar aOutErrorMessage 4 35 2 Arguments Argument Description aErrorMgr This is an Error Manager structure aOutErrorMessage The error message is returned in this argument 4 35 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 35 4 Description This function is used to obtain the actual error message from an Error Manager 4 35 5 Consideration Since only a pointer to the actual error message is returned in aOutErrorMessage there is no need to allocate memory in which to store aOutErrorMessage 4 35 6 Related Functions ALA ClearErrorMgr ALA GetErrorCode ALA GetErrorLevel 4 35 7 Example Please refer to ALA ClearErrorMgr 105 Lo
54. ain XLog Primary Key void ALA GetXLogPrimaryKey aXLog amp sXLogPrimaryKey NULL Obtain XLog Column void ALA GetXLogColumn aXLog amp sXLogColumn NULL tain og Savepoint Obtain XL S i void ALA GetXLogSavepoint aXLog amp sXLogSavepoint NULL Obtain XLog LOB void ALA GetXLogLOB aXLog amp sXLogLOB NULL 73 Log Analysis API 4 18 ALA GetXLogPrimaryKey 4 18 ALA GetXLogPrimaryKey 4 18 1 Syntax ALA RC ALA GetXLogPrimaryKey const ALA XLog aXLog const ALA XLogPrimaryKey aOutXLogPrimaryKey ALA ErrorMgr aOutErrorMgr 4 18 2 Arguments Argument Description aXLog This is the XLog for which to retrieve the primary key aOutXLogPrimaryKey The XLog primary key of aXLog is returned in this argu ment aOutErrorMgr This is an Error Manager structure 4 18 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 18 4 Description This function is used to obtain the XLog primary key for the specified XLog 4 18 5 Related Functions ALA GetXLog ALA GetXLogHeader ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB 4 18 6 Example Please refer to ALA GetXLogHeader LogAnalyzer User s Manual 74 4 19 ALA GetXLogColumn 4 19 ALA GetXLogColumn 4 19 1 Syntax ALA RC ALA GetXLogColumn const ALA XLog aXLog const ALA XLogColumn aOutXLogColumn ALA ErrorMgr aOutErrorMgr 4 19 2 Arguments Argument Description
55. alizeAPI LogAnalyzer User s Manual 44 4 3 ALA EnableLogging 4 3 ALA EnableLogging 4 3 1 Syntax ALA RC ALA EnableLogging const SChar aLogDirectory const SChar aLogFileName UInt aFileSize UInt aMaxFileNumber ALA ErrorMgr aOutErrorMgr 4 3 2 Arguments Argument Description aLogDirectory This is the log directory aLogFileName This is the name of the log file aFileSize This is the size of each log file aMaxFileNumber This is the maximum number of completed log files aOutErrorMgr This is an Error Manager structure 4 3 3 Possible Result Values ALA_SUCCESS ALA_FAILURE 4 3 4 Description This function enables logging for help in tracking the cause of problems If this function is not called logging will not be performed If there is no log file having the specified name a new log file is created If a log file having the speci fied name already exists logs will be appended to the end of this log file If the size of this log file reaches aFileSize the log file is renamed and a new log file having the speci fied name is created The header of each log file contains a number ranging from 1 to aMaxFileNum ber The log file is renamed with reference to this number For example if the header of a log file named analysis log contains the number 1 and the size of the log file reaches the size specified in aFileSize the name of the log file is changed from analysis log to
56. analysis log 1 and a new log file named analysis log and having the number 2 in the header is created The numbers in the log file headers start at 1 and are incremented by 1 If this number reaches aMax FileNumber the numbering restarts at 1 As a result only the log file that is currently in use and the 45 Log Analysis API 4 3 ALA EnableLogging most recent aMaxFileNumber log files are kept 4 3 5 Considerations The maximum length of the log directory and file name including NULL character is 1024bytes If logging has already been enabled calling this function will result in an error Calling another Log Analysis API function while execution of this function is underway will cause unexpected behavior If the contents of the log file header are abnormal or unexpected the log file is deleted and created again Setting the value of aFileSize to 0 will allow the log file to grow infinitely large depending on system resources 4 3 6 Related Function ALA DisableLogging 4 3 7 Example include alaAPI h void testLogging Create Log Analysis API Environment void ALA InitializeAPI ALA FALSE NULL Enable logging Log Directory The current directory Log File Name analysis log The Size of Log File Size 10 MB The Max Number of Previous Log Files 10 void ALA EnableLogging analysis log 10 1024 1024 LO NULL Invoke Log Analysis API Disab
57. ansmission With the above exceptions the use of this statement with an XLog Sender is the same as in Replica tion 2 1 3 3 Considerations Before the XLog Sender is started the XLog Collector must be online and waiting for a connec tion When using the UNIX domain protocol the setting for the SALTIBASE_HOME environment 17 The XLog Sender 2 1 SQL Statements Used to Manage the XLog Sender variable must be the same as for the XLog Collector Because the maximum allowable socket filename length varies depending on the operating system be sure to check and avoid exceeding the maximum allowable length on your system In order to start the XLog Sender with the AT SN clause the following conditions must be satisfied The database must be running in Archivelog mode The number of Log File Groups LFG is one that is the LOG FILE GROUP COUNT property must be set to 1 The dedicated replication log buffer must be not used That is the REPLICATION LOG BUFFER SIZE property must be set to 0 2 1 3 4 Example Start an XLog Sender named og analysis at the point at which it was last stopped iSOL gt ALTER REPLICATION log analysis START 2 1 4 Stopping an XLog Sender This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 4 1 Syntax ALTER REPLICATION replication name STOP 2 1 4 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1
58. atte a ate t ce iste nC T ORA oC E QU ERBEN Uaec 58 410 6 Rel ted FUNCtONSs a ecrire hee Lu ra hs concra oe core Reo ne o BA eoe a 59 AO TEN li EET 59 AV ALA REGCCIVEXLOG 4 it AA ete ie te A A rete vere ae acie ee rer ee Ridens 61 Actis 61 AN ments spe RR 61 4 11 3 P ssible Result Values indias 61 4 11 4 DeSCTIPTI OM zive ss E 61 411 5 Conslderatioris uace O i n 61 411 6 Related FUNCION ii pa etc eti e CP ER ee dna ree UA Re Op OPEN 62 GATT Ie ETE LUE 62 EP ALAGEEXLOG c dioda MUEEMODU DID 63 A om M 63 4 12 2 Arguments A URANO 63 4 12 3 Possible Res ete o tecti ea tei eee det e T uet tora e te addu 63 AAV QA Descriptioh toa 63 4 12 5 Consideration 2 63 4 12 6 Related Functions 63 4 12 7 Example 64 4 13 ALA SendACK 4 13 1 Syntax 65 4 13 2 Arguments 65 4 13 3 Possible Result Values 165 4 13 4 DESC PUO Nini 65 4 13 5 E SA ERE e PAR Hen dedii aee eR RR ede tps epe AE 66 413 6 Related FUNCIONS RET X EE 66 413 7 EXaiTiple e eR pr RD EE REA RU ERR ERR E pe to Ee RR EUR ERE ER aen 66 A 1AALAFreeXLOO pt NUUS Radio 67 O seoneeanses 67 ANAL UM ES nette s esee ote e abet eie aee sene re oreet 67 414 3 Possible Result Values o eir ce E ER i E EAE ERE Do re sec e ER Coa ud 67 ATAA Description se e ree ches ete eee vere eese aenea stet eene ue eee eee e ege 67 414 5 Consideration ansan ioiii Na A E A 67 4
59. be allocated before this function is called ALA Handshake ALA ReceiveXLog ALA GetXLog ALA SendACK ALA FreeXLog LogAnalyzer User s Manual 70 4 16 ALA GetXLogCollectorStatus 4 16 7 Example Please refer to ALA Handshake 71 Log Analysis API 4 17 ALA GetXLogHeader 4 17 ALA GetXLogHeader 4 17 1 Syntax ALA RC ALA GetXLogHeader const ALA XLog aXLog const ALA XLogHeader aOutXLogHeader ALA ErrorMgr aOutErrorMgr 4 17 2 Arguments Argument Description aXLog This is the XLog for which to retrieve the header aOutXLogHeader The XLog header of aXLog is returned in this argument aOutErrorMgr This is an Error Manager structure 4 17 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 17 4 Description This function is used to obtain the XLog header for the specified XLog 4 17 5 Related Functions ALA GetXLog ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB 4 17 6 Example include alaAPI h LogAnalyzer User s Manual 72 4 17 ALA GetXLogHeader void testXLogGetPart const ALA XLog aXLog LA XLogHeader LA XLogPrimaryKey A sXLogHeader NULL A ALA XLogColumn A A sXLogPrimaryKey NULL sXLogColumn NULL sXLogSavepoint NULL sXLogLOB NULL LA XLogSavepoint OB ook o Xx LA XLogI Obtain XLog Header void ALA GetXLogHeader aXLog amp sXLogHeader NULL Obt
60. ch belongs to the sys user to an XLog Collector running on the same machine The port number must be set to the same port number that is specified in the XLog Collector iSOL gt CREATE REPLICATION log analysis FOR ANALYSIS WITH 127 0 0 1 20300 FROM sys t1 TO sys tl LogAnalyzer User s Manual 16 2 1 SQL Statements Used to Manage the XLog Sender 2 1 2 Deleting an XLog Sender This task is accomplished using the DROP REPLICATION ALTIBASE HDB SQL statement 2 1 2 1 Syntax DROP REPLICATION replication name 2 1 2 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 2 3 Example Delete an XLog Sender named og analysis iSOL gt DROP REPLICATION log analysis 2 1 3 Starting an XLog Sender This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 3 1 Syntax ALTER REPLICATION replication name START AT SN xlog sender start sn QUICKSTART 2 1 3 2 Description This statement is used to start an XLog Sender When using the UNIX domain protocol the socket filename is automatically generated accord ing to the pattern shown below Socket Filename SALTIBASE HOME trc rp replication name Unlike in Replication an XLog Sender is not registered in the HeartBeat thread when started Unlike the Replication Sender an XLog Sender can start from the SN specified in the AT SN clause xlog sender start sn is the SN of the XLog from which to start tr
61. chapter describes the concept behind the ALTIBASE HDB Log Analyzer and explains in simple terms how to use it 1 Introduction 1 1 ALTIBASE HDB Log Analyzer 1 1 ALTIBASE HDB Log Analyzer The ALTIBASE HDB Log Analyzer comprises a module that is included with ALTIBASE HDB for use in providing a history of database DML transactions on the basis of active logs an external module that is connected to the internal module and an API that is provided for using XLogs The ALTIBASE HDB Log Analyzer can be used 1 tolink ALTIBASE HDB with other DBMS products and 2 todetect changes within ALTIBASE HDB from outside so as to respond to these changes in the desired manner 1 1 1 Terms amp Concepts 1 1 1 1 XLog An XLog is a logical form of log that results from the conversion of a physical log It is used to store a history of transactions involving DML INSERT UPDATE and DELETE statements such that it can be accessed by users 1 1 1 2 XLog Sender The XLog Sender is the module that analyzes active logs to create XLogs which it then passes to the XLog Collector The XLog Sender actively performs handshaking and XLog transmission 1 1 1 3 XLog Collector The XLog Collector is the module that receives meta data and XLogs from the XLog Sender The XLog Collector comprises meta data an XLog queue a transaction table and an XLog pool It is called via the Log Analysis API 1 1 1 4 Log Analysis API The Log Analysis API is used to
62. converts ALTIBASE HDB data into string form For date time type data the output string format is YYYY MM DD HH MI SS SSSSSS BIT type data are converted to the BIT value format and VARBIT type data are converted to the VARBIT value format NCHAR or NVARCHAR type data are always converted to the UCS 2 UTF 16 character set 4 29 5 Considerations In order to convert NCHAR or NVARCHAR type data between different character sets it is necessary to set the value of the ALTIBASE ALA NCHARSET environment variable on the server on which the logs will be analyzed i e on the XLog Collector side to the value of the national character set on the server from which the data originate i e on the XLog Sender side LogAnalyzer User s Manual 92 4 29 ALA GetAltibaseText For example if the character set for NCHAR and NVARCHAR type data is set to UTF8 on the server acting as the data source execute the following on the server on which the logs will be analyzed export ALTIBASE ALA NCHARSET UTF8 Then when the ALA GetAltibaseText function is executed on NCHAR or NVARCHAR type data the data written to aOutBuffer are in UCS 2 UTF 16 form ex 0031 0020 0020 0020 This function cannot be used with BLOB CLOB or GEOMETRY type data 4 29 6 Related Function ALA GetAltibaseSOL 4 29 7 Example include alaAPI h void testAltibaseText ALA Table aTable ALA XLog aXLog SChar sBuffer 1024 Obtain Altibase SQL void ALA Ge
63. e used to query the status of Replication objects are also used to query the status of the XLog Sender For complete descriptions of these meta tables please refer to the ALTI BASE HDB General Reference 2 2 1 SYSTEM SYS REPLICATIONS _ This meta table contains information on the settings and status of the XLog Sender A value of 1 in the ROLE column indicates that the Replication object is an XLog Sender 2 2 2 SYSTEM SYS REPL HOSTS This meta table contains information on the XLog Collector to which the XLog Sender will connect For a host that was specified using the UNIX domain protocol the value in the HOST IP column is UNIX DOMAIN and the value in the PORT NO column is the same as the value in the HOST NO column 2 2 3 SYSTEM SYS REPL ITEMS This meta table contains information on the tables for which the XLog Sender sends XLogs LogAnalyzer User s Manual 22 2 3 Performance Views 2 3 Performance Views The performance views that are used to query the status of Replication objects are also used to query the status of the XLog Sender For complete descriptions of these performance views please refer to the ALTIBASE HDB General Reference 2 3 1 VSREPEXEC This performance view displays information about the Replication port and the use of multiple Rep lication threads 2 3 2 VSREPSENDER This performance view displays information on the status of the XLog Sender When using the UNIX domain protocol the va
64. eiveXLog ALA SendACK 0x51019 Failed to remove a network protocol 0x5101A Failed to finalize the network environ ment 0x51017 The network session has already been ALA ReceiveXLog terminated ALA SendACK 0x51018 The network protocol is unfamiliar ALA Handshake ALA ReceiveXLog 0x51016 Failed to read from the network 0x5101B Failed to write to the network ALA Handshake ALA SendACK 0x5101C Failed to flush the network 0x51015 A network timeout and thus a probable ALA Handshake network error has occurred 0x5102C Failed to add a network session ALA Handshake 0x51024 Protocol versions are mismatched ALA Handshake 0x51027 Failed to allocate a link ALA Handshake 0x51028 Failed to listen for a link ALA Handshake 0x51029 Failed to wait for a link ALA Handshake 0x5102A Failed to accept a link ALA Handshake 0x5102B Failed to set a link ALA Handshake 0x51022 Failed to shut down a link ALA Handshake ALA DestroyXLogCollector 0x51023 Failed to free a link 0x51012 The meta information does not exist ALA Handshake ALA GetXLog ALA GetReplicationInfo ALA GetTablelnfo ALA GetTablelnfoByName 0x5103F The table information does not exist ALA GetXLog 0x51040 The column information does not exist ALA GetXLog LogAnalyzer User s Manual 108 Error Code Table Error Code Description Can be returned by 0x52034 Log Analysis API Environment Create ALA InitializeAPI Failed
65. ender The XLog Sender is managed using ALTIBASE HDB SQL statements that are normally used to man age Replication The following descriptions highlight only the differences in how these statements are used when they are used to manage the XLog Sender For complete descriptions of these state ments please refer to the Replication Manual and to the SQL Reference 2 1 1 Creating an XLog Sender This task is accomplished using the CREATE REPLICATION ALTIBASE HDB SQL statement 2 1 1 1 Syntax CREATE REPLICATION replication name FOR ANALYSIS WITH remote host ip remote host port no UNIX DOMAIN FROM user name table name TO user name table name FROM user name table name TO user name table name uu 2 1 1 2 Description This statement is used to create an XLog Sender The XLog Sender is automatically created in LAZY mode EAGER mode cannot be specified when creating an XLog Sender Unlike Replication it is possible to specify a UNIX domain connection This is accomplished by specifying UNIX DOMAIN in the WITH clause It is acceptable to specify tables with foreign keys in the FROM clause With the above exceptions the use of this statement with an XLog Sender is the same as in Replica tion 2 1 1 3 Consideration The UNIX domain connection protocol can only be used in UNIX and Linux 2 1 1 4 Example Create an XLog Sender named og analysis that uses the TCP IP protocol to send information about table t7 whi
66. ender will connect It is used when ALA Handshake is called xlog ip stack can be specified when socket type is set to TCP This indicates the kind of Inter net Protocol Stack to be used If it is not specified an Internet Protocol Stack that supports only IPv4 will be used This is the default If itis set to 0 an Internet Protocol Stack that supports only IPv4 will be used If itis set to 1 a dual stack i e an Internet Protocol Stack that supports both IPv4 and IPv6 will be used If itis set to 2 an Internet Protocol Stack that supports only IPv6 will be used aACKPerXLogCount is used when ALA SendACK is called The following must be taken into consideration when the transaction XLogs are obtained in the order in which transactions were committed Because XLogs for a given transaction accumulate in the transaction table until the cor responding COMMIT XLog arrives the size of the XLog Pool must be set sufficiently large In other words more memory space is required No XLogs for a transaction can be obtained until after the corresponding COMMIT XLog has been received In other words the time interval between the time that an XLog arrives and the time that it is actually processed increases This means that a decrease in performance is highly likely in situations in which individual transactions are used for batch processing If the number of XLogs for which ACK is to be sent out is set to a number greate
67. er char sSocketInfo 128 XLog Sender Collector Socket Information SOLCHAR sConInfo 128 ODBC Connection Information unsigned int sStep 0 BRR KR KR KR RK RR RR RR RR RK kk e RR RRR RR AA RK RR RRR RRR RR RR RR KK RR ke ke RR KKK Altibase ODBC Initialization KR KR KK KR RK KR KR RR RRR RR RR RK SA If you call SQLAllocEnv that is included in Altibase ODBC you have to set ALA TRUE to the first parameter when you call ALA IntializeAPI if SQLAllocEnv amp gEnv SOL SUCCESS goto FINALYZE sStep 1 if SOLAllocConnect gEnv amp gDbc SQL SUCCESS goto FINALYZE sStep 2 memset sConInfo 0x00 128 sprintf char sConInfo DSN s UID SYS PWD MANAGER PORT NO d SLAVE IP SLAVE PORT if SQLDriverConnect gDbc NULL sConInfo SQL NTS NULL 0 NULL SOL DRIVER NOPROMPT SOL SUCCESS printSqlErr gDbc gStmt goto FINALYZE sStep 3 LogAnlyzer User s Manual 112 Autocommit OFF if SOLSetConnectAttr gDbc SOL ATTR AUTOCOMMIT SOL POINTER SQL AUTOCOMMIT OFF 0 SOL SUCCESS printSqlErr gDbc gStmt goto FINALYZE BRR RR RK RK RR KR RR KR RK AAA RK RRR RR RR RK RR RR KR RRR RR RR k RR RR RR ke ke KKK ALA Initialization SSA Initialize Error Manager void ALA ClearErrorMgr amp sErrorMgr Initialize ALA API environment if ALA InitializeAPI ALA TRUE amp sErrorMgr ALA SUCCESS
68. erence to sample code This section describes the conventions used in this manual Understanding these conventions will make it easier to find information in this manual and in the other manuals in the series There are two sets of conventions Syntax Diagram Conventions Sample Code Conventions In this manual the syntax of commands is described using diagrams composed of the following ele ments Element Description Indicates the start of a command If a syntactic element starts with an arrow it is not a complete command Reserved word Indicates that the command continues to the next line If a syntactic element ends with this symbol it is not a complete command Indicates that the command continues from the previous line If a syntactic element starts with this symbol it is not a com gt plete command Indicates the end of a statement iii Preface About This Manual Element Description Indicates a mandatory element SELECT Indicates an optional element NOT Indicates a mandatory element comprised of options One and only one option must be specified ADD DROP Indicates an optional element comprised of options ASC DESC Indicates an optional element in which
69. ers that coexist in a single Altibase database cannot exceed 32 The same version of the ALTIBASE HDB Replication protocol must be used for both Replication and the Log Analysis API If more than one XLog Collector is being used within a single process the Replication protocol version in all associated Altibase databases must be the same as the Replication protocol ver sion being used by the Log Analysis API However the Log Analyzer differs from Replication in the following ways The Log Analyzer can be used with tables having foreign keys Only Lazy Mode is supported for use with the Log Analyzer Replication SYNC is not supported For more information on Replication please refer to the Replication Manual LogAnalyzer User s Manual 6 1 2 How to Use the Log Analysis API 1 2 How to Use the Log Analysis API This section explains how to use the Log Analysis API which is provided for use in client applications For complete information on the use of the XLog Sender please refer to 1 1 1 2 XLog Sender 1 2 1 Required Files Table 1 1 Required Files File Type Filename Description Header alaAPl h This file must be included when authorizing a client program using the Log Analysis API It includes the alaTypes h file alaTypes h This file contains the definitions of data types and macros that are necessary when writing a client program using the Log Analysis API Library libala_sl x This is the Log Anal
70. g Analysis API 4 35 ALA GetErrorMessage LogAnalyzer User s Manual 106 Error Code Table Appendix A Error Codes Error Code Table The Log Analyzer error codes and the cause of each kind of error are set forth in the following table Error Code Description Can be returned by 0x50008 Returned in response to an attempt to ALA ReceiveXLog begin a transaction that is already active ALA GetXLog 0x5000A Failed to initialize a mutex ALA CreateXLogCollector ALA Handshake 0x5000B Failed to remove a mutex ALA Handshake ALA DestroyXLogCollector 0x5000C Failed to lock a mutex ALA AddAuthlnfo ALA_RemoveAuthInfo 0x5000D Failed to unlock a mutex ALA Handshake ALA_ReceiveXLog ALA_GetXLog ALA_SendACK ALA_FreeXLog ALA DestroyXLogCollector ALA GetXLogCollectorStatus Error Code Description Can be returned by 0x51006 Failed to allocate memory All Log Analysis API functions 0x5101E Failed to allocate memory in pool ALA_ReceiveXLog 0x5101F Failed to free memory in pool ALA_Handshake ALA_ReceiveXLog ALA_FreeXLog ALA DestroyXLogCollector 0x51020 Failed to initialize the memory pool ALA CreateXLogCollector 0x51021 Failed to remove the memory pool ALA DestroyXLogCollector Error Codes Error Code Table Error Code Description Can be returned by 0x51013 Failed to initialize the network environ ALA Handshake ment ALA Rec
71. gs 3 3 ALTIBASE HDB Data Types and Internal Structure 3 3 1 FLOAT NUMERIC 3 3 1 1 Internal Structure The internal data structures of the FLOAT and NUMERIC types are the same typedef struct mtdNumericType UChar length Length of signExponent mantissa UChar signExponent Sign and Exponent UChar mantissa 1 UChar Array Base 100 mtdNumericType To determine the sign and exponent of a FLOAT or NUMERIC value call ALA GetInternalNumericInfo or check the values of the mtdNumericType structural elements as shown below 3 3 1 2 Obtaining the sign from mtdNumericType if signExponent is 128 255 Sign else if signExponent is 0 127 Sign 3 3 1 3 Obtaining the exponent from mtdNumericType This is the exponent of a decimal number if signExponent is 128 255 Exponent SInt signExponent amp Ox7F 64 2 mantissa 0 lt 10 1 0 else if signExponent is 0 127 Exponent 64 SInt signExponent amp Ox7F 2 mantissa 0 gt 90 1 0 3 3 1 4 Obtaining the mantissa from mtdNumericType The value of each UChar ranges from 0 and 99 inclusive that is each UChar is a base 100 number The result is a number between 0 and 1 if Sign is Example 01 23 45 67 89 gt 0 123456789 12 34 56 78 99 gt 0 1234567899 mantissa 0 if mantissa 0 10 LogAnalyzer User s Manual 34 3 3 ALTIBASE HDB Data
72. is recommended that those reading this manual possess the following background knowledge Basic knowledge in the use of computers operating systems and operating system utilities Experience in using relational databases and an understanding of database concepts Computer programming experience Experience in database server operating system or network administration Software Environment This manual has been prepared assuming that ALTIBASE HDB 5 5 1 will be used as the database server Organization This manual is organized as follows Chapter1 Introduction This chapter describes the concept behind the ALTIBASE HDB Log Analyzer and explains in simple terms how to use it Chapter2 The XLog Sender This chapter explains how to use the XLog Sender which is one of the components of the ALTI BASE HDB Log Analyzer Chapter3 Analyzing XLogs This chapter describes XLogs meta data and the ALTIBASE HDB internal data types all of Log Analyzer User s Manual ii About This Manual which are required in order to analyze XLogs Chapter4 Log Analysis API This chapter describes how to use the Log Analysis API component of the ALTIBASE HDB Log Analyzer Appendix A Error Codes This appendix describes the Log Analyzer error codes and the cause of each kind of error Appendix B Sample Code This appendix explains the location ofthe sample applications and provides a brief description of the use of the Log Analyzer with ref
73. is used when ALA ReceiveXLog is called The default XLog reception timeout is 10 seconds 4 9 5 Related Function ALA ReceiveXLog 4 9 6 Example Please refer to ALA Handshake 57 Log Analysis API 4 10 ALA Handshake 4 10 ALA Handshake 4 10 1 Syntax ALA RC ALA Handshake ALA Handle aHandle ALA ErrorMgr aOutErrorMgr 4 10 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutErrorMgr This is an Error Manager structure 4 10 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 10 4 Description This function is used to tell the XLog Collector to listen for the XLog Sender and perform handshak ing With the exception of user settings and the XLog Pool all of the data in the XLog Collector are initial ized Meta data about the target tables are received and stored internally 4 10 5 Considerations When the connection type is TCP and the authentication information does not match hand shaking will fail If the peer being connected to is not an XLog Sender handshaking will fail If a connection with an XLog Sender is not established within the specified handshaking time out period a timeout event will occur ALA_ReceiveXLog ALA_GetXLog and ALA_SendACK must not be called before handshak ing is completed Before commencing handshaking ALA_FreeXLog must be executed for all XLogs that were obtained using ALA_GetXLog in order
74. kkkkk kkkkkkkkkkk Replication to Altibase DBMS Sample based on Committed Transaction Only kkxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk include lt string h gt include lt stdlib h gt include lt stdio h gt Include Altibase ODBC header include lt sglcli h gt Include Altibase Log Analysis API header include lt alaAPI h gt User specific Definitions define QUERY SIZE 4196 SQL Query Buffer Size 111 define ALA LOG FILE ALA1 log Log File Name define ALA NAME ALA1 XLog Sender Name define SOCKET TYPE TCP TCP or UNIX define PEER IP 127 0 0 1 TCP XLog Sender IP define MY PORT 47146 TCP XLog Collector Listen Port define SLAVE IP 127 0 0 1 ODBC Target Altibase DBMS IP define SLAVE PORT 43146 ODBC Target Altibase DBMS Port Get XLog from XLog Sender after handshake with XLog Sender ALA RC runXLogCollector ALA Handle ALA ErrorMgr And apply XLog to Altibase DBMS ALA RC applyXLogToAltibase ALA Handle ALA XLog ALA ErrorMgr Print error to console void printSqlErr SQLHDBC SQLHSTMT void printAlaErr ALA ErrorMgr aErrorMgr ODBC variables SOLHENV gEnv SOLHDBC gDbc SOLHSTMT gStmt Start function int main void ALA Handle sHandle XLog Collector Handle ALA ErrorMgr sErrorMgr Error Manag
75. lErr gDbc gStmt void SOLFreeStmt gStmt SOL DROP return ALA FAILURE void SQLFreeStmt gStmt SOL DROP return ALA SUCCESS void printSqlErr SQLHDBC aDbc SQLHSTMT aStmt SOLINTEGER errNo SOLSMALLINT msgLength SOLCHAR errMsg 1024 if SOLError SOL NULL HENV aDbc aStmt NULL amp errNo errMsg sizeof errMsg amp msgLength SQL SUCCESS printf SQL Error d s n int errNo char errMsg void printAlaErr ALA ErrorMgr aErrorMgr char sErrorMessage NULL int sErrorCode void ALA GetErrorCode aErrorMgr unsigned int amp sErrorCode void ALA GetErrorMessage aErrorMgr const signed char amp sErrorMes sage printf ALA Error d s n sErrorCode sErrorMessage LogAnlyzer User s Manual 118 Index A ABORT Errors 107 Adding a Host 19 Adding a Table for Analysis 18 ALA AddAuthlnfo 52 ALA ClearErrorMgr 99 ALA CreateXLogCollector 48 ALA DestroyAPI 44 ALA DestroyXLogCollector 68 ALA DisableLogging 47 ALA EnableLogging 45 ALA FreeXLog 67 ALA GetAltibaseSOL 94 ALA GetAltibaseText 92 ALA GetColumnlInfo 86 ALA GetErrorCode 101 ALA GetErrorLevel 103 ALA GetErrorMessage 105 ALA GetIndexInfo 88 ALA GetlnternalNumericInfo 90 ALA GetODBCCValue 96 ALA GetProtocolVersion 78 ALA GetReplicationInfo 79 ALA GetTablelnfo 82 ALA GetTablelnfoByName 84 ALA GetXLog 63 ALA GetXLogCollectorStatus 69 ALA GetXLogColumn 75 ALA GetXLogHeader 72 ALA GetXLogL
76. lU s ii tintas 96 2 3 VAL DSscHDtlOD naa 96 2 31 5 Considerations reete A A ee Ce or A A 97 431 6 C100 ini iia 97 4 32 AL A Clea EOM O e e ee ee et d eel PRO A eR ted dut 99 A qc M 99 4 32 2 Arg Ime nts AN 99 4 32 3 Possible Result Valles 99 D UC A DOSCIIPti ON ED RE P 99 4 32 5 ConslderatiOri 2 c RR ee o Pere e s te eto uo on re e CR bae tee Peto Reis 99 4 32 6 Related F nctlOlns ie tte tte ERR C dcus e occae ree Rot 99 4 327 Example uci OR 99 4 33 ALA GetErrorCode 101 433 N SYNIR ER MM NETS 101 A 33 2 ArOUM ENTS arnes R 101 433 3 Possible REUS 101 4 3 3 4 DeSCriptiOnescassissssssesscssscassssasecacssdcsssseasssesecssscessasassescssdscessvsaazssatssscunsussaseaseadaascussussiasss abcedessasinsossdsendaassvacascaagsssouenyacas 101 433 5 CONSIAESLATIONS asescccasessssscscceccssesstpvaasouscecsnvesssaaescasacesunsspvaasouschseeaussvasonscusstassosnruasnsscossdasvosnsscnisensnvonssccabssnshavonsoscieeles 101 7 33 6 Related FUNCION cs 101 433 Example RAN 102 434 AVA GetErrorbevel cic ett rase escas e citado 103 4 34 A O RN 103 4 342 Arg mie nite ee temere A Aia 103 4 34 3 Possible Result Values tr ec e S ebbe e ie PR a oe RU RARO 103 4 34 4 DescrIptiOn e et ee eri tesi emet eere ves eese Pari dde pena OK P O 103 434 5 ConsidefatioN RR O 103 4 34 6 Related FO oett oo de ee S ei tao rene uses on aea oec ni 103 4 347 EK AIM PS sedisse
77. le logging void ALA DisableLogging NULL Remove Log Analysis API Environment void ALA DestroyAPI ALA FALSE NULL LogAnalyzer User s Manual 46 4 4 ALA DisableLogging 4 4 ALA DisableLogging 4 4 1 Syntax ALA RC ALA DisableLogging ALA ErrorMgr aOutErrorMgr 4 4 2 Arguments Argument Description aOutErrorMgr This is an Error Manager structure 4 4 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 4 4 Description This function disables logging 4 4 5 Considerations If logging has not been enabled calling this function will result in an error Calling another Log Analysis API function while execution of this function is underway will cause unexpected behavior 4 4 6 Related Function ALA EnableLogging 4 4 7 Example Please refer to ALA EnableLogging 47 Log Analysis API 4 5 ALA CreateXLogCollector 4 5 ALA CreateXLogCollector 4 5 1 Syntax ALA RC ALA CreateXLogCollector const SChar aXLogSenderName const SChar aSocketInfo SInt aXLogPoolSize ALA BOOL aUseCommittedTxBuffer UInt aACKPerXLogCount ALA Handle aOutHandle ALA ErrorMgr aOutErrorMgr 4 5 2 Arguments Argument Description aXLogSenderName This is the name of the corresponding XLog Sender length 1 40 aSocketlnfo This is the socket type TCP UNIX Domain aXLogPoolSize This is the maximum size of the XLog Pool unit the number
78. lue in the SENDER IP and PEER IP columns is UNIX DOMAIN and the value in the SENDER PORT and PEER PORT columns is 0 2 3 3 VSREPSENDER_TRANSTBL This performance view displays information about transaction tables 2 3 4 VSREPGAP This performance view displays information about which log file is currently being read by the XLog Sender 23 The XLog Sender 2 3 Performance Views LogAnalyzer User s Manual 24 3 Analyzing XLogs This chapter describes XLogs meta data and the ALTIBASE HDB internal data types all of which are required in order to analyze XLogs XLogs and meta data can be accessed using the Log Analysis API 25 Analyzing XLogs 3 1 XLogs 3 1 XLogs This section describes the various kinds of XLogs and their constituent elements In order to access XLogs it is necessary to call ALA GetXLog 3 1 1 Types of XLog typedef enum XLOG TYPE BEGIN 1 Transaction Begin XLOG TYPE COMMIT 2 Transaction Commit XLOG TYPE ABORT 3 Transaction Rollback XLOG TYPE INSERT 4 DML Insert XLOG TYPE UPDATE 5 DML Update XLOG TYPE DELETE 6 DML Delete XLOG TYPE SP SET 8 Savepoint Set XLOG TYPE SP ABORT 9 Abort to savepoint XLOG TYPE LOB CURSOR OPEN 14 LOB Cursor open XLOG TYPE LOB CURSOR CLOSE 15 LOB Cursor close XLOG TYPE LOB PREPAREAWRITE 16 LOB Prepare for write XLOG TYPE LOB PARTIAL WRITE 17 LOB Par
79. mplished using the ALTER REPLICATION ALTIBASE HDB SQL statement LogAnalyzer User s Manual 20 2 1 SQL Statements Used to Manage the XLog Sender 2 1 9 1 Syntax ALTER REPLICATION replication name SET HOST remote host ip remote port no 2 1 9 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 9 3 Considerations The newly set host will be used after the XLog Sender is restarted Only a host for which the connection type is TCP IP can be specified 2 1 9 4 Example Choose the XLog Collector having the IP address 127 0 0 1 and port number 20300 as the active host for an XLog Sender named log analysis iSOL gt ALTER REPLICATION log analysis SET HOST 127 0 0 1 20300 2 1 10 Flushing XLogs This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 10 1 Syntax ALTER REPLICATION replication name FLUSH ALL WAIT timeout sec 2 1 10 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 10 3 Consideration If the XLog Collector does not send ACK a timeout may occur 2 1 10 4 Example Flush the logs up to the log that was current at the time point at which the flush command was exe cuted for the XLog Sender named og analysis Specify a 10 second timeout iSOL gt ALTER REPLICATION log analysis FLUSH WAIT 10 21 The XLog Sender 2 2 Meta Tables 2 2 Meta Tables The meta tables that ar
80. multiple elements may be specified A comma must precede all but the first element ASC DESC E Sie The code examples explain SQL statements stored procedures iSQL statements and other com mand line syntax The following table describes the printing conventions used in the code examples Convention Meaning Example Indicates an optional item VARCHAR size FIXED VARIABLE Log Analyzer User s Manual About This Manual Convention Meaning Example Indicates a mandatory field for which one or more items must be selected ENABLE DISABLE COMPILE A delimiter between optional or mandatory arguments ENABLE DISABLE COMPILE ENABLE DISABLE COMPILE Indicates that the previous argu ment is repeated or that sample code has been omitted iSQL gt select e lastname from employees E LASTNAME Moon Davenport Kobain 20 rows selected Other symbols Symbols other than those shown above are part of the actual code EXEC pl 1 acc NUMBER 11 2 Italics Lower Case Let ters Statement elements in italics indi cate variables and special values specified by the user Indicate program elements set by the user such as table names col umn names file names etc SELECT FROM table name CONNECT userID password SELECT e lastname FROM employees Upper Case Let
81. n if sXLogHeader mType XLOG TYPE COMMIT void SQLEndTran SQL HANDLE DBC gDbc SQL COMMIT if ABORT XLog then Rollback Current Transaction else if sXLogHeader gt mType XLOG TYPE ABORT if REPL STOP XLog then Rollback Current Transaction else if sXLogHeader gt mType XLOG TYPE REPL STOP etc else void SQLEndTran SQL HANDLE DBC gDbc SQL ROLLBACK void SQLEndTran SQL HANDLE DBC gDbc SQL ROLLBACK Get Table Information if ALA GetTableInfo aHandle sXLogHeader gt mTableOID const ALA Table amp sTable aErrorMgr ALA SUCCESS printAlaErr aErrorMgr return ALA FAILURE Get Altibase SOL from XLog memset sOuery 0x00 QUERY SIZE if ALA GetAltibaseSQL sTable aXLog QUERY SIZE signed char sQuery aErrorMgr ALA SUCCESS printAlaErr aErrorMgr return ALA FAILURE In order to Apply Implicit Savepoint to Altibase DBMS S characters of Savepoint s Name has to be changed Unused in Committed Transaction Only if sXLogHeader mType XLOG TYPE SP SET sXLogHeader mType XLOG TYPE SP ABORT 117 while sImplictSPPos strchr sQuery NULL sImplictSPPos Apply SQL to DBMS with ODBC if SQLAllocStmt gDbc amp gStmt SOL SUCCESS return ALA FAILURE if SQLExecDirect gStmt SQLCHAR sQuery SOL NTS SOL SUCCESS printSq
82. n the XLog Queue the value of aOutXLog will be NULL 4 12 5 Consideration XLogs must be managed by the client application until ALA FreeXLog is called 4 12 6 Related Functions ALA ReceiveXLog ALA FreeXLog ALA GetXLogHeader ALA GetXLogPrimaryKey 63 Log Analysis API 4 12 ALA GetXLog ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB 4 12 7 Example Please refer to ALA Handshake LogAnalyzer User s Manual 64 4 13 ALA SendACK 4 13 ALA SendACK 4 13 1 Syntax ALA RC ALA SendACK ALA Handle aHandle ALA ErrorMgr aOutErrorMgr 4 13 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aOutErrorMgr This is an Error Manager structure 4 13 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 13 4 Description This function sends ACK to the XLog Sender ACK is not sent to the XLog Sender immediately at the time that this function is called Rather ACK is sent to the XLog Sender some time after this function is called when the number of successful calls to ALA GetXLog exceeds the number of XLogs for which ACK is to be sent out or when a KEEP ALIVE or REPL STOP XLog is received When a REPL STOP XLog is received the network connection is disconnected The ACK message contains the so called Restart SN The Restart SN is the SN having the lowest value among the following SNs The lowest XLog SN for active transactions that were
83. ndex 31 Analyzing XLogs 3 2 Meta Data The meta data include data about the Protocol Version Replication tables columns and indexes The mPKColumnArray element of the ALA Table structure is an array 0fALA Column pointers LogAnalyzer User s Manual 32 3 3 ALTIBASE HDB Data Types and Internal Structure 3 3 ALTIBASE HDB Data Types and Internal Structure This section describes the format in which the data are stored internally for each data type of ALTI BASE HDB Information about columns which is stored in the ALA Column structure can be accessed by calling ALA GetColumnlnfo whereas actual column values which are stored in the ALA Value structure can be accessed using the XLog Log Analysis API The actual column value is stored in the value element ofthe ALA Value structure whereas the length of the column value is stored in the Length element of the ALA Value structure Mean while the type of data stored in the column can be determined by checking the value of mDataType in the ALA Column structure Table 3 1 ALTIBASE HDB Data Types Category Data Type Constant Number FLOAT 6 NUMERIC 2 DOUBLE 8 REAL 7 BIGINT Ulnt 5 INTEGER 4 SMALLINT 5 Date Time DATE 9 Character Binary CHAR 1 VARCHAR 12 NCHAR Ulnt 8 NVARCHAR Ulnt 9 BYTE 20001 NIBBLE 20002 BIT Ulnt 7 VARBIT Ulnt 100 BLOB 30 CLOB 40 Spatial GEOMETRY 10003 33 Analyzing XLo
84. nscdcsebssbconsssntassehdageszessscabsndisien 2 111 Terms Se Concepts 3 ssa dedecesahua cucedaacessyuas E SEA E EAA aaas 2 1 1 2 How the ALTIBASE HDB Log Analyzer Works ssssscssssssccssesccsnsecsssescssseecssusecesusecesssecsssusecssnsecesnseessuecessueeessneeessne 3 11 3 Features of the Log Analyzer seiorn iiia Ed 5 PLA Limitati atinada 6 1 2 How to Use the Log Analysis API oo EURO 7 1 2 1 Required Files NA 1 2 2 Data Types 1 2 3 Error Handling WED ABASIC USE LM EE EN 9 T 3 Summiary of th Log Analysis API eusina e ASAE EE E EE E E E Eiai Neasa 12 1 3 1 Log Analysis API Environment Management u scsssssccsssscsssessecssecseneecsssecesssseccsnecessuececsueeccsneceseenecssneeeesnseees 12 1 32 XL09 Collector Mana ida 12 1 3 3 XLog Analysis 8 Conversion z 1 3 4 Error Handling 14 2 The XLog Sender eere eee eese testes eene tenete senatu 15 2 1 SQL Statements Used to Manage the XLog Sendel sssscssssccsssssessssccsecssnssscssseccesueecssneceesnseceesuecsssecesasecssueeeesaseeseneeesees 16 2 11 Creating an XLog Sender india 16 2 172 Deleting MALO ii t RR HERREN UR UR HAAS SIR ed 17 2 13 Starting an XLOg ii deett deter en re ete ente ende 17 2 1 4 Stopping an XLog Sender e 2 1 5 Adding a Table to a Log Analysis Task 18 2 1 6 Removing a Table from a Log Analysis Task E 2 1 7 Adding cl 2 1 8 Remowving a FlOSt
85. or use in the C and C languages are described in detail in this chapter 41 Log Analysis API 4 1 ALA InitializeAP 4 1 ALA InitializeAPI 4 1 1 Syntax ALA RC ALA InitializeAPI ALA BOOL ALA ErrorMgr aOutErrorMgr aUseAltibaseODBCDriver 4 1 2 Arguments Argument Description aUseAltibaseODBCDriver This indicates whether the ODBC driver of ALTIBASE HDB is being used aOutErrorMgr This is an Error Manager structure 4 1 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 1 4 Description This creates an environment in which the Log Analysis API can be invoked 4 1 5 Considerations With the exception of ALA ClearErrorMgr no other Log Analyzer API functions can be called before this function If execution of this function fails it will be impossible to use the Log Analysis API When using the ODBC Driver of ALTIBASE HDB it is necessary to call SOLAllocEnv before call ing this fu nction 4 1 6 Related Function ALA DestroyAP 4 1 7 Example include lt sqlcli h gt LogAnalyzer User s Manual 42 include lt alaAPI h gt When the Altibase ODBC driver is not used void testAPIEnvironmentl Create Log Analysis API Environment void ALA InitializeAPI ALA FALSE NULL Invoke Log Analysis API Remove Log Analysis API Environment void ALA DestroyAPI ALA FALSE NULL When the Altibase ODBC driver is used
86. r ip is from 1 to 39 bytes 4 6 5 Considerations This function can only be called when the socket type is set to TCP Up to 32 different pieces of XLog Sender authentication information can be specified 4 6 6 Related Functions ALA CreateXLogCollector ALA RemoveAuthlnfo ALA Handshake LogAnalyzer User s Manual 52 4 6 ALA AddAuthlnfo 4 6 7 Example Please refer to ALA CreateXLogCollector 53 Log Analysis API 4 7 ALA RemoveAuthlnfo 4 7 ALA RemoveAuthlnfo 4 7 1 Syntax ALA RC ALA RemoveAuthInfo ALA Handle aHandle const SChar aAuthInfo ALA ErrorMgr aOutErrorMgr 4 7 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aAuthlnfo This is the XLog Sender authentication information aOutErrorMgr This is an Error Manager structure 4 7 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 7 4 Description This function removes the specified XLog Sender authentication information When the connection type is TCP aAuthinfo is a string having the format PEER IP xlog sender ip The valid length of xlog sender ip is from 1 to 39 bytes 4 7 5 Considerations This function can only be called when the socket type is set to TCP At least one piece of XLog Sender authentication information is required 4 7 6 Related Functions ALA_CreateXLogCollector ALA AddAuthlnfo ALA Handshake LogAnalyzer User s Manual 54 4
87. r than 1 one ACK may not be sent to the XLog Sender even when ALA SendACK is called When the socket type is set to TCP the listen port must not be being used by any other pro cess When the socket type is set to UNIX the value of the ALTIBASE HOME environment variable must be set the same as in the Altibase database to which the XLog Sender belongs Addition ally since the maximum allowable length of the socket filename varies depending on the operating system be sure to check and avoid exceeding the maximum allowable length on your system 49 Log Analysis API 4 5 ALA 4 5 6 R CreateXLogCollector elated Functions ALA AddAuthInfo ALA RemoveAuthlnfo ALA DestroyXLogCollector 4 5 7 E xample include alaAPI h void testXLogCollectorTCP ALA Handle sHandle RA ox o vo E ook x Create XLog Collector that uses TCP XLog Sender Name log analysis XLog Sender Authentication Information IP 127 0 0 1 Listening Port The max size of XLog Pool Obtain transaction XLog in the order of commit The reference number of XLog for which ACK will be sent out void ALA CreateXLogCollector log analysis SOCKET TCP PEER IP 127 0 0 1 MY PORT 30300 10000 ALA FALSE 100 amp sHandle NULL Adde XLog Sender Authentication Information void ALA AddAuthInfo sHandle PEER IP 127 0 0 2 NULL Remove XLog Sender Authentication Information
88. replication is started For more information please refer to the description of the ALTER REPLI CATION statement in the Replication Manual 1 1 2 How the ALTIBASE HDB Log Analyzer Works The location of the XLog Sender is within an Altibase database It creates XLogs based on active logs and sends the XLogs along with related meta data to the XLog Collector The XLog Collector exists within a client application and provides end users with the XLogs and meta data via the Log Analy sis API If for some reason a call to the Log Analysis API fails it is of course necessary to take suitable mea sures depending on the cause of the error The most recent error information is stored in the Error Manager Additionally the Log Manager is provided for use in tracing errors The Log Manager records simple trace and error information in the log files that are specified when the Log Manager is created The overall structure is shown in the following illustration 3 Introduction 1 1 ALTIBASE HDB Log Analyzer Figure 1 1 The Structure of the ALTIBASE HDB Log Analyzer UPDATE INSERT DELETE Error Manager Altibase DBMS Meta KLog The Log Analysis API can be used to obtain XLogs and related meta data from the XLog Collector The XLog Collector receives these meta data from the XLog Sender at the time of handshaking between the XLog Sender and the XLog Collector The meta data are valid until the next time hand shaking is performed
89. ruc tures Each of these elements can be read either by accessing the ALA XLog structure directly or via the XLog Log Analysis API ALA XLogPrimaryKey does not actually contain the primary key column ID array values These values can be accessed as individual mColumnID values in the mPKColumnArray sIndex array element in the ALA Table structure that contains meta data about the table The meta data in turn can be accessed using either ALA GetTablelnfo or ALA GetTablelnfoByName Q 3 1 3 Configuration Based on XLog Type The type of XLog can be determined by checking the value of the mType member of the ALA XLogHeader structure 3 1 3 1 BEGIN XLog Header mType mTID mSN mSyncSN 3 1 3 2 COMMIT XLog Header mType mTID mSN mSyncSN 3 1 3 3 ABORT XLog Header mType mTID mSN mSyncSN 3 1 3 4 INSERT XLog Header mType mTID mSN mSyncSN mTableOID Column mColCnt mCIDArray mAColArray 3 1 3 5 UPDATE XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray Column mColCnt mCIDArray mBColArray mAColArray LogAnalyzer User s Manual 28 3 1 XLogs 3 1 3 6 DELETE XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray 3 1 3 7 SP SET XLog Header mType mTID mSN mSyncSN Savepoint mSPNameLen mSPName If mSPName begins with SSIMPLICIT it is an implicit savepoint If mSPName is SSPSM SVP itis a PSM Savepoint 3 1 3 8 SP ABOR
90. sPKColumn sTable gt mPKColumnArray sPKColumnPos Fatal Error Error in Log Analysis API break Process primary key column Process column for sColumnPos 0 sColumnPos lt sTable gt mColumnCount sColumnPos Obtain column information by column ID void ALA GetColumnInfo sTable sTable gt mColumnArray sColumnPos mColumnID amp sColumn NULL if sColumn amp sTable mColumnArray sColumnPos Fatal Error Error in Log Analysis API break Process column Process Index for sIndexPos 0 sIndexPos lt sTable mIndexCount sIndexPos Obtain index information by index ID void ALA GetIndexInfo sTable sTable gt mIndexArray sIndexPos mIndexID amp sIndex NULL if sIndex amp sTable gt mIndexArray sIndexPos Fatal Error Error in Log Analysis API break Process index 81 Log Analysis API 4 24 ALA GetTablelnfo 4 24 ALA GetTablelnfo 4 24 1 Syntax ALA RC ALA GetTableInfo ALA Handle ULong const ALA Table ALA ErrorMgr aHandle aTableOID aOutTable aOutErrorMgr 4 24 2 Arguments Argument Description aHandle This is the handle of the XLog Collector aTableOID This is the OID of the table for which to retrieve the information aOutTable This is information about the table aOutErrorMgr This is an Error Manager structure 4 24 3 Possible
91. ssible Result Values ti eee e eie tried ee E a eR e ddd ere E ou 79 4 23 4 Description e ere n eret este ed eret E ue estet O 79 4 23 5 ConsidefatiOrs oco cele nn II 79 423 6 Related FUNCIONS ii idee eee ri a e c Nt oe Ee hec 79 4 237 Example rccte O O REA DATE NER ERU n 80 A QAALA Get Tab lel ito a E beet e E a deg 82 4 241 SYNTAX A onod ka 82 A HARDER RR PR dod ROA 82 4 24 3 Possible Result Values intet nea Tn n tto cT aep aos o etat 82 ADA A DESCriPL ON emm 82 424 5 ConslideratiOriSs aoi ica scetur eae ta P cipe oerte aa 82 4246 Related FUNCTIONS DR bae An al 82 LITE MM Mn o ree ster oe or eed 83 425 AE A GetTablelntoByNamie eit a TRE REESE HER CREE SR d 84 4 25 Syntax ceste AS 84 4 25 2 Arguments 84 4 25 3 Possible Result Values 94 4 25 4 Description 11 84 4 25 5 Considerations 84 4 25 6 Related Functions 85 4 25 7 Example 85 4 26 ALA GetColumninfo 1 86 4 26 V SYNTAX qu M 86 426 2 NEP pe 86 4 26 3 Possible Result Val es i n 86 4 264 DescriptlODu soie te ern tbe evite a di 86 4 26 5 Consideratiofis ca e E D e d d tbe Re boa da e aco ue 86 A26 6 Related Functions ee o esa 87 426 7 Example E uum 87 ADT ALA GetlndexXlInfo i e ee RI 88 4 27 1 Qr gm 88 4 22 Arguments en biet ro iare Ur PENA RV e UMEN UM ee QN ERE be COL RERBA Adnan A ese HaT 88 427 3 Possible Result Values
92. structure 4 26 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 26 4 Description This function retrieves the information about the column identified by the specified Column ID in the specified table 4 26 5 Considerations If there are no meta data corresponding to the specified column or the specified table this function returns NULL for the aOutColumn argument Any meta data that were obtained using this function before handshaking was performed should not be used again after handshaking as the information might be out of date LogAnalyzer User s Manual 86 4 26 ALA GetColumninfo 4 26 6 Related Functions ALA Handshake ALA GetReplicationlnfo ALA GetTablelnfo ALA GetTablelnfoByName ALA GetIndexInfo 4 26 7 Example Please refer to ALA GetReplicationInfo 87 Log Analysis API 4 27 ALA GetlndexInfo 4 27 ALA GetIndexInfo 4 27 1 Syntax ALA RC ALA GetIndexInfo const ALA Table aTable UInt aIndexID const ALA Index aOutIndex ALA ErrorMgr aOutErrorMgr 4 27 2 Arguments Argument Description aTable This is the meta information aboutthe table containing the index for which to retrieve the information alndexID This is the ID of the index for which to retrieve the infor mation aOutlndex The index information is returned in this argument aOutErrorMgr This is an Error Manager structure 4 27 3 Possible Result Values ALA SUCCESS ALA FAILUR
93. t ALA SetReceiveXLogTimeout y STEP 3a Wait for a Connection to Xlog Sender and Handshaking ALA Handshake Y STEP 3b Obtain Xlog ALA_ReceiveXLog ALA_GetXLog STEP 3c Analyze and Convert Xlog Please refer to XLog Analysis amp Conversion API Y STEP 3d Remove Xlog and Send ACK ALA_FreeXLog ALA_SendACK Repeat until Xlog Sender ends S STEP 4 Remove XLog Collector ALA_DestroyXLogCollector Y STEP 5 Finish Logging and Remove Environment which was created to invoke the Log Analysis API ALA_DisableLogging ALA_DestroyAPI The following must be kept in mind when using the Log Analysis API The XLog Collector can be monitored from Step 3a to Step 3d The Error Handling API is used in all steps When using more than one XLog Collector Steps 2 to 4 must be performed for each XLog Col lector ALA SendACK does not have to be called for every iteration of Step 3 For a detailed explana tion of when it is necessary to send ACK please refer to the descriptions of the ALA CreateXLogCollector and ALA SendACK If in Step 3c the XLog is to be applied to the database using the ODBC interface AUTOCOM MIT must be set to OFF LogAnalyzer User s Manual 10 1 2 How to Use the Log Analysis API The XLog Sender must be started after STEP 3a In Step 3b ALA ReceiveXLog and ALA GetXLog do not have to be called by the same thread
94. t2 TO sys t2 2 1 7 Adding a Host This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 7 1 Syntax ALTER REPLICATION replication name ADD HOST remote host ip remote port no 19 The XLog Sender 2 1 SQL Statements Used to Manage the XLog Sender 2 1 7 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 7 3 Considerations It is impossible to add a host when the UNIX domain protocol has been specified as the connection type Furthermore when adding a host only TCP IP can be specified for the new host 2 1 7 4 Example Add a host having the IP address 127 0 0 1 and port number 30301 to an XLog Sender named log analysis iSOL gt ALTER REPLICATION log analysis ADD HOST 127 0 0 1 30301 2 1 8 Removing a Host This task is accomplished using the ALTER REPLICATION ALTIBASE HDB SQL statement 2 1 8 1 Syntax ALTER REPLICATION replication name DROP HOST remote host ip remote port no 2 1 8 2 Description The use of this statement with an XLog Sender is the same as in Replication 2 1 8 3 Consideration It is only possible to remove a host for which a TCP IP type connection has been specified 2 1 8 4 Example Remove a host having the IP address 127 0 0 1 and port number 30301 from an XLog Sender named og analysis iSOL gt ALTER REPLICATION log analysis DROP HOST 127 0 0 1 30301 2 1 9 Setting a Host This task is acco
95. tAltibaseSOL aTable aXLog 1024 sBuffer NULL 93 Log Analysis API 4 30 ALA GetAltibaseSQL 4 30 ALA GetAltibaseSQL 4 30 1 Syntax ALA RC ALA GetAltibaseSQL ALA Table aTable ALA XLog aXLog UInt aBufferSize SChar aOutBuffer ALA ErrorMgr aOutErrorMgr 4 30 2 Arguments Argument Description aTable The table information for XLog aXLog XLog aBufferSize Buffer Size aOutBuffer Buffer aOutErrorMgr This is an Error Manager structure 4 30 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 30 4 Description This function is used to convert information in an XLog into an SOL string of ALTIBASE HDB For date time type data the output string format is YYYY MM DD HH MI SS SSSSSS BIT type data are con verted to the BIT value format and VARBIT type data are converted to the VARBIT value format NCHAR and NVARCHAR type data are converted to the UNISTR value format When an INSERT UPDATE or DELETE SQL statement is reconstructed from XLogs the target table in the SQL string is specified using the mToUserName and mToTableName elements of the aTable structure 4 30 5 Considerations This function cannot be used with BLOB CLOB or GEOMETRY type data This function may generate SQL that is incompatible with other DBMS products LogAnalyzer User s Manual 94 4 30 ALA GetAltibaseSQL 4 30 6 Related Function ALA GetAltibaseText 4 30 7 Example
96. tial write XLOG TYPE LOB FINISH2WRITE 18 LOB Finish to write XLOG TYPE KEEP ALIVE 19 Keep Alive XLOG TYPE REPL STOP 21 Replication Stop ALA XLogType There are 13 kinds of transaction related XLogs and two kinds of control related XLogs The first XLog for a given transaction is XLOG TYPE BEGIN and the last is either XLOG TYPE COMMIT or XLOG TYPE ABORT Because LOB data are typically voluminous a LOB update task can be associated with more than one XLog In such cases the LOB XLogs are received in the sequence shown below XLOG TYPE LOB CURSOR OPEN XLOG TYPE LOB PREPARE4WRITE XLOG TYPE LOB PARTIAL WRITE XLOG TYPE LOB FINISH2WRITE XLOG TYPE LOB CURSOR CLOSE The control related XLogs are KEEP ALIVE and REPL STOP The KEEP ALIVE XLog is sent by the XLog Sender to check whether the network connection is still valid when it has no XLogs to send The REPL STOP XLog indicates that the XLog Sender is shutting down normally After ALA SendACK is called the connection is terminated LogAnalyzer User s Manual 26 3 1 XLogs 3 1 2 XLog Structure typedef UInt ALA TID Transaction ID typedef ULong ALA SN Log Record SN typedef struct ALA Value Altibase Internal Data UInt length Length of value const void value ALA Value Structure Member Description length The length of the internal ALTIBASE HDB data value val
97. tored procedures are executed These savepoints are only maintained during the execution of stored procedures For more detailed information about stored procedures please refer to the Stored Procedures Manual Each kind of savepoint is managed separately and savepoint xlogs can be processed in applications depending on the circumstances 3 4 1 Example iSQL CREATE TABLE T1 I1 INTEGER PRIMARY KEY Create success iSQL INSERT INTO T1 VALUES 2 1 row inserted iSOL gt CREATE OR REPLACE PROCEDURE PROC1 AS BEGIN INSERT INTO T1 VALUES 1 SAVEPOINT EXPLICIT SP INSERT INTO T1 VALUES 2 INSERT INTO T1 VALUES 3 END Create success iSQL AUTOCOMMIT OFF Set autocommit off success iSQL EXEC PROC1 ERR 11058 The row already exists in a unique index 0006 INSERT INTO T1 VALUES 2 iSOL gt ROLLBACK TO SAVEPOINT EXPLICIT SP LogAnalyzer User s Manual 38 3 4 SAVEPOINT Rollback success 39 Analyzing XLogs 3 4 SAVEPOINT LogAnalyzer User s Manual 40 4 Log Analysis API This chapter describes how to use the Log Analysis API component of the ALTIBASE HDB Log Ana lyzer The Log Analysis API is an API that is invoked by a client application It provides functions for receiving XLogs from an XLog Sender and analyzing them In the following function descriptions any argument whose name begins with aOut is an output argument All of the Log Analysis API functions which are intended f
98. ue The internal ALTIBASE HDB data value typedef struct ALA XLogHeader XLog Header ALA XLogType mType XLog Type ALA TID mTID Transaction ID ALA SN mSN SN ALA SN mSyncSN Reserved ULong mTableOID Table OID ALA XLogHeader typedef struct ALA XLogPrimaryKey Primary Key UInt mPKColCnt Primary Key Column Count ALA Value mPKColArray Primary Key Column Value Array ALA XLogPrimaryKey typedef struct ALA XLogColumn Column Ulnt mColCnt Column Count UInt mCIDArray Column ID Array ALA Value mBColArray Before Image Column Value Array ALA Value mAColArray After Image Column Value Array ALA XLogColumn typedef struct ALA XLogSavepoint Savepoint UInt mSPNameLen Savepoint Name Length SChar mSPName Savepoint Name ALA XLogSavepoint typedef struct ALA XLogLOB LOB ULong mLobLocator LOB Locator of Altibase UInt mLobColumnID UInt mLobOffset UInt mLobOldSize UInt mLobNewSize UInt mLobPieceLen UChar mLobPiece ALA XLogLOB typedef struct ALA XLog XLog 27 Analyzing XLogs 3 1 XLogs ALA XLogHeader mHeader ALA XLogPrimaryKey mPrimaryKey ALA XLogColumn mColumn ALA XLogSavepoint mSavepoint ALA XLogLOB mLOB Used internally struct ALA XLog mPrev struct ALA XLog mNext ALA XLog An XLog structure consists of a header a primary key a column a savepoint and LOB related st
99. void testAPIEnvironment2 ALA BOOL aUseAltibaseODBCDriver SQLHENV sEnv NULL Create Altibase ODBC Environment void SQLAllocEnv amp sEnv Create Log Analysis API Environment void ALA InitializeAPI ALA TRUE NULL Invoke Altibase ODBC API and Log Analysis API Remove Log Analysis API Environment void ALA DestroyAPI ALA TRUE NULL Remove Altibase ODBC Environment void SOLFreeEnv sEnv 43 4 1 ALA InitializeAPI Log Analysis API 4 2 ALA DestroyAPI 4 2 ALA DestroyAPI 4 2 1 Syntax ALA RC ALA DestroyAPI ALA BOOL ALA ErrorMgr aOutErrorMgr aUseAltibaseODBCDriver 4 2 2 Arguments Argument Description aUseAltibaseODBCDriver This indicates whether the ODBC driver of ALTIBASE HDB was being used aOutErrorMgr This is an Error Manager structure 4 2 3 Possible Result Values ALA SUCCESS ALA FAILURE 4 2 4 Description This function terminates the environment that was created by calling ALA InitializeAPI 4 2 5 Considerations Regardless of the result value it will be impossible to call any of the Log Analysis API functions after this function has been called When using the ODBC Driver of ALTIBASE HDB this function must be called before SOL FreeEnv is called which is the last step in terminating the Log Analysis API environment 4 2 6 Related Function ALA InitializeAPI 4 2 7 Example Please refer to ALA Initi
100. with XLog Sender break return ALA FAILURE else If XLog is NULL then Receive XLog if sXLog NULL Receive XLog and Insert into Queue if ALA ReceiveXLog aHandle amp sDummyFlag aErrorMgr ALA SUCCESS printAlaErr aErrorMgr void ALA GetErrorLevel aErrorMgr amp sErrorLevel if sErrorLevel ALA ERROR FATAL else return ALA FAILURE void ALA GetErrorCode aErrorMgr amp sErrorCode if sErrorCode 0x52014 Timeout Receive XLog and Insert into Queue continue Wait and Handshake with XLog Sender break Get XLog from XLog Queue continue Get XLog Header void ALA GetXLogHeader sXLog const ALA XLogHeader amp sXLogHeader aErrorMgr Check REPL STOP XLog if sXLogHeader gt mType XLOG TYPE REPL STOP SReplStopFlag ALA TRUE Apply XLog to Altibase DBMS SAckFlag ALA FALSE 115 switch sXLogHeader gt mType se XLOG TYPE COMMIT case XLOG TYPE ABORT Unused in Committed Transaction Only case XLOG TYPE REPL STOP void applyXLogToAltibase aHandle sXLog aErrorMgr SAckFlag ALA TRUE break case XLOG TYPE INSERT case XLOG TYPE UPDATE case XLOG TYPE DELETE 4 case XLOG TYPE SP SET Unused in Committed Transaction Only case XLOG TYPE SP ABORT Unused in Committed Transaction Only void applyXLogToAltibase aHandle sXLog aErrorMgr break case
101. ype are between 0 and 254 inclusive A length value of 255 indicates a NULL value LogAnalyzer User s Manual 3 3 ALTIBASE HDB Data Types and Internal Structure 3 3 5 GEOMETRY 3 3 5 1 Internal Structure For information on the GEOMETRY data structure and how to handle GEOMETRY type data please refer to the ALTIBASE HDB Spatial SQL Reference The ALA GetAltibaseText ALA GetAltibaseSOL and ALA GetODBCCValue functions cannot be used with GEOMETRY type values 37 Analyzing XLogs 3 4 SAVEPOINT 3 4 SAVEPOINT Savepoints are declared to temporarily save the interim results of partially processed transactions In ALTIBASE HDB the following three kinds of savepoints are available for use Implicit Savepoints Explicit Savepoints PSM Savepoints Implicit savepoints are used internally and managed in lists One such list is maintained for each transaction Implicit savepoints are used for partial rollback which is performed automatically if the execution of a particular statement fails so that only that statement and not the entire transaction needs to be rolled back It is also possible for users to expressly define explicit savepoints which are also managed in lists that are maintained for individual transactions These lists are managed separately from the lists of implicit savepoints noted above Please refer to the SOL Reference for more details about explicit savepoints PSM savepoints are used internally when s
102. ysis API shared library libala x This is the Log Analysis API static library The following must be taken into consideration when creating and compiling source code The source code must reference the alaAPI h file When creating an application for use in Windows the windows h file must be included before the alaAPl h file in the source code If the WINDOWS macro is not defined in the windows h file it must be manually defined by the author of the application When linking during the compile operation it is necessary to linkto either the shared library or the static library The filename extension of the library files varies depending on the platform 1 2 2 Data Types The basic data types used by the Log Analysis API are as follows Table 1 2 Log Analysis API Basic Data Types Type Data Type Description Boolean ALA BOOL ALA TRUE true ALA FALSE false Return Code ALA RC ALA SUCCESS success ALA FAILURE failure 7 Introduction 1 2 How to Use the Log Analysis API Type Data Type Description Character char SChar Signed Character 8 bits unsigned char Unsigned Character 8 bits UChar Integer short SShort Signed Small Integer 16 bits unsigned short Unsigned Small Integer 16 bits UShort int SInt Signed Integer 32 bits unsigned int Ulnt Unsigned Integer 32 bits long SLong Signed Big Integer 64 bits unsigned long
Download Pdf Manuals
Related Search
Related Contents
Asrock G41MH/USB3 motherboard Skpad SKP-FLIP-IBO3 SMART Table 442i Centro de aprendizaje colaborativo Guía del Galera Documentation - Galera Cluster for MySQL LG LFX21960 User's Manual PI FLOWSIC 600 d_2 Medidor de Fallas - Abastecedora Grafica providencia snat/2007/0469, mediante la cual se disponde que los Copyright © All rights reserved.
Failed to retrieve file