diff --git a/go.mod1 b/go.mod1 index e88bd7bf2..2cb128779 100644 --- a/go.mod1 +++ b/go.mod1 @@ -10,16 +10,16 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0 github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c - github.com/pingcap/failpoint v0.0.0-20220303073211-00fea37feb66 - github.com/pingcap/kvproto v0.0.0-20220314103629-10e688307221 - github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee - github.com/pingcap/tidb v1.1.0-beta.0.20220321041832-f9beb51a644c - github.com/pingcap/tidb/parser v0.0.0-20220321041832-f9beb51a644c + github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3 + github.com/pingcap/kvproto v0.0.0-20220328072018-6e75c12dbd73 + github.com/pingcap/log v1.1.0 + github.com/pingcap/tidb v1.1.0-beta.0.20220511160835-98c31070d958 + github.com/pingcap/tidb/parser v0.0.0-20220511160835-98c31070d958 github.com/pingcap/tiflow v0.0.0-20220217071740-1e3dd1550494 github.com/pingcap/tipb v0.0.0-20220215045658-d12dec7a7609 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710 go.etcd.io/etcd/api/v3 v3.5.2 go.etcd.io/etcd/client/v3 v3.5.2 diff --git a/go.sum1 b/go.sum1 index fde63159a..7dc93baa0 100644 --- a/go.sum1 +++ b/go.sum1 @@ -94,6 +94,7 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/ReneKroon/ttlcache/v2 v2.3.0/go.mod h1:zbo6Pv/28e21Z8CzzqgYRArQYGYtjONRxaAKGxzQvG4= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/sarama v1.27.2/go.mod h1:g5s5osgELxgM+Md9Qni9rzo7Rbt+vvFQI4bt/Mc93II= +github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU= github.com/Shopify/sarama v1.31.1 h1:uxwJ+p4isb52RyV83MCJD8v2wJ/HBxEGMmG/8+sEzG0= github.com/Shopify/sarama v1.31.1/go.mod h1:99E1xQ1Ql2bYcuJfwdXY3cE17W8+549Ty8PG/11BDqY= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= @@ -253,8 +254,8 @@ github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27 github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/ristretto v0.0.1/go.mod h1:T40EBc7CJke8TkpiYfGGKAeFjSaxuFXhuXRyumBd6RE= -github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= -github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= +github.com/dgraph-io/ristretto v0.1.1-0.20220403145359-8e850b710d6d h1:Wrc3UKTS+cffkOx0xRGFC+ZesNuTfn0ThvEC72N0krk= +github.com/dgraph-io/ristretto v0.1.1-0.20220403145359-8e850b710d6d/go.mod h1:RAy2GVV4sTWVlNMavv3xhLsk18rxhfhDnombTe6EF5c= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -312,6 +313,7 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.10.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= github.com/frankban/quicktest v1.11.1/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss= github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -696,6 +698,7 @@ github.com/klauspost/compress v1.10.5/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.10.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -866,6 +869,7 @@ github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5 github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/badger v1.5.1-0.20210831093107-2f6cb8008145/go.mod h1:LyrqUOHZrUDf9oGi1yoz1+qw9ckSIhQb5eMa1acOLNQ= @@ -891,8 +895,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ue github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce/go.mod h1:w4PEZ5y16LeofeeGwdgZB4ddv9bLyDuIX+ljstgKZyk= github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd/go.mod h1:IVF+ijPSMZVtx2oIqxAg7ur6EyixtTYfOHwpfmlhqI4= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= -github.com/pingcap/failpoint v0.0.0-20220303073211-00fea37feb66 h1:v+/0tBl7umw+ZxfTeAId/R9pmb8fn2MqsrTHAs8qFAk= -github.com/pingcap/failpoint v0.0.0-20220303073211-00fea37feb66/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= +github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3 h1:kJolJWbyadVeL8RKBlqmXQR7FRKPsIeU85TUYyhbhiQ= +github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059 h1:Pe2LbxRmbTfAoKJ65bZLmhahmvHm7n9DUxGRQT00208= github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059/go.mod h1:fMRU1BA1y+r89AxUoaAar4JjrhUkVDt0o0Np6V8XbDQ= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E= @@ -904,16 +908,17 @@ github.com/pingcap/kvproto v0.0.0-20211213085605-3329b3c5404c/go.mod h1:IOdRDPLy github.com/pingcap/kvproto v0.0.0-20211224055123-d1a140660c39/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20220302110454-c696585a961b/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20220304032058-ccd676426a27/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= -github.com/pingcap/kvproto v0.0.0-20220314103629-10e688307221 h1:QiHOVihPED67vDEZE6kP3cGrS55U1+QXbSTahGaEyOI= -github.com/pingcap/kvproto v0.0.0-20220314103629-10e688307221/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= +github.com/pingcap/kvproto v0.0.0-20220328072018-6e75c12dbd73 h1:jKixsi6Iw00hL0+o23hmr8BNzlsQP9pShHTOwyuf/Os= +github.com/pingcap/kvproto v0.0.0-20220328072018-6e75c12dbd73/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM= github.com/pingcap/log v0.0.0-20210906054005-afc726e70354/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pingcap/log v0.0.0-20211207084639-71a2e5860834/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= -github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee h1:VO2t6IBpfvW34TdtD/G10VvnGqjLic1jzOuHjUb5VqM= github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= +github.com/pingcap/log v1.1.0 h1:ELiPxACz7vdo1qAvvaWJg1NrYFoY6gqAh/+Uo6aXdD8= +github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pingcap/parser v0.0.0-20210415081931-48e7f467fd74/go.mod h1:xZC8I7bug4GJ5KtHhgAikjTfU4kBv1Sbo3Pf1MZ6lVw= github.com/pingcap/parser v0.0.0-20210525032559-c37778aff307/go.mod h1:xZC8I7bug4GJ5KtHhgAikjTfU4kBv1Sbo3Pf1MZ6lVw= github.com/pingcap/sysutil v0.0.0-20210730114356-fcd8a63f68c5/go.mod h1:XsOaV712rUk63aOEKYP9PhXTIE3FMNHmC2r1wX5wElY= @@ -922,18 +927,17 @@ github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4 h1:HYbcxtnkN3s5tqr github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4/go.mod h1:sDCsM39cGiv2vwunZkaFA917vVkqDTGSPbbV7z4Oops= github.com/pingcap/tidb v1.1.0-beta.0.20211023132847-efa94595c071/go.mod h1:Ci7ABF58a4jn6YtaHi7655jP409edqC2JxWWFRqOubg= github.com/pingcap/tidb v1.1.0-beta.0.20220210065735-92f5a6340ca2/go.mod h1:1ATxD29hPy7OXNIxyZWb9PqA12F5YjmYoO9uh/655OY= -github.com/pingcap/tidb v1.1.0-beta.0.20220321041832-f9beb51a644c h1:zSXHDNOYjE4gXggQGrYxJTG9tVeNK8kQ9hCaRgXOPVg= -github.com/pingcap/tidb v1.1.0-beta.0.20220321041832-f9beb51a644c/go.mod h1:21CLd91u8X3A5Pi3v5zeude6ZWFWzrIYTdZcv/5NRbQ= +github.com/pingcap/tidb v1.1.0-beta.0.20220511160835-98c31070d958 h1:o8U3zgBCcY/x1GAOrEUczvN232Uu7wMsb8STTyo7z1A= +github.com/pingcap/tidb v1.1.0-beta.0.20220511160835-98c31070d958/go.mod h1:luW4sIZoLHY3bCWuKqyqk2QgMvF+/M7nWOXf/me0+fY= github.com/pingcap/tidb-dashboard v0.0.0-20220117082709-e8076b5c79ba/go.mod h1:4hk/3owVGWdvI9Kx6yCqqvM1T5PVgwyQNyMQxD3rwfc= github.com/pingcap/tidb-tools v5.0.3+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= github.com/pingcap/tidb-tools v5.2.2-0.20211019062242-37a8bef2fa17+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= github.com/pingcap/tidb-tools v5.2.3-0.20211105044302-2dabb6641a6e+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= -github.com/pingcap/tidb-tools v6.0.0-alpha.0.20220309081549-563c2a342f9c+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= github.com/pingcap/tidb/parser v0.0.0-20211011031125-9b13dc409c5e/go.mod h1:e1MGCA9Sg3T8jid8PKAEq5eYVuMMCq4n8gJ+Kqp4Plg= github.com/pingcap/tidb/parser v0.0.0-20211023132847-efa94595c071/go.mod h1:e1MGCA9Sg3T8jid8PKAEq5eYVuMMCq4n8gJ+Kqp4Plg= github.com/pingcap/tidb/parser v0.0.0-20220210065735-92f5a6340ca2/go.mod h1:ElJiub4lRy6UZDb+0JHDkGEdr6aOli+ykhyej7VCLoI= -github.com/pingcap/tidb/parser v0.0.0-20220321041832-f9beb51a644c h1:9/ImFPX84oM4CSOVyQ9HDT/JRwGSeOjUspQTB7SCJ0k= -github.com/pingcap/tidb/parser v0.0.0-20220321041832-f9beb51a644c/go.mod h1:ElJiub4lRy6UZDb+0JHDkGEdr6aOli+ykhyej7VCLoI= +github.com/pingcap/tidb/parser v0.0.0-20220511160835-98c31070d958 h1:ogz4WwmeUkXchy2LEEN69aLe1rHOCqSs+D3lMLO3hqk= +github.com/pingcap/tidb/parser v0.0.0-20220511160835-98c31070d958/go.mod h1:ElJiub4lRy6UZDb+0JHDkGEdr6aOli+ykhyej7VCLoI= github.com/pingcap/tiflow v0.0.0-20220217071740-1e3dd1550494 h1:9fMWycN55FQjfGUs0RsX7p4G4PgofvqmgcrzfI0C2Vg= github.com/pingcap/tiflow v0.0.0-20220217071740-1e3dd1550494/go.mod h1:ElzX5n3zrMihG25DqJqrgmoi4dng8tOWQRvgOSr6Trs= github.com/pingcap/tipb v0.0.0-20211008080435-3fd327dfce0e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs= @@ -1087,8 +1091,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df h1:rh3VYpfvzXRbJ90ymx1yfhGl/wq8ac2m/cUbao61kwY= +github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= @@ -1110,8 +1115,8 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/tidwall/sjson v1.2.2/go.mod h1:jmW2RZpbKuExPFUHeFSBMiovT9ZyOziEHDRkbsdp0B0= github.com/tikv/client-go/v2 v2.0.0-alpha.0.20211011083157-49c8dd23f1f0/go.mod h1:00plYwQsQ5kBUmafHO+JkjznGgFaBokMZl82TZIbsQk= github.com/tikv/client-go/v2 v2.0.0-rc.0.20220107040026-d22815099720/go.mod h1:Yn4EKNn2y8XrudACiBGnVpDwfIXqi5oLPADpIoAcPyg= -github.com/tikv/client-go/v2 v2.0.1-0.20220311043619-5042c6f2aaa6 h1:wEyMlpW7dGbQmRcM7LdfW5muU84kvHSaZnYY387O/qY= -github.com/tikv/client-go/v2 v2.0.1-0.20220311043619-5042c6f2aaa6/go.mod h1:0scaG+seu7L56apm+Gjz9vckyO7ABIzM6T7n00mrIXs= +github.com/tikv/client-go/v2 v2.0.1-0.20220510032238-ff5e35ac2869 h1:yOApqwZVzC1ne1v9Qc1OQtCe5Wtm1Vv6xqaOs6/y4NQ= +github.com/tikv/client-go/v2 v2.0.1-0.20220510032238-ff5e35ac2869/go.mod h1:0scaG+seu7L56apm+Gjz9vckyO7ABIzM6T7n00mrIXs= github.com/tikv/pd v0.0.0-20220218061340-602217e4455a h1:hLh8ONEtEz3apJZOjITq8+xrU/H/bctEkoRDpfR+zGw= github.com/tikv/pd v0.0.0-20220218061340-602217e4455a/go.mod h1:GbYFOvbEHrnbPCMvMsIgZwk08in1Nwtr8N9n5Xhte3A= github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710 h1:jxgmKOscXSjaFEKQGRyY5qOpK8hLqxs2irb/uDJMtwk= @@ -1165,7 +1170,9 @@ github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT github.com/xdg-go/scram v1.1.0/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/scram v1.0.3/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -1310,11 +1317,12 @@ golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201217014255-9d1352758620/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed h1:YoWVYYAfvQ4ddHv3OKmIvX7NCAhFGTj62VP2l2kfBbA= golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1330,6 +1338,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5 h1:rxKZ2gOnYxjfmakvUUqh9Gyb6KXfrj7JWTxORTYqb0E= +golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1358,6 +1368,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1413,6 +1424,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1549,8 +1561,8 @@ golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f h1:8w7RhxzTVgUzw/AH/9mUV5q0vMgy40SQRursCcfmkCw= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1653,6 +1665,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1899,7 +1912,6 @@ modernc.org/lex v1.0.0/go.mod h1:G6rxMTy3cH2iA0iXL/HRRv4Znu8MK4higxph/lE7ypk= modernc.org/lexer v1.0.0/go.mod h1:F/Dld0YKYdZCLQ7bD0USbWL4YKCyTDRDHiDTOs0q0vk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/parser v1.0.0/go.mod h1:H20AntYJ2cHHL6MHthJ8LZzXCdDCHMWt1KZXtIMjejA= modernc.org/parser v1.0.2/go.mod h1:TXNq3HABP3HMaqLK7brD1fLA/LfN0KS6JxZn71QdDqs= diff --git a/pkg/check/table_structure.go b/pkg/check/table_structure.go index 0aac39b65..ca0d40950 100644 --- a/pkg/check/table_structure.go +++ b/pkg/check/table_structure.go @@ -438,9 +438,9 @@ func (c *ShardingTablesChecker) findAutoIncrementKey(stmt *ast.CreateTableStmt, if hasAutoIncrementOpt { if isUnique { - autoIncrementKeys[col.Name.Name.O] = col.Tp.Tp == mysql.TypeLonglong + autoIncrementKeys[col.Name.Name.O] = col.Tp.GetType() == mysql.TypeLonglong } else { - autoIncrementCols[col.Name.Name.O] = col.Tp.Tp == mysql.TypeLonglong + autoIncrementCols[col.Name.Name.O] = col.Tp.GetType() == mysql.TypeLonglong } } } diff --git a/pkg/dbutil/common.go b/pkg/dbutil/common.go index 374f0c687..306ed30e0 100644 --- a/pkg/dbutil/common.go +++ b/pkg/dbutil/common.go @@ -548,10 +548,10 @@ func AnalyzeValuesFromBuckets(valueString string, cols []*model.ColumnInfo) ([]s } for i, col := range cols { - if IsTimeTypeAndNeedDecode(col.Tp) { + if IsTimeTypeAndNeedDecode(col.GetType()) { // check if values[i] is already a time string sc := &stmtctx.StatementContext{TimeZone: time.UTC} - _, err := types.ParseTime(sc, values[i], col.Tp, types.MinFsp) + _, err := types.ParseTime(sc, values[i], col.GetType(), types.MinFsp) if err == nil { continue } diff --git a/pkg/dbutil/common_test.go b/pkg/dbutil/common_test.go index 2a021f94a..65c5df63b 100644 --- a/pkg/dbutil/common_test.go +++ b/pkg/dbutil/common_test.go @@ -185,6 +185,10 @@ func (s *testDBSuite) TestGetParser(c *C) { } func (s *testDBSuite) TestAnalyzeValuesFromBuckets(c *C) { + ftTypeDatetime := types.NewFieldType(pmysql.TypeDatetime) + ftTypeTimestamp := types.NewFieldType(pmysql.TypeTimestamp) + ftTypeDate := types.NewFieldType(pmysql.TypeDate) + cases := []struct { value string col *model.ColumnInfo @@ -192,32 +196,32 @@ func (s *testDBSuite) TestAnalyzeValuesFromBuckets(c *C) { }{ { "2021-03-05 21:31:03", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeDatetime}}, + &model.ColumnInfo{FieldType: *ftTypeDatetime}, "2021-03-05 21:31:03", }, { "2021-03-05 21:31:03", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeTimestamp}}, + &model.ColumnInfo{FieldType: *ftTypeTimestamp}, "2021-03-05 21:31:03", }, { "2021-03-05", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeDate}}, + &model.ColumnInfo{FieldType: *ftTypeDate}, "2021-03-05", }, { "1847956477067657216", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeDatetime}}, + &model.ColumnInfo{FieldType: *ftTypeDatetime}, "2020-01-01 10:00:00", }, { "1847955927311843328", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeTimestamp}}, + &model.ColumnInfo{FieldType: *ftTypeTimestamp}, "2020-01-01 02:00:00", }, { "1847955789872889856", - &model.ColumnInfo{FieldType: types.FieldType{Tp: pmysql.TypeDate}}, + &model.ColumnInfo{FieldType: *ftTypeDate}, "2020-01-01 00:00:00", }, } diff --git a/pkg/dbutil/table.go b/pkg/dbutil/table.go index 80eb5c0c7..5db041fa9 100644 --- a/pkg/dbutil/table.go +++ b/pkg/dbutil/table.go @@ -110,8 +110,8 @@ func EqualTableInfo(tableInfo1, tableInfo2 *model.TableInfo) (bool, string) { if col.Name.O != tableInfo2.Columns[j].Name.O { return false, fmt.Sprintf("column name not equal, one is %s another is %s", col.Name.O, tableInfo2.Columns[j].Name.O) } - if col.Tp != tableInfo2.Columns[j].Tp { - return false, fmt.Sprintf("column %s's type not equal, one is %v another is %v", col.Name.O, col.Tp, tableInfo2.Columns[j].Tp) + if col.GetType() != tableInfo2.Columns[j].GetType() { + return false, fmt.Sprintf("column %s's type not equal, one is %v another is %v", col.Name.O, col.GetType(), tableInfo2.Columns[j].GetType()) } } diff --git a/pkg/diff/util.go b/pkg/diff/util.go index a450b0da0..65e280543 100644 --- a/pkg/diff/util.go +++ b/pkg/diff/util.go @@ -98,7 +98,7 @@ func getColumnsFromIndex(index *model.IndexInfo, tableInfo *model.TableInfo) []* } func needQuotes(ft types.FieldType) bool { - return !(dbutil.IsNumberType(ft.Tp) || dbutil.IsFloatType(ft.Tp)) + return !(dbutil.IsNumberType(ft.GetType()) || dbutil.IsFloatType(ft.GetType())) } func rowContainsCols(row map[string]*dbutil.ColumnData, cols []*model.ColumnInfo) bool { diff --git a/pkg/importer/db.go b/pkg/importer/db.go index a22e57e1e..535967ee7 100644 --- a/pkg/importer/db.go +++ b/pkg/importer/db.go @@ -95,9 +95,9 @@ func genRowData(table *table) (string, error) { func genColumnData(table *table, column *column) (string, error) { tp := column.tp _, isUnique := table.uniqIndices[column.name] - isUnsigned := mysql.HasUnsignedFlag(tp.Flag) + isUnsigned := mysql.HasUnsignedFlag(tp.GetFlag()) - switch tp.Tp { + switch tp.GetType() { case mysql.TypeTiny: var data int64 if isUnique { @@ -149,9 +149,9 @@ func genColumnData(table *table, column *column) (string, error) { case mysql.TypeVarchar, mysql.TypeString, mysql.TypeTinyBlob, mysql.TypeBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob: data := []byte{'\''} if isUnique { - data = append(data, []byte(column.data.uniqString(tp.Flen))...) + data = append(data, []byte(column.data.uniqString(tp.GetFlen()))...) } else { - data = append(data, []byte(randString(randInt(1, tp.Flen)))...) + data = append(data, []byte(randString(randInt(1, tp.GetFlen())))...) } data = append(data, '\'') diff --git a/pkg/schemacmp/table.go b/pkg/schemacmp/table.go index b346efc03..f25e297fd 100644 --- a/pkg/schemacmp/table.go +++ b/pkg/schemacmp/table.go @@ -54,14 +54,14 @@ func restoreColumnInfoFromUnwrapped(ctx *format.RestoreCtx, col []interface{}, c if col[columnInfoTupleIndexGeneratedStored].(bool) { ctx.WriteKeyWord(" STORED") } - if mysql.HasNotNullFlag(typ.Flag) { + if mysql.HasNotNullFlag(typ.GetFlag()) { ctx.WriteKeyWord(" NOT NULL") } if defVal := col[columnInfoTupleIndexDefaultValue]; defVal != nil { ctx.WriteKeyWord(" DEFAULT ") ctx.WritePlainf("%v", defVal) } - if mysql.HasAutoIncrementFlag(typ.Flag) { + if mysql.HasAutoIncrementFlag(typ.GetFlag()) { ctx.WriteKeyWord(" AUTO_INCREMENT") } } @@ -260,7 +260,7 @@ func encodeTableInfoToLattice(ti *model.TableInfo) Tuple { columns := make(columnMap) for _, ci := range ti.Columns { columns[ci.Name.L] = encodeColumnInfoToLattice(ci) - if !hasExplicitPrimaryKey && (ci.Flag&mysql.PriKeyFlag) != 0 { + if !hasExplicitPrimaryKey && (ci.GetFlag()&mysql.PriKeyFlag) != 0 { indices["primary"] = encodeImplicitPrimaryKeyToLattice(ci) } } diff --git a/pkg/schemacmp/type.go b/pkg/schemacmp/type.go index ea6f7e7f3..074d555db 100644 --- a/pkg/schemacmp/type.go +++ b/pkg/schemacmp/type.go @@ -59,35 +59,35 @@ func decodeAntiKeys(encoded byte) uint { // encodeTypeTpAsLattice func encodeFieldTypeToLattice(ft *types.FieldType) Tuple { var flen, dec Lattice - if ft.Tp == mysql.TypeNewDecimal { - flen = Singleton(ft.Flen) - dec = Singleton(ft.Decimal) + if ft.GetType() == mysql.TypeNewDecimal { + flen = Singleton(ft.GetFlen()) + dec = Singleton(ft.GetDecimal()) } else { - flen = Int(ft.Flen) - dec = Int(ft.Decimal) + flen = Int(ft.GetFlen()) + dec = Int(ft.GetDecimal()) } var defVal Lattice - if mysql.HasAutoIncrementFlag(ft.Flag) || !mysql.HasNoDefaultValueFlag(ft.Flag) { - defVal = Maybe(Singleton(ft.Flag & flagMaskDefVal)) + if mysql.HasAutoIncrementFlag(ft.GetFlag()) || !mysql.HasNoDefaultValueFlag(ft.GetFlag()) { + defVal = Maybe(Singleton(ft.GetFlag() & flagMaskDefVal)) } else { defVal = Maybe(nil) } return Tuple{ - FieldTp(ft.Tp), + FieldTp(ft.GetType()), flen, dec, // TODO: recognize if the remaining flags can be merged or not. - Singleton(ft.Flag &^ (flagMaskDefVal | mysql.NotNullFlag | flagMaskKeys)), - Bool(!mysql.HasNotNullFlag(ft.Flag)), - Byte(encodeAntiKeys(ft.Flag)), + Singleton(ft.GetFlag() &^ (flagMaskDefVal | mysql.NotNullFlag | flagMaskKeys)), + Bool(!mysql.HasNotNullFlag(ft.GetFlag())), + Byte(encodeAntiKeys(ft.GetFlag())), defVal, - Singleton(ft.Charset), - Singleton(ft.Collate), - StringList(ft.Elems), + Singleton(ft.GetCharset()), + Singleton(ft.GetCollate()), + StringList(ft.GetElems()), } } @@ -104,16 +104,14 @@ func decodeFieldTypeFromLattice(tup Tuple) *types.FieldType { } else { flags |= mysql.NoDefaultValueFlag } - - return &types.FieldType{ - Tp: lst[fieldTypeTupleIndexTp].(byte), - Flen: lst[fieldTypeTupleIndexFlen].(int), - Decimal: lst[fieldTypeTupleIndexDec].(int), - Flag: flags, - Charset: lst[fieldTypeTupleIndexCharset].(string), - Collate: lst[fieldTypeTupleIndexCollate].(string), - Elems: lst[fieldTypeTupleIndexElems].([]string), - } + ft := types.NewFieldType(lst[fieldTypeTupleIndexTp].(byte)) + ft.SetFlag(flags) + ft.SetFlen(lst[fieldTypeTupleIndexFlen].(int)) + ft.SetDecimal(lst[fieldTypeTupleIndexDec].(int)) + ft.SetCharset(lst[fieldTypeTupleIndexCharset].(string)) + ft.SetCollate(lst[fieldTypeTupleIndexCollate].(string)) + ft.SetElems(lst[fieldTypeTupleIndexElems].([]string)) + return ft } type typ struct{ Tuple } diff --git a/pkg/schemacmp/type_test.go b/pkg/schemacmp/type_test.go index 0a6471909..992f56b01 100644 --- a/pkg/schemacmp/type_test.go +++ b/pkg/schemacmp/type_test.go @@ -27,292 +27,309 @@ var _ = Suite(&typeSchema{}) const binary = "binary" +func init() { + // INT + typeInt = types.NewFieldType(mysql.TypeLong) + typeInt.SetFlag(0) + typeInt.SetFlen(11) + typeInt.SetDecimal(0) + typeInt.SetCharset(binary) + typeInt.SetCollate(binary) + + // INT NOT NULL + typeIntNotNull = types.NewFieldType(mysql.TypeLong) + typeIntNotNull.SetFlag(mysql.NoDefaultValueFlag | mysql.NotNullFlag) + typeIntNotNull.SetFlen(10) + typeIntNotNull.SetDecimal(0) + typeIntNotNull.SetCharset(binary) + typeIntNotNull.SetCollate(binary) + + // INT AUTO_INCREMENT UNIQUE + typeIntAutoIncrementUnique = types.NewFieldType(mysql.TypeLong) + typeIntAutoIncrementUnique.SetFlag(mysql.AutoIncrementFlag | mysql.UniqueKeyFlag) + typeIntAutoIncrementUnique.SetFlen(11) + typeIntAutoIncrementUnique.SetDecimal(0) + typeIntAutoIncrementUnique.SetCharset(binary) + typeIntAutoIncrementUnique.SetCollate(binary) + + // INT NOT NULL, KEY + typeIntNotNullKey = types.NewFieldType(mysql.TypeLong) + typeIntNotNullKey.SetFlag(mysql.NoDefaultValueFlag | mysql.MultipleKeyFlag | mysql.NotNullFlag) + typeIntNotNullKey.SetFlen(11) + typeIntNotNullKey.SetDecimal(0) + typeIntNotNullKey.SetCharset(binary) + typeIntNotNullKey.SetCollate(binary) + + // INT(1) + typeInt1 = types.NewFieldType(mysql.TypeLong) + typeInt1.SetFlag(0) + typeInt1.SetFlen(1) + typeInt1.SetDecimal(0) + typeInt1.SetCharset(binary) + typeInt1.SetCollate(binary) + + // INT(22) + typeInt22 = types.NewFieldType(mysql.TypeLong) + typeInt22.SetFlag(0) + typeInt22.SetFlen(22) + typeInt22.SetDecimal(0) + typeInt22.SetCharset(binary) + typeInt22.SetCollate(binary) + + // BIT(4) + typeBit4 = types.NewFieldType(mysql.TypeBit) + typeBit4.SetFlag(mysql.UnsignedFlag) + typeBit4.SetFlen(4) + typeBit4.SetDecimal(0) + typeBit4.SetCharset(binary) + typeBit4.SetCollate(binary) + + // BIGINT(22) ZEROFILL + typeBigInt22ZeroFill = types.NewFieldType(mysql.TypeLonglong) + typeBigInt22ZeroFill.SetFlag(mysql.ZerofillFlag | mysql.UnsignedFlag) + typeBigInt22ZeroFill.SetFlen(22) + typeBigInt22ZeroFill.SetDecimal(0) + typeBigInt22ZeroFill.SetCharset(binary) + typeBigInt22ZeroFill.SetCollate(binary) + + // DECIMAL(16, 8) DEFAULT 2.5 + typeDecimal16_8 = types.NewFieldType(mysql.TypeNewDecimal) + typeDecimal16_8.SetFlag(0) + typeDecimal16_8.SetFlen(16) + typeDecimal16_8.SetDecimal(8) + typeDecimal16_8.SetCharset(binary) + typeDecimal16_8.SetCollate(binary) + + // DECIMAL + typeDecimal = types.NewFieldType(mysql.TypeNewDecimal) + typeDecimal.SetFlag(0) + typeDecimal.SetFlen(11) + typeDecimal.SetDecimal(0) + typeDecimal.SetCharset(binary) + typeDecimal.SetCollate(binary) + + // Date + typeDate = types.NewFieldType(mysql.TypeDate) + typeDate.SetFlag(mysql.BinaryFlag) + typeDate.SetFlen(10) + typeDate.SetDecimal(0) + typeDate.SetCharset(binary) + typeDate.SetCollate(binary) + + // DATETIME(3) + typeDateTime3 = types.NewFieldType(mysql.TypeDatetime) + typeDateTime3.SetFlag(mysql.BinaryFlag) + typeDateTime3.SetFlen(23) + typeDateTime3.SetDecimal(3) + typeDateTime3.SetCharset(binary) + typeDateTime3.SetCollate(binary) + + // TIMESTAMP + typeTimestamp = types.NewFieldType(mysql.TypeTimestamp) + typeTimestamp.SetFlag(mysql.BinaryFlag) + typeTimestamp.SetFlen(19) + typeTimestamp.SetDecimal(0) + typeTimestamp.SetCharset(binary) + typeTimestamp.SetCollate(binary) + + // TIME(6) + typeTime6 = types.NewFieldType(mysql.TypeDuration) + typeTime6.SetFlag(mysql.BinaryFlag) + typeTime6.SetFlen(17) + typeTime6.SetDecimal(6) + typeTime6.SetCharset(binary) + typeTime6.SetCollate(binary) + + // YEAR(4) + typeYear4 = types.NewFieldType(mysql.TypeYear) + typeYear4.SetFlag(mysql.ZerofillFlag | mysql.UnsignedFlag) + typeYear4.SetFlen(4) + typeYear4.SetDecimal(0) + typeYear4.SetCharset(binary) + typeYear4.SetCollate(binary) + + // CHAR(123) + typeChar123 = types.NewFieldType(mysql.TypeString) + typeChar123.SetFlag(0) + typeChar123.SetFlen(123) + typeChar123.SetDecimal(0) + typeChar123.SetCharset(mysql.UTF8MB4Charset) + typeChar123.SetCollate(mysql.UTF8MB4DefaultCollation) + + // VARCHAR(65432) CHARSET ascii + typeVarchar65432CharsetASCII = types.NewFieldType(mysql.TypeVarchar) + typeVarchar65432CharsetASCII.SetFlag(0) + typeVarchar65432CharsetASCII.SetFlen(65432) + typeVarchar65432CharsetASCII.SetDecimal(0) + typeVarchar65432CharsetASCII.SetCharset("ascii") + typeVarchar65432CharsetASCII.SetCollate("ascii_bin") + + // BINARY(69) + typeBinary69 = types.NewFieldType(mysql.TypeString) + typeBinary69.SetFlag(mysql.BinaryFlag) + typeBinary69.SetFlen(69) + typeBinary69.SetDecimal(0) + typeBinary69.SetCharset(binary) + typeBinary69.SetCollate(binary) + + // VARBINARY(420) + typeVarBinary420 = types.NewFieldType(mysql.TypeVarchar) + typeVarBinary420.SetFlag(mysql.BinaryFlag) + typeVarBinary420.SetFlen(420) + typeVarBinary420.SetDecimal(0) + typeVarBinary420.SetCharset(binary) + typeVarBinary420.SetCollate(binary) + + // LONGBLOB + typeLongBlob = types.NewFieldType(mysql.TypeLongBlob) + typeLongBlob.SetFlag(mysql.BinaryFlag) + typeLongBlob.SetFlen(0xffffffff) + typeLongBlob.SetDecimal(0) + typeLongBlob.SetCharset(binary) + typeLongBlob.SetCollate(binary) + + // MEDIUMTEXT + typeMediumText = types.NewFieldType(mysql.TypeMediumBlob) + typeMediumText.SetFlag(0) + typeMediumText.SetFlen(0xffffff) + typeMediumText.SetDecimal(0) + typeMediumText.SetCharset(mysql.UTF8MB4Charset) + typeMediumText.SetCollate(mysql.UTF8MB4DefaultCollation) + + // ENUM('tidb', 'tikv', 'tiflash', 'golang', 'rust') + typeEnum5 = types.NewFieldType(mysql.TypeEnum) + typeEnum5.SetFlag(0) + typeEnum5.SetFlen(types.UnspecifiedLength) + typeEnum5.SetDecimal(0) + typeEnum5.SetCharset(mysql.UTF8MB4Charset) + typeEnum5.SetCollate(mysql.UTF8MB4DefaultCollation) + typeEnum5.SetElems([]string{"tidb", "tikv", "tiflash", "golang", "rust"}) + + // ENUM('tidb', 'tikv') + typeEnum2 = types.NewFieldType(mysql.TypeEnum) + typeEnum2.SetFlag(0) + typeEnum2.SetFlen(types.UnspecifiedLength) + typeEnum2.SetDecimal(0) + typeEnum2.SetCharset(mysql.UTF8MB4Charset) + typeEnum2.SetCollate(mysql.UTF8MB4DefaultCollation) + typeEnum2.SetElems([]string{"tidb", "tikv"}) + + // SET('tidb', 'tikv', 'tiflash', 'golang', 'rust') + typeSet5 = types.NewFieldType(mysql.TypeSet) + typeSet5.SetFlag(0) + typeSet5.SetFlen(types.UnspecifiedLength) + typeSet5.SetDecimal(0) + typeSet5.SetCharset(mysql.UTF8MB4Charset) + typeSet5.SetCollate(mysql.UTF8MB4DefaultCollation) + typeSet5.SetElems([]string{"tidb", "tikv", "tiflash", "golang", "rust"}) + + // SET('tidb', 'tikv') + typeSet2 = types.NewFieldType(mysql.TypeSet) + typeSet2.SetFlag(0) + typeSet2.SetFlen(types.UnspecifiedLength) + typeSet2.SetDecimal(0) + typeSet2.SetCharset(mysql.UTF8MB4Charset) + typeSet2.SetCollate(mysql.UTF8MB4DefaultCollation) + typeSet2.SetElems([]string{"tidb", "tikv"}) + + // JSON + typeJSON = types.NewFieldType(mysql.TypeJSON) + typeJSON.SetFlag(mysql.BinaryFlag) + typeJSON.SetFlen(types.UnspecifiedLength) + typeJSON.SetDecimal(0) + typeJSON.SetCharset(binary) + typeJSON.SetCollate(binary) + + // INT NOT NULL KEY INT AUTO_INC UNIQUE = INT AUTO_INC KEY, + typeLongIncrMultiKey = types.NewFieldType(mysql.TypeLong) + typeLongIncrMultiKey.SetFlag(mysql.AutoIncrementFlag | mysql.MultipleKeyFlag) + typeLongIncrMultiKey.SetFlen(11) + typeLongIncrMultiKey.SetDecimal(0) + typeLongIncrMultiKey.SetCharset(binary) + typeLongIncrMultiKey.SetCollate(binary) +} + var ( // INT - typeInt = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: 0, - Flen: 11, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeInt *types.FieldType // INT NOT NULL - typeIntNotNull = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: mysql.NoDefaultValueFlag | mysql.NotNullFlag, - Flen: 10, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeIntNotNull *types.FieldType // INT AUTO_INCREMENT UNIQUE - typeIntAutoIncrementUnique = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: mysql.AutoIncrementFlag | mysql.UniqueKeyFlag, - Flen: 11, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeIntAutoIncrementUnique *types.FieldType // INT NOT NULL, KEY - typeIntNotNullKey = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: mysql.NoDefaultValueFlag | mysql.MultipleKeyFlag | mysql.NotNullFlag, - Flen: 11, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeIntNotNullKey *types.FieldType // INT(1) - typeInt1 = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: 0, - Flen: 1, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeInt1 *types.FieldType // INT(22) - typeInt22 = &types.FieldType{ - Tp: mysql.TypeLong, - Flag: 0, - Flen: 22, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeInt22 *types.FieldType // BIT(4) - typeBit4 = &types.FieldType{ - Tp: mysql.TypeBit, - Flag: mysql.UnsignedFlag, - Flen: 4, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeBit4 *types.FieldType // BIGINT(22) ZEROFILL - typeBigInt22ZeroFill = &types.FieldType{ - Tp: mysql.TypeLonglong, - Flag: mysql.ZerofillFlag | mysql.UnsignedFlag, - Flen: 22, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeBigInt22ZeroFill *types.FieldType // DECIMAL(16, 8) DEFAULT 2.5 - typeDecimal16_8 = &types.FieldType{ - Tp: mysql.TypeNewDecimal, - Flag: 0, - Flen: 16, - Decimal: 8, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeDecimal16_8 *types.FieldType // DECIMAL - typeDecimal = &types.FieldType{ - Tp: mysql.TypeNewDecimal, - Flag: 0, - Flen: 11, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeDecimal *types.FieldType // DATE - typeDate = &types.FieldType{ - Tp: mysql.TypeDate, - Flag: mysql.BinaryFlag, - Flen: 10, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeDate *types.FieldType // DATETIME(3) - typeDateTime3 = &types.FieldType{ - Tp: mysql.TypeDatetime, - Flag: mysql.BinaryFlag, - Flen: 23, - Decimal: 3, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeDateTime3 *types.FieldType // TIMESTAMP - typeTimestamp = &types.FieldType{ - Tp: mysql.TypeTimestamp, - Flag: mysql.BinaryFlag, - Flen: 19, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeTimestamp *types.FieldType // TIME(6) - typeTime6 = &types.FieldType{ - Tp: mysql.TypeDuration, - Flag: mysql.BinaryFlag, - Flen: 17, - Decimal: 6, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeTime6 *types.FieldType // YEAR(4) - typeYear4 = &types.FieldType{ - Tp: mysql.TypeYear, - Flag: mysql.ZerofillFlag | mysql.UnsignedFlag, - Flen: 4, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeYear4 *types.FieldType // CHAR(123) - typeChar123 = &types.FieldType{ - Tp: mysql.TypeString, - Flag: 0, - Flen: 123, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: nil, - } + typeChar123 *types.FieldType // VARCHAR(65432) CHARSET ascii - typeVarchar65432CharsetASCII = &types.FieldType{ - Tp: mysql.TypeVarchar, - Flag: 0, - Flen: 65432, - Decimal: 0, - Charset: "ascii", - Collate: "ascii_bin", - Elems: nil, - } + typeVarchar65432CharsetASCII *types.FieldType // BINARY(69) - typeBinary69 = &types.FieldType{ - Tp: mysql.TypeString, - Flag: mysql.BinaryFlag, - Flen: 69, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeBinary69 *types.FieldType // VARBINARY(420) - typeVarBinary420 = &types.FieldType{ - Tp: mysql.TypeVarchar, - Flag: mysql.BinaryFlag, - Flen: 420, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeVarBinary420 *types.FieldType // LONGBLOB - typeLongBlob = &types.FieldType{ - Tp: mysql.TypeLongBlob, - Flag: mysql.BinaryFlag, - Flen: 0xffffffff, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeLongBlob *types.FieldType // MEDIUMTEXT - typeMediumText = &types.FieldType{ - Tp: mysql.TypeMediumBlob, - Flag: 0, - Flen: 0xffffff, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: nil, - } + typeMediumText *types.FieldType // ENUM('tidb', 'tikv', 'tiflash', 'golang', 'rust') - typeEnum5 = &types.FieldType{ - Tp: mysql.TypeEnum, - Flag: 0, - Flen: types.UnspecifiedLength, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: []string{"tidb", "tikv", "tiflash", "golang", "rust"}, - } + typeEnum5 *types.FieldType // ENUM('tidb', 'tikv') - typeEnum2 = &types.FieldType{ - Tp: mysql.TypeEnum, - Flag: 0, - Flen: types.UnspecifiedLength, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: []string{"tidb", "tikv"}, - } + typeEnum2 *types.FieldType // SET('tidb', 'tikv', 'tiflash', 'golang', 'rust') - typeSet5 = &types.FieldType{ - Tp: mysql.TypeSet, - Flag: 0, - Flen: types.UnspecifiedLength, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: []string{"tidb", "tikv", "tiflash", "golang", "rust"}, - } + typeSet5 *types.FieldType - // ENUM('tidb', 'tikv') - typeSet2 = &types.FieldType{ - Tp: mysql.TypeSet, - Flag: 0, - Flen: types.UnspecifiedLength, - Decimal: 0, - Charset: mysql.UTF8MB4Charset, - Collate: mysql.UTF8MB4DefaultCollation, - Elems: []string{"tidb", "tikv"}, - } + // SET('tidb', 'tikv') + typeSet2 *types.FieldType // JSON - typeJSON = &types.FieldType{ - Tp: mysql.TypeJSON, - Flag: mysql.BinaryFlag, - Flen: 0xffffffff, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - } + typeJSON *types.FieldType + + // INT NOT NULL KEY INT AUTO_INC UNIQUE = INT AUTO_INC KEY, + typeLongIncrMultiKey *types.FieldType ) func (*typeSchema) TestTypeUnwrap(c *C) { @@ -401,18 +418,10 @@ func (*typeSchema) TestTypeCompareJoin(c *C) { a: typeIntNotNullKey, b: typeIntAutoIncrementUnique, compareError: `at tuple index \d+: combining contradicting orders.*`, - join: &types.FieldType{ - Tp: mysql.TypeLong, - Flag: mysql.AutoIncrementFlag | mysql.MultipleKeyFlag, - Flen: 11, - Decimal: 0, - Charset: binary, - Collate: binary, - Elems: nil, - }, + join: typeLongIncrMultiKey, }, { - // DECIMAL of differet Flen/Decimal cannot be compared + // DECIMAL of different Flen/Decimal cannot be compared a: typeDecimal16_8, b: typeDecimal, compareError: `at tuple index \d+: distinct singletons.*`, @@ -446,7 +455,7 @@ func (*typeSchema) TestTypeCompareJoin(c *C) { for _, tc := range testCases { assert := func(expected interface{}, checker Checker, args ...interface{}) { - args = append(args, Commentf("a = %v %#x, b = %v %#x", tc.a, tc.a.Flag, tc.b, tc.b.Flag)) + args = append(args, Commentf("a = %v %#x, b = %v %#x", tc.a, tc.a.GetFlag(), tc.b, tc.b.GetFlag())) c.Assert(expected, checker, args...) } diff --git a/sync_diff_inspector/source/common/common_test.go b/sync_diff_inspector/source/common/common_test.go index 0555fd222..3008f1acf 100644 --- a/sync_diff_inspector/source/common/common_test.go +++ b/sync_diff_inspector/source/common/common_test.go @@ -29,7 +29,7 @@ func TestRowData(t *testing.T) { require.NoError(t, err) _, orderKeyCols := dbutil.SelectUniqueOrderKey(tableInfo) - require.Equal(t, utils.NeedQuotes(orderKeyCols[1].FieldType.Tp), true) + require.Equal(t, utils.NeedQuotes(orderKeyCols[1].FieldType.GetType()), true) ids := []string{"3", "2", "2", "2", "4", "1", "NULL"} names := []string{"d", "NULL", "c", "g", "b", "a", "e"} ages := []string{"1", "2", "3", "3", "NULL", "5", "4"} diff --git a/sync_diff_inspector/source/common/rows.go b/sync_diff_inspector/source/common/rows.go index 32a42d965..b8d72e76c 100644 --- a/sync_diff_inspector/source/common/rows.go +++ b/sync_diff_inspector/source/common/rows.go @@ -58,7 +58,7 @@ func (r RowDatas) Less(i, j int) bool { strData1 := string(col1.Data) strData2 := string(col2.Data) - if utils.NeedQuotes(col.FieldType.Tp) { + if utils.NeedQuotes(col.FieldType.GetType()) { if strData1 == strData2 { continue } diff --git a/sync_diff_inspector/utils/utils.go b/sync_diff_inspector/utils/utils.go index 269c5576c..d4d3f41c8 100644 --- a/sync_diff_inspector/utils/utils.go +++ b/sync_diff_inspector/utils/utils.go @@ -126,9 +126,9 @@ func GetTableRowsQueryFormat(schema, table string, tableInfo *model.TableInfo, c name := dbutil.ColumnName(col.Name.O) // When col value is 0, the result is NULL. // But we can use ISNULL to distinguish between null and 0. - if col.FieldType.Tp == mysql.TypeFloat { + if col.FieldType.GetType() == mysql.TypeFloat { name = fmt.Sprintf("round(%s, 5-floor(log10(abs(%s)))) as %s", name, name, name) - } else if col.FieldType.Tp == mysql.TypeDouble { + } else if col.FieldType.GetType() == mysql.TypeDouble { name = fmt.Sprintf("round(%s, 14-floor(log10(abs(%s)))) as %s", name, name, name) } columnNames = append(columnNames, name) @@ -163,7 +163,7 @@ func GenerateReplaceDML(data map[string]*dbutil.ColumnData, table *model.TableIn continue } - if NeedQuotes(col.FieldType.Tp) { + if NeedQuotes(col.FieldType.GetType()) { values = append(values, fmt.Sprintf("'%s'", strings.Replace(string(data[col.Name.O].Data), "'", "\\'", -1))) } else { values = append(values, string(data[col.Name.O].Data)) @@ -196,7 +196,7 @@ func GenerateReplaceDMLWithAnnotation(source, target map[string]*dbutil.ColumnDa if data1.IsNull { value1 = "NULL" } else { - if NeedQuotes(col.FieldType.Tp) { + if NeedQuotes(col.FieldType.GetType()) { value1 = fmt.Sprintf("'%s'", strings.Replace(string(data1.Data), "'", "\\'", -1)) } else { value1 = string(data1.Data) @@ -217,7 +217,7 @@ func GenerateReplaceDMLWithAnnotation(source, target map[string]*dbutil.ColumnDa if data2.IsNull { values2 = append(values2, "NULL") } else { - if NeedQuotes(col.FieldType.Tp) { + if NeedQuotes(col.FieldType.GetType()) { values2 = append(values2, fmt.Sprintf("'%s'", strings.Replace(string(data2.Data), "'", "\\'", -1))) } else { values2 = append(values2, string(data2.Data)) @@ -253,7 +253,7 @@ func GenerateDeleteDML(data map[string]*dbutil.ColumnData, table *model.TableInf continue } - if NeedQuotes(col.FieldType.Tp) { + if NeedQuotes(col.FieldType.GetType()) { kvs = append(kvs, fmt.Sprintf("%s = '%s'", dbutil.ColumnName(col.Name.O), strings.Replace(string(data[col.Name.O].Data), "'", "\\'", -1))) } else { kvs = append(kvs, fmt.Sprintf("%s = %s", dbutil.ColumnName(col.Name.O), string(data[col.Name.O].Data))) @@ -298,23 +298,23 @@ func isCompatible(tp1, tp2 byte) bool { } func sameProperties(c1, c2 *model.ColumnInfo) bool { - switch c1.Tp { + switch c1.GetType() { case mysql.TypeVarString, mysql.TypeString, mysql.TypeVarchar: - if c1.FieldType.Charset != c2.FieldType.Charset { + if c1.FieldType.GetCharset() != c2.FieldType.GetCharset() { log.Warn("Ignoring character set differences", zap.String("column name", c1.Name.O), - zap.String("charset source", c1.FieldType.Charset), - zap.String("charset target", c2.FieldType.Charset), + zap.String("charset source", c1.FieldType.GetCharset()), + zap.String("charset target", c2.FieldType.GetCharset()), ) } - if c1.FieldType.Collate != c2.FieldType.Collate { + if c1.FieldType.GetCollate() != c2.FieldType.GetCollate() { log.Warn("Ignoring collation differences", zap.String("column name", c1.Name.O), - zap.String("collation source", c1.FieldType.Collate), - zap.String("collation target", c2.FieldType.Collate), + zap.String("collation source", c1.FieldType.GetCollate()), + zap.String("collation target", c2.FieldType.GetCollate()), ) } - return c1.FieldType.Flen == c2.FieldType.Flen + return c1.FieldType.GetFlen() == c2.FieldType.GetFlen() default: return true } @@ -350,15 +350,15 @@ func CompareStruct(upstreamTableInfos []*model.TableInfo, downstreamTableInfo *m return false, true } - if !isCompatible(column.Tp, downstreamTableInfo.Columns[i].Tp) { + if !isCompatible(column.GetType(), downstreamTableInfo.Columns[i].GetType()) { // column types are different, panic! log.Error("column type not compatible", zap.String("upstream table", upstreamTableInfo.Name.O), zap.String("column name", column.Name.O), - zap.Uint8("column type", column.Tp), + zap.Uint8("column type", column.GetType()), zap.String("downstream table", downstreamTableInfo.Name.O), zap.String("column name", downstreamTableInfo.Columns[i].Name.O), - zap.Uint8("column type", downstreamTableInfo.Columns[i].Tp), + zap.Uint8("column type", downstreamTableInfo.Columns[i].GetType()), ) return false, true } @@ -368,10 +368,10 @@ func CompareStruct(upstreamTableInfos []*model.TableInfo, downstreamTableInfo *m log.Error("column properties not compatible", zap.String("upstream table", upstreamTableInfo.Name.O), zap.String("column name", column.Name.O), - zap.Uint8("column type", column.Tp), + zap.Uint8("column type", column.GetType()), zap.String("downstream table", downstreamTableInfo.Name.O), zap.String("column name", downstreamTableInfo.Columns[i].Name.O), - zap.Uint8("column type", downstreamTableInfo.Columns[i].Tp), + zap.Uint8("column type", downstreamTableInfo.Columns[i].GetType()), ) return false, true } @@ -517,7 +517,7 @@ func CompareData(map1, map2 map[string]*dbutil.ColumnData, orderKeyCols, columns } str1 = string(data1.Data) str2 = string(data2.Data) - if column.FieldType.Tp == mysql.TypeFloat || column.FieldType.Tp == mysql.TypeDouble { + if column.FieldType.GetType() == mysql.TypeFloat || column.FieldType.GetType() == mysql.TypeDouble { if data1.IsNull == data2.IsNull && data1.IsNull { continue } @@ -556,7 +556,7 @@ func CompareData(map1, map2 map[string]*dbutil.ColumnData, orderKeyCols, columns return } - if NeedQuotes(col.FieldType.Tp) { + if NeedQuotes(col.FieldType.GetType()) { strData1 := string(data1.Data) strData2 := string(data2.Data) @@ -721,9 +721,9 @@ func GetCountAndCRC32Checksum(ctx context.Context, db *sql.DB, schemaName, table name := dbutil.ColumnName(col.Name.O) // When col value is 0, the result is NULL. // But we can use ISNULL to distinguish between null and 0. - if col.FieldType.Tp == mysql.TypeFloat { + if col.FieldType.GetType() == mysql.TypeFloat { name = fmt.Sprintf("round(%s, 5-floor(log10(abs(%s))))", name, name) - } else if col.FieldType.Tp == mysql.TypeDouble { + } else if col.FieldType.GetType() == mysql.TypeDouble { name = fmt.Sprintf("round(%s, 14-floor(log10(abs(%s))))", name, name) } columnNames = append(columnNames, name) @@ -787,7 +787,7 @@ func ResetColumns(tableInfo *model.TableInfo, columns []string) (*model.TableInf for i, col := range tableInfo.Columns { col.Offset = i colMap[col.Name.O] = i - hasTimeStampType = hasTimeStampType || (col.FieldType.Tp == mysql.TypeTimestamp) + hasTimeStampType = hasTimeStampType || (col.FieldType.GetType() == mysql.TypeTimestamp) } // Initialize the offset of the column of each index to new `tableInfo.Columns`.