Home
Log Analyzer User`s Manual - ALTIBASE Customer Support
Contents
1. Error Code Description Can be returned from 0x50008 Attempted to begin an active transaction ALA_ReceiveXLog ALA_GetXLog 0x5000A Mutex Initialization Failure ALA CreateXLogCollector ALA Handshake 0x5000B Mutex Remove Failure ALA Handshake ALA DestroyXLogCollector 0x5000C Mutex Lock Failure ALA AddAuthlInfo f ALA_RemoveAuthlnfo 0x5000D Mutex Unlock Failure ALA_Handshake ALA_ReceiveXLog ALA_GetXLog ALA_SendACK ALA_FreeXLog ALA_DestroyXLogCollector ALA GetXLogCollectorStatus Error Code Description Can be returned from 0x51006 Memory Allocation Failure All Log Analysis API s 0x5101E Failed to allocate memory from pool ALA_ReceiveXLog 0x5101F Failed to free memory from pool ALA_Handshake ALA_ReceiveXLog ALA_FreeXLog ALA_DestroyXLogCollector 0x51020 Memory Pool Initialization Failure ALA_CreateXLogCollector 103 Error Codes Error Code Table Error Code Description Can be returned from 0x51021 Memory Pool Remove Failure ALA DestroyXLogCollector 0x51013 Network Context Initialization Failure ALA Handshake ALA_ReceiveXLog 0x51019 Network Protocol Remove Failure ALA_SendACK 0x5101A Network Context End Failure 0x51017 The network session has already ended ALA_ReceiveXLog ALA_SendACK 0x51018 Abnormal Network Protocol ALA_Handshake ALA_ReceiveXLog 0x51016 Network Read Failure 0x5101B Network Write Fa
2. Obtain the error level void ALA GetErrorLevel amp sErrorMgr amp sErrorLevel Obtain the error message void ALA GetErrorMessage amp sErrorMgr amp sErrorMessage LogAnalyzer Users Manual 96 ALA_GetErrorCode Syntax ALA RC ALA GetErrorCode const ALA ErrorMgr aErrorMgr ALA GetErrorCode UInt aOutErrorCode Argument Argument Description aErrorMgr Error Manager aOutErrorCode Error Code Result ALA SUCCESS ALA FAILURE Description Obtains an error code An error code is a unique value that identifies an error Note Memory for aOutErrorCode should be allocated in advance Since mErrorCode in the ALA_ErrorMgr structure contains internal data an error Code should be obtained via ALA_GetErrorCode Related Function ALA_ClearErrorMgr ALA_GetErrorLevel ALA_GetErrorMessage 97 Log Analysis API ALA GetErrorCode Example Please refer to ALA_ClearErrorMgr LogAnalyzer Users Manual 98 ALA_GetErrorLevel Syntax ALA RC ALA GetErrorLevel ALA GetErrorLevel const ALA ErrorMgr aErrorMgr ALA ErrorLevel aOutErrorLevel Argument Argument Description aErrorMgr Error Manager aOutErrorLevel Error Level Result ALA_SUCCESS ALA_FAILURE Description Obtains the error level Since ALA ERROR FATAL is a fatal error ALA DestroyXLogCollector should be invoked to termi nate th
3. if COMMIT XLog then Commit Current Transaction if sXLogHeader gt 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 SQL from XLog memset SQuery 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 113 Sample Codes Sample Code Replication to Altibase DBMS while sImplictSPPos strchr sQuery NULL sImplictSPPos Apply SQL to DBMS with ODBC if SQLAllocStmt gDbc amp gStmt SO
4. 38 4 Log Analysis API 39 ALA InitializeAPI 40 ALA DestroyAPI 42 ALA_EnableLogging 43 ALA SDISABISL OG GIG PAE R O L O O O EERE ti 45 ALA Cre teXLogCol ctor M M 46 ALA AdJAULRINfOR cioe aoctor cete eese ette a one A I Lice Red acp sedo beet eR TR Heo cea nee tL EDU e CHEER CH 49 ALA RemoveAuthlnfo oett estet tete NN ONU vod o Ende cde tud 51 ALA SetHandshakeTimeout 53 ALA SetReceiveXLogTimeout 54 ALA_Handshake 2 55 AL _ReceiVveXLOG AO N OE AOLO O 58 ALA GEOLOG a lk w dk ana 60 ALA SONGAGK wyd O i D 62 ALA EreeXEOg xe te O W O AE E NE n dea 64 ALA DestroyXLogCollector 65 ALA_GetXLogCollectorStatus 66 ALA_GetXLogHeader 68 ALA GetXLogPrimaryKey eainiie ierra E E EAEE E R AAE EEE 70 ALA GEtXLOGGOlUMN sissssissecassessesesstizassizsansiscd esas carasisteaiestaessueeeh VAA E E T a 71 ALA GOtXLOGSAVED OLIN sisino 72 LAE GOtXLOGLOB R REA 73 ALA_GetProtocolVersion 74 ALA GetReplicationlnfo 75 ALA GetTablelnfo 78 ALA GetTablelnfoByNam utter A et A R A A 80 ALA GetCol mnlnpfto 5 e AA BA R AO AAA 82 ALA Getlndexlrifo asa aka RE kw cea eo e e ER da EL O W o OWA 84 ALA GetlInternalNumeericlnfoO eerte tentent tette nte aaa aaa nene eve 86 ALA GetAltibaseText
5. ALA GetTableInfoByName ALA GetReplicationInfo ALA GetTablelnfo ALA GetColumnlInfo ALA GetIndexInfo Example Please refer to ALA GetReplicationlnfo 81 Log Analysis API ALA GetColumnInfo ALA_GetColumninfo Syntax ALA RC ALA GetColumnInfo const ALA Table aTable UInt aColumnID const ALA Column aOutColumn ALA ErrorMgr aOutErrorMgr Argument Argument Description aTable Target Table information aColumniD The column ID that will be searched for aOutColumn Column information aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Retrieves the column information in a table by Column ID Note If there is no corresponding meta data it returns NULL as an argument The meta data obtained before handshaking should not be used again and again Related Function ALA Handshake ALA GetReplicationInfo ALA GetTablelnfo LogAnalyzer Users Manual 82 ALA GetColumnInfo ALA_GetTablelnfoByName ALA_Getlndexlnfo Example Please refer to ALA_GetReplicationInfo 83 Log Analysis API ALA GetIndexInfo ALA_Getlndexinfo Syntax ALA RC ALA GetIndexInfo const ALA Table aTable UInt aIndexID const ALA Index aOutIndex ALA ErrorMgr aOutErrorMgr Argument Argument Description aTable Target Table information alndexID The index ID that will be searched for aOutlndex Index information aOutErrorMgr Error Manag
6. Length of Bits UChar value 1 UChar Array mtdBitType typedef struct mtdLobType UInt length Length of value UChar value 1 UChar Array mtdLobType typedef mtdLobType mtdBlobType BLOB typedef mtdLobType mtdClobType CLOB BLOB and CLOB are not supported by ALA_GetAltibaseText ALA_GetAltibaseSQL and ALA_GetODBCCValue GEOMETRY Internal Structure For information on the data structure and handling for the GEOMETRY data please refer to Altibase Application Development Spatial SOL User s Manual GEOMETRY is not supported by ALA_GetAltibaseText ALA_GetAltibaseSQL and ALA_GetODBCCValue 37 XLog Analysis SAVEPOINT SAVEPOINT If you specify SAVEPOINT transactions executed until now are saved temporarily in their process SAVEPOINTS used in Altibase are classified as follows Implicit Savepoint Explicit Savepoint PSM Savepoint If you execute statements related to transactions Implicit Savepoint is managed as the savepoint used internally and list If you fail to do only corresponding statements are used for partial rollback automatically Users can specify Explicit Savepoint and this is managed as the list Refer to SQL User s Manual for more details about Explicit Savvepoint PSM Savepoint is used internally when you execute PSM Only PSM Savepoint used currently is man aged Refer to Stored Procedure User s Manual for more details about stored pr
7. Obtain the primary key column information by primary key column ID void ALA GetColumnInfo sTable sTable gt mPKColumnArray sPKColumnPos gt mColumnID amp sPKColumn NULL LogAnalyzer Users Manual 76 ALA GetReplicationInfo if sPKColumn sTable gt mPKColumnArray sPKColumnPos Fatal Error Error in Log Analysis API break Process primary key column Process column for sColumnPos 0 sColumnPos sTable 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 gt 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 wee 77 Log Analysis API ALA GetTablelnfo ALA_GetTablelnfo Syntax ALA RC ALA GetTableInfo ALA Handle aHandle ULong aTableOID const ALA Table aOutTable ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aTableOID T
8. Analyze and Process XLog void ALA GetXLogHeader sXLog amp sXLogHeader NULL LogAnalyzer Users Manual 56 ALA Handshake if sXLogHeader gt mType XLOG TYPE REPL STOP 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 57 Log Analysis API ALA ReceiveXLog ALA ReceiveXLog Syntax ALA RC ALA ReceiveXLog ALA Handle ALA BOOL aOutInsertXLogInOueue ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aOutlnsertXLoglnQueue Whether XLog has been added to XLog Pool aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Receives XLog and adds it to XLog Queue Obtains XLog from XLog Pool When transaction XLog is obtained in the order of commit it is stored in the transaction table until COMMIT XLog i s received It can be invoked together with ALA GetXLog at a time Note ALA Handshake should be invoked first It fails if a network error has already occurred If XLog is not received within the XLog Receive timeout a timeout will occur It fails if there is no XLog available in XLog Pool When transaction XLog is obtained in the orde
9. void 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 50 void ALA CreateXLogCollector log analysis SOCKET UNIX 20000 ALA TRUE 50 amp sHandle NULL Invoke Log Analysis API Remove XLog Collector void ALA DestroyXLogCollector sHandle NULL LogAnalyzer Users Manual 48 ALA AddAuthInfo ALA AddAuthinfo Syntax ALA RC ALA AddAuthInfo ALA Handle aHandle const SChar aAuthInfo ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aAuthlnfo XLog Sender Authentication Information aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Adds the authentication information for XLog Sender For TCP aAuthInfo is a string in the PEER IP xlog sender ip format The valid length for Xlog sender ip is between 1 39 Note It can used only when the socket type is set to TCP Up to 32 pieces of authentication information can be specified for XLog Sender Related Function ALA CreateXLogCollector ALA_RemoveAuthlnfo ALA_Handshake 49 Log Analysis API ALA AddAuthInfo Example Please refer to ALA CreateXLogCollector LogAnalyzer Users M
10. Argument Argument Description aUseAltibaseODBCDriver Whether to use the Altibase ODBC driver aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Removes environment in which Log Analysis API can be invoked Note Regardless of the result other Log Analysis API may not be used after invoking this function When the ALTIBASE ODBC Driver is used the last SQLFreeEnv should be used before it is invoked Related Function ALA InitializeAPI Example Please refer to ALA InitializeAPI LogAnalyzer Users Manual 42 ALA EnableLogging ALA EnableLogging Syntax ALA RC ALA EnableLogging const SChar aLogDirectory const SChar aLogFileName UInt aFileSize UInt aMaxFileNumber ALA ErrorMgr aOutErrorMgr Argument Argument Description aLogDirectory Log Directory aLogFileName Log Filename aFileSize The size of a log file aMaxFileNumber The maximum number of previous log files aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Enables logging for problem tracking If it is not invoked logging will not be performed If there is no log file a new log file is created If there is one logs are appended to the existing log file If the size of a log file reaches aFileSize the log file is renamed and a new log file is created A log file is renamed by referring to 1 aMaxFileNumber in the head
11. 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 LogAnalyzer User s Manual 106 Sample Code Replication to Altibase DBMS Appendix B Sample Codes Sample Code Replication to Altibase DBMS Sample code is provided as sample ALA Altibase ReplToAltiSample c Following is a brief description of how to use Log Analyzer Refer to Chapter 2 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 t1 XLog Collector Execution ReplToAltiSample XLog Sender Startup ALTER REPLICATION ALA1 START Sample Code This sample code is available in the sample ALA Altibase ReplToAltiSample c file kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk Replication to Altibase DBMS Sample based on Committed Transaction Only kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxk include lt string h gt include lt stdlib h gt include lt stdio h gt Include Altibase ODBC header include lt sqlcli h gt Include Altibase Log Analysis API header include lt alaAPI h gt User specific Definitions define QUERY SIZE 4196 SQL Query Buffer Size 107 Sample Codes
12. employee name etc Upper Case Elements provided by the system or DESC SYSTEM SYS INDICES keywords appearing in a statement J h D For more information please refer to the following documentation Altibase Administration Starting User s Manual Altibase Administration Administrator s Manual Altibase Administration Replication User s Manual Altibase Application Development SQL User s Manual Altibase Application Development ODBC User s Manual Altibase Application Development Spatial SQL User s Manual Altibase Application Development Application Program Interface User s Manual Altibase Tools iSQL User s Manual Altibase Message Error Message Reference Online Manual U Korean and English versions of on line manuals PDF or HTML are available from Altibase Download Center http atc altibase com i Altibase Welcomes Your Opinions Please send us your comments and suggestions regarding this manual Your comments and sugges tions are important and they 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 in use Your comments or suggestions regarding the manual Your name address and phone number v Preface Regarding This Manual Please send your e mail to the following address support altibase com This address is intended to report any errors or omissions discovered in t
13. mLobOldSize mLobNewSize LOB PARTIAL WRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator mLobOffset mLobPieceLen mLobPiece mLobOffset is a relative position from the mLobOffset of LOB PREPAREAWRITE XLog LOB FINISH2WRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator 31 XLog Analysis XLog KEEP_ALIVE XLog Header mType mTID mSN mSyncSN REPL STOP XLog Header mType mTID mSN mSyncSN LogAnalyzer Users Manual 32 Meta D ata Meta Data This section describes how to obtain the meta data that can be used to analyze XLog A user should invoke ALA_Handshake before he she can obtain the meta data Meta Data Structure typede UShor UShor UShor ALA_ typede SChar mXLogSenderName ALA NAME LEN XLo UInt ALA T ALA typede ULong SChar SChar SChar SChar UInt UInt ALA C Int LA C Int LA I ALA typede UInt SChar UInt UInt UInt Sint SInt ALA_B U A U A f struct ALA ProtocolVersion t mMajor t mMinor t mFix ProtocolVersion f struct ALA Replication g Sender Name mTableCount able mTableArray Replication f struct ALA Table mTableOID mFromUserName ALA NAME LEN mFromTableName ALA NAME LEN mToUserName ALA NAME LEN mToTableName ALA NAME LEN mPKIndexID mPKColumnCount olumn mPKColumnArray mColumnCount olumn mColumnArray mIndexCount ndex mIndexArray Table f struct
14. mSPName ALA XLogSavepoint typedef struct ALA XLogLOB ULong mLobLocator UInt mLobColumnID UInt mLobOffset UInt mLobOldSize UInt mLobNewSize UInt mLobPieceLen UChar mLobPiece ALA XLogLOB typedef struct ALA XLog ALA XLogHeader mHeader ALA XLogPrimaryKey mPrimaryKey ALA XLogColumn mColumn ALA XLogSavepoint mSavepoint ALA XLogLOB mLOB 29 Structure Member Description length The length of the internal data value of Altibase Value The internal data value of Altibase XLog Header XLog Type Transaction ID SN Reserved Table OID Primary Key Primary Key Column Count Priamry Key Column Value Array Column Column Count Column ID Array Before Image Column Value Array After Image Column Value Array Savepoint Savepoint Name Length Savepoint Name LOB LOB Locator of Altibase XLog Used internally XLog Analysis XLog struct ALA XLog mPrev struct ALA XLog mNext ALA XLog XLog consists of a header primary key column savepoint and LOB Each of these components can be obtained directly from ALA XLog or via Log Analysis API for XLog ALA XLogPrimaryKey does not have the Primary Key Column ID Array This can be obtained with mPKColumnaArray sIndex gt mColumnID in th
15. should be taken based on the error code Error that have already occurred can be checked via Log Manager For information on using Log Manager please refer to the sections that describe ALA EnableLogging and ALA_DisableLogging STEP 1 Create Log Analyzer API Invoke Environment and Start Logging ALA InitializeAPI ALA EnableLogging STEP 2 Create and Set XLog Collector ALA CreateXLogCollector ALA_AddAuthlnfo ALA_RemoveAuthlnfo ALA_SetHandshakeTimeout ALA SetReceiveXLogTimeout STEP 3a Wait for a Connection to XLog Sender and Handshake ALA Handshake STEP 3b Obtain XLog ALA ReceiveXLog ALA GetXLog STEP 3c Analyze and Convert XLog Please refer to XLog Analysis amp Conversion API STEP 3d Remove XLog and Send ACK ALA FreeXLog ALA SendACK Repeat until XLog Sender ends LogAnalyzer Users Manual 10 How to Use Log Analysis API STEP 4 Remove XLog Collector ALA_DestroyXLogCollector STEP 5 Finish Logging and Remove Log Analysis API Invoke Environment ALA_DisableLogging ALA DestroyAPI When Log Analysis API is used the followings should be considered XLog Collector Monitoring is used in STEP 3a 3d Error Handling API is used in all steps If there are more than one XLog Collector STEP 2 4 should be performed for each XLog Col lector ALA SendACK does not have to be called every time For information on when to send ACK please refer to ALA_CreateXLogCollector and ALA_
16. 88 ALA_GetAltibaseSQL 90 ALA GetODBCCValue 92 ALA lt learErTorMeg ra az ad O Aaaa ki 95 ALA GetError dE ee ACAR Eda kd 97 ALA GetError evelhenn AA O E OE aed C n eee if 99 ALA lt GetEtrorMESSAg az i R A W R A REA A AO 101 AppendixA Error COdeS ROYA nake 103 Error Gode Table utc NA WEAR A Do ei e ce de ee O AAAA SKOK A 103 AppendixB Sample Codes 107 Sample Code Replication to Altibase DBMS esssssscsssesssssssccssecssnsescsssecsesutecssuecesuseessnsecesssecessucecssueeeecnsecesnseessnneecssueessnees 107 Preface Regarding This Manual Regarding This Manual This manual describes the concept of Altibase Log Analyzer and its use Intended Audience The manual has been prepared for the following Altibase users Database Administrator Performance Administrator Database User Application Development Technical Assistant Team Before reading this manual understanding of following background knowledge is recommended Basic knowledge regarding operation of a computer operating system and operating system utility Experience in use of a relational database or understanding of the database concept Experience in administration of database server operating system or network Experience in computer programming Software Environment The manual has been prepared by assuming that Altibase Version 5 3 1 is used as a dat
17. ALA XLogColumn ALA XLogSavepoint A OB LA XLog Obtain XLog Header void ALA GetXLogHeader aXLog Obtain XLog Primary Key Obtain XLog Column void ALA GetXLogColumn aXLog Obtain XLog Savepoint Obtain XLog LOB 69 void ALA GetXLogPrimaryKey aXLog void ALA GetXLogSavepoint aXLog aXLog sXLogHeader sXLogPrimaryKey sXLogColumn NUL sXLogSavepoint SXLogLOB NULL amp sXLogHeader NULL ALA GetXLogHeader NULL NULL NULL amp sXLogPrimaryKey NULL amp sXLogColumn NULL void ALA GetXLogLOB aXLog amp sXLogLOB NULL amp sXLogSavepoint NULL Log Analysis API ALA GetXLogPrimaryKey ALA GetXLogPrimaryKey Syntax ALA RC ALA GetXLogPrimaryKey const ALA XLog aXLog const ALA XLogPrimaryKey aOutXLogPrimaryKey ALA ErrorMgr aOutErrorMgr Argument Argument Description aXLog XLog aOutXLogPrimaryKey XLog Primary Key aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the XLog header from XLog Related Function ALA GetXLog ALA GetXLogHeader ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB Example Please refer to ALA GetXLogHeader LogAnalyzer Users Manual 70 ALA_GetXLogColumn ALA GetXLogColumn Syntax ALA RC ALA GetXLogColumn const ALA XLog aXLog const ALA XLogColumn aOutXLogC
18. Sample Code Replication to Altibase DBMS 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 SQLHENV gEnv SQLHDBC gDbc SQLHSTMT gStmt Start function int main void ALA Handle sHandle XLog Collector Handle ALA ErrorMgr sErrorMgr Error Manager 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 KR 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 k k RRR RR RR k k RR ee ke ke KK If you call SQLAllocEnv that is included in Altibase ODBC you have to set ALA TRUE to the fir
19. The conflict resolution for replication REPL MODE INTEGER The default replication mode ROLE INTEGER Role OPTIONS INTEGER Flag for Extra Features of Replication INVALID RECOVERY INTEGER Whether to recover replication If the value for the role column is 1 it indicates XLog Sender For more information please refer to the Altibase Administration Administrator s Manual It has information on a target to which XLog Sender will connect Column name Type Description HOST NO INTEGER Serial Number REPLICATION NAME VARCHAR 40 Replication Name HOST IP VARCHAR 40 IP address for a remote server PORT NO INTEGER Replication port number for a remote server LogAnalyzer Users Manual 22 Meta Table For a UNIX domain the value for the HOST IP column is UNIX_DOMAIN and the value for the PORT NO column is the value for the HOST NO column For more information please refer to the Altibase Administration Administrator s Manual It has information on a table for analysis Column name Type Description REPLICATION NAME VARCHAR 40 Replication Name TABLE OID BIGINT Table Object Identifier LOCAL USER NAME VARCHAR 40 Username for a local server LOCAL_TABLE_NAME VARCHAR 40 Table name for a local server LOCAL_PARTITION_NAME VARCHAR 40 Partition Name in Local Server REMOTE_USER_NAME VARCHAR 40 Username for a remote server REMOTE_TABLE_NAME VARCHAR 40 Table na
20. XLog begins with XLOG TYPE BEGIN and ends with XLOG TYPE COMMIT or XLOG TYPE ABORT Since LOB is a large data updating LOB type of data can be made of more than one XLog In this case the LOB XLog is received in the following structure XLOG TYPE LOB CURSOR OPEN XLOG TYPE LOB PREPARE4WRITE XLOG TYPE LOB PARTIAL WRITE XLOG TYPE LOB FINISH2WRITE e XLOG TYPE LOB CURSOR CLOSE The XLog related the control includes KEEP ALIVE and REPL STOP KEEP ALIVE is the XLog that XLog Sender sends to check if the network is still connected when it has no XLog to send REPL STOP indicates that XLog Sender ends normally Once ALA SendACK is invoked the network is disconnected LogAnalyzer Users Manual 28 Configuration of XLog typedef UInt ALA TID typedef ULong ALA SN typedef struct ALA Value UInt length const void value ALA Value XLog Transaction ID Log Record SN Altibase Internal Data Length of value typedef struct ALA XLogHeader ALA XLogType mType LA TID mTID LA SN mSN LA SN mSyncSN Long mTableOID ALA XLogHeader typedef struct ALA XLogPrimaryKey A A A U UInt mPKColCnt ALA Value mPKColArray ALA XLogPrimaryKey typedef struct ALA XLogColumn UInt mColCnt UInt mCIDArray ALA Value mBColArray ALA Value mAColArray ALA XLogColumn typedef struct ALA XLogSavepoint UInt mSPNameLen SChar
21. as in Replication For more information please refer to the Altibase Administration Replication User s Manual Example XLog Sender Name log analysis Table for Analysis sys t2 iSQL gt ALTER REPLICATION log analysis DROP TABLE FROM sys t2 TO sys t2 Add a Host Syntax ALTER REPLICATION replication name ADD HOST remote host ip remote port no Description The same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Note Only TCP information can be added A host cannot be added when a UNIX Domain is already specifed as a connection type Example XLog Sender Name log analysis 19 XLog Sender XLog Sender SQL XLog Collector Info TCP IP 127 0 0 1 PORT 30301 iSQL gt ALTER REPLICATION log analysis ADD HOST 127 0 0 1 30301 Remove a Host Syntax ALTER REPLICATION replication name DROP HOST remote host ip remote port no Description The same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Note Only the TCP information can be removed Example XLog Sender Name log analysis XLog Collector Info TCP IP 127 0 0 1 PORT 30301 iSQL gt ALTER REPLICATION log analysis DROP HOST 127 0 0 1 30301 Set a Host Syntax ALTER REPLICATION replication name SET HOST remote host ip remote port no Description The same as in Replication For more
22. data before it sends receives XLog XLog Queue XLog Queue is a place where available XLog is stored before a user can get it XLog Pool XLog Pool is a place where memory to allocate for XLog is stored LogAnalyzer Users Manual 2 Altibase Log Analyzer XLog Pool is used to reuse memory to allocate for XLog and to prevent excessive use of memory Transaction Table Transaction Table is a place where the transaction status and additional information are stored Restart SN Restart SN is the SN for an active log that will be read when XLog Sender is restarted SN SN Sequence Number is a serial number of a log record in an active log Replication Replication is a module that synchronizes data between different Altibase DBMS s in real time Please refer to the Altibase Administration Replication User s Manual to get more information Replication SYNC Replication SYNC is a function that sends all records in the replication tables of a local server to a remote server It is used to synchronize replication tables before the replication module is started based on active logs Please refer to the Altibase Administration Replication User s Manual to get more information How Altibase Log Analyzer Works XLog Sender exists within Altibase DBMS It creates XLog with active logs and sends the XLog and its meta data to XLog Collector XLog Collector exists within user s application It provides a user with XLog and its meta dat
23. duplicated aSocketlnfo is a string in the SOCKET socket type PEER IP xlog sender ip MY PORT listen port format LogAnalyzer Users Manual 46 ALA CreateXLogCollector socket type can only be specified to either of TCP or UNIX If it is specified to UNIX the socket filename is automatically created in the SALTIBASE_HOME trc rp replication_name format xlog_sender_ip is specified when socket_type is TCP The valid length is between 1 39 This information is required for authentication of XLog Sender listen_port is specified when socket_type is TCP The valid range is between 1024 65535 OxFFFF This is a port number to which XLog Sender will connect It is used by ALA_Handshake aACKPerXLogCount is applied when ALA_SendACK is invoked When the transaction XLog is obtained in the order of commit the followings should be considered Since XLog is accumulated in the transaction table until COMMIT XLog arrives the size of XLog Pool should be set large enough That is it requires more memory space XLog can be obtained after COMMIT XLog is received That is the time interval between the time that XLog arrives and the time that it is actually proccessed becomes larger If a transac tion is a bulk job it is very likely to decrease performance If the reference number of XLog for which ACK will be sent out is set to a number bigger than 1 ACK may not be sent to XLog Sender even when ALA_SendA
24. information please refer to the Altibase Administration Replication User s Manual Note It is applied when XLog Sender is started LogAnalyzer Users Manual 20 XLog Sender SQL Only the TCP information can be specified Example XLog Sender Name log_analysis XLog Collector Info TCP IP 127 0 0 1 PORT 30301 iSQL gt ALTER REPLICATION log analysis SET HOST 127 0 0 1 30301 Flush XLog Syntax ALTER REPLICATION replication name FLUSH ALL WAIT timeout sec Description The same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Note If XLog Collector does not send ACK a timeout may occur Example XLog Sender Name log_analysis Reference Point for Flush The time point at which it is performed Timeout 10 seconds iSQL gt ALTER REPLICATION log analysis FLUSH WAIT 10 21 XLog Sender Meta Table Meta Table The same meta table as in Replication is used It has information on the settings and status of XLog Sender Column name Type Description REPLICATION_NAME VARCHAR 40 Replication Name LAST_USED_HOST_NO INTEGER The most recently used remote server HOST_COUNT INTEGER The number of remote servers IS_STARTED INTEGER Whether replication has been started or not XSN BIGINT The Transmission Start SN for a sender ITEM_COUNT INTEGER The number of tables to replicate CONFLICT RESOLUTION INTEGER
25. mXLogCountInPool ALA SN mLastArrivedSN ALA SN mLastProcessedSN ALA BOOL mNetworkValid ALA XLogCollectorStatus Structure Member Description mMylP TCP XLog Collector IP mMyPort TCP XLog Collector Port mPeerlP TCP XLog Sender IP mPeerPort TCP XLog Sender Port mSocketFile UNIX Domain Socket File Name mXLogCountInPool The number of XLog remaining in XLog Pool mLastArrivedSN The SN for the last XLog received mLastProcessedSN The SN for the last XLog processed mNetworkValid The network validity Memory for aOutXLogCollectorStatus should be allocated in advance ALA Handshake ALA ReceiveXLog ALA GetXLog ALA SendACK ALA FreeXLog Please refer to ALA Handshake 67 Log Analysis API ALA GetXLogHeader ALA_GetXLogHeader Syntax ALA RC ALA GetXLogHeader const ALA_XLog aXLog const ALA XLogHeader aOutXLogHeader ALA ErrorMgr Argument aOutErrorMgr Argument Description aXLog XLog aOutXLogHeader XLog Header aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the XLog header from XLog Related Function ALA GetXLog ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB Example include lt alaAPI h gt LogAnalyzer Users Manual 68 void testXLogGetPart const ALA XLog ALA XLogHeader ALA XLogPrimaryKey
26. should be speci fied in XLog Collector Since the maximum allowable length of a socket filename varies depending on an operating system the maximum allowable length should be checked so that it is not exceeded 17 XLog Sender XLog Sender SQL Example XLog Sender Name log_analysis Start Point for Log Analysis The point at which the last analysis ended iSQL gt ALTER REPLICATION log analysis START End XLog Sender Syntax ALTER REPLICATION replication name STOP Description The same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Example XLog Sender Name log_analysis iSQL gt ALTER REPLICATION log analysis STOP Add a Table for Analysis Syntax ALTER REPLICATION replication name ADD TABLE FROM user name table name TO user name table name Description Adds a table for analysis In the FROM clause a table with a foreign key can be specified The remaining parts are the same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Example XLog Sender Name log analysis Table for Analysis sys t2 LogAnalyzer Users Manual 18 XLog Sender SQL iSQL gt ALTER REPLICATION log analysis ADD TABLE FROM sys t2 TO sys t2 Remove a Table for Analysis Syntax ALTER REPLICATION replication name DROP TABLE FROM user name table name TO user name table name Description The same
27. ALA Column mColumnID mColumnName ALA NAME LEN mDataType mLanguageID mSize mPrecision mScale OOL mNotNull ALA Column typede UInt SChar ALA B UInt UInt struct ALA Index mIndexID mIndexName ALA NAME LEN OOL mUnique mColumnCount mColumnIDArray ALA Index Major Version Minor Version Fix Version Table Count Table Array Table OID From User Name From Table Name To User Name To Table Name Index ID of Primary Key Primary Key Column Count Primary Key Column Array Column Count Column Array Index Count Index Array Column ID Column Name Column information Type Column Language ID Column Size Column Precision Column Scale Column Not Null Index ID Index Name Index Unique Index Column Count Index Column ID Array The meta data includes Protocol Version Replication Table Column and Index The mPKColumnArray member of the ALA Table structure is an array of the ALA Column pointers 33 XLog Analysis ALTIBASE Internal Data Type ALTIBASE Internal Data Type This section describes the format of the internal data of Altibase The column information ALA Column can be obtained by invoking ALA_GetColumnInfo and the internal
28. ALTIBASE Application Development Log Analyzer User s Manual release 5 3 3 A ALTIBASE PERFORMANCE SOLUTIONS ALTIBASE Application Development Log Analyzer User s Manual Release 5 3 3 Copyright 2001 2009 Altibase Corporation All rights reserved This manual contains proprietary information of Altibase Corporation it is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright patent and other intellectual property law Reverse engineering of the soft ware is prohibited 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 supportQaltibase com www http www altibase com Contents dipl i Regarding This Manual ji 1 Introduction 1 Altibase ELOG Analy Er sea A A AE AAA W itae eee 2 How to Use Fog Anal sis APN zzo za RN RM S 8 Summary of Log Analysis AP rre eee A Oda 12 Ds CE erede 15 XLog Sender SOL 16 Meta Table 22 Performance View 24 3 XLOGAMALYSIS 2ssccssacissscsccsecsnscecccestenscnscessenascdscnncdusenssiecsoaussasseusessesascndcanchecasssascnssenseedsadccussasecassasstuseoesbasossssnssecesnceves 27 XEOG id Ai OO ki EER W AE AO OE R ALA 28 Meta Data PPOR O O A O P O O O O O EO 33 ALTIBASE Internal Data Typ dots AR ARA EO A OE EE 34 SAVEPOINT 2 2 1 112 211
29. Analysis API The followings should be considered when a source code is being created and compiled User s source file should contain the alaAPI h file If it is going to be used in Windows it should contain the windows h before the alaAPI h file If WINDOWS is not defined in the windows h file it should be defined by a user For compiling a shared library or static library should be linked The extension of a library varies depending on a platform The basic data types used by Log Analysis API are as follows Table 1 2 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 fail Character SChar Signed Character 8 bits UChar Unsigned Character 8 bits LogAnalyzer Users Manual 8 How to Use Log Analysis API Type Data Type Description Integer SShort Signed Small Integer 16 bits UShort Unsigned Small Integer 16 bits SInt Signed Integer 32 bits Ulnt Unsigned Integer 32 bits SLong Signed Big Integer 64 bits ULong Unsigned Big Integer 64 bits All Log Analysis API s receive Error Manager as an argument If invoking Log Analysis API results in ALA FAILURE a cause for the error should be checked for and handled The error information that is provided to a user consists of Error Code Error Level and Error Message typedef struct A
30. Buffer 1024 UInt sPKColumnPos UInt sColumnPos Process the primary key column for sPKColumnPos 0 sPKColumnPos lt aXLog gt mPrimaryKey mPKColCnt sPKColumnPos The primary key sequence for 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 column for sColumnPos 0 sColumnPos aXLog mColumn mColCnt sColumnPos Obtain the column information void ALA GetColumnInfo aTable aXLog mColumn mCIDArray sColumnPos amp sColumn NULL Obtain the Altibase text for Before Image void ALA GetAltibaseText sColumn amp aXLog gt mColumn mBColArray sColumnPos 1024 sBuffer NULL Obtain the Altibase text for After Image void ALA GetAltibaseText sColumn amp aXLog mColumn mAColArray sColumnPos 1024 sBuffer NULL 91 Log Analysis API ALA GetODBCCValue ALA_GetODBCCValue aColumn aAltibaseValue aODBCCTypeID aODBCCValueBufferSize aOutODBCCValueBuffer aOutIsNull aOutODBCCValueSize Syntax ALA RC ALA GetODBCCValue ALA Column i ALA Value SInt UInt void ALA BOOL UInt ALA ErrorMgr Argument aOutErrorMgr Argument Description aColumn The column i
31. C ALA_GetAltibaseText Convert the internal data of Altibase to a string ALA_GetAltibaseSQL Convert transaction XLog to an Altibase SQL string ODBC C Conversion ALA_GetODBCCValue Convert the internal data of Altibase to the ODBC C value 13 Introduction Summary of Log Analysis API Type Log Analysis API Description Error Handling ALA_ClearErrorMgr Initialize Error Manager ALA_GetErrorCode Obtain an error code ALA_GetErrorLevel Obtain the error level ALA_GetErrorMessage Obtain a specific error message LogAnalyzer Users Manual 14 2 XLog Sender This section provides description on using the XLog Sender component of Altibase Log Analyzer XLog Sender combines log records in XLog and passes it to XLog Collector XLog Sender is a module within Altibase DBMS and it is managed via the SQL interface similar to that for replication 15 XLog Sender XLog Sender SQL XLog Sender SQL Create XLog Sender 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 Description Creates XLog Sender Lazy Mode is forced UNIX DOMAIN in the WITH clause specifies the UNIX Domain Connection In the FROM clause a table with a foreign key can be specified The remaining parts are the s
32. CK is invoked If the socket type is TCP the listening port should not be a duplicate If the socket type is UNIX Domain the same environment variable SALTIBASE HOME should be specified as in the Altibase DBMS to which XLog Sender belongs Since the maximum allowable length of a socket filename varies depending on an operating system the maximum allowable length should be checked so that it is not exceeded unction ALA_AddAuthlnfo ALA_RemoveAuthlnfo ALA_DestroyXLogCollector m include lt alaAPI h gt void testXLogCollectorTCP ALA Handle sHandle Create XLog Collector that uses TCP XLog Sender Name log analysis XLog Sender Authentication Information IP 127 0 0 1 Listening Port 30300 47 Log Analysis API ALA CreateXLogCollector The max size of XLog Pool 10000 Obtain transaction XLog in the order of commit Disabled The reference number of XLog for which ACK will be sent out 100 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 emove og Sender Authentication Information R XL Send Auth i i Inf i void ALA RemoveAuthInfo sHandle PEER IP 127 0 0 2 NULL Invoke Log Analysis API Remove XLog Collector void ALA DestroyXLogCollector sHandle NULL
33. L 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 mType XLOG TYPE REPL STOP sReplStopFlag ALA TRUE Apply XLog to Altibase DBMS sAckFlag ALA FALSE 111 Sample Codes Sample Code Replication to Altibase DBMS switch sXLogHeader gt mType se XLOG TYPE COMMIT case case XLOG TYPE ABORT Unused in Committed Transaction Only 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
34. L SUCCESS return ALA FAILURE if SQLExecDirect gStmt SQLCHAR sQuery SOL NTS SOL SUCCESS printSqlErr gDbc gStmt void SOLFreeStmt gStmt SOL DROP return ALA FAILURE void SQLFreeStmt gStmt SOL DROP return ALA SUCCESS void printSqlErr SQLHDBC aDbc SQLHSTMT aStmt void SQLINTEGER errNo SQLSMALLINT msgLength SQLCHAR errMsg 1024 if SQLError SQL NULL HENV aDbc aStmt NULL amp errNo errMsg sizeof errMsg amp msgLength SQL SUCCESS printf SQL Error d s n int errNo printAlaErr ALA ErrorMgr aErrorMgr char sErrorMessage NULL int sErrorCode char errMsg 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 114 Index A ABORT Error 103 Add a Host 19 Add a Table for Analysis 18 ALA_AddAuthlnfo 49 ALA ClearErrorMgr 95 ALA CreateXLogCollector 46 ALA_DestroyAPI 42 ALA DestroyXLogCollector 65 ALA DisableLogging 45 ALA EnableLogging 43 ALA FreeXLog 64 ALA GetAltibaseSQL 90 ALA GetAltibaseText 88 ALA_GetColumninfo 82 ALA_GetErrorCode 97 ALA_GetErrorLevel 99 ALA_GetErrorMessage 101 ALA_Getlndexlnfo 84 ALA_GetInternalNumericlnfo 86 ALA_GetODBCCValue 92 ALA_GetProtocolVersion 74 ALA GetReplicationInfo 75 ALA GetTablelnfo 78 ALA GetTa
35. LA ErrorMgr UInt mErrorCode CODE SChar mErrorState 6 STATE SChar mErrorMessage ALA MAX ERROR MSG LEN 256 ALA ErrorMgr The followings should be considered when the Error Manager is used A host a process or thread that invokes Log Analysis API creates and stores the Error Manager The Error Manager keeps information on the last error only Error handling functions cannot use a NULL as the Error Manager s argument If a function other than the error handling functions uses the NULL as the Error Manager s argument in Log Analysis API an error is not recorded by Log Manager when it occurs Since an error code contains internal data it must be obtained with ALA_GetErrorCode ALA ErrorLevel can be obtained with ALA_GetErrorLevel and it represents the error level typedef enum ALA ERROR FATAL 0 Need to Destroy ALA ERROR ABORT Need to Handshake ALA ERROR_INFO Information ALA ErrorLevel Actions to be taken for each error level are as follows Since ALA_ERROR_FATAL is a fatal error ALA_DestroyXLogCollector should be invoked to end the corresponding XLog Collector 9 Introduction How to Use Log Analysis API Since ALA ERROR ABORT indicates that XLog Collector is in an abnormal status ALA_Handshake should be invoked to perform handshaking again for the corresponding XLog Collector ALA_ERROR_INFO indicates that invoking Log Analysis API has failed An appropriate action
36. LINT Internal Structure Each type is mapping 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 DATE Internal Structure There is only one internal data type available for time and date typedef struct mtdDateType SShort year Year 16bit UShort mon_day_hour Not Used 2bit Month 4bit Day 5bit Hour 5bit UInt min sec mic Minute 6bit Second 6bit LogAnalyzer Users Manual 36 ALTIBASE Internal Data Type MicroSec 20bit mtdDateType CHAR VARCHAR NCHAR NVARCHAR BYTE NIBBLE BIT VARBIT BLOB CLOB Internal Structure Each data type has similar structure with one another typedef struct mtdCharType CHAR VARCHAR UShort length Length of value UChar value 1 UChar Array mtdCharType typedef struct mtdNcharType NCHAR NVARCHAR UShort length Length of value UChar value 1 UChar Array mtdNcharType typedef struct mtdByteType BYTE UShort length Length of value UChar value 1 UChar Array mtdByteType typedef struct mtdNibbleType NIBBLE UChar length Length of Nibbles UChar value 1 UChar Array mtdNibbleType typedef struct mtdBitType BIT VARBIT UInt length
37. PI ALA FALSE NULL LogAnalyzer Users Manual 44 ALA DisableLogging ALA_DisableLogging Syntax ALA RC ALA DisableLogging ALA ErrorMgr aOutErrorMgr Argument Argument Description aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Disables logging Note It cannot be invoked when logging is not enabled Log Analysis API cannot be invoked while it is being invoked Related Function ALA EnableLogging Example Please refer to ALA_EnableLogging 45 Log Analysis API ALA CreateXLogCollector ALA_CreateXLogCollector Syntax ALA RC ALA CreateXLogCollector const SChar aXLogSenderName const SChar aSocketInfo SInt aXLogPoolSize ALA BOOL aUseCommittedTxBuffer UInt aACKPerXLogCount ALA Handle aOutHandle ALA ErrorMgr aOutErrorMgr Argument Argument Description aXLogSenderName The name of the corresponding XLog Sender length 1 40 aSocketlnfo Socket Information TCP UNIX Domain aXLogPoolSize The maximum size of XLog Pool range 1 aUseCommittedTxBuffer Whether to obtain Transaction XLog in the order of commit aACKPerXLogCount The reference number of XLog for which ACK will be sent range 1 aOutHandle XLog Collector Handle aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Creates XLog Collector corresponding to XLog Sender The name of XLog Sender can be
38. SendACK If XLog is to be applied to DBMS via ODBC in STEP 3c the Autocommit option should be turned off XLog Sender should be started after STEP 3a In STEP 3b ALA ReceiveXLog and ALA_GetXLog can be invoked by different threads from each other Once ALA FreeXLog is used the corresponding XLog and data cannot be used anymore 11 Introduction Summary of Log Analysis API Summary of Log Analysis API Log Analysis API Environment Management Type Log Analysis API Description Create amp Remove Log Analysis API Environ ment ALA InitializeAPI Create environment in which Log Analy sis API can be invoked ALA DestroyAPI Remove environment in which Log Anal ysis API can be invoked Logging ALA EnableLogging Enable logging for problem tracking ALA DisableLogging Disable logging XLog Collector related API Type Log Analysis API Description Create amp Prepare XLog Collector ALA_CreateXLogCollect or Create XLog Collector corresponding to XLog Sender ALA_AddAuthInfo Add authentication information for XLog Sender ALA_RemoveAuthInfo Remove authentication information for XLog Sender ALA_SetHandshakeTim eout Specify the handshake timeout ALA SetReceiveXLogTi meout Specify the XLog receiving timeout Receive Meta Data and XLog ALA Handshake Wait for a connection to XLog Sender and perform hand
39. URE Description Creates environment in which Log Analysis API can be invoked Note ALA ClearErrorMgr should be called before any other Log Analyzer API is called If it fails Log Analysis API cannot be used SQLAllocEnv should be called before the ALTIBASE ODBC Driver is used in case of connecting thru ALTIBASE ODBC Driver Related Function ALA_DestroyAPI Example include lt sqlcli h gt include lt alaAPI h gt LogAnalyzer Users Manual 40 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 void testAPIEnvironment2 ALA BOOL aUseAltibaseODBCDriver SQLHENV sEnv NULL Create Altibase ODBC Environment void SOLAllocEnv 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 SQLFreeEnv sEnv 41 ALA InitializeAPI Log Analysis API ALA DestroyAPI ALA DestroyAPI Syntax ALA RC ALA DestroyAPI ALA BOOL aUseAltibaseODBCDriver ALA ErrorMgr aOutErrorMgr
40. a via Log Analysis API If it fails to invoke Log Analysis API a proper action should be taken based on a cause for the error The latest error information is stored in Error Manager Log Manager is provided to trace the error Log Manager records brief trace and error information The entire structure is shown in the following illustration 3 Introduction Altibase Log Analyzer Figure 1 1 The Structure of Altibase Log Analyzer QL UPDATE NSERT DELETE Altibase DBMS Error Manager Meta KLog With Log Analysis API a user can obtain XLog and the meta data from XLog Collector The move ment of the meta data and XLog within XLog Collector is as follows The meta data is received by XLog Sender during handshaking and it is valid until the next hand shaking XLog is circulated in the following order 1 2 4 Memory for XLog is obtained from XLog Pool XLog Sender receives the XLog configuration data and creates XLog The XLog is added to XLog Queue and a user takes it from there To obtain the XLog for a transaction in the order of commit the XLog is temporalily stored in Transaction Table before it is added to XLog Queue The used XLog is returned to XLog Pool The following illustration shows the movement of the meta data and XLog within XLog Collector LogAnalyzer Users Manual 4 Altibase Log Analyzer Figure 1 2 The Structure of XLog Collector Log Analysis API C C XLog Collecto
41. abase server Organization The manual consists of the following sections Chapter 1 Introduction Chapter 2 XLog Sender Chapter 3 XLog Analysis Chapter 4 Log Analysis API Appendix A Error Codes Appendix B Sample Codes Conventions LogAnalyzer Users Manual ii Regarding This Manual This section describes the conventions used throughout the manual If you get familiarized with these rules you will be able to find necessary information more easily from this manual or other manuals in the documentation set The rules used throughout the manual are as follows Syntax Diagram Sample Code Rules In order to describe the syntax of a statement this manual uses a diagram that consists of the follow ing components Component Meaning A statement begins A syntactic element that is not a complete statement begins with an arrow Reserved word A statement continues in the next line A syntactic element that is not a complete statement ends with this symbol A statement continues from the previous line A syntactic ele ment that is not a complete statement begins with this sym gt bol A statement ends A reguired item SELECT An optional item NOT A required item with options Only one item must be speci fied ADD DROP lii Preface Rega
42. alize Logging void ALA DisableLogging amp sErrorMgr case 4 Destroy ALA API environment void ALA DestroyAPI ALA TRUE amp sErrorMgr case 3 void SQLDisconnect gDbc case 2 void SQLFreeConnect 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 110 Sample Code Replication to Altibase DBMS 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 with XLog Sender break return ALA FAILURE else If XLog is NUL
43. ame as in Replication For more information please refer to the Altibase Administration Replication User s Manual Note The UNIX Domain Connectivity can only be used in UNIX and LINUX Example XLog Sender Name log analysis XLog Collector Info TCP IP 127 0 0 1 PORT 35300 IP of server running XLog Collector Port number specified in XLog Collector Table for Analysis sys t1 iSQL gt CREATE REPLICATION log analysis FOR ANALYSIS WITH 127 0 0 1 35300 FROM sys t1 TO sys tl LogAnalyzer Users Manual 16 XLog Sender SQL Remove XLog Sender Syntax DROP REPLICATION replication name Description The same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Example XLog Sender Name log_analysis iSQL gt DROP REPLICATION log analysis Start XLog Sender Syntax ALTER REPLICATION replication name START OUICKSTART Description Starts XLog Sender For UNIX Domain a socket filename is automatically created Socket Filename SALTIBASE HOME trc rp replication name Unlike in Replication it is not registered in the Heart Beat thread The remaining parts are the same as in Replication For more information please refer to the Altibase Administration Replication User s Manual Note XLog Collector should be available for connection before this task can be performed When a UNIX Domain is used the same environment variable SALTIBASE HOME
44. 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 109 Sample Codes Sample Code Replication to Altibase DBMS printAlaErr amp sErrorMgr goto FINALYZE BRR RR RK RK RR RR RR KR RK ke ke e KR RR KR RK RR RR RK RRR RR RK RRR RR RK KR RR RR RR k k KK Using XLog Collector kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk void runXLogCollector sHandle amp sErrorMgr FINALYZE kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk Finalization kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk switch sStep case 6 Destroy XLog Collector void ALA DestroyXLogCollector sHandle amp sErrorMgr case 5 Fin
45. anual 50 ALA RemoveAuthlnfo Syntax ALA RC ALA RemoveAuthInfo ALA Handle const SChar aAuthInfo ALA RemoveAuthInfo ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aAuthlnfo XLog Sender Authentication Information aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Removes the authentication information for XLog Sender For TCP aAuthlnfo is a string in the PEER IP xlog sender ip format The valid length for xlog sender ip is between 1 39 Note It can used only when the socket type is set to TCP At least one piece of authentication information is required for XLog Sender Related Function ALA CreateXLogCollector ALA_AddAuthInfo ALA_Handshake 51 Log Analysis API ALA RemoveAuthInfo Example Please refer to ALA_CreateXLogCollector LogAnalyzer Users Manual 52 ALA SetHandshakeTimeout ALA SetHandshakeTimeout Syntax ALA RC ALA SetHandshakeTimeout ALA Handle UInt ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aSecond Handshake Timeout unit second range 1 OxFFFFFFFE aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Sets the handshake timeout The handshake timeout applies when ALA Handshake is invoked The default handshake timeout is 600 seconds Related Fun
46. blelnfoByName 80 ALA GetXLog 60 ALA GetXLogCollectorStatus 66 ALA GetXLogColumn 71 ALA GetXLogHeader 68 ALA GetXLogLOB 73 ALA GetXLogPrimaryKey 70 ALA GetXLogSavepoint 72 ALA Handshake 55 ALA InitializeAPI 40 ALA ReceiveXLog 58 ALA RemoveAuthlnfo 51 ALA SendACK 62 ALA SetHandshakeTimeout 53 ALA SetReceiveXLogTimeout 54 Altibase Internal Data Type 34 Altibase Log Analyzer 2 B Basic Use 10 BIGINT 36 BIT 37 BLOB 37 BYTE 37 C CHAR 37 CLOB 37 Create XLog Sender 16 D Data Type 8 DATE 36 DOUBLE 36 E End XLog Sender 18 Error Code Table 103 Error Handling 9 Error Handling API 14 F FATAL Error 103 FLOAT 35 G GEOMETRY 37 H Handshake 2 l INFO Error 105 INTEGER 36 L Log Analysis API 2 Log Analysis API Environment 12 M Meta Data 33 Meta Data Structure 33 Meta Table 22 N NCHAR 37 NIBBLE 37 NUMERIC 35 NVARCHAR 37 P Performance View 24 R REAL 36 Remove a Host 20 Remove a Table for Analysis 19 Remove XLog Sender 17 Replication 3 Replication SYNC 3 Restart SN 3 S SAVEPOINT 38 Set a Host 20 SMALLINT 36 SN 3 Start XLog Sender 17 SYSTEM SYS REPL HOSTS 22 SYSTEM SYS REPLICATIONS 22 SYSTEM SYS REPL ITEMS 23 T Transaction Table 3 Types of XLog 28 V VSREPEXEC 24 VSREPGAP 25 VSREPSENDER 24 VSREPSENDER TRANSTBL 25 VARBIT 37 VARCHAR 37 X XLog 2 28 XLog Analysis amp Conversion API 13 XLog Collector 2 XLog Collector related API 12 XLo
47. case XLOG TYPE KEEP ALIVE SAckFlag ALA TRUE break case XLOG TYPE BEGIN case XLOG TYPE LOB CURSOR OPEN case XLOG TYPE LOB CURSOR CLOSE case XLOG TYPE LOB PREPARE4WRITE 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 112 Sample Code Replication to Altibase DBMS 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
48. ction ALA Handshake Example Please refer to ALA Handshake 53 Log Analysis API ALA SetReceiveX LogTimeout ALA_SetReceiveXLogTimeout Syntax ALA RC ALA SetReceiveXLogTimeout ALA Handle aHandle UInt aSecond ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aSecond XLog Receive Timeout unit second range 1 OxFFFFFFFE aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Sets the XLog Receive timeout The XLog Receive timeout applies when ALA ReceiveXLog is invoked The default XLog Receive timeout is 10 seconds Related Function ALA ReceiveXLog Example Please refer to ALA Handshake LogAnalyzer Users Manual 54 ALA_Handshake Syntax ALA RC ALA Handshake ALA Handle ALA ErrorMgr aOutErrorMgr ALA Handshake Argument Argument Description aHandle XLog Collector Handle aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Listens for XLog Sender and performs handshaking The user settings and all data in XLog Collector excluding XLog Pool are initialized The meta data is received and stored internally Note If TCP is used it fails when there is no matching authentication information It fails if the connected peer is not XLog Sender If XLog Sender is not connected within the handshake timeout a timeout will occur ALA Receiv
49. d Related Function ALA_GetAltibaseSQL Example include lt alaAPI h gt void testAltibaseText ALA Table aTable ALA XLog aXLog SChar sBuffer 1024 Obtain Altibase SQL void ALA GetAltibaseSQL aTable aXLog 1024 sBuffer NULL 89 Log Analysis API ALA GetAltibaseSQL ALA_GetAltibaseSQL Syntax ALA RC ALA GetAltibaseSQL ALA Table aTable ALA XLog aXLog UInt aBufferSize SChar aOutBuffer ALA ErrorMgr aOutErrorMgr Argument Argument Description aTable The table information for XLog aXLog XLog aBufferSize Buffer Size aOutBuffer Buffer aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Converts transaction XLog to an Altibase SQL string For time date type the date format is YYYY MM DD HH MI SS SSSSSS BIT is converted to the BIT value format and VARBIT is converted to the VARBIT value format NCHAR and NVARCHAR is converted to the UNISTR value format When the Insert Update or Delete SQL is created the target table is specified using mToUserName and mToTableName in aTable Note BLOB CLOB and GEOMETRY are not supported LogAnalyzer Users Manual 90 ALA GetAltibaseSQL It may not be compatible with SQL for other DBMS Related Function ALA_GetAltibaseText Example Hinclude lt alaAPI h gt void testAltibaseSQL ALA Table aTable ALA XLog aXLog ALA Column sColumn SChar s
50. d before handshaking should not be used again and again Related Function ALA Handshake ALA GetTablelnfo ALA GetTablelnfoByName ALA GetColumnlInfo 75 Log Analysis API ALA GetReplicationInfo ALA_Getlndexlnfo Example Hinclude lt alaAPI h gt void testMetalnformation 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
51. data ALA Value can be obtained by using Log Analysis API for XLog The internal data value is the value member of the ALA Value structure and the length of the inter nal data value is the length member of the ALA Value structure The mDataType value for ALA Column can be used to determine the type of the internal data Table 3 1 ALTIBASE Internal Data Types Category Type of Internal Data 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 LogAnalyzer Users Manual 34 ALTIBASE Internal Data Type FLOAT NUMERIC Internal Structure The internal data structure of FLOAT and NUMERIC are the same typedef struct mtdNumericType UChar length Length of signExponent mantissa UChar signExponent Sign and Exponent UChar mantissa 1 UChar Array 100 Base mtdNumericType ALA GetlnternalNumericlnfo can be used to obtain the sign and exponent Obtaining the sign from mtdNumericType if signExponent is 128 255 Sign else if signExponent is 0 127 Sign Obtaining the exponent from mtdNumericType It is an exponent for a decimal number if signExponent is 128 255 Exp
52. e corresponding XLog Collector Since ALA ERROR ABORT indicates that XLog Collector is in an abnormal status ALA Handshake should be invoked to perform handshaking again for the corresponding XLog Collector ALA ERROR INFO indicates that invoking Log Analysis API has failed An appropriate action should be taken based on the error code Note Memory for aOutErrorLevel should be allocated in advance Related Function ALA ClearErrorMgr ALA GetErrorCode 99 Log Analysis API ALA GetErrorLevel ALA GetErrorMessage Example Please refer to ALA ClearErrorMgr LogAnalyzer Users Manual 100 ALA_GetErrorMessage Syntax ALA RC ALA GetErrorMessage const ALA ErrorMgr akrrorMgr ALA_ GetErrorMessage const SChar aOutErrorMessage Argument Argument Description aErrorMgr Error Manager aOutErrorMessage Error Message Result ALA_SUCCESS ALA_FAILURE Description Obtains a specific error message Note Since aOutErrorMessage is replaced with a pointer to the error message memory is not allocated for aOutErrorMessage Related Function ALA_ClearErrorMgr ALA_GetErrorCode ALA_GetErrorLevel Example Please refer to ALA_ClearErrorMgr 101 Log Analysis API ALA GetErrorMessage LogAnalyzer Users Manual 102 Error Code Table Error Code Table Appendix A Error Codes The following table describes error codes and their possible causes
53. e meta table The meta table can be obtained via ALA GetTablelnfo or ALA GetTablelnfoByNamef Configuration Based on XLog Type The type of XLog can be identified with the mType member in ALA XLogHeader BEGIN XLog Header mType mTID mSN mSyncSN COMMIT XLog Header mType mTID mSN mSyncSN ABORT XLog Header mType mTID mSN mSyncSN INSERT XLog Header mType mTID mSN mSyncSN mTableOID Column mColCnt mCIDArray mAColArray UPDATE XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray Column mColCnt mCIDArray mBColArray mAColArray DELETE XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray LogAnalyzer Users Manual 30 XLog SP_SET XLog Header mType mTID mSN mSyncSN Savepoint mSPNameLen mSPName If mSPName begins with IMPLICIT it is the implict savepoint If mSPName is S PSM_SVP it is PSM Savepoint SP_ABORT XLog Header mType mTID mSN mSyncSN Savepoint mSPNameLen mSPName If mSPName begins with IMPLICIT it is the implict savepoint If mSPName is S PSM_SVP it is PSM Savepoint LOB_CURSOR_OPEN XLog Header mType mTID mSN mSyncSN mTableOID Primary Key mPKColCnt mPKColArray LOB mLobLocator mLobColumnID LOB CURSOR CLOSE XLog Header mType mTID mSN mSyncSN LOB mLobLocator LOB PREPAREAWRITE XLog Header mType mTID mSN mSyncSN LOB mLobLocator mLobOffset
54. eXLog ALA GetXLog and ALA SendACK should not be invoked before handshak ing is completed Before handshaking is started ALA FreeXLog should be performed on all XLog obtained via ALA_GetXLog so that XLog Pool is not depleted 55 Log Analysis API ALA Handshake Related Function ALA_AddAuthInfo ALA_RemoveAuthInfo ALA_SetHandshakeTimeout ALA_ReceiveXLog ALA_SendACK ALA_GetReplicationlnfo ALA_GetTablelnfo ALA_GetColumnInfo ALA_Getlndexlnfo Example include lt alaAPI h gt 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 ix HaddenEKarinogat 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
55. er Result ALA SUCCESS ALA FAILURE Description Retrieves the index information in a table by Index ID Note If there is no corresponding meta data it returns NULL as an argument The meta data obtained before handshaking should not be used again and again Related Function ALA Handshake ALA GetReplicationInfo ALA GetTablelnfo LogAnalyzer Users Manual 84 ALA GetIndexInfo ALA_GetTablelnfoByName ALA GetColumnlInfo Example Please refer to ALA GetReplicationlnfo 85 Log Analysis API ALA GetlnternalNumericinfo ALA_GetlnternalNumericinfo Syntax ALA RC ALA GetInternalNumericInfo ALA Column aColumn ALA Value aAltibaseValue SInt aOutSign SInt aOutExponent ALA ErrorMgr aOutErrorMgr Argument Argument Description aColumn The column information for the internal data of Alti base aAltibaseValue The internal data of Altibase aOutSign Sign aOutExponent Exponent aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the sign and exponent of FLOAT and NUMERIC If aOutSign is 1 it represents a positive number If it is 0 it represents a negative number aOutExponent is an exponent for a decimal number Example include lt alaAPI h gt void testInternalNumeric ALA Column aColumn ALA Value aAltibaseValue LogAnalyzer Users Manual 86 ALA GetlnternalNumericinfo SInt sNumericSign SInt sNu
56. er of the file For example if the header of the log file analysis log has number 1 and the size of the log file reaches aFileSize its filename is changed from analysis log to analysis log 1 and a new log file named analysis log is created The number of the log file header starting from 1 is incremented by 1 If it reaches aMaxFileNumber incrementing starts over from 1 As a result only the current log file in use and the last aMaxFile Number log files are kept 43 Log Analysis API ALA EnableLogging Note Up to 1 024 combinations of log directory and log file names are allowed including NULL It cannot be invoked when logging is already enabled Log Analysis API cannot be invoked while it is being invoked If the log file header is not normal the log file is deleted and created again If aFileSize is 0 the log file can grow infinitely Related Function ALA DisableLogging Example Hinclude lt alaAPI h gt 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 10 NULL Invoke Log Analysis API Disable logging void ALA DisableLogging NULL Remove Log Analysis API Environment void ALA DestroyA
57. etXLog 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 s 0x5201D Invalid Parameter All Log Analysis API s 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 cor ALA_AddAuthInfo responding Log Analysis API ALA_RemoveAuthInfo 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 105 Error Codes Error Code Table ODBC C Error Code Description Can be returned from 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
58. g Flush 21 XLog Pool 2 XLog Queue 2 XLog Sender 2 XLog Sender SQL 16 116
59. har sBuffer 1024 ALA BOOL sIsNull UInt sODBCCValueSize UInt sPKColumnPos Convert the primary key to SQL C CHAR for sPKColumnPos 0 sPKColumnPos aXLog mPrimaryKey mPKColCnt sPKColumnPos The primary key sequence for XLog and the primary key sequence for the table are the same sColumn aTable gt mPKColumnArray sPKColumnPos Convert the internal data to SQL_C CHAR void ALA GetODBCCValue sColumn amp aXLog mPrimaryKey mPKColArray sPKColumnPos SQL C CHAR 1024 sBuffer amp sIsNull amp sODBCCValueSize NULL LogAnalyzer Users Manual 94 ALA_ClearErrorMgr Syntax ALA RC ALA ClearErrorMgr ALA ErrorMgr aOutErrorMgr Argument ALA ClearErrorMgr Argument Description aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Initializes Error Manager Note Before Error Manager is used for the first time it should be initialized Related Function ALA GetErrorCode ALA GetErrorLevel ALA GetErrorMessage Example include lt alaAPI h gt void testErrorHandling ALA ErrorMgr sErrorMgr UInt sErrorCode 95 Log Analysis API ALA ClearErrorMgr ALA ErrorLevel sErrorLevel 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
60. he manual When you need an immediate assistance regarding technical issues please contact Altibase Customer Support Cen ter We always appreciate your comments and suggestions LogAnalyzer Users Manual vi Introduction This section describes the concept of Altibase Log Analyzer and its basic use 1 Introduction Altibase Log Analyzer Altibase Log Analyzer Altibase Log Analyzer is a set of modules and API in Altibase DBMS that provides a history of DML related transactions based on active logs in Altibase DBMS Altibase Log Analyzer can be used for 1 linking of Altibase DBMS and other DBMS 2 detecting and handling of changes within Altibase DBMS from the outside of Altibase DBMS Terms amp Concepts XLog XLog is a logical log that is converted from a physical log It stores the DML Insert Update Delete transaction history XLog Sender XLog Sender is a module that creates XLog by analyzing active logs and passes it to XLog Collector XLog Sender performs a handshake and XLog transmission actively XLog Collector XLog Collector is a module that receives meta data and XLog from XLog Sender XLog Collector contains meta data XLog Queue Trasaction Table and XLog Pool It is called via Log Analysis API Log Analysis API Log Analysis API provides XLog and the meta data that can be used to interpret the XLog Handshake A handshake is a process in which XLog Collector checks protocol version and meta
61. he table OID that will be searched for aOutTable Table information aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Retrieves the table information by table OID Note If there is no corresponding meta data it returns NULL as an argument The meta data obtained before handshaking should not be used again and again Related Function ALA Handshake ALA GetReplicationInfo ALA GetTablelnfoByName LogAnalyzer Users Manual 78 ALA GetTablelnfo ALA GetColumnlInfo ALA GetIndexInfo Example Please refer to ALA GetReplicationlnfo 79 Log Analysis API ALA GetTablelnfoByName ALA_GetTablelnfoByName Syntax ALA RC ALA GetTableInfoByName ALA Handle aHandle const SChar aFromUserName const SChar aFromTableName const ALA Table aOutTable ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aFromUserName The From User Name that will be searched for aFromTableName The From Table Name that will be searched for aOutTable Table information aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Retrieves the table information by user name and table name Note If there is no corresponding meta data it returns NULL as an argument The meta data obtained before handshaking should not be used again and again Related Function ALA Handshake LogAnalyzer Users Manual 80
62. hould not be invoked Related Function ALA CreateXLogCollector Example Please refer to ALA CreateXLogCollector 65 Log Analysis API ALA GetXLogCollectorStatus ALA_GetXLogCollectorStatus Syntax ALA RC ALA GetXLogCollectorStatus ALA Handle aHandle ALA XLogCollectorStatus aOutXLogCollectorStatus ALA ErrorMgr Argument aOutErrorMgr Argument Description aHandle XLog Collector Handle aOutXLogCollectorStatus The status structure of XLog Collector aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the status of XLog Collector mMyIP mMyPort mPeerlP mPeerPort and mSocketFile are updated with ALA_Handshake mXLogCountlnPool is incremented decremented with ALA ReceiveXLog and it is decremented with ALA_FreeXLog mLastArrivedSN is the SN for the last XLog received via ALA ReceiveXLog mLastProcessedSN is the SN for the last XLog received via ALA_GetXLogf Since mNetworkValid indicates the network validity it can be changed when ALA_Handshake ALA ReceiveXLog or ALA SendACK is invoked The status structure of XLog Collector can be defined as follows typedef struct ALA XLogCollectorStatus SChar mMyIP ALA IP LEN SInt mMyPort SChar mPeerIP ALA IP LEN SInt mPeerPort LogAnalyzer Users Manual 66 ALA GetXLogCollectorStatus SChar mSocketFile ALA SOCKET FILENAME LEN UInt
63. ilure ALA_Handshake ALA_SendACK 0x5101C Network Flush Failure 0x51015 Network Timeout Network Error ALA_Handshake 0x5102C Network Session Add Failure ALA_Handshake 0x51024 The protocol version is not the same ALA_Handshake 0x51027 Link Allocation Failure ALA_Handshake 0x51028 Link Listen Failure ALA_Handshake 0x51029 Link Wait Failure ALA_Handshake 0x5102A Link Accept Failure ALA_Handshake 0x5102B Link Set Failure ALA_Handshake 0x51022 Link Shutdown Failure ALA_Handshake ALA_DestroyXLogCollector 0x51023 Link Free Failure 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 104 Error Code Table Error Code Description Can be returned from 0x52034 Log Analysis API Environment Create ALA InitializeAPI Failed 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 s 0x52005 Log Manager Unlock Failure All Log Analysis API s 0x52003 Log Manager Remove Failure ALA_DisableLogging 0x52002 Log File Close Failure ALA_DisableLogging 0x52009 Not an active transaction ALA_G
64. ld be processed before ALA SendACK is invoked If a network error occurs XLog Sender attempts to handshake periodically If it succeeds it sends XLog begining with Restart SN Related Function ALA Handshake ALA ReceiveXLog Example Please refer to ALA Handshake 63 Log Analysis API ALA FreeXLog ALA_FreeXLog Syntax ALA RC ALA FreeXLog ALA Handle aHandle ALA XLog aXLog ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aXLog XLog that will be returned to XLog Pool aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Returns XLog to XLog Pool Note If the XLog obtained with ALA GetXLog is not returned overlong XLog Pool may get depleted Related Function ALA ReceiveXLog ALA GetXLog Example Please refer to ALA Handshake LogAnalyzer Users Manual 64 ALA DestroyXLogCollector Syntax ALA RC ALA DestroyXLogCollector ALA Handle aHandle ALA ErrorMgr aOutErrorMgr ALA DestroyXLogCollector Argument Argument Description aHandle XLog Collector Handle aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Removes XLog Collector Note Before it is invoked ALA FreeXLog should be performed on all XLog obtained via ALA_GetXLog Regardless of the result the Log Analysis API that is related to the corresponding XLog Collector s
65. mary key of the table to analyze cannot be modified However INSERT or DELETE can be performed on the primary key DDL cannot be performed on the table to analyze Up to 32 XLog Senders and Replication Senders can be created together in a single Altibase DBMS The protocol version of Log Analysis API should be the same with the protocol version of Rep lication If there are more than one XLog Collector in a single process the protocol version of Replica tion in Altibase DBMS should be the same with the protocol version of Replication However unlike Replication it does not examine the foreign key column in a table supports Lazy Mode only LogAnalyzer Users Manual 6 Altibase Log Analyzer does not support Replication SYNC For more information on Replication please refer to the Altibase Administration Replication User s Manual 7 Introduction How to Use Log Analysis API How to Use Log Analysis API This section explains how to use Log Analysis API that is included in user s application For information on using XLog Sender please refer to Chapter 2 XLog Sender quired Files Table 1 1 Required Files Type Filename Description Header alaAPl h The file is required to use Log Analysis API and it contains alaTypes h alaTypes h It defines data types that will be used by Log Analysis API Library libala sl x A shared library of Log Analysis API libala x A static library of Log
66. me for a remote server REMOTE_PARTITION_NAME VARCHAR 40 Partition Name in Remote Server IS_PARTITION CHAR 1 Whether to Partition INVALID_MAX_SN BIGINT The highest SN of logs to skip CONDITION VAR Replication Conditional Clause CHAR 1000 For a UNIX domain the value for the HOST_IP column is UNIX_DOMAIN and the value for the PORT_NO column is the value for the HOST_NO column For more information please refer to the Altibase Administration Administrator s Manual 23 XLog Sender Performance View Performance View It provides the same performance view as in Replication It has information on an administrator Column name Type Description PORT INTEGER The number of port being used MAX_SENDER_COUNT INTEGER The maximum number of senders MAX_RECEIVER_COUNT INTEGER The maximum number of receivers For more information please refer to the Altibase Administration Administrator s Manual It has information on the status of XLog Sender Column name Type Description REP_NAME VARCHAR 42 Name START_FLAG BIGINT Start flag NET_ERROR_FLAG BIGINT Error status flag XSN BIGINT SN of shipping log STATUS BIGINT Current status SENDER_IP VARCHAR 50 Sender s IP PEER_IP VARCHAR 50 Remote IP SENDER_PORT INTEGER Sender s port PEER_PORT INTEGER Remote port XSN BIGINT The SN for the transmission log COMMIT_XSN BIGINT The SN for
67. mericExponent Obtain the internal numeric information void ALA GetInternalNumericInfo aColumn aAltibaseValue amp sNumericSign amp sNumericExponent NULL 87 Log Analysis API ALA GetAltibaseText ALA_GetAltibaseText Syntax ALA RC ALA GetAltibaseText ALA Column aColumn ALA Value UInt SChar ALA ErrorMgr aBufferSize aOutBuffer aOutErrorMgr Argument Argument Description aColumn The column information for the internal data of Alti base aValue The internal data value of Altibase aBufferSize Buffer Size aOutBuffer Buffer aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Converts the internal data of Altibase to a string For time date type the date format is YYYY MM DD HH MI SS SSSSSS BIT is converted to the BIT value format and VARBIT is converted to the VARBIT value format Simple Rules You should specify the value of national character set as ALTIBASE_ALA_NCHARSET that is an envi ronment variable in the server where you want to analyze logs if using NCHAR or NVARCHAR typed data LogAnalyzer Users Manual 88 ALA GetAltibaseText ex If character set of NCHAR and NVARCHAR is set to UTF8 in target server export ALTIBASE ALA NCHARSET UTF8 ALA prints it as UCS 2 UTF 16 by calling aOutBuffer parameter of ALA_GetAltibaseText function ex 0031 0020 0020 0020 BLOB CLOB and GEOMETRY are not supporte
68. nformation for the internal data of Alti base aAltibaseValue The internal data value of Altibase aODBCCTypelD The ODBC C type to convert aODBCCValueBufferSize The size of the result buffer aOutODBCCValueBuffer The result buffer aOutlsNull Whether the internal data of Altibase is NULL aOutODBCCValueSize The size of the ODBC C value converted aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAILURE Description Convert the internal data of Altibase to the ODBC C value LogAnalyzer Users Manual 92 ALA GetODBCCValue Table 4 1 ODBC C Conversion dWVLSAWIL 3dAL D 1OS 3WIL 3dAL D 1OS Alva 3dAL D 10S AWUVNIS D TOS q318nod 3 10s 1VO14 D 105 INIDIGN D TOSLNIDI8S D 10S DNOTN D TOSDNOTS 2 10S LYOHSN D TOSLHOHSS D 10S ANIANILN D TOSLNIANILS D 105 lig D 1OS JDIH3WNN D 10S YYHD D 10S O O O O O O nal Data ALTIBASElnter ODBC C Value FLOAT NUMERIC DOUBLE REAL BIGINT INTEGER SMALLINT DATE CHAR VARCHAR NCHAR NVARCHAR BYTE NIBBLE BIT VARBIT BLOB CLOB and GEOMETRY are not supported ODBC 3 0 or later is supported Hinclude lt alaAPI h gt Log Analysis API 93 ALA GetODBCCValue void testODBCCConversion ALA Table aTable ALA XLog aXLog ALA Column sColumn SC
69. ocedure Each SAVEPOINT is managed separately and users process it depending on situation Example iSQL CREATE TABLE T1 I1 INTEGER PRIMARY KEY Create success iSQL INSERT INTO T1 VALUES 2 1 row inserted iSQL CREATE OR REPLACE PROCEDURE PROC1 2 AS 3 BEGIN 4 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 4 R iSQL ROLLBACK TO SAVEPOINT EXPLICIT SP Rollback success KO J UT LogAnalyzer Users Manual 38 4 Log Analysis API This chapter provides description on using the Log Analysis API component of Altibase Log Analyzer Log Analysis API is an API that is invoked by the user s application It provides functions which receive XLog from XLog Sender and analyze it An argument which begins with aOut is an output argument The following sections describes functions that can be used in C C languages 39 Log Analysis API ALA InitializeAPI ALA InitializeAPI Syntax ALA RC ALA InitializeAPI aUseAltibaseODBCDriver ALA BOOL ALA ErrorMgr aOutErrorMgr Argument Argument Description aUseAltibaseODBCDriver Whether to use the Altibase ODBC driver aOutErrorMgr Error Manager Result ALA_SUCCESS ALA_FAIL
70. ogHeader ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogSavepoint Example Please refer to ALA_GetXLogHeader 73 Log Analysis API ALA GetProtocolVersion ALA_GetProtocolVersion Syntax ALA RC ALA GetProtocolVersion const ALA ProtocolVersion aOutProtocolVersion ALA ErrorMgr aOutErrorMgr Argument Argument Description aOutProtocolVersion Protocol Version Structure aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the protocol version of Log Analysis API It can be obtained regardless of handshaking Note Memory for aOutProtocolVersion should be allocated in advance Example Hinclude alaAPI h void testProtocolVersion ALA ProtocolVersion sProtocolVersion Obtain Protocol Version void ALA GetProtocolVersion amp sProtocolVersion NULL LogAnalyzer Users Manual 74 ALA_GetReplicationinfo Syntax ALA GetReplicationInfo ALA RC ALA GetReplicationInfo ALA Handle const ALA Replication aOutReplication ALA ErrorMgr Argument aHandle aOutErrorMgr Argument Description aHandle XLog Collector Handle aOutReplication Replication Information aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the Replication information Note If there is no corresponding meta data it returns NULL as an argument The meta data obtaine
71. olumn ALA ErrorMgr aOutErrorMgr Argument Argument Description aXLog XLog aOutXLogColumn XLog Column aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the XLog column from XLog Related Function ALA GetXLog ALA GetXLogHeader ALA GetXLogPrimarykey ALA GetXLogSavepoint ALA GetXLogLOB Example Please refer to ALA GetXLogHeader 71 Log Analysis API ALA GetXLogSavepoint ALA_GetXLogSavepoint Syntax ALA RC ALA GetXLogSavepoint const ALA XLog aXLog const ALA XLogSavepoint aOutXLogSavepoint ALA ErrorMgr aOutErrorMgr Argument Argument Description aXLog XLog aOutXLogSavepoint XLog Savepoint aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the XLog savepoint from XLog Related Function ALA GetXLog ALA GetXLogHeader ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogLOB Example Please refer to ALA_GetXLogHeader LogAnalyzer Users Manual 72 ALA_GetXLogLOB Syntax ALA RC ALA GetXLogLOB const ALA_XLog aXLog const ALA XLogLOB aOutXLogLOB ALA ErrorMgr Argument aOutErrorMgr ALA_GetXLogLOB Argument Description aXLog XLog aOutXLogLOB XLog LOB aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains the XLog LOB from XLog Related Function ALA GetXLog ALA GetXL
72. onent SInt signExponent amp 0x7F 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 Obtaining the mantissa string from mtdNumericType Each UChar has a value between 0 and 99 100 nary The result is a number between 0 and 1 if Sign is Example 01 23 45 67 89 0 123456789 12 34 56 78 99 0 1234567899 i mantissa 0 if mantissa 0 10 MantissaStr mantissa 0 else 35 XLog Analysis ALTIBASE Internal Data Type MantissaStr mantissa 0 10 MantissaStr MantissaStr mantissa 0 10 mantissa 1 mantissa mLength 1 for Index 1 Index mLength 1 Index MantissaStr MantissaStr mantissa Index 10 MantissaStr MantissaStr mantissa Index 10 else if Sign is Sus Example 98 76 54 32 10 0 123456789 09 87 65 43 21 0 9012345678 mantissa 0 if mantissa 0 gt 90 MantissaStr else MantissaStr MantissaStr 99 mantissa 0 MantissaStr MantissaStr 99 mantissa 0 mantissa 1 mantissa mLength 1 for Index 1 Index lt mLength 1 Index MantissaStr 99 mantissa 0 LO 10 MantissaStr MantissaStr 99 mantissa Index 10 MantissaStr MantissaStr 99 mantissa Index 10 DOUBLE REAL BIGINT INTEGER SMAL
73. r Meta Information a s n s ue Transaction Table Session Features Log Sender uses the Replication module XLog Sender is managed with the almost same SQL as in the Replicaton and it is applied with prop erties in Replication For more information on Replication please refer to the Altibase Administration Replication User s Manual 5 Introduction Altibase Log Analyzer Transaction XLog can be obtained in the order of commit When XLog Collector is created it can be set such that transaction XLog can be obtained in the order of commit If this is the case the following restrictions apply The corresponding transaction XLog can be obtained after COMMIT XLog is received When a user obtains XLog the savepoint related XLog is not neccessary and thus it is not pro vided A user may not obtain XLog for the Abort transaction TCP and UNIX Domain are supported for XLog transmission UNIX Domain can be used only when XLog Sender and XLog Collector are in the same machine and the OS is UNIX or LINUX Only one socket type can be used for a XLog Sender Conversion to the ODBC C value is supported The internal data of Altibase can be converted to the ODBC C value Restrictions Because XLog Sender uses the Replication module the following restrictions apply A user must have the SYSDBA system privilege Analysis targets are in table base A table to analyze must have a primary key The pri
74. r aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Sends ACK to XLog Sender If ALA_GetXLog succeeds for more than the reference number of XLog for which ACK will be sent out or there is a record showing that KEEP_ALIVE or REPL STOP XLog has been received ACK is sent to XLog Sender If there is REPL STOP XLog received a network connection will be disconnected ACK contains Restart SN Restart SN is determined as the one with the minimum value among the following SN s The minimum BEGIN XLog SN for the active transactions checked at the point when ALA GetXLog is invoked lastly The SN for the last XLog obtained with ALA_GetXLogf if there is no active transaction The minimum BEGIN XLog SN for uncommitted transactions that are stored in the transaction table if transaction XLog is obtained in the order of commit Note It affects the meta table and flush of XLog Sender If ACK is not sent within the LogAnalyzer Users Manual 62 ALA SendACK REPLICATION_RECEIVE_TIMEOUT property of XLog Sender XLog Sender drops the network connec tion And also if it is not invoked for a long time XLog Sender may stop sending XLog updates Restart SN with the SN for the most recently recorded log and start over Since Restart SN in XLog Sender can be updated all XLog obtained with ALA_GetXLog shou
75. r of commit it may not be added to XLog Queue even if it is received LogAnalyzer Users Manual 58 ALA ReceiveXLog If a network error occurs or REPL STOP XLog is received the transactions that have been obtained via ALA GetXLog but not committed should be rolled back Memory for aOutlnsertXLoglnQueue should be allocated in advance Related Function ALA SetReceiveXLogTimeout ALA Handshake ALA GetXLog ALA SendACK ALA FreeXLog Example Please refer to ALA Handshake 59 Log Analysis API ALA GetXLog ALA_GetXLog Syntax ALA RC ALA GetXLog ALA Handle aHandle const ALA XLog aOutXLog ALA ErrorMgr aOutErrorMgr Argument Argument Description aHandle XLog Collector Handle aOutXLog XLog obtained from XLog Queue aOutErrorMgr Error Manager Result ALA SUCCESS ALA FAILURE Description Obtains XLog from XLog Queue It can be invoked together with ALA ReceiveXLog at a time If there is no XLog in XLog Queue aOutXLog is NULL Note XLog is managed by a user until ALA_FreeXLog is invoked Related Function ALA ReceiveXLog ALA FreeXLog ALA GetXLogHeader LogAnalyzer Users Manual 60 ALA GetXLog ALA GetXLogPrimaryKey ALA GetXLogColumn ALA GetXLogSavepoint ALA GetXLogLOB Example Please refer to ALA Handshake 61 Log Analysis API ALA SendACK ALA SendACK Syntax ALA RC ALA SendACK ALA Handle aHandle ALA ErrorMg
76. rding This Manual Component Meaning An optional item with options ASC DESC An optional item More than one item is allowed Each repeti tion must be preceded by a comma ASC DESC am eo Code examples demonstrate the use of SQL Stored Procedure iSQL or other command line syntax The following table describes the print conventions used in code examples Rule Meaning Example Indicates an optional item VARCHAR size FIXED VARIABLE Indicates a required item At least one ENABLE DISABLE COMPILE item must be selected Separates arguments for an optional ENABLE DISABLE COMPILE or required item ENABLE DISABLE COMPILE Repeats the previous arguments Indi SOL SELECT ename FROM cates an omission in an example code employee ENAME HSCHOI 20 rows selected Other Symbols LogAnalyzer Users Manual The symbols other than those shown EXEC p1 1 above acc NUMBER 11 2 iv Regarding This Manual Rule Meaning Example Italic A variable that should be specified by SELECT FROM table name a user A placeholder to which a spe CONNECT userlD password cific value should be supplied Lower Case Program elements provided by a user SELECT ename FROM Ex table name column name file
77. rently READ OFFSET INTEGER Location Read Currently 25 XLog Sender Performance View For more information please refer to the Altibase Administration Administrator s Manual LogAnalyzer Users Manual 26 3 XLog Analysis This chapter describes XLog the meta data and Altibase internal data types that are required for XLog analysis XLog and the meta data can be obtained via Log Analysis API 27 XLog Analysis XLog XLog This section describes the types and components of XLog A user should invoke ALA_GetXLog to obtain XLog 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 Partial write XLOG TYPE LOB FINISHZWRITE 18 LOB Finish to write XLOG TYPE KEEP ALIVE 19 Keep Alive XLOG TYPE REPL STOP 21 Replication Stop ALA XLogType XLog can be classified into 13 types of the transaction XLog and two types of the control XLog The transaction
78. shaking ALA ReceiveXLog After receiving XLog add it to XLog Queue ALA_GetXLog Obtain XLog from XLog Queue ALA_SendACK Send ACK to XLog Sender ALA_FreeXLog Return XLog to XLog Pool Remove XLog Collector LogAnalyzer Users Manual ALA_DestroyXLogCollec tor 12 Remove XLog Collector Summary of Log Analysis API Type Log Analysis API Description Monitor XLog Collector ALA GetXLogCollectorS tatus Obtain the status of XLog Collector Type Log Analysis API Description XLog ALA GetXLogHeader Obtain the XLog header from XLog ALA GetXLogPrimaryKey Obtain the XLog header from XLog ALA GetXLogColumn Obtain the XLog column from XLog ALA GetXLogSavepoint Obtain the XLog savepoint from XLog ALA GetXLogLOB Obtain the XLog LOB from XLog Meta data ALA GetProtocolVersion Obtain the protocol version of Log Analy sis API ALA GetReplicationInfo Obtain the Replication information ALA GetTablelnfo Retrieve the table information by table OID ALA_GetTablelnfoByNam e Retrieve the table information by user name and table name ALA GetColumnlnfo Retrieve the column information in a table by Column ID ALA_Getlndexlnfo Retrieve the index information in a table by Index ID Altibase Internal Data Type ALA_GetInternalNumericl nfo Obtain the sign and exponent of FLOAT and NUMERI
79. st parameter when you call ALA IntializeAPI if SQLAllocEnv amp gEnv SOL SUCCESS goto FINALYZE sStep 1 if SQLAllocConnect 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 108 Sample Code Replication to Altibase DBMS Autocommit OFF if SOLSetConnectAttr gDbc SOL ATTR AUTOCOMMIT SQL POINTER SOL AUTOCOMMIT OFF 0 SOL SUCCESS printSqlErr gDbc gStmt goto FINALYZE BRR RR RK RK RR KR RR KR RK KR KR RK RRR RR RR RK RR RR KR RRR RR RR k RR RR RR ke ke KKK ALA Initialization KK K K KR KK RR KK RR KR RK k k k KK RR RR RRR RRR RR RR k k RR ee ke ke k k Initialize Error Manager void ALA ClearErrorMgr amp sErrorMgr Initialize ALA API environment if ALA InitializeAPI ALA TRUE ssErrorMgr ALA SUCCESS 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
80. the commit log READ LOG COUNT BIGINT The number of logs read SEND LOG COUNT BIGINT The number of replication logs read REPL MODE VARCHAR 7 Current Replication Mode LogAnalyzer Users Manual 24 Performance View Column name Type Description ACT_REPL_MODE VARCHAR 7 Replication runs in lazy mode if its process exceeds the value of property For a UNIX domain the value for the SENDER IP and PEER IP columns is UNIX_DOMAIN and the value for the SENDER_PORT and PEER_PORT columns is 0 For more information please refer to the Altibase Administration Administrator s Manual It has information on the transaction table in XLog Sender Column name Type Description REP_NAME VARCHAR 40 Name LOCAL_TID INTEGER The local transaction ID REMOTE_TID INTEGER Currently not used BEGIN FLAG INTEGER Whether BEGIN for a transaction has been sent or not BEGIN SN BIGINT The initial log SN for a transaction For more information please refer to the Altibase Administration Administrator s Manual It has information on the log analysis progress Column name Type Description REP NAME VARCHAR 40 Name REP LAST SN BIGINT The serial number for the last log REP SN BIGINT The serial number for the transmission log REP GAP BIGINT Interval READ LFG ID INTEGER Group of Log Files Read Currently READ FILE NO INTEGER The Number of Log Files Read Cur
Download Pdf Manuals
Related Search
Related Contents
Lift Test Cap User Manual Cursus Plongeur Diluant Air 火の用心通信(2013年4月)№19 Lux Products TX500E Instruction Manual Copyright © All rights reserved.
Failed to retrieve file