zamotivator

Untitled

Feb 13th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.13 KB | None | 0 0
  1. diff -ruN 212/patch_info/wl5151.info 213/patch_info/wl5151.info
  2. --- 212/patch_info/wl5151.info 2012-02-14 14:02:16.133443771 +0900
  3. +++ 213/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 213/sql/field.cc
  12. --- 212/sql/field.cc 2012-02-14 14:02:16.663507601 +0900
  13. +++ 213/sql/field.cc 2012-02-14 14:01:28.630723421 +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,9 +6914,10 @@
  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. + return Field::compatible_field_size(field_metadata, rli_arg,
  142. + mflags, order_var);
  143. }
  144.  
  145.  
  146. @@ -9498,11 +9561,41 @@
  147. }
  148.  
  149.  
  150. +/**
  151. + This method is used in row-based replication to verify that the
  152. + slave's field size is less than or equal to the master's field
  153. + size. The encoded field metadata (from the master or source) is
  154. + decoded and compared to the size of this field (the slave or
  155. + destination).
  156. +
  157. + @note
  158. +
  159. + The comparison is made so that if the source data (from the master)
  160. + is less than the target data (on the slave), -1 is returned in @c
  161. + <code>*order_var</code>. This implies that a conversion is
  162. + necessary, but that it is lossy and can result in truncation of the
  163. + value.
  164. +
  165. + If the source data is strictly greater than the target data, 1 is
  166. + returned in <code>*order_var</code>. This implies that the source
  167. + type can is contained in the target type and that a conversion is
  168. + necessary but is non-lossy.
  169. +
  170. + If no conversion is required to fit the source type in the target
  171. + type, 0 is returned in <code>*order_var</code>.
  172. + @param field_metadata Encoded size in field metadata
  173. + @param mflags Flags from the table map event for the table.
  174. + @param order_var Pointer to variable where the order
  175. + between the source field and this field
  176. + will be returned.
  177. +
  178. + @return @c true if this field's size is compatible with the
  179. + master's field size, @c false otherwise.
  180. +*/
  181. bool
  182. Field_bit::compatible_field_size(uint field_metadata,
  183. - Relay_log_info * __attribute__((unused)),
  184. - uint16 mflags,
  185. - int *order_var)
  186. + Relay_log_info *__attribute__((unused)),
  187. + uint16 mflags, int *order_var)
  188. {
  189. DBUG_ENTER("Field_bit::compatible_field_size");
  190. DBUG_ASSERT((field_metadata >> 16) == 0);
  191. @@ -9518,8 +9611,9 @@
  192.  
  193. We do this by computing the number of bytes to store the field
  194. instead, and then compare the result.
  195. - */
  196. - if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F)) {
  197. + */
  198. + if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F))
  199. + {
  200. from_bit_len= (from_bit_len + 7) / 8;
  201. to_bit_len= (to_bit_len + 7) / 8;
  202. }
  203. diff -ruN 212/sql/field.h 213/sql/field.h
  204. --- 212/sql/field.h 2012-02-14 14:02:16.220454248 +0900
  205. +++ 213/sql/field.h 2012-02-14 14:01:28.169667901 +0900
  206. @@ -189,7 +189,7 @@
  207. virtual uint32 pack_length_in_rec() const { return pack_length(); }
  208. virtual bool compatible_field_size(uint metadata, Relay_log_info *rli,
  209. uint16 mflags, int *order);
  210. - virtual uint pack_length_from_metadata(uint field_metadata)
  211. + virtual uint pack_length_from_metadata(uint field_metadata)
  212. {
  213. DBUG_ENTER("Field::pack_length_from_metadata");
  214. DBUG_RETURN(field_metadata);
  215. @@ -673,8 +673,12 @@
  216. return store_decimal_truncated(value,0);
  217. }
  218. int store_decimal_truncated(const my_decimal *,bool *truncated);
  219. - uint row_pack_length() { return pack_length(); }
  220. - uint32 pack_length_from_metadata(uint field_metadata) {
  221. + uint row_pack_length()
  222. + {
  223. + return pack_length();
  224. + }
  225. + uint32 pack_length_from_metadata(uint field_metadata)
  226. + {
  227. uint32 length= pack_length();
  228. DBUG_PRINT("result", ("pack_length_from_metadata(%d): %u",
  229. field_metadata, length));
  230. @@ -1787,7 +1791,10 @@
  231. }
  232. bool compatible_field_size(uint field_metadata, Relay_log_info *rli,
  233. uint16 mflags, int *order_var);
  234. - uint row_pack_length() { return field_length; }
  235. + uint row_pack_length()
  236. + {
  237. + return field_length;
  238. + }
  239. int pack_cmp(const uchar *a,const uchar *b,uint key_length,
  240. my_bool insert_or_update);
  241. int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
  242. @@ -2328,8 +2335,8 @@
  243. uint pack_length_from_metadata(uint field_metadata);
  244. uint row_pack_length()
  245. { return (bytes_in_rec + ((bit_len > 0) ? 1 : 0)); }
  246. - bool compatible_field_size(uint metadata, Relay_log_info *rli,
  247. - uint16 mflags, int *order_var);
  248. + bool compatible_field_size(uint metadata, Relay_log_info *rli, uint16 mflags,
  249. + int *order_var);
  250. void sql_type(String &str) const;
  251. virtual uchar *pack(uchar *to, const uchar *from,
  252. uint max_length, bool low_byte_first);
  253. @@ -2440,7 +2447,7 @@
  254. void init_for_tmp_table(enum_field_types sql_type_arg,
  255. uint32 max_length, uint32 decimals,
  256. bool maybe_null, bool is_unsigned,
  257. - uint pack_length = ~0U);
  258. + uint pack_length= ~0U);
  259.  
  260. bool init(THD *thd, char *field_name, enum_field_types type, char *length,
  261. char *decimals, uint type_modifier, Item *default_value,
  262. diff -ruN 212/sql/log_event.cc 213/sql/log_event.cc
  263. --- 212/sql/log_event.cc 2012-02-14 14:02:16.737516513 +0900
  264. +++ 213/sql/log_event.cc 2012-02-14 14:01:28.678729202 +0900
  265. @@ -31,6 +31,7 @@
  266. #include "rpl_rli.h"
  267. #include "rpl_mi.h"
  268. #include "rpl_filter.h"
  269. +#include "rpl_utility.h"
  270. #include "rpl_record.h"
  271. #include <my_dir.h>
  272.  
  273. @@ -38,7 +39,6 @@
  274.  
  275. #include <base64.h>
  276. #include <my_bitmap.h>
  277. -#include "rpl_utility.h"
  278.  
  279. #define log_cs &my_charset_latin1
  280.  
  281. @@ -1599,7 +1599,7 @@
  282. type= byte0 | 0x30;
  283. }
  284. else
  285. - length = meta & 0xFF;
  286. + length= meta & 0xFF;
  287. }
  288. else
  289. length= meta;
  290. @@ -1749,16 +1749,16 @@
  291. char *pos= &buf[10];
  292.  
  293. /* Copied from field.cc */
  294. - *pos--=0; // End NULL
  295. - part=(int) (tmp & 31);
  296. + *pos--= 0; // End NULL
  297. + part= (int) (tmp & 31);
  298. *pos--= (char) ('0'+part%10);
  299. *pos--= (char) ('0'+part/10);
  300. *pos--= ':';
  301. - part=(int) (tmp >> 5 & 15);
  302. + part= (int) (tmp >> 5 & 15);
  303. *pos--= (char) ('0'+part%10);
  304. *pos--= (char) ('0'+part/10);
  305. *pos--= ':';
  306. - part=(int) (tmp >> 9);
  307. + part= (int) (tmp >> 9);
  308. *pos--= (char) ('0'+part%10); part/=10;
  309. *pos--= (char) ('0'+part%10); part/=10;
  310. *pos--= (char) ('0'+part%10); part/=10;
  311. @@ -1767,7 +1767,7 @@
  312. my_snprintf(typestr, typestr_length, "DATE");
  313. return 3;
  314. }
  315. -
  316. +
  317. case MYSQL_TYPE_DATE:
  318. {
  319. uint i32= uint3korr(ptr);
  320. @@ -1786,7 +1786,8 @@
  321. }
  322.  
  323. case MYSQL_TYPE_ENUM:
  324. - switch (meta & 0xFF) {
  325. + switch (meta & 0xFF)
  326. + {
  327. case 1:
  328. my_b_printf(file, "%d", (int) *ptr);
  329. my_snprintf(typestr, typestr_length, "ENUM(1 byte)");
  330. @@ -7597,8 +7598,7 @@
  331. MY_BITMAP *slave_skip_columns;
  332. if (!ptr->m_tabledef.compatible_with(thd,
  333. const_cast<Relay_log_info*>(rli),
  334. - ptr->table,
  335. - &conv_table,
  336. + ptr->table, &conv_table,
  337. &slave_skip_columns))
  338. {
  339.  
  340. @@ -7619,9 +7619,7 @@
  341. DBUG_PRINT("debug", ("Table: %s.%s is compatible with master"
  342. " - conv_table: %p, slave_skip_columns: %p",
  343. ptr->table->s->db.str,
  344. - ptr->table->s->table_name.str,
  345. - conv_table,
  346. - slave_skip_columns));
  347. + ptr->table->s->table_name.str, conv_table, slave_skip_columns));
  348. ptr->m_conv_table= conv_table;
  349. ptr->m_slave_skip_columns= slave_skip_columns;
  350. }
  351. diff -ruN 212/sql/log_event_old.cc 213/sql/log_event_old.cc
  352. --- 212/sql/log_event_old.cc 2012-02-14 14:02:16.770520488 +0900
  353. +++ 213/sql/log_event_old.cc 2012-02-14 14:01:28.686730165 +0900
  354. @@ -123,9 +123,9 @@
  355. {
  356. TABLE *conv_table;
  357. MY_BITMAP *slave_skip_columns;
  358. - if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
  359. - ptr->table,
  360. - &conv_table,
  361. + if (!ptr->m_tabledef.compatible_with(thd,
  362. + const_cast<Relay_log_info*>(rli),
  363. + ptr->table, &conv_table,
  364. &slave_skip_columns))
  365. {
  366. DBUG_PRINT("debug", ("Table: %s.%s is not compatible with master",
  367. @@ -1633,8 +1633,7 @@
  368. MY_BITMAP *slave_skip_columns;
  369. if (ptr->m_tabledef.compatible_with(thd,
  370. const_cast<Relay_log_info*>(rli),
  371. - ptr->table,
  372. - &conv_table,
  373. + ptr->table, &conv_table,
  374. &slave_skip_columns))
  375. {
  376. mysql_unlock_tables(thd, thd->lock);
  377. diff -ruN 212/sql/rpl_utility.cc 213/sql/rpl_utility.cc
  378. --- 212/sql/rpl_utility.cc 2012-02-14 14:02:16.789522776 +0900
  379. +++ 213/sql/rpl_utility.cc 2012-02-14 14:01:28.703732213 +0900
  380. @@ -39,7 +39,8 @@
  381.  
  382. The somewhat contorted expression is to avoid overflow.
  383. */
  384. -uint32 uint_max(int bits) {
  385. +uint32 uint_max(int bits)
  386. +{
  387. return (((1UL << (bits - 1)) - 1) << 1) | 1;
  388. }
  389.  
  390. @@ -640,7 +641,7 @@
  391. {
  392. if (source_type == MYSQL_TYPE_NEWDECIMAL ||
  393. source_type == MYSQL_TYPE_DECIMAL)
  394. - *order_var = 1; // Always require lossy conversions
  395. + *order_var= 1; // Always require lossy conversions
  396. else
  397. *order_var= compare_lengths(field, source_type, metadata);
  398. DBUG_ASSERT(*order_var != 0);
  399. @@ -896,15 +897,6 @@
  400. return true;
  401. }
  402.  
  403. -/**
  404. - Create a conversion table.
  405. -
  406. - If the function is unable to create the conversion table, an error
  407. - will be printed and NULL will be returned.
  408. -
  409. - @return Pointer to conversion table, or NULL if unable to create
  410. - conversion table.
  411. - */
  412.  
  413. MY_BITMAP* table_def::create_slave_skip_columns(THD *thd,
  414. Relay_log_info *rli,
  415. @@ -939,7 +931,17 @@
  416. return result;
  417. }
  418.  
  419. -TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *target_table) const
  420. +/**
  421. + Create a conversion table.
  422. +
  423. + If the function is unable to create the conversion table, an error
  424. + will be printed and NULL will be returned.
  425. +
  426. + @return Pointer to conversion table, or NULL if unable to create
  427. + conversion table.
  428. +*/
  429. +TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli,
  430. + TABLE *target_table) const
  431. {
  432. DBUG_ENTER("table_def::create_conversion_table");
  433.  
  434. @@ -1090,12 +1092,9 @@
  435. m_field_metadata(0), m_null_bits(0), m_flags(flags),
  436. m_memory(NULL), m_columns(size, column_names, column_names_size)
  437. {
  438. - m_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
  439. - &m_type, size,
  440. - &m_field_metadata,
  441. - size * sizeof(uint16),
  442. - &m_null_bits, (size + 7) / 8,
  443. - NULL);
  444. + m_memory= (uchar *)my_multi_malloc(MYF(MY_WME), &m_type, size,
  445. + &m_field_metadata, size * sizeof(uint16),
  446. + &m_null_bits, (size + 7) / 8, NULL);
  447.  
  448. bzero(m_field_metadata, size * sizeof(uint16));
  449.  
  450. @@ -1142,8 +1141,8 @@
  451. }
  452. case MYSQL_TYPE_BIT:
  453. {
  454. - uint16 x= field_metadata[index++];
  455. - x = x + (field_metadata[index++] << 8U);
  456. + uint16 x= field_metadata[index++];
  457. + x= x + (field_metadata[index++] << 8U);
  458. m_field_metadata[i]= x;
  459. break;
  460. }
Advertisement
Add Comment
Please, Sign In to add comment