~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication/utility.cc

  • Committer: Stewart Smith
  • Date: 2009-01-12 05:43:13 UTC
  • mto: (784.1.4 for-brian)
  • mto: This revision was merged to the branch mainline in revision 785.
  • Revision ID: stewart@flamingspork.com-20090112054313-edk6kpf4l6kpz4j7
fix archive_basic for drizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include <drizzled/server_includes.h>
17
 
#include "rpl_utility.h"
18
 
#include "rpl_rli.h"
19
 
#include <drizzled/drizzled_error_messages.h>
 
17
#include <drizzled/replication/utility.h>
 
18
#include <drizzled/replication/rli.h>
 
19
#include <drizzled/error.h>
 
20
#include <drizzled/gettext.h>
20
21
 
21
22
/*********************************************************************
22
23
 *                   table_def member definitions                    *
26
27
  This function returns the field size in raw bytes based on the type
27
28
  and the encoded field data from the master's raw data.
28
29
*/
29
 
uint32_t table_def::calc_field_size(uint col, uchar *master_data) const
 
30
uint32_t table_def::calc_field_size(uint32_t col, unsigned char *master_data) const
30
31
{
31
32
  uint32_t length= 0;
32
33
 
33
34
  switch (type(col)) {
34
35
  case DRIZZLE_TYPE_NEWDECIMAL:
35
 
    length= my_decimal_get_binary_size(m_field_metadata[col] >> 8, 
 
36
    length= my_decimal_get_binary_size(m_field_metadata[col] >> 8,
36
37
                                       m_field_metadata[col] & 0xff);
37
38
    break;
38
39
  case DRIZZLE_TYPE_DOUBLE:
48
49
    length= m_field_metadata[col] & 0x00ff;
49
50
    break;
50
51
  }
51
 
  case DRIZZLE_TYPE_TINY:
52
 
    length= 1;
53
 
    break;
54
 
  case DRIZZLE_TYPE_SHORT:
55
 
    length= 2;
56
 
    break;
57
52
  case DRIZZLE_TYPE_LONG:
58
53
    length= 4;
59
54
    break;
63
58
  case DRIZZLE_TYPE_NULL:
64
59
    length= 0;
65
60
    break;
66
 
  case DRIZZLE_TYPE_NEWDATE:
 
61
  case DRIZZLE_TYPE_DATE:
67
62
    length= 3;
68
63
    break;
69
64
  case DRIZZLE_TYPE_TIME:
99
94
 
100
95
*/
101
96
int
102
 
table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table)
 
97
table_def::compatible_with(Relay_log_info const *rli_arg, Table *table)
103
98
  const
104
99
{
105
100
  /*
106
101
    We only check the initial columns for the tables.
107
102
  */
108
 
  uint const cols_to_check= min(table->s->fields, size());
 
103
  uint32_t const cols_to_check= cmin(table->s->fields, size());
109
104
  int error= 0;
110
105
  Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
111
106
 
112
107
  TABLE_SHARE const *const tsh= table->s;
113
108
 
114
 
  for (uint col= 0 ; col < cols_to_check ; ++col)
 
109
  for (uint32_t col= 0 ; col < cols_to_check ; ++col)
115
110
  {
116
111
    if (table->field[col]->type() != type(col))
117
112
    {
129
124
    /*
130
125
      Check the slave's field size against that of the master.
131
126
    */
132
 
    if (!error && 
 
127
    if (!error &&
133
128
        !table->field[col]->compatible_field_size(field_metadata(col)))
134
129
    {
135
130
      error= 1;
140
135
               "column size."), col,
141
136
               table->field[col]->pack_length_from_metadata(
142
137
                                    m_field_metadata[col]),
143
 
               tsh->db.str, tsh->table_name.str, 
 
138
               tsh->db.str, tsh->table_name.str,
144
139
               table->field[col]->row_pack_length());
145
140
      rli->report(ERROR_LEVEL, ER_BINLOG_ROW_WRONG_TABLE_DEF,
146
141
                  ER(ER_BINLOG_ROW_WRONG_TABLE_DEF), buf);