github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/proto/EntryProtocol.proto (about)

     1  /*
     2   * Copyright (C) 2010-2101 Alibaba Group Holding Limited.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  syntax = "proto3";
    18  package com.alibaba.otter.canal.protocol;
    19  
    20  option java_package = "com.alibaba.otter.canal.protocol";
    21  option java_outer_classname = "CanalEntry";
    22  option optimize_for = SPEED;
    23  
    24  /****************************************************************
    25   * message model
    26   *如果要在Enum中新增类型,确保以前的类型的下标值不变.
    27   ****************************************************************/
    28  message Entry {
    29  	/**协议头部信息**/
    30       Header						header 				= 1;
    31  	///**打散后的事件类型**/ [default = ROWDATA]
    32  	oneof entryType_present{
    33  		EntryType					entryType			= 2;
    34  	}
    35  
    36  	/**传输的二进制数组**/
    37  	bytes						storeValue			= 3;
    38  }
    39  
    40  /**message Header**/
    41  message Header {
    42  	/**协议的版本号**/  //[default = 1]
    43  	oneof version_present {
    44  		int32 					version				= 1;
    45  	}
    46  
    47  
    48  	/**binlog/redolog 文件名**/
    49  	string					logfileName			= 2;
    50  
    51  	/**binlog/redolog 文件的偏移位置**/
    52  	int64 					logfileOffset		= 3;
    53  
    54  	/**服务端serverId**/
    55  	int64				serverId         	= 4;
    56  
    57  	/** 变更数据的编码 **/
    58  	string					serverenCode		= 5;
    59  
    60  	/**变更数据的执行时间 **/
    61  	int64					executeTime			= 6;
    62  
    63  	/** 变更数据的来源**/ //[default = MYSQL]
    64  	oneof sourceType_present {
    65  		Type					sourceType			= 7;
    66  	}
    67  
    68  
    69  	/** 变更数据的schemaname**/
    70  	string					schemaName			= 8;
    71  
    72  	/**变更数据的tablename**/
    73  	string					tableName			= 9;
    74  
    75  	/**每个event的长度**/
    76  	int64					eventLength         = 10;
    77  
    78  	/**数据变更类型**/  // [default = UPDATE]
    79  	oneof eventType_present {
    80  		EventType 				eventType			= 11;
    81  	}
    82  
    83  
    84  	/**预留扩展**/
    85  	repeated Pair					props				= 12;
    86  
    87      /**当前事务的gitd**/
    88  	string                 gtid                = 13;
    89  }
    90  
    91  /**每个字段的数据结构**/
    92  message Column {
    93  	/**字段下标**/
    94  	int32		index			= 		1;
    95  
    96  	/**字段java中类型**/
    97  	int32 		sqlType			= 		2;
    98  
    99  	/**字段名称(忽略大小写),在mysql中是没有的**/
   100  	string		name			=		3;
   101  
   102  	/**是否是主键**/
   103  	bool 		isKey			= 		4;
   104  
   105  	/**如果EventType=UPDATE,用于标识这个字段值是否有修改**/
   106  	bool		updated			= 		5;
   107  
   108  	/** 标识是否为空  **/ //[default = false]
   109  	oneof isNull_present {
   110  		bool		isNull			= 		6;
   111  	}
   112  
   113  
   114  	/**预留扩展**/
   115  	repeated Pair		props			=		7;
   116  
   117  	/** 字段值,timestamp,Datetime是一个时间格式的文本 **/
   118  	string		value			= 		8;
   119  
   120  	/** 对应数据对象原始长度 **/
   121  	int32		length			= 		9;
   122  
   123  	/**字段mysql类型**/
   124  	string		mysqlType		= 		10;
   125  }
   126  
   127  message RowData {
   128  
   129  	/** 字段信息,增量数据(修改前,删除前) **/
   130  	repeated Column			beforeColumns  	= 		1;
   131  
   132  	/** 字段信息,增量数据(修改后,新增后)  **/
   133  	repeated Column			afterColumns	= 		2;
   134  
   135  	/**预留扩展**/
   136  	repeated Pair			props			=		3;
   137  }
   138  
   139  /**message row 每行变更数据的数据结构**/
   140  message RowChange {
   141  
   142  	/**tableId,由数据库产生**/
   143  	int64	 		tableId			=		1;
   144  
   145  
   146  	/**数据变更类型**/ //[default = UPDATE]
   147  	oneof eventType_present {
   148  		EventType 		eventType		= 		2;
   149  	}
   150  
   151  
   152  	/** 标识是否是ddl语句  **/ // [default = false]
   153  	oneof isDdl_present {
   154  		bool			isDdl			= 		10;
   155  	}
   156  
   157  
   158  	/** ddl/query的sql语句  **/
   159  	string			sql 			= 		11;
   160  
   161  	/** 一次数据库变更可能存在多行  **/
   162  	repeated RowData		rowDatas		= 		12;
   163  
   164  	/**预留扩展**/
   165  	repeated Pair			props			=		13;
   166  
   167  	/** ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName  **/
   168  	string			ddlSchemaName 	= 		14;
   169  }
   170  
   171  /**开始事务的一些信息**/
   172  message TransactionBegin{
   173  
   174  	/**已废弃,请使用header里的executeTime**/
   175  	int64			executeTime		=		1;
   176  
   177  	/**已废弃,Begin里不提供事务id**/
   178  	string			transactionId	=		2;
   179  
   180  	/**预留扩展**/
   181  	repeated Pair			props			=		3;
   182  
   183  	/**执行的thread Id**/
   184  	int64			threadId		=		4;
   185  }
   186  
   187  /**结束事务的一些信息**/
   188  message TransactionEnd{
   189  
   190  	/**已废弃,请使用header里的executeTime**/
   191  	int64			executeTime		=		1;
   192  
   193  	/**事务号**/
   194  	string			transactionId	=		2;
   195  
   196  	/**预留扩展**/
   197  	repeated Pair			props			=		3;
   198  }
   199  
   200  /**预留扩展**/
   201  message Pair{
   202  	string 		key				= 			1;
   203  	string 		value			= 			2;
   204  }
   205  
   206  /**打散后的事件类型,主要用于标识事务的开始,变更数据,结束**/
   207  enum EntryType{
   208  	ENTRYTYPECOMPATIBLEPROTO2 = 0;
   209  	TRANSACTIONBEGIN 		=		1;
   210  	ROWDATA					=		2;
   211  	TRANSACTIONEND			=		3;
   212  	/** 心跳类型,内部使用,外部暂不可见,可忽略 **/
   213  	HEARTBEAT				=		4;
   214  	GTIDLOG                 =       5;
   215  }
   216  
   217  /** 事件类型 **/
   218  enum EventType {
   219  	EVENTTYPECOMPATIBLEPROTO2 = 0;
   220      INSERT 		= 		1;
   221      UPDATE 		= 		2;
   222      DELETE 		= 		3;
   223      CREATE		= 		4;
   224      ALTER		= 		5;
   225      ERASE		= 		6;
   226      QUERY		=		7;
   227      TRUNCATE	=		8;
   228      RENAME 		= 		9;
   229      /**CREATE INDEX**/
   230      CINDEX		= 		10;
   231      DINDEX 		= 		11;
   232      GTID        =       12;
   233      /** XA **/
   234      XACOMMIT    =       13;
   235      XAROLLBACK  =		14;
   236      /** MASTER HEARTBEAT **/
   237      MHEARTBEAT  =       15;
   238  }
   239  
   240  /**数据库类型**/
   241  enum Type {
   242  	TYPECOMPATIBLEPROTO2 = 0;
   243      ORACLE		= 		1;
   244      MYSQL		= 		2;
   245      PGSQL		= 		3;
   246  }