13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
#include <drizzled/server_includes.h>
17
16
#include "rpl_utility.h"
18
17
#include "rpl_rli.h"
19
#include <drizzled/drizzled_error_messages.h>
21
19
/*********************************************************************
22
20
* table_def member definitions *
26
24
This function returns the field size in raw bytes based on the type
27
25
and the encoded field data from the master's raw data.
29
uint32_t table_def::calc_field_size(uint32_t col, unsigned char *master_data) const
27
uint32 table_def::calc_field_size(uint col, uchar *master_data) const
33
31
switch (type(col)) {
34
case DRIZZLE_TYPE_NEWDECIMAL:
32
case MYSQL_TYPE_NEWDECIMAL:
35
33
length= my_decimal_get_binary_size(m_field_metadata[col] >> 8,
36
34
m_field_metadata[col] & 0xff);
38
case DRIZZLE_TYPE_DOUBLE:
36
case MYSQL_TYPE_FLOAT:
37
case MYSQL_TYPE_DOUBLE:
39
38
length= m_field_metadata[col];
42
41
The cases for SET and ENUM are include for completeness, however
43
both are mapped to type DRIZZLE_TYPE_STRING and their real types
42
both are mapped to type MYSQL_TYPE_STRING and their real types
44
43
are encoded in the field metadata.
46
case DRIZZLE_TYPE_ENUM:
47
case MYSQL_TYPE_STRING:
48
length= m_field_metadata[col] & 0x00ff;
49
uchar type= m_field_metadata[col] >> 8U;
50
if ((type == MYSQL_TYPE_SET) || (type == MYSQL_TYPE_ENUM))
51
length= m_field_metadata[col] & 0x00ff;
55
We are reading the actual size from the master_data record
56
because this field has the actual lengh stored in the first
59
length= (uint) *master_data + 1;
51
case DRIZZLE_TYPE_TINY:
54
case DRIZZLE_TYPE_LONG:
68
case MYSQL_TYPE_SHORT:
57
case DRIZZLE_TYPE_LONGLONG:
74
case MYSQL_TYPE_LONGLONG:
60
case DRIZZLE_TYPE_NULL:
63
case DRIZZLE_TYPE_NEWDATE:
66
case DRIZZLE_TYPE_TIME:
69
case DRIZZLE_TYPE_TIMESTAMP:
80
case MYSQL_TYPE_NEWDATE:
86
case MYSQL_TYPE_TIMESTAMP:
72
case DRIZZLE_TYPE_DATETIME:
89
case MYSQL_TYPE_DATETIME:
75
case DRIZZLE_TYPE_VARCHAR:
92
case MYSQL_TYPE_VARCHAR:
77
94
length= m_field_metadata[col] > 255 ? 2 : 1; // c&p of Field_varstring::data_length()
78
95
assert(uint2korr(master_data) > 0);
79
length+= length == 1 ? (uint32_t) *master_data : uint2korr(master_data);
96
length+= length == 1 ? (uint32) *master_data : uint2korr(master_data);
82
case DRIZZLE_TYPE_BLOB:
84
101
length= uint4korr(master_data);
85
102
length+= m_field_metadata[col];
89
length= ~(uint32_t) 0;
99
table_def::compatible_with(Relay_log_info const *rli_arg, Table *table)
116
table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table)
103
120
We only check the initial columns for the tables.
105
uint32_t const cols_to_check= cmin(table->s->fields, size());
122
uint const cols_to_check= min(table->s->fields, size());
107
124
Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
109
126
TABLE_SHARE const *const tsh= table->s;
111
for (uint32_t col= 0 ; col < cols_to_check ; ++col)
128
for (uint col= 0 ; col < cols_to_check ; ++col)
113
130
if (table->field[col]->type() != type(col))
116
133
assert(tsh->db.str && tsh->table_name.str);
119
snprintf(buf, sizeof(buf), _("Column %d type mismatch - "
120
"received type %d, %s.%s has type %d"),
136
snprintf(buf, sizeof(buf), "Column %d type mismatch - "
137
"received type %d, %s.%s has type %d",
121
138
col, type(col), tsh->db.str, tsh->table_name.str,
122
139
table->field[col]->type());
123
140
rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF,
134
snprintf(buf, sizeof(buf), _("Column %d size mismatch - "
151
snprintf(buf, sizeof(buf), "Column %d size mismatch - "
135
152
"master has size %d, %s.%s on slave has size %d."
136
153
" Master's column size should be <= the slave's "
137
"column size."), col,
138
155
table->field[col]->pack_length_from_metadata(
139
156
m_field_metadata[col]),
140
157
tsh->db.str, tsh->table_name.str,