zamotivator

Untitled

Feb 14th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.00 KB | None | 0 0
  1. diff -ruN 212/patch_info/wl5151.info 214/patch_info/wl5151.info
  2. --- 212/patch_info/wl5151.info 2012-02-15 11:40:53.591548115 +0900
  3. +++ 214/patch_info/wl5151.info 1970-01-01 08:00:00.000000000 +0800
  4. @@ -1,6 +0,0 @@
  5. -File=wl5151.patch
  6. -Name=Backported wl5151 from mysql 5.5 (Row-based replication: attribute promotion and demotion.)
  7. -Version=1.0
  8. -Author=Percona <[email protected]>
  9. -License=GPL
  10. -Comment=http://dev.mysql.com/doc/refman/5.5/en/replication-features-differing-tables.html#replication-features-attribute-promotion
  11. diff -ruN 212/sql/field.cc 214/sql/field.cc
  12. --- 212/sql/field.cc 2012-02-15 11:40:54.604672749 +0900
  13. +++ 214/sql/field.cc 2012-02-15 11:40:47.775832663 +0900
  14. @@ -1004,7 +1004,8 @@
  15. Used below. In an anonymous namespace to not clash with definitions
  16. in other files.
  17. */
  18. -namespace {
  19. +namespace
  20. +{
  21. int compare(unsigned int a, unsigned int b)
  22. {
  23. if (a < b)
  24. @@ -1424,15 +1425,15 @@
  25. master's field size, @c false otherwise.
  26. */
  27. bool Field::compatible_field_size(uint field_metadata,
  28. - Relay_log_info *rli_arg __attribute__((unused)),
  29. - uint16 mflags __attribute__((unused)),
  30. + Relay_log_info *__attribute__((unused)),
  31. + uint16 __attribute__((unused)),
  32. int *order_var)
  33. {
  34. uint const source_size= pack_length_from_metadata(field_metadata);
  35. uint const destination_size= row_pack_length();
  36. DBUG_PRINT("debug", ("real_type: %d, source_size: %u, destination_size: %u",
  37. real_type(), source_size, destination_size));
  38. - *order_var = compare(source_size, destination_size);
  39. + *order_var= compare(source_size, destination_size);
  40. return true;
  41. }
  42.  
  43. @@ -2962,15 +2963,45 @@
  44. }
  45.  
  46.  
  47. +/**
  48. + This method is used in row-based replication to verify that the
  49. + slave's field size is less than or equal to the master's field
  50. + size. The encoded field metadata (from the master or source) is
  51. + decoded and compared to the size of this field (the slave or
  52. + destination).
  53. +
  54. + @note
  55. +
  56. + The comparison is made so that if the source data (from the master)
  57. + is less than the target data (on the slave), -1 is returned in @c
  58. + <code>*order_var</code>. This implies that a conversion is
  59. + necessary, but that it is lossy and can result in truncation of the
  60. + value.
  61. +
  62. + If the source data is strictly greater than the target data, 1 is
  63. + returned in <code>*order_var</code>. This implies that the source
  64. + type can is contained in the target type and that a conversion is
  65. + necessary but is non-lossy.
  66. +
  67. + If no conversion is required to fit the source type in the target
  68. + type, 0 is returned in <code>*order_var</code>.
  69. + @param field_metadata Encoded size in field metadata
  70. + @param order_var Pointer to variable where the order
  71. + between the source field and this field
  72. + will be returned.
  73. +
  74. + @return @c true if this field's size is compatible with the
  75. + master's field size, @c false otherwise.
  76. +*/
  77. bool Field_new_decimal::compatible_field_size(uint field_metadata,
  78. - Relay_log_info * __attribute__((unused)),
  79. - uint16 mflags __attribute__((unused)),
  80. + Relay_log_info *__attribute__((unused)),
  81. + uint16 __attribute__((unused)),
  82. int *order_var)
  83. {
  84. - uint const source_precision= (field_metadata >> 8U) & 0x00ff;
  85. - uint const source_decimal= field_metadata & 0x00ff;
  86. - int order= compare(source_precision, precision);
  87. - *order_var= order != 0 ? order : compare(source_decimal, dec);
  88. + uint const src_precision= (field_metadata >> 8U) & 0x00ff;
  89. + uint const src_decimal= field_metadata & 0x00ff;
  90. + int order= compare(src_precision, precision);
  91. + *order_var= order != 0 ? order : compare(src_decimal, dec);
  92. return true;
  93. }
  94.  
  95. @@ -6842,6 +6873,37 @@
  96. }
  97. #endif
  98.  
  99. +/**
  100. + This method is used in row-based replication to verify that the
  101. + slave's field size is less than or equal to the master's field
  102. + size. The encoded field metadata (from the master or source) is
  103. + decoded and compared to the size of this field (the slave or
  104. + destination).
  105. +
  106. + @note
  107. +
  108. + The comparison is made so that if the source data (from the master)
  109. + is less than the target data (on the slave), -1 is returned in @c
  110. + <code>*order_var</code>. This implies that a conversion is
  111. + necessary, but that it is lossy and can result in truncation of the
  112. + value.
  113. +
  114. + If the source data is strictly greater than the target data, 1 is
  115. + returned in <code>*order_var</code>. This implies that the source
  116. + type can is contained in the target type and that a conversion is
  117. + necessary but is non-lossy.
  118. +
  119. + If no conversion is required to fit the source type in the target
  120. + type, 0 is returned in <code>*order_var</code>.
  121. + @param field_metadata Encoded size in field metadata
  122. + @param rli_arg Relay log information
  123. + @param order_var Pointer to variable where the order
  124. + between the source field and this field
  125. + will be returned.
  126. +
  127. + @return @c true if this field's size is compatible with the
  128. + master's field size, @c false otherwise.
  129. +*/
  130. bool
  131. Field_string::compatible_field_size(uint field_metadata,
  132. Relay_log_info *rli_arg,
  133. @@ -6852,7 +6914,7 @@
  134. const Check_field_param check_param = { this };
  135. if (rpl_master_has_bug(rli_arg, 37426, TRUE,
  136. check_field_for_37426, &check_param))
  137. - return FALSE; // Not compatible field sizes
  138. + return FALSE; // Not compatible field sizes
  139. #endif
  140. return Field::compatible_field_size(field_metadata, rli_arg, mflags, order_var);
  141. }
  142. @@ -9498,11 +9560,41 @@
  143. }
  144.  
  145.  
  146. +/**
  147. + This method is used in row-based replication to verify that the
  148. + slave's field size is less than or equal to the master's field
  149. + size. The encoded field metadata (from the master or source) is
  150. + decoded and compared to the size of this field (the slave or
  151. + destination).
  152. +
  153. + @note
  154. +
  155. + The comparison is made so that if the source data (from the master)
  156. + is less than the target data (on the slave), -1 is returned in @c
  157. + <code>*order_var</code>. This implies that a conversion is
  158. + necessary, but that it is lossy and can result in truncation of the
  159. + value.
  160. +
  161. + If the source data is strictly greater than the target data, 1 is
  162. + returned in <code>*order_var</code>. This implies that the source
  163. + type can is contained in the target type and that a conversion is
  164. + necessary but is non-lossy.
  165. +
  166. + If no conversion is required to fit the source type in the target
  167. + type, 0 is returned in <code>*order_var</code>.
  168. + @param field_metadata Encoded size in field metadata
  169. + @param mflags Flags from the table map event for the table.
  170. + @param order_var Pointer to variable where the order
  171. + between the source field and this field
  172. + will be returned.
  173. +
  174. + @return @c true if this field's size is compatible with the
  175. + master's field size, @c false otherwise.
  176. +*/
  177. bool
  178. Field_bit::compatible_field_size(uint field_metadata,
  179. - Relay_log_info * __attribute__((unused)),
  180. - uint16 mflags,
  181. - int *order_var)
  182. + Relay_log_info *__attribute__((unused)),
  183. + uint16 mflags, int *order_var)
  184. {
  185. DBUG_ENTER("Field_bit::compatible_field_size");
  186. DBUG_ASSERT((field_metadata >> 16) == 0);
  187. @@ -9518,8 +9610,9 @@
  188.  
  189. We do this by computing the number of bytes to store the field
  190. instead, and then compare the result.
  191. - */
  192. - if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F)) {
  193. + */
  194. + if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F))
  195. + {
  196. from_bit_len= (from_bit_len + 7) / 8;
  197. to_bit_len= (to_bit_len + 7) / 8;
  198. }
  199. diff -ruN 212/sql/field.h 214/sql/field.h
  200. --- 212/sql/field.h 2012-02-15 11:40:53.765569523 +0900
  201. +++ 214/sql/field.h 2012-02-15 11:40:46.961732510 +0900
  202. @@ -189,7 +189,7 @@
  203. virtual uint32 pack_length_in_rec() const { return pack_length(); }
  204. virtual bool compatible_field_size(uint metadata, Relay_log_info *rli,
  205. uint16 mflags, int *order);
  206. - virtual uint pack_length_from_metadata(uint field_metadata)
  207. + virtual uint pack_length_from_metadata(uint field_metadata)
  208. {
  209. DBUG_ENTER("Field::pack_length_from_metadata");
  210. DBUG_RETURN(field_metadata);
  211. @@ -673,8 +673,12 @@
  212. return store_decimal_truncated(value,0);
  213. }
  214. int store_decimal_truncated(const my_decimal *,bool *truncated);
  215. - uint row_pack_length() { return pack_length(); }
  216. - uint32 pack_length_from_metadata(uint field_metadata) {
  217. + uint row_pack_length()
  218. + {
  219. + return pack_length();
  220. + }
  221. + uint32 pack_length_from_metadata(uint field_metadata)
  222. + {
  223. uint32 length= pack_length();
  224. DBUG_PRINT("result", ("pack_length_from_metadata(%d): %u",
  225. field_metadata, length));
  226. @@ -1787,7 +1791,10 @@
  227. }
  228. bool compatible_field_size(uint field_metadata, Relay_log_info *rli,
  229. uint16 mflags, int *order_var);
  230. - uint row_pack_length() { return field_length; }
  231. + uint row_pack_length()
  232. + {
  233. + return field_length;
  234. + }
  235. int pack_cmp(const uchar *a,const uchar *b,uint key_length,
  236. my_bool insert_or_update);
  237. int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
  238. @@ -2328,8 +2335,8 @@
  239. uint pack_length_from_metadata(uint field_metadata);
  240. uint row_pack_length()
  241. { return (bytes_in_rec + ((bit_len > 0) ? 1 : 0)); }
  242. - bool compatible_field_size(uint metadata, Relay_log_info *rli,
  243. - uint16 mflags, int *order_var);
  244. + bool compatible_field_size(uint metadata, Relay_log_info *rli, uint16 mflags,
  245. + int *order_var);
  246. void sql_type(String &str) const;
  247. virtual uchar *pack(uchar *to, const uchar *from,
  248. uint max_length, bool low_byte_first);
  249. @@ -2440,7 +2447,7 @@
  250. void init_for_tmp_table(enum_field_types sql_type_arg,
  251. uint32 max_length, uint32 decimals,
  252. bool maybe_null, bool is_unsigned,
  253. - uint pack_length = ~0U);
  254. + uint pack_length= ~0U);
  255.  
  256. bool init(THD *thd, char *field_name, enum_field_types type, char *length,
  257. char *decimals, uint type_modifier, Item *default_value,
  258. diff -ruN 212/sql/log_event.cc 214/sql/log_event.cc
  259. --- 212/sql/log_event.cc 2012-02-15 11:40:54.642677424 +0900
  260. +++ 214/sql/log_event.cc 2012-02-15 11:40:47.837840290 +0900
  261. @@ -31,6 +31,7 @@
  262. #include "rpl_rli.h"
  263. #include "rpl_mi.h"
  264. #include "rpl_filter.h"
  265. +#include "rpl_utility.h"
  266. #include "rpl_record.h"
  267. #include <my_dir.h>
  268.  
  269. @@ -38,7 +39,6 @@
  270.  
  271. #include <base64.h>
  272. #include <my_bitmap.h>
  273. -#include "rpl_utility.h"
  274.  
  275. #define log_cs &my_charset_latin1
  276.  
  277. @@ -1599,7 +1599,7 @@
  278. type= byte0 | 0x30;
  279. }
  280. else
  281. - length = meta & 0xFF;
  282. + length= meta & 0xFF;
  283. }
  284. else
  285. length= meta;
  286. @@ -1749,16 +1749,16 @@
  287. char *pos= &buf[10];
  288.  
  289. /* Copied from field.cc */
  290. - *pos--=0; // End NULL
  291. - part=(int) (tmp & 31);
  292. + *pos--= 0; // End NULL
  293. + part= (int) (tmp & 31);
  294. *pos--= (char) ('0'+part%10);
  295. *pos--= (char) ('0'+part/10);
  296. *pos--= ':';
  297. - part=(int) (tmp >> 5 & 15);
  298. + part= (int) (tmp >> 5 & 15);
  299. *pos--= (char) ('0'+part%10);
  300. *pos--= (char) ('0'+part/10);
  301. *pos--= ':';
  302. - part=(int) (tmp >> 9);
  303. + part= (int) (tmp >> 9);
  304. *pos--= (char) ('0'+part%10); part/=10;
  305. *pos--= (char) ('0'+part%10); part/=10;
  306. *pos--= (char) ('0'+part%10); part/=10;
  307. @@ -1767,7 +1767,7 @@
  308. my_snprintf(typestr, typestr_length, "DATE");
  309. return 3;
  310. }
  311. -
  312. +
  313. case MYSQL_TYPE_DATE:
  314. {
  315. uint i32= uint3korr(ptr);
  316. @@ -1786,7 +1786,8 @@
  317. }
  318.  
  319. case MYSQL_TYPE_ENUM:
  320. - switch (meta & 0xFF) {
  321. + switch (meta & 0xFF)
  322. + {
  323. case 1:
  324. my_b_printf(file, "%d", (int) *ptr);
  325. my_snprintf(typestr, typestr_length, "ENUM(1 byte)");
  326. @@ -7597,8 +7598,7 @@
  327. MY_BITMAP *slave_skip_columns;
  328. if (!ptr->m_tabledef.compatible_with(thd,
  329. const_cast<Relay_log_info*>(rli),
  330. - ptr->table,
  331. - &conv_table,
  332. + ptr->table, &conv_table,
  333. &slave_skip_columns))
  334. {
  335.  
  336. @@ -7619,9 +7619,7 @@
  337. DBUG_PRINT("debug", ("Table: %s.%s is compatible with master"
  338. " - conv_table: %p, slave_skip_columns: %p",
  339. ptr->table->s->db.str,
  340. - ptr->table->s->table_name.str,
  341. - conv_table,
  342. - slave_skip_columns));
  343. + ptr->table->s->table_name.str, conv_table, slave_skip_columns));
  344. ptr->m_conv_table= conv_table;
  345. ptr->m_slave_skip_columns= slave_skip_columns;
  346. }
  347. diff -ruN 212/sql/log_event_old.cc 214/sql/log_event_old.cc
  348. --- 212/sql/log_event_old.cc 2012-02-15 11:40:54.650678408 +0900
  349. +++ 214/sql/log_event_old.cc 2012-02-15 11:40:47.846841397 +0900
  350. @@ -123,9 +123,9 @@
  351. {
  352. TABLE *conv_table;
  353. MY_BITMAP *slave_skip_columns;
  354. - if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
  355. - ptr->table,
  356. - &conv_table,
  357. + if (!ptr->m_tabledef.compatible_with(thd,
  358. + const_cast<Relay_log_info*>(rli),
  359. + ptr->table, &conv_table,
  360. &slave_skip_columns))
  361. {
  362. DBUG_PRINT("debug", ("Table: %s.%s is not compatible with master",
  363. @@ -1633,8 +1633,7 @@
  364. MY_BITMAP *slave_skip_columns;
  365. if (ptr->m_tabledef.compatible_with(thd,
  366. const_cast<Relay_log_info*>(rli),
  367. - ptr->table,
  368. - &conv_table,
  369. + ptr->table, &conv_table,
  370. &slave_skip_columns))
  371. {
  372. mysql_unlock_tables(thd, thd->lock);
  373. diff -ruN 212/sql/rpl_utility.cc 214/sql/rpl_utility.cc
  374. --- 212/sql/rpl_utility.cc 2012-02-15 11:40:54.662679888 +0900
  375. +++ 214/sql/rpl_utility.cc 2012-02-15 11:40:47.862843366 +0900
  376. @@ -39,7 +39,8 @@
  377.  
  378. The somewhat contorted expression is to avoid overflow.
  379. */
  380. -uint32 uint_max(int bits) {
  381. +uint32 uint_max(int bits)
  382. +{
  383. return (((1UL << (bits - 1)) - 1) << 1) | 1;
  384. }
  385.  
  386. @@ -640,7 +641,7 @@
  387. {
  388. if (source_type == MYSQL_TYPE_NEWDECIMAL ||
  389. source_type == MYSQL_TYPE_DECIMAL)
  390. - *order_var = 1; // Always require lossy conversions
  391. + *order_var= 1; // Always require lossy conversions
  392. else
  393. *order_var= compare_lengths(field, source_type, metadata);
  394. DBUG_ASSERT(*order_var != 0);
  395. @@ -896,15 +897,6 @@
  396. return true;
  397. }
  398.  
  399. -/**
  400. - Create a conversion table.
  401. -
  402. - If the function is unable to create the conversion table, an error
  403. - will be printed and NULL will be returned.
  404. -
  405. - @return Pointer to conversion table, or NULL if unable to create
  406. - conversion table.
  407. - */
  408.  
  409. MY_BITMAP* table_def::create_slave_skip_columns(THD *thd,
  410. Relay_log_info *rli,
  411. @@ -939,7 +931,17 @@
  412. return result;
  413. }
  414.  
  415. -TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *target_table) const
  416. +/**
  417. + Create a conversion table.
  418. +
  419. + If the function is unable to create the conversion table, an error
  420. + will be printed and NULL will be returned.
  421. +
  422. + @return Pointer to conversion table, or NULL if unable to create
  423. + conversion table.
  424. +*/
  425. +TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli,
  426. + TABLE *target_table) const
  427. {
  428. DBUG_ENTER("table_def::create_conversion_table");
  429.  
  430. @@ -1090,12 +1092,9 @@
  431. m_field_metadata(0), m_null_bits(0), m_flags(flags),
  432. m_memory(NULL), m_columns(size, column_names, column_names_size)
  433. {
  434. - m_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
  435. - &m_type, size,
  436. - &m_field_metadata,
  437. - size * sizeof(uint16),
  438. - &m_null_bits, (size + 7) / 8,
  439. - NULL);
  440. + m_memory= (uchar *)my_multi_malloc(MYF(MY_WME), &m_type, size,
  441. + &m_field_metadata, size * sizeof(uint16),
  442. + &m_null_bits, (size + 7) / 8, NULL);
  443.  
  444. bzero(m_field_metadata, size * sizeof(uint16));
  445.  
  446. @@ -1142,8 +1141,8 @@
  447. }
  448. case MYSQL_TYPE_BIT:
  449. {
  450. - uint16 x= field_metadata[index++];
  451. - x = x + (field_metadata[index++] << 8U);
  452. + uint16 x= field_metadata[index++];
  453. + x= x + (field_metadata[index++] << 8U);
  454. m_field_metadata[i]= x;
  455. break;
  456. }
Advertisement
Add Comment
Please, Sign In to add comment