~jan-kneschke/mysql-proxy/packet-tracking-assertions

« back to all changes in this revision

Viewing changes to lib/sql-tokenizer-tokens.c

  • Committer: jan at mysql
  • Date: 2010-05-27 14:19:43 UTC
  • Revision ID: jan@mysql.com-20100527141943-inwv2cohofexa2pb
added entry about #49716 - literals starting with digits

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "sql-tokenizer.h"
2
2
 
3
 
#define S(x) { #x, sizeof(#x) - 1 }
 
3
#define S(x) #x
4
4
 
5
5
/**
6
6
 * this list has to be kept in sync with the tokens itself 
7
7
 *
8
8
 * maps token_ids (array-pos) to token-names
9
9
 */
10
 
static struct {
11
 
        const char *token;
12
 
        size_t token_len;
13
 
} token_names[] = {
 
10
static const char *token_names[] = {
14
11
        S(TK_UNKNOWN),
15
12
        S(TK_LE),
16
13
        S(TK_GE),
278
275
        
279
276
        S(TK_COMMENT_MYSQL),
280
277
 
281
 
        { NULL, 0 }
 
278
        NULL
282
279
};
283
280
#undef S
284
281
 
285
282
/**
286
283
 * get the name for a token-id
287
284
 */
288
 
const gchar *sql_token_get_name(sql_token_id token_id, size_t *name_len) {
 
285
const gchar *sql_token_get_name(sql_token_id token_id) {
289
286
        if (token_id >= TK_LAST_TOKEN) return NULL;
290
287
 
291
 
        if (sizeof(token_names)/sizeof(token_names[0]) != TK_LAST_TOKEN + 1) {
292
 
                g_error("sql_token_get_name() is out of sync [%"G_GSIZE_FORMAT" != %d]", sizeof(token_names)/sizeof(token_names[0]), TK_LAST_TOKEN + 1);
293
 
        }
294
 
 
295
 
        if (name_len) {
296
 
                *name_len = token_names[token_id].token_len;
297
 
        }
298
 
 
299
 
        return token_names[token_id].token;
 
288
        if (sizeof(token_names)/sizeof(char *) != TK_LAST_TOKEN + 1) {
 
289
                g_error("sql_token_get_name() is out of sync [%"G_GSIZE_FORMAT" != %d]", sizeof(token_names)/sizeof(char *), TK_LAST_TOKEN + 1);
 
290
        }
 
291
 
 
292
        return token_names[token_id];
300
293
}
301
294
 
302
295
int sql_token_get_last_id() {