Advertisement
Guest User

Untitled

a guest
Sep 16th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.43 KB | None | 0 0
  1. diff --git a/client/client_priv.h b/client/client_priv.h
  2. index 7348726..7a46e9e 100644
  3. --- a/client/client_priv.h
  4. +++ b/client/client_priv.h
  5. @@ -102,20 +102,22 @@ enum options_client
  6. OPT_REMOTE_PROTO,
  7. OPT_CONFIG_ALL,
  8. OPT_REWRITE_DB,
  9. OPT_SERVER_PUBLIC_KEY,
  10. OPT_ENABLE_CLEARTEXT_PLUGIN,
  11. OPT_INNODB_OPTIMIZE_KEYS,
  12. OPT_LOCK_FOR_BACKUP,
  13. OPT_CONNECTION_SERVER_ID,
  14. OPT_TLS_VERSION,
  15. OPT_SSL_MODE,
  16. + OPT_RAW_ESCAPE,
  17. + OPT_RAW_NULL,
  18. /* Add new option above this */
  19. OPT_MAX_CLIENT_OPTION
  20. };
  21.  
  22. /**
  23. First mysql version supporting the information schema.
  24. */
  25. #define FIRST_INFORMATION_SCHEMA_VERSION 50003
  26.  
  27. /**
  28. diff --git a/client/mysql.cc b/client/mysql.cc
  29. index a55d5c7..00a5e0e 100644
  30. --- a/client/mysql.cc
  31. +++ b/client/mysql.cc
  32. @@ -144,20 +144,21 @@ static my_bool debug_info_flag, debug_check_flag;
  33. static my_bool column_types_flag;
  34. static my_bool preserve_comments= 0;
  35. static ulong opt_max_allowed_packet, opt_net_buffer_length;
  36. static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
  37. static uint opt_enable_cleartext_plugin= 0;
  38. static my_bool using_opt_enable_cleartext_plugin= 0;
  39. static uint my_end_arg;
  40. static char * opt_mysql_unix_port=0;
  41. static char *opt_bind_addr = NULL;
  42. static int connect_flag=CLIENT_INTERACTIVE;
  43. +static int opt_raw_escape=-1, opt_raw_null=-1;
  44. static my_bool opt_binary_mode= FALSE;
  45. static my_bool opt_connect_expired_password= FALSE;
  46. static char *current_host,*current_db,*current_user=0,*opt_password=0,
  47. *current_prompt=0, *delimiter_str= 0,
  48. *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
  49. *opt_init_command= 0;
  50. static char *histfile;
  51. static char *histfile_tmp;
  52. static char *opt_histignore= NULL;
  53. DYNAMIC_STRING histignore_buffer;
  54. @@ -250,22 +251,23 @@ my_win_is_console_cached(FILE *file)
  55. return win_is_console_cache & (1 << _fileno(file));
  56. }
  57. #endif /* _WIN32 */
  58.  
  59. /* Various printing flags */
  60. #define MY_PRINT_ESC_0 1 /* Replace 0x00 bytes to "\0" */
  61. #define MY_PRINT_SPS_0 2 /* Replace 0x00 bytes to space */
  62. #define MY_PRINT_XML 4 /* Encode XML entities */
  63. #define MY_PRINT_MB 8 /* Recognize multi-byte characters */
  64. #define MY_PRINT_CTRL 16 /* Replace TAB, NL, CR to "\t", "\n", "\r" */
  65. +#define MY_PRINT_RAWE 32 /* Escape "\n", "\t", --raw-escape and --raw-null chars */
  66.  
  67. -void tee_write(FILE *file, const char *s, size_t slen, int flags);
  68. +void tee_write(FILE *file, const char *s, size_t slen, int flags, int rawe);
  69. void tee_fprintf(FILE *file, const char *fmt, ...);
  70. void tee_fputs(const char *s, FILE *file);
  71. void tee_puts(const char *s, FILE *file);
  72. void tee_putc(int c, FILE *file);
  73. static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
  74. /* The names of functions that actually do the manipulation. */
  75. static int get_options(int argc,char **argv);
  76. extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
  77. char *argument);
  78. static int com_quit(String *str,char*),
  79. @@ -1294,20 +1296,27 @@ int main(int argc,char *argv[])
  80. }
  81. my_getopt_use_args_separator= FALSE;
  82.  
  83. defaults_argv=argv;
  84. if (get_options(argc, (char **) argv))
  85. {
  86. free_defaults(defaults_argv);
  87. my_end(0);
  88. exit(1);
  89. }
  90. + if (opt_raw_null >= 0 && opt_raw_null == opt_raw_escape)
  91. + {
  92. + put_info("--raw-null must differ from --raw-escape.", INFO_ERROR, 0);
  93. + free_defaults(defaults_argv);
  94. + my_end(0);
  95. + exit(1);
  96. + }
  97. if (status.batch && !status.line_buff &&
  98. !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
  99. {
  100. put_info("Can't initialize batch_readline - may be the input source is "
  101. "a directory or a block device.", INFO_ERROR, 0);
  102. free_defaults(defaults_argv);
  103. my_end(0);
  104. exit(1);
  105. }
  106. if (mysql_server_init(embedded_server_arg_count, embedded_server_args,
  107. @@ -1784,20 +1793,24 @@ static struct my_option my_long_options[] =
  108. REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  109. {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).",
  110. 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  111. {"quick", 'q',
  112. "Don't cache result, print it row by row. This may slow down the server "
  113. "if the output is suspended. Doesn't use history file.",
  114. &quick, &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
  115. {"raw", 'r', "Write fields without conversion. Used with --batch.",
  116. &opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
  117. 0, 0, 0},
  118. + {"raw-escape", OPT_RAW_ESCAPE, "Like --raw but escape \\n, \\t, and --raw-null chars.",
  119. + &opt_raw_escape, &opt_raw_escape, 0, GET_INT, REQUIRED_ARG, -1, -1, 0xff, 0, 0, 0},
  120. + {"raw-null", OPT_RAW_NULL, "Set value for NULL. Used with --raw or --raw-escape.",
  121. + &opt_raw_null, &opt_raw_null, 0, GET_INT, REQUIRED_ARG, -1, -1, 0xff, 0, 0, 0},
  122. {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable "
  123. "with --disable-reconnect. This option is enabled by default.",
  124. &opt_reconnect, &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
  125. {"silent", 's', "Be more silent. Print results with a tab as separator, "
  126. "each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
  127. #if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
  128. {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
  129. "Base name of shared memory.", &shared_memory_base_name,
  130. &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  131. #endif
  132. @@ -4073,21 +4086,21 @@ tee_print_sized_data(const char *data, unsigned int data_length, unsigned int to
  133. For '\0's print ASCII spaces instead, as '\0' is eaten by (at
  134. least my) console driver, and that messes up the pretty table
  135. grid. (The \0 is also the reason we can't use fprintf() .)
  136. */
  137. unsigned int i;
  138.  
  139. if (right_justified)
  140. for (i= data_length; i < total_bytes_to_send; i++)
  141. tee_putc((int)' ', PAGER);
  142.  
  143. - tee_write(PAGER, data, data_length, MY_PRINT_SPS_0 | MY_PRINT_MB);
  144. + tee_write(PAGER, data, data_length, MY_PRINT_SPS_0 | MY_PRINT_MB, 0);
  145.  
  146. if (! right_justified)
  147. for (i= data_length; i < total_bytes_to_send; i++)
  148. tee_putc((int)' ', PAGER);
  149. }
  150.  
  151.  
  152.  
  153. static void
  154. print_table_data_html(MYSQL_RES *result)
  155. @@ -4193,21 +4206,21 @@ print_table_data_vertically(MYSQL_RES *result)
  156.  
  157. ulong *lengths= mysql_fetch_lengths(result);
  158.  
  159. for (uint off=0; off < mysql_num_fields(result); off++)
  160. {
  161. field= mysql_fetch_field(result);
  162. if (column_names)
  163. tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name);
  164. if (cur[off])
  165. {
  166. - tee_write(PAGER, cur[off], lengths[off], MY_PRINT_SPS_0 | MY_PRINT_MB);
  167. + tee_write(PAGER, cur[off], lengths[off], MY_PRINT_SPS_0 | MY_PRINT_MB, 0);
  168. tee_putc('\n', PAGER);
  169. }
  170. else
  171. tee_fprintf(PAGER, "NULL\n");
  172. }
  173. }
  174. }
  175.  
  176.  
  177. /* print_warnings should be called right after executing a statement */
  178. @@ -4263,34 +4276,41 @@ static const char *array_value(const char **array, char key)
  179. return 0;
  180. }
  181.  
  182.  
  183. static void
  184. xmlencode_print(const char *src, uint length)
  185. {
  186. if (!src)
  187. tee_fputs("NULL", PAGER);
  188. else
  189. - tee_write(PAGER, src, length, MY_PRINT_XML | MY_PRINT_MB);
  190. + tee_write(PAGER, src, length, MY_PRINT_XML | MY_PRINT_MB, 0);
  191. }
  192.  
  193.  
  194. static void
  195. safe_put_field(const char *pos,ulong length)
  196. {
  197. if (!pos)
  198. - tee_fputs("NULL", PAGER);
  199. + {
  200. + if (opt_raw_null >= 0)
  201. + tee_putc(opt_raw_null, PAGER);
  202. + else
  203. + tee_fputs("NULL", PAGER);
  204. + }
  205. else
  206. {
  207. - int flags= MY_PRINT_MB | (opt_raw_data ? 0 : (MY_PRINT_ESC_0 | MY_PRINT_CTRL));
  208. + int flags= MY_PRINT_MB
  209. + | (opt_raw_data ? 0 : (MY_PRINT_ESC_0 | MY_PRINT_CTRL))
  210. + | (opt_raw_escape >= 0 ? MY_PRINT_RAWE : 0);
  211. /* Can't use tee_fputs(), it stops with NUL characters. */
  212. - tee_write(PAGER, pos, length, flags);
  213. + tee_write(PAGER, pos, length, flags, opt_raw_escape);
  214. }
  215. }
  216.  
  217.  
  218. static void
  219. print_tab_data(MYSQL_RES *result)
  220. {
  221. MYSQL_ROW cur;
  222. MYSQL_FIELD *field;
  223. ulong *lengths;
  224. @@ -5381,29 +5401,30 @@ static void remove_cntrl(String &buffer)
  225. char *start,*end;
  226. end=(start=(char*) buffer.ptr())+buffer.length();
  227. while (start < end && !my_isgraph(charset_info,end[-1]))
  228. end--;
  229. buffer.length((uint) (end-start));
  230. }
  231.  
  232.  
  233. /**
  234. Write data to a stream.
  235. - Various modes, corresponding to --tab, --xml, --raw parameters,
  236. + Various modes, corresponding to --tab, --xml, --raw, --raw-escape parameters
  237. are supported.
  238.  
  239. @param file Stream to write to
  240. @param s String to write
  241. @param slen String length
  242. - @flags Flags for --tab, --xml, --raw.
  243. + @param flags Flags for --tab, --xml, --raw, --raw-escape
  244. + @param rawe Raw escape char for --raw-escape
  245. */
  246. -void tee_write(FILE *file, const char *s, size_t slen, int flags)
  247. +void tee_write(FILE *file, const char *s, size_t slen, int flags, int rawe)
  248. {
  249. #ifdef _WIN32
  250. my_bool is_console= my_win_is_console_cached(file);
  251. #endif
  252. const char *se;
  253. for (se= s + slen; s < se; s++)
  254. {
  255. const char *t;
  256.  
  257. if (flags & MY_PRINT_MB)
  258. @@ -5423,21 +5444,28 @@ void tee_write(FILE *file, const char *s, size_t slen, int flags)
  259. if (opt_outfile) {
  260. if (fwrite(s, 1, mblen, OUTFILE) != (size_t) mblen) {
  261. perror("fwrite");
  262. }
  263. }
  264. s+= mblen - 1;
  265. continue;
  266. }
  267. }
  268.  
  269. - if ((flags & MY_PRINT_XML) && (t= array_value(xmlmeta, *s)))
  270. + if (flags & MY_PRINT_RAWE)
  271. + {
  272. + if (*s == '\n' || *s == '\t' || *s == rawe
  273. + || (opt_raw_null >= 0 && *s == opt_raw_null))
  274. + tee_putc(rawe, file);
  275. + tee_putc((int)*s, file);
  276. + }
  277. + else if ((flags & MY_PRINT_XML) && (t= array_value(xmlmeta, *s)))
  278. tee_fputs(t, file);
  279. else if ((flags & MY_PRINT_SPS_0) && *s == '\0')
  280. tee_putc((int) ' ', file); // This makes everything hard
  281. else if ((flags & MY_PRINT_ESC_0) && *s == '\0')
  282. tee_fputs("\\0", file); // This makes everything hard
  283. else if ((flags & MY_PRINT_CTRL) && *s == '\t')
  284. tee_fputs("\\t", file); // This would destroy tab format
  285. else if ((flags & MY_PRINT_CTRL) && *s == '\n')
  286. tee_fputs("\\n", file); // This too
  287. else if ((flags & MY_PRINT_CTRL) && *s == '\\')
  288. diff --git a/storage/tokudb/PerconaFT b/storage/tokudb/PerconaFT
  289. --- a/storage/tokudb/PerconaFT
  290. +++ b/storage/tokudb/PerconaFT
  291. @@ -1 +1 @@
  292. -Subproject commit d5c2e669b3db88e8270398abf353f123d184dfb9
  293. +Subproject commit d5c2e669b3db88e8270398abf353f123d184dfb9-dirty
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement