add IS NULL/IS NOT NULL support, patches

This commit is contained in:
brianb
2004-02-06 23:55:18 +00:00
parent af7b6953ad
commit 5f02ba4fd2
10 changed files with 211 additions and 145 deletions

View File

@@ -1,3 +1,13 @@
Fri Feb 6 18:08:59 EST 2004 Brian Bruns <brian@bruns.com>
* include/mdbtools.h:
* src/sql/mdbsql.c:
* src/libmdb/sargs.c: change signature of mdb_test_sarg to test for nulls
* src/mdbsql/lexer.l: add NULL token
* src/libmdb/data.c: memo patch from <teodor@sigaev.ru>
* src/libmdb/file.c: patch #889589
* src/libmdb/write.c: patch #889586
Thu Feb 5 20:45:00 EST 2004 Brian Bruns <brian@bruns.com>
* HACKING: added information on indexes

View File

@@ -428,7 +428,7 @@ extern char *mdb_get_relationships(MdbHandle *mdb);
/* sargs.c */
extern int mdb_test_sargs(MdbTableDef *table, MdbField *fields, int num_fields);
extern int mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, void *buf, int len);
extern int mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, MdbField *field);
extern void mdb_sql_walk_tree(MdbSargNode *node, MdbSargTreeFunc func, gpointer data);
extern int mdb_find_indexable_sargs(MdbSargNode *node, gpointer data);
extern int mdb_add_sarg_by_name(MdbTableDef *table, char *colname, MdbSarg *in_sarg);

View File

@@ -392,7 +392,7 @@ int mdb_read_row(MdbTableDef *table, int row)
} else {
len=mdb->pg_buf[col_ptr - var_cols_found ] - col_start;
}
if (len<0)
while (len<0)
len+=256;
}
@@ -471,7 +471,7 @@ mdb_read_next_dpg_by_map1(MdbTableDef *table)
* offset gives us a page offset into the bitmap (must be converted
* to bytes and bits).
*/
pgnum = table->cur_phys_pg + 1;
pgnum = table->cur_phys_pg + 1;
map_ind = pgnum / ((mdb->fmt->pg_size - 4) * 8);
offset = pgnum % ((mdb->fmt->pg_size - 4) * 8);
bit_offset = offset % 8;

View File

@@ -356,7 +356,7 @@ mdb_get_double(unsigned char *buf, int offset)
double d;
memcpy(&d, &buf, 8);
memcpy(&d, &buf[offset], 8);
#ifdef WORDS_BIGENDIAN
d2 = d;

View File

@@ -212,7 +212,7 @@ mdb_index_cache_sarg(MdbColumn *col, MdbSarg *sarg, MdbSarg *idx_sarg)
//cache_int = sarg->value.i * -1;
c = (unsigned char *) &(idx_sarg->value.i);
c[0] |= 0x80;
//printf("int %08x %02x %02x %02x %02x\n", sarg->value.i, c[0], c[1], c[2], c[3]);
printf("int %08x %02x %02x %02x %02x\n", sarg->value.i, c[0], c[1], c[2], c[3]);
break;
case MDB_INT:
@@ -259,6 +259,7 @@ mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, int offset, int len)
MdbTableDef *table = idx->table;
MdbSarg *idx_sarg;
MdbSarg *sarg;
MdbField field;
MdbSargNode node;
int c_offset = 0, c_len;
@@ -298,7 +299,10 @@ mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, int offset, int len)
/* XXX - kludge */
node.op = sarg->op;
node.value = sarg->value;
if (!mdb_test_sarg(mdb, col, &node, &mdb->pg_buf[offset + c_offset], c_len)) {
field.value = &mdb->pg_buf[offset + c_offset];
field.siz = c_len;
field.is_null = FALSE;
if (!mdb_test_sarg(mdb, col, &node, &field)) {
/* sarg didn't match, no sense going on */
return 0;
}

View File

@@ -128,27 +128,37 @@ mdb_find_indexable_sargs(MdbSargNode *node, gpointer data)
return 0;
}
int
mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, void *buf, int len)
mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, MdbField *field)
{
char tmpbuf[256];
int lastchar;
if (node->op == MDB_ISNULL) {
if (field->is_null) return 0;
else return 1;
} else if (node->op == MDB_NOTNULL) {
if (field->is_null) return 1;
else return 0;
}
switch (col->col_type) {
case MDB_BOOL:
return mdb_test_int(node, field->is_null);
break;
case MDB_BYTE:
return mdb_test_int(node, (gint32)((char *)buf)[0]);
return mdb_test_int(node, (gint32)((char *)field->value)[0]);
break;
case MDB_INT:
return mdb_test_int(node, (gint32)mdb_get_int16(buf, 0));
return mdb_test_int(node, (gint32)mdb_get_int16(field->value, 0));
break;
case MDB_LONGINT:
return mdb_test_int(node, (gint32)mdb_get_int32(buf, 0));
return mdb_test_int(node, (gint32)mdb_get_int32(field->value, 0));
break;
case MDB_TEXT:
if (IS_JET4(mdb)) {
mdb_unicode2ascii(mdb, buf, 0, len, tmpbuf);
mdb_unicode2ascii(mdb, field->value, 0, field->siz, tmpbuf);
} else {
strncpy(tmpbuf, buf,255);
lastchar = len > 255 ? 255 : len;
strncpy(tmpbuf, field->value, 255);
lastchar = field->siz > 255 ? 255 : field->siz;
tmpbuf[lastchar]='\0';
}
return mdb_test_string(node, tmpbuf);
@@ -178,10 +188,7 @@ mdb_test_sarg_node(MdbHandle *mdb, MdbSargNode *node, MdbField *fields, int num_
if (mdb_is_relational_op(node->op)) {
col = node->col;
elem = mdb_find_field(col->col_num, fields, num_fields);
if (!mdb_test_sarg(mdb, col,
node,
fields[elem].value,
fields[elem].siz))
if (!mdb_test_sarg(mdb, col, node, &fields[elem]))
return 0;
} else { /* logical op */
switch (node->op) {

View File

@@ -195,6 +195,7 @@ int col_start, next_col;
unsigned char *nullmask;
int bitmask_sz;
int byte_num, bit_num;
int num_of_jumps = 0, jumps_used = 0;
int eod, len; /* end of data */
num_cols = mdb->pg_buf[row_start];
@@ -225,6 +226,7 @@ int eod, len; /* end of data */
bit_num = i % 8;
/* logic on nulls is reverse, 1 is not null, 0 is null */
fields[i].is_null = nullmask[byte_num] & 1 << bit_num ? 0 : 1;
//printf("col %d is %s\n", i, fields[i].is_null ? "null" : "not null");
}
/* find the end of data pointer */
@@ -248,9 +250,37 @@ int eod, len; /* end of data */
col_start += col->col_size;
}
}
//fprintf(stderr, "col_start: %d\n", col_start);
/* if fixed columns add up to more than 256, we need a jump */
int col_ptr = row_end - bitmask_sz - num_of_jumps - 1;
if (col_start >= 256) {
num_of_jumps++;
jumps_used++;
row_start = row_start + col_start - (col_start % 256);
}
col_start = row_start;
while (col_start+256 < row_end-bitmask_sz-1-var_cols-num_of_jumps){
col_start += 256;
num_of_jumps++;
}
if (mdb->pg_buf[col_ptr]==0xFF) {
col_ptr--;
}
col_start = mdb->pg_buf[col_ptr];
for (j=0;j<table->num_cols;j++) {
col = g_ptr_array_index(table->columns,j);
if (!mdb_is_fixed_col(col) && ++var_cols_found <= var_cols) {
if (var_cols_found == mdb->pg_buf[row_end-bitmask_sz-jumps_used-1] &&
jumps_used < num_of_jumps) {
row_start += 256;
col_start -= 256;
jumps_used++;
}
if (var_cols_found==var_cols) {
len=eod - col_start;
//printf("len = %d eod %d col_start %d\n",len, eod, col_start);
@@ -324,7 +354,7 @@ int i;
byte = 0;
bit = 0;
for (i=0;i<num_fields;i++) {
/* column is null is bit is clear (0) */
/* column is null if bit is clear (0) */
if (!fields[i].is_null) {
byte |= 1 << bit;
//printf("%d %d %d %d\n", i, bit, 1 << bit, byte);

View File

@@ -1,7 +1,7 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /Users/brian/cvs/mdbtools/mdbtools/src/sql/Attic/lexer.c,v 1.7 2004/02/06 02:34:22 brianb Exp $
* $Header: /Users/brian/cvs/mdbtools/mdbtools/src/sql/Attic/lexer.c,v 1.8 2004/02/06 23:55:29 brianb Exp $
*/
#define FLEX_SCANNER
@@ -282,20 +282,20 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 25
#define YY_END_OF_BUFFER 26
static yyconst short int yy_accept[97] =
#define YY_NUM_RULES 26
#define YY_END_OF_BUFFER 27
static yyconst short int yy_accept[100] =
{ 0,
22, 22, 26, 24, 18, 25, 24, 24, 23, 24,
22, 24, 24, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 24, 0, 0, 21, 0,
23, 0, 23, 23, 22, 15, 16, 20, 20, 20,
20, 20, 20, 20, 14, 20, 20, 12, 20, 20,
5, 20, 0, 19, 0, 22, 22, 11, 20, 20,
20, 20, 20, 20, 13, 20, 20, 20, 20, 20,
20, 2, 17, 6, 20, 20, 20, 20, 20, 20,
20, 9, 7, 20, 20, 20, 1, 8, 3, 20,
20, 10, 20, 20, 4, 0
23, 23, 27, 25, 19, 26, 25, 25, 24, 25,
23, 25, 25, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 25, 0, 0, 22, 0,
24, 0, 24, 24, 23, 16, 17, 21, 21, 21,
21, 21, 21, 21, 14, 21, 21, 21, 12, 21,
21, 5, 21, 0, 20, 0, 23, 23, 11, 21,
21, 21, 21, 21, 21, 13, 21, 21, 21, 21,
21, 21, 21, 2, 18, 6, 15, 21, 21, 21,
21, 21, 21, 21, 9, 7, 21, 21, 21, 1,
8, 3, 21, 21, 10, 21, 21, 4, 0
} ;
@@ -309,12 +309,12 @@ static yyconst int yy_ec[256] =
12, 12, 12, 12, 12, 12, 12, 1, 1, 13,
14, 15, 1, 1, 17, 18, 19, 20, 21, 22,
23, 24, 25, 23, 26, 27, 28, 29, 30, 23,
23, 31, 32, 33, 23, 23, 34, 23, 23, 23,
23, 31, 32, 33, 34, 23, 35, 23, 23, 23,
7, 1, 1, 1, 16, 1, 17, 18, 19, 20,
21, 22, 23, 24, 25, 23, 26, 27, 28, 29,
30, 23, 23, 31, 32, 33, 23, 23, 34, 23,
23, 23, 1, 1, 1, 35, 1, 1, 1, 1,
30, 23, 23, 31, 32, 33, 34, 23, 35, 23,
23, 23, 1, 1, 1, 36, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -331,124 +331,126 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst int yy_meta[36] =
static yyconst int yy_meta[37] =
{ 0,
1, 1, 2, 3, 3, 1, 4, 4, 1, 5,
5, 6, 1, 1, 1, 7, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 1
8, 8, 8, 8, 8, 1
} ;
static yyconst short int yy_base[103] =
static yyconst short int yy_base[106] =
{ 0,
0, 0, 177, 289, 289, 289, 0, 156, 29, 31,
36, 126, 111, 41, 43, 45, 52, 51, 39, 24,
44, 58, 59, 69, 67, 75, 114, 92, 75, 88,
83, 91, 96, 102, 0, 289, 289, 86, 0, 95,
92, 97, 103, 106, 105, 112, 118, 120, 121, 129,
128, 131, 73, 289, 55, 54, 122, 134, 136, 139,
147, 142, 148, 150, 153, 155, 160, 161, 163, 168,
170, 169, 176, 177, 184, 183, 185, 192, 191, 193,
194, 199, 200, 205, 211, 212, 214, 219, 221, 222,
224, 227, 232, 229, 234, 289, 50, 262, 267, 271,
0, 0, 183, 297, 297, 297, 0, 176, 30, 32,
37, 136, 127, 42, 44, 46, 53, 52, 40, 25,
45, 59, 60, 70, 68, 76, 121, 114, 93, 89,
84, 92, 97, 103, 0, 297, 297, 87, 0, 96,
93, 98, 104, 107, 106, 113, 119, 121, 122, 128,
133, 135, 136, 77, 297, 56, 55, 123, 138, 141,
146, 153, 148, 143, 154, 156, 159, 164, 167, 170,
172, 175, 177, 178, 183, 184, 189, 192, 191, 194,
199, 200, 201, 202, 207, 208, 213, 219, 220, 222,
227, 229, 230, 232, 235, 240, 237, 242, 297, 51,
277, 280
270, 275, 279, 285, 288
} ;
static yyconst short int yy_def[103] =
static yyconst short int yy_def[106] =
{ 0,
96, 1, 96, 96, 96, 96, 97, 98, 99, 99,
99, 96, 96, 100, 100, 100, 100, 17, 17, 17,
17, 17, 17, 17, 17, 11, 101, 98, 98, 96,
11, 11, 11, 11, 11, 96, 96, 17, 102, 17,
99, 1, 99, 99, 99, 99, 100, 101, 102, 102,
102, 99, 99, 103, 103, 103, 103, 17, 17, 17,
17, 17, 17, 17, 17, 11, 104, 101, 101, 99,
11, 11, 11, 11, 11, 99, 99, 17, 105, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 101, 96, 96, 96, 11, 17, 17, 17,
17, 17, 17, 104, 99, 99, 99, 11, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 0, 96, 96, 96, 96,
17, 17, 17, 17, 17, 17, 17, 17, 0, 99,
96, 96
99, 99, 99, 99, 99
} ;
static yyconst short int yy_nxt[325] =
static yyconst short int yy_nxt[334] =
{ 0,
4, 5, 6, 5, 7, 8, 4, 4, 4, 9,
10, 11, 12, 4, 13, 4, 14, 15, 16, 17,
15, 18, 15, 15, 19, 15, 20, 15, 21, 22,
15, 23, 24, 25, 26, 30, 30, 96, 96, 32,
33, 96, 96, 96, 38, 34, 32, 35, 46, 33,
31, 32, 31, 32, 31, 32, 39, 27, 39, 38,
39, 31, 32, 38, 38, 56, 56, 39, 38, 40,
45, 38, 42, 47, 41, 38, 43, 54, 38, 49,
29, 44, 38, 38, 31, 50, 31, 38, 48, 38,
52, 38, 31, 38, 31, 55, 55, 29, 51, 56,
15, 23, 24, 15, 25, 26, 30, 30, 99, 99,
32, 33, 99, 99, 99, 38, 34, 32, 35, 46,
33, 31, 32, 31, 32, 31, 32, 39, 27, 39,
38, 39, 31, 32, 38, 38, 57, 57, 39, 38,
40, 45, 38, 42, 47, 41, 38, 43, 48, 38,
50, 55, 44, 38, 38, 31, 51, 31, 38, 49,
38, 53, 38, 31, 38, 31, 56, 56, 29, 52,
31, 96, 31, 55, 55, 31, 38, 57, 30, 30,
38, 31, 38, 33, 58, 38, 38, 38, 54, 38,
59, 38, 33, 38, 37, 38, 38, 38, 60, 38,
38, 31, 38, 57, 61, 62, 38, 63, 38, 36,
38, 38, 38, 64, 38, 38, 67, 66, 38, 38,
65, 68, 38, 38, 38, 38, 38, 70, 38, 38,
38, 29, 38, 38, 69, 71, 38, 38, 73, 72,
38, 38, 38, 38, 38, 75, 96, 38, 96, 38,
38, 38, 74, 78, 38, 38, 76, 38, 38, 38,
38, 77, 38, 38, 38, 96, 38, 38, 79, 80,
57, 31, 99, 31, 56, 56, 31, 38, 58, 30,
30, 38, 31, 38, 33, 59, 38, 38, 38, 29,
38, 60, 38, 33, 38, 55, 38, 38, 38, 61,
38, 38, 31, 38, 58, 62, 63, 38, 64, 38,
37, 38, 38, 38, 65, 38, 38, 67, 38, 36,
69, 66, 38, 38, 68, 38, 70, 38, 38, 38,
38, 38, 38, 75, 72, 38, 38, 38, 38, 71,
38, 73, 38, 38, 38, 74, 38, 38, 38, 38,
38, 29, 99, 38, 78, 77, 76, 38, 38, 99,
38, 38, 81, 79, 38, 38, 38, 38, 38, 38,
38, 38, 81, 82, 38, 83, 96, 38, 38, 38,
84, 38, 38, 38, 38, 85, 38, 38, 38, 38,
38, 86, 96, 38, 38, 38, 87, 96, 90, 38,
88, 38, 38, 96, 38, 38, 38, 89, 38, 38,
91, 38, 92, 38, 93, 38, 38, 38, 38, 38,
94, 38, 38, 38, 38, 96, 38, 96, 38, 96,
96, 95, 28, 96, 28, 28, 28, 28, 28, 28,
31, 31, 31, 96, 31, 38, 38, 38, 38, 53,
96, 96, 53, 53, 53, 39, 39, 39, 3, 96,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
80, 38, 38, 38, 38, 82, 83, 38, 38, 38,
84, 85, 38, 38, 86, 38, 38, 87, 38, 38,
38, 38, 38, 38, 88, 38, 38, 38, 38, 89,
99, 38, 38, 38, 90, 99, 93, 38, 91, 38,
38, 99, 38, 38, 38, 92, 38, 38, 94, 38,
95, 38, 96, 38, 38, 38, 38, 38, 97, 38,
38, 38, 38, 99, 38, 99, 38, 99, 99, 98,
28, 99, 28, 28, 28, 28, 28, 28, 31, 31,
31, 99, 31, 38, 38, 38, 38, 54, 99, 99,
54, 54, 54, 39, 39, 39, 3, 99, 99, 99,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99
} ;
static yyconst short int yy_chk[325] =
static yyconst short int yy_chk[334] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 9, 9, 10, 10, 9,
9, 10, 11, 11, 20, 11, 11, 11, 20, 9,
14, 14, 15, 15, 16, 16, 14, 97, 15, 19,
16, 17, 17, 19, 21, 56, 55, 17, 21, 14,
19, 18, 17, 21, 16, 18, 17, 53, 22, 23,
29, 18, 22, 23, 26, 24, 26, 25, 22, 24,
25, 25, 31, 24, 31, 30, 30, 28, 24, 30,
1, 1, 1, 1, 1, 1, 9, 9, 10, 10,
9, 9, 10, 11, 11, 20, 11, 11, 11, 20,
9, 14, 14, 15, 15, 16, 16, 14, 100, 15,
19, 16, 17, 17, 19, 21, 57, 56, 17, 21,
14, 19, 18, 17, 21, 16, 18, 17, 21, 22,
23, 54, 18, 22, 23, 26, 24, 26, 25, 22,
24, 25, 25, 31, 24, 31, 30, 30, 29, 24,
32, 32, 32, 33, 33, 33, 38, 33, 34, 34,
38, 34, 41, 34, 40, 40, 41, 42, 27, 40,
41, 42, 34, 43, 13, 45, 44, 43, 42, 45,
44, 57, 46, 57, 43, 44, 46, 46, 47, 12,
48, 49, 47, 46, 48, 49, 50, 49, 51, 50,
47, 52, 51, 50, 58, 52, 59, 60, 58, 60,
59, 8, 62, 60, 59, 61, 62, 61, 63, 62,
64, 61, 63, 65, 64, 66, 3, 65, 0, 66,
67, 68, 64, 69, 67, 68, 67, 69, 70, 72,
71, 68, 70, 72, 71, 0, 73, 74, 70, 71,
30, 32, 32, 32, 33, 33, 33, 38, 33, 34,
34, 38, 34, 41, 34, 40, 40, 41, 42, 28,
40, 41, 42, 34, 43, 27, 45, 44, 43, 42,
45, 44, 58, 46, 58, 43, 44, 46, 46, 47,
13, 48, 49, 47, 46, 48, 49, 48, 50, 12,
51, 47, 50, 51, 50, 52, 53, 51, 59, 52,
53, 60, 59, 64, 61, 60, 61, 64, 63, 60,
61, 62, 63, 62, 65, 63, 66, 62, 65, 67,
66, 8, 3, 67, 68, 67, 65, 69, 68, 0,
70, 69, 71, 69, 70, 72, 71, 73, 74, 72,
73, 74, 75, 76, 75, 77, 0, 76, 75, 77,
78, 79, 78, 80, 81, 79, 78, 80, 81, 82,
83, 80, 0, 82, 83, 84, 81, 0, 85, 84,
82, 85, 86, 0, 87, 85, 86, 84, 87, 88,
86, 89, 90, 88, 91, 89, 90, 92, 91, 94,
93, 92, 93, 94, 95, 0, 93, 0, 95, 0,
0, 94, 98, 0, 98, 98, 98, 98, 98, 98,
99, 99, 99, 0, 99, 100, 100, 100, 100, 101,
0, 0, 101, 101, 101, 102, 102, 102, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
70, 73, 74, 75, 76, 72, 73, 75, 76, 77,
78, 79, 78, 77, 80, 79, 78, 81, 80, 81,
82, 83, 84, 81, 82, 83, 84, 85, 86, 83,
0, 85, 86, 87, 84, 0, 88, 87, 85, 88,
89, 0, 90, 88, 89, 87, 90, 91, 89, 92,
93, 91, 94, 92, 93, 95, 94, 97, 96, 95,
96, 97, 98, 0, 96, 0, 98, 0, 0, 97,
101, 0, 101, 101, 101, 101, 101, 101, 102, 102,
102, 0, 102, 103, 103, 103, 103, 104, 0, 0,
104, 104, 104, 105, 105, 105, 99, 99, 99, 99,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99
} ;
static yy_state_type yy_last_accepting_state;
@@ -487,7 +489,7 @@ char *yytext;
#include "mdbsql.h"
#include "parser.h"
#line 491 "lexer.c"
#line 493 "lexer.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -640,7 +642,7 @@ YY_DECL
#line 26 "lexer.l"
#line 644 "lexer.c"
#line 646 "lexer.c"
if ( yy_init )
{
@@ -691,13 +693,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 97 )
if ( yy_current_state >= 100 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 289 );
while ( yy_base[yy_current_state] != 297 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -796,65 +798,70 @@ YY_RULE_SETUP
case 15:
YY_RULE_SETUP
#line 41 "lexer.l"
{ return LTEQ; }
{ return NULL; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 42 "lexer.l"
{ return GTEQ; }
{ return LTEQ; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 43 "lexer.l"
{ return LIKE; }
{ return GTEQ; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 44 "lexer.l"
;
{ return LIKE; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 45 "lexer.l"
;
YY_BREAK
case 20:
YY_RULE_SETUP
#line 46 "lexer.l"
{
yylval.name = strdup(&yytext[1]);
yylval.name[strlen(yylval.name)-1]='\0';
return IDENT;
}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 50 "lexer.l"
{ yylval.name = strdup(yytext); return NAME; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 52 "lexer.l"
{ yylval.name = strdup(yytext); return STRING; }
#line 51 "lexer.l"
{ yylval.name = strdup(yytext); return NAME; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 53 "lexer.l"
{ yylval.name = strdup(yytext); return STRING; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 54 "lexer.l"
{
yylval.name = strdup(yytext); return NUMBER;
}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 56 "lexer.l"
{ yylval.name = strdup(yytext); return PATH; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 57 "lexer.l"
{ return yytext[0]; }
{ yylval.name = strdup(yytext); return PATH; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 58 "lexer.l"
{ return yytext[0]; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 59 "lexer.l"
ECHO;
YY_BREAK
#line 858 "lexer.c"
#line 865 "lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1146,7 +1153,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 97 )
if ( yy_current_state >= 100 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1181,11 +1188,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 97 )
if ( yy_current_state >= 100 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 96);
yy_is_jam = (yy_current_state == 99);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1735,7 +1742,7 @@ int main()
return 0;
}
#endif
#line 58 "lexer.l"
#line 59 "lexer.l"
int yywrap()

View File

@@ -38,6 +38,7 @@ and { return AND; }
or { return OR; }
not { return NOT; }
is { return IS; }
null { return NULL; }
(<=) { return LTEQ; }
(>=) { return GTEQ; }
like { return LIKE; }

View File

@@ -311,6 +311,13 @@ mdb_sql_add_sarg(MdbSQL *sql, char *col_name, int op, char *constant)
sql_sarg->col_name = g_strdup(col_name);
sql_sarg->sarg->op = op;
if (!constant) {
/* XXX - do we need to check operator? */
g_ptr_array_add(sql->sargs, sql_sarg);
sql->num_sargs++;
mdb_sql_push_node(sql, node);
return 0;
}
/* FIX ME -- we should probably just be storing the ascii value until the
** column definition can be checked for validity
*/