]> git.pld-linux.org Git - packages/mysql.git/blob - error_pad.patch
- disable response-time-distribution patch on arch which has no atomic builtins even...
[packages/mysql.git] / error_pad.patch
1 # name       : error_pad.patch
2 # introduced : 12
3 # maintainer : Oleg
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 diff -ruN a/extra/comp_err.c b/extra/comp_err.c
9 --- a/extra/comp_err.c  2011-04-09 18:48:04.000000000 +0400
10 +++ b/extra/comp_err.c  2011-04-09 18:48:56.000000000 +0400
11 @@ -30,11 +30,12 @@
12  #include <assert.h>
13  #include <my_dir.h>
14  
15 -#define MAX_ROWS  1000
16 +#define MAX_ROWS  5000
17  #define HEADER_LENGTH 32                /* Length of header in errmsg.sys */
18  #define DEFAULT_CHARSET_DIR "../sql/share/charsets"
19  #define ER_PREFIX "ER_"
20  #define WARN_PREFIX "WARN_"
21 +#define PADD_PREFIX "PADD_"
22  static char *OUTFILE= (char*) "errmsg.sys";
23  static char *HEADERFILE= (char*) "mysqld_error.h";
24  static char *NAMEFILE= (char*) "mysqld_ername.h";
25 @@ -89,6 +90,7 @@
26    const char *sql_code1;               /* sql state */
27    const char *sql_code2;               /* ODBC state */
28    struct errors *next_error;            /* Pointer to next error */
29 +  my_bool is_padding;                   /* If true - padd this er_name while er_code != d_code*/
30    DYNAMIC_ARRAY msg;                    /* All language texts for this error */
31  };
32  
33 @@ -127,6 +129,7 @@
34  
35  
36  static struct languages *parse_charset_string(char *str);
37 +static struct errors *parse_padd_string(char *ptr, int er_count);
38  static struct errors *parse_error_string(char *ptr, int er_count);
39  static struct message *parse_message_string(struct message *new_message,
40                                             char *str);
41 @@ -251,6 +254,11 @@
42  
43    for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
44    {
45 +    if (tmp_error->is_padding)
46 +    {
47 +      er_last= tmp_error->d_code;
48 +      continue;
49 +    }
50      /*
51         generating mysqld_error.h
52         fprintf() will automatically add \r on windows
53 @@ -343,12 +351,29 @@
54                 "language\n", tmp_error->er_name, tmp_lang->lang_short_name);
55         goto err;
56        }
57 -      if (copy_rows(to, tmp->text, row_nr, start_pos))
58 +      if (tmp_error->is_padding)
59        {
60 -       fprintf(stderr, "Failed to copy rows to %s\n", outfile);
61 -       goto err;
62 +        uint padd_to= tmp_error->d_code;
63 +        char* padd_message= tmp->text;
64 +        while ((row_nr+er_offset) < padd_to)
65 +        {
66 +          if (copy_rows(to, padd_message,row_nr,start_pos))
67 +          {
68 +            fprintf(stderr, "Failed to copy rows to %s\n", outfile);
69 +            goto err;
70 +          }
71 +          row_nr++;
72 +        }
73 +      }
74 +      else
75 +      {
76 +        if (copy_rows(to, tmp->text, row_nr, start_pos))
77 +        {
78 +          fprintf(stderr, "Failed to copy rows to %s\n", outfile);
79 +          goto err;
80 +        }
81 +        row_nr++;
82        }
83 -      row_nr++;
84      }
85  
86      /* continue with header of the errmsg.sys file */
87 @@ -499,14 +524,26 @@
88         DBUG_RETURN(0);
89        continue;
90      }
91 -    if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX))
92 +    if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX) || is_prefix(str, PADD_PREFIX))
93      {
94 -      if (!(current_error= parse_error_string(str, rcount)))
95 +      if (is_prefix(str, PADD_PREFIX))
96        {
97 -       fprintf(stderr, "Failed to parse the error name string\n");
98 -       DBUG_RETURN(0);
99 +        if (!(current_error= parse_padd_string(str, rcount)))
100 +        {
101 +          fprintf(stderr, "Failed to parse the error pad string\n");
102 +          DBUG_RETURN(0);
103 +        }
104 +        rcount= current_error->d_code - er_offset;  /* Count number of unique errors */
105 +      }
106 +      else
107 +      {
108 +        if (!(current_error= parse_error_string(str, rcount)))
109 +        {
110 +          fprintf(stderr, "Failed to parse the error name string\n");
111 +          DBUG_RETURN(0);
112 +        }
113 +        rcount++;                         /* Count number of unique errors */
114        }
115 -      rcount++;                         /* Count number of unique errors */
116  
117        /* add error to the list */
118        *tail_error= current_error;
119 @@ -847,78 +884,122 @@
120    DBUG_RETURN(new_message);
121  }
122  
123 +static struct errors* create_new_error(my_bool is_padding, char *er_name, int d_code, const char *sql_code1, const char *sql_code2)
124 +{
125 +  struct errors *new_error;
126 +  DBUG_ENTER("create_new_error");
127 +  /* create a new element */
128 +  new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME));
129 +  if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0))
130 +    DBUG_RETURN(0);                            /* OOM: Fatal error */
131 +  new_error->is_padding= is_padding;
132 +  DBUG_PRINT("info", ("is_padding: %s", (is_padding ? "true" : "false")));
133 +  new_error->er_name= er_name;
134 +  DBUG_PRINT("info", ("er_name: %s", er_name));
135 +  new_error->d_code= d_code;
136 +  DBUG_PRINT("info", ("d_code: %d", d_code));
137 +  new_error->sql_code1= sql_code1;
138 +  DBUG_PRINT("info", ("sql_code1: %s", sql_code1));
139 +  new_error->sql_code2= sql_code2;
140 +  DBUG_PRINT("info", ("sql_code2: %s", sql_code2));
141 +  DBUG_RETURN(new_error);
142 +}
143  
144  /*
145 -  Parsing the string with error name and codes; returns the pointer to
146 +  Parsing the string with padd syntax (name + error to pad); returns the pointer to
147    the errors struct
148  */
149  
150 -static struct errors *parse_error_string(char *str, int er_count)
151 +static struct errors *parse_padd_string(char* str, int er_count)
152  {
153 -  struct errors *new_error;
154 +  char *er_name;
155 +  uint d_code;
156 +  char *start;
157    DBUG_ENTER("parse_error_string");
158    DBUG_PRINT("enter", ("str: %s", str));
159  
160 -  /* create a new element */
161 -  new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME));
162 +  start= str;
163 +  str= skip_delimiters(str);
164  
165 -  if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0))
166 +  /* getting the error name */
167 +
168 +  if (!(er_name= get_word(&str)))
169      DBUG_RETURN(0);                            /* OOM: Fatal error */
170  
171 -  /* getting the error name */
172    str= skip_delimiters(str);
173  
174 -  if (!(new_error->er_name= get_word(&str)))
175 +  if (!(d_code= parse_error_offset(start)))
176 +  {
177 +    fprintf(stderr, "Failed to parse the error pad string '%s' '%s' (d_code doesn't parse)!\n",er_name,str);
178 +    DBUG_RETURN(0);
179 +  }
180 +  if (d_code < (uint)(er_offset + er_count))
181 +  {
182 +    fprintf(stderr, "Error to padding less current error number!\n");
183 +    DBUG_RETURN(0);
184 +  }
185 +  DBUG_RETURN(create_new_error(TRUE,er_name,d_code,empty_string,empty_string));
186 +}
187 +
188 +/*
189 +  Parsing the string with error name and codes; returns the pointer to
190 +  the errors struct
191 +*/
192 +
193 +static struct errors *parse_error_string(char *str, int er_count)
194 +{
195 +  char *er_name;
196 +  int d_code;
197 +  const char *sql_code1= empty_string;
198 +  const char *sql_code2= empty_string;
199 +  DBUG_ENTER("parse_error_string");
200 +  DBUG_PRINT("enter", ("str: %s", str));
201 +
202 +  str= skip_delimiters(str);
203 +
204 +  /* getting the error name */
205 +
206 +  if (!(er_name= get_word(&str)))
207      DBUG_RETURN(0);                            /* OOM: Fatal error */
208 -  DBUG_PRINT("info", ("er_name: %s", new_error->er_name));
209  
210    str= skip_delimiters(str);
211  
212    /* getting the code1 */
213 -
214 -  new_error->d_code= er_offset + er_count;
215 -  DBUG_PRINT("info", ("d_code: %d", new_error->d_code));
216 +  d_code= er_offset + er_count;
217  
218    str= skip_delimiters(str);
219  
220    /* if we reached EOL => no more codes, but this can happen */
221    if (!*str)
222    {
223 -    new_error->sql_code1= empty_string;
224 -    new_error->sql_code2= empty_string;
225      DBUG_PRINT("info", ("str: %s", str));
226 -    DBUG_RETURN(new_error);
227 +    goto complete_create;
228    }
229 -
230    /* getting the sql_code 1 */
231 -
232 -  if (!(new_error->sql_code1= get_word(&str)))
233 +  if (!(sql_code1= get_word(&str)))
234      DBUG_RETURN(0);                            /* OOM: Fatal error */
235 -  DBUG_PRINT("info", ("sql_code1: %s", new_error->sql_code1));
236  
237    str= skip_delimiters(str);
238  
239    /* if we reached EOL => no more codes, but this can happen */
240    if (!*str)
241    {
242 -    new_error->sql_code2= empty_string;
243      DBUG_PRINT("info", ("str: %s", str));
244 -    DBUG_RETURN(new_error);
245 +    goto complete_create;
246    }
247 -
248    /* getting the sql_code 2 */
249 -  if (!(new_error->sql_code2= get_word(&str)))
250 +  if (!(sql_code2= get_word(&str)))
251      DBUG_RETURN(0);                            /* OOM: Fatal error */
252 -  DBUG_PRINT("info", ("sql_code2: %s", new_error->sql_code2));
253  
254    str= skip_delimiters(str);
255 +
256    if (*str)
257    {
258      fprintf(stderr, "The error line did not end with sql/odbc code!");
259      DBUG_RETURN(0);
260    }
261 -
262 -  DBUG_RETURN(new_error);
263 +complete_create:
264 +  DBUG_RETURN(create_new_error(FALSE,er_name,d_code,sql_code1,sql_code2));
265  }
266  
267  
This page took 0.650743 seconds and 3 git commands to generate.