Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avro supports handle key(s) as Kafka key, and other miscellaneous improvements #862

Merged
merged 15 commits into from
Aug 26, 2020
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ cscope.*
cmd/cdc/cdc

# Files generated when testing
vendor/
tiflash-config-preprocessed.toml

# Files generated when running docker-compose
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM golang:1.14-alpine as builder
RUN apk add --no-cache git make bash
WORKDIR /go/src/github.com/pingcap/ticdc
COPY . .
ENV CDC_ENABLE_VENDOR=1
RUN make

FROM alpine:3.12
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ TEST_DIR := /tmp/tidb_cdc_test
SHELL := /usr/bin/env bash

GO := GO111MODULE=on go
GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG) -trimpath
ifeq (${CDC_ENABLE_VENDOR}, 1)
GOVENDORFLAG := -mod=vendor
endif

GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG) -trimpath $(GOVENDORFLAG)
ifeq ($(GOVERSION114), 1)
GOTEST := CGO_ENABLED=1 $(GO) test -p 3 --race -gcflags=all=-d=checkptr=0
else
Expand Down
3 changes: 3 additions & 0 deletions cdc/model/schema_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ func (ti *TableInfo) initColumnsFlag() {
if mysql.HasMultipleKeyFlag(colInfo.Flag) {
flag.SetIsMultipleKey()
}
if mysql.HasUnsignedFlag(colInfo.Flag) {
flag.SetIsUnsigned()
}
ti.ColumnsFlag[colInfo.ID] = flag
}

Expand Down
59 changes: 38 additions & 21 deletions cdc/model/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,113 +55,130 @@ const (
MultipleKeyFlag
// NullableFlag means the column is nullable
NullableFlag
// UnsignedFlag means the column stores an unsigned integer
UnsignedFlag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add this flag to document

)

//SetIsBinary set BinaryFlag
//SetIsBinary sets BinaryFlag
func (b *ColumnFlagType) SetIsBinary() {
(*util.Flag)(b).Add(util.Flag(BinaryFlag))
}

//UnsetIsBinary unset BinaryFlag
//UnsetIsBinary unsets BinaryFlag
func (b *ColumnFlagType) UnsetIsBinary() {
(*util.Flag)(b).Remove(util.Flag(BinaryFlag))
}

//IsBinary show whether BinaryFlag is set
//IsBinary shows whether BinaryFlag is set
func (b *ColumnFlagType) IsBinary() bool {
return (*util.Flag)(b).HasAll(util.Flag(BinaryFlag))
}

//SetIsHandleKey set HandleKey
//SetIsHandleKey sets HandleKey
func (b *ColumnFlagType) SetIsHandleKey() {
(*util.Flag)(b).Add(util.Flag(HandleKeyFlag))
}

//UnsetIsHandleKey unset HandleKey
//UnsetIsHandleKey unsets HandleKey
func (b *ColumnFlagType) UnsetIsHandleKey() {
(*util.Flag)(b).Remove(util.Flag(HandleKeyFlag))
}

//IsHandleKey show whether HandleKey is set
//IsHandleKey shows whether HandleKey is set
func (b *ColumnFlagType) IsHandleKey() bool {
return (*util.Flag)(b).HasAll(util.Flag(HandleKeyFlag))
}

//SetIsGeneratedColumn set GeneratedColumn
//SetIsGeneratedColumn sets GeneratedColumn
func (b *ColumnFlagType) SetIsGeneratedColumn() {
(*util.Flag)(b).Add(util.Flag(GeneratedColumnFlag))
}

//UnsetIsGeneratedColumn unset GeneratedColumn
//UnsetIsGeneratedColumn unsets GeneratedColumn
func (b *ColumnFlagType) UnsetIsGeneratedColumn() {
(*util.Flag)(b).Remove(util.Flag(GeneratedColumnFlag))
}

//IsGeneratedColumn show whether GeneratedColumn is set
//IsGeneratedColumn shows whether GeneratedColumn is set
func (b *ColumnFlagType) IsGeneratedColumn() bool {
return (*util.Flag)(b).HasAll(util.Flag(GeneratedColumnFlag))
}

//SetIsPrimaryKey set PrimaryKeyFlag
//SetIsPrimaryKey sets PrimaryKeyFlag
func (b *ColumnFlagType) SetIsPrimaryKey() {
(*util.Flag)(b).Add(util.Flag(PrimaryKeyFlag))
}

//UnsetIsPrimaryKey unset PrimaryKeyFlag
//UnsetIsPrimaryKey unsets PrimaryKeyFlag
func (b *ColumnFlagType) UnsetIsPrimaryKey() {
(*util.Flag)(b).Remove(util.Flag(PrimaryKeyFlag))
}

//IsPrimaryKey show whether PrimaryKeyFlag is set
//IsPrimaryKey shows whether PrimaryKeyFlag is set
func (b *ColumnFlagType) IsPrimaryKey() bool {
return (*util.Flag)(b).HasAll(util.Flag(PrimaryKeyFlag))
}

//SetIsUniqueKey set UniqueKeyFlag
//SetIsUniqueKey sets UniqueKeyFlag
func (b *ColumnFlagType) SetIsUniqueKey() {
(*util.Flag)(b).Add(util.Flag(UniqueKeyFlag))
}

//UnsetIsUniqueKey unset UniqueKeyFlag
//UnsetIsUniqueKey unsets UniqueKeyFlag
func (b *ColumnFlagType) UnsetIsUniqueKey() {
(*util.Flag)(b).Remove(util.Flag(UniqueKeyFlag))
}

//IsUniqueKey show whether UniqueKeyFlag is set
//IsUniqueKey shows whether UniqueKeyFlag is set
func (b *ColumnFlagType) IsUniqueKey() bool {
return (*util.Flag)(b).HasAll(util.Flag(UniqueKeyFlag))
}

//IsMultipleKey show whether MultipleKeyFlag is set
//IsMultipleKey shows whether MultipleKeyFlag is set
func (b *ColumnFlagType) IsMultipleKey() bool {
return (*util.Flag)(b).HasAll(util.Flag(MultipleKeyFlag))
}

//SetIsMultipleKey set MultipleKeyFlag
//SetIsMultipleKey sets MultipleKeyFlag
func (b *ColumnFlagType) SetIsMultipleKey() {
(*util.Flag)(b).Add(util.Flag(MultipleKeyFlag))
}

//UnsetIsMultipleKey unset MultipleKeyFlag
//UnsetIsMultipleKey unsets MultipleKeyFlag
func (b *ColumnFlagType) UnsetIsMultipleKey() {
(*util.Flag)(b).Remove(util.Flag(MultipleKeyFlag))
}

//IsNullable show whether NullableFlag is set
//IsNullable shows whether NullableFlag is set
func (b *ColumnFlagType) IsNullable() bool {
return (*util.Flag)(b).HasAll(util.Flag(NullableFlag))
}

//SetIsNullable set NullableFlag
//SetIsNullable sets NullableFlag
func (b *ColumnFlagType) SetIsNullable() {
(*util.Flag)(b).Add(util.Flag(NullableFlag))
}

//UnsetIsNullable unset NullableFlag
//UnsetIsNullable unsets NullableFlag
func (b *ColumnFlagType) UnsetIsNullable() {
(*util.Flag)(b).Remove(util.Flag(NullableFlag))
}

//IsUnsigned shows whether UnsignedFlag is set
func (b *ColumnFlagType) IsUnsigned() bool {
return (*util.Flag)(b).HasAll(util.Flag(UnsignedFlag))
}

//SetIsUnsigned sets UnsignedFlag
func (b *ColumnFlagType) SetIsUnsigned() {
(*util.Flag)(b).Add(util.Flag(UnsignedFlag))
}

//UnsetIsUnsigned unsets UnsignedFlag
func (b *ColumnFlagType) UnsetIsUnsigned() {
(*util.Flag)(b).Remove(util.Flag(UnsignedFlag))
}

// TableName represents name of a table, includes table name and schema name.
type TableName struct {
Schema string `toml:"db-name" json:"db-name"`
Expand Down
Loading