Merge pull request #83 from javrucebo/limit-offset

Allow more variations of LIMIT/OFFSET
This commit is contained in:
mrks 2018-02-08 17:36:22 +01:00 committed by GitHub
commit 2dea18f515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1080 additions and 1029 deletions

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
extern int hsql_debug; extern int hsql_debug;
#endif #endif
/* "%code requires" blocks. */ /* "%code requires" blocks. */
#line 35 "bison_parser.y" /* yacc.c:1909 */ #line 35 "bison_parser.y" /* yacc.c:1915 */
// %code requires block // %code requires block
@ -72,7 +72,7 @@ extern int hsql_debug;
} \ } \
} }
#line 76 "bison_parser.h" /* yacc.c:1909 */ #line 76 "bison_parser.h" /* yacc.c:1915 */
/* Token type. */ /* Token type. */
#ifndef HSQL_TOKENTYPE #ifndef HSQL_TOKENTYPE
@ -218,7 +218,7 @@ extern int hsql_debug;
union HSQL_STYPE union HSQL_STYPE
{ {
#line 95 "bison_parser.y" /* yacc.c:1909 */ #line 95 "bison_parser.y" /* yacc.c:1915 */
double fval; double fval;
int64_t ival; int64_t ival;
@ -257,7 +257,7 @@ union HSQL_STYPE
std::vector<hsql::Expr*>* expr_vec; std::vector<hsql::Expr*>* expr_vec;
std::vector<hsql::OrderDescription*>* order_vec; std::vector<hsql::OrderDescription*>* order_vec;
#line 261 "bison_parser.h" /* yacc.c:1909 */ #line 261 "bison_parser.h" /* yacc.c:1915 */
}; };
typedef union HSQL_STYPE HSQL_STYPE; typedef union HSQL_STYPE HSQL_STYPE;

View File

@ -711,6 +711,11 @@ opt_top:
opt_limit: opt_limit:
LIMIT int_literal { $$ = new LimitDescription($2->ival, kNoOffset); delete $2; } LIMIT int_literal { $$ = new LimitDescription($2->ival, kNoOffset); delete $2; }
| LIMIT int_literal OFFSET int_literal { $$ = new LimitDescription($2->ival, $4->ival); delete $2; delete $4; } | LIMIT int_literal OFFSET int_literal { $$ = new LimitDescription($2->ival, $4->ival); delete $2; delete $4; }
| OFFSET int_literal { $$ = new LimitDescription(kNoLimit, $2->ival); delete $2; }
| LIMIT ALL { $$ = nullptr; }
| LIMIT NULL { $$ = nullptr; }
| LIMIT ALL OFFSET int_literal { $$ = new LimitDescription(kNoLimit, $4->ival); delete $4; }
| LIMIT NULL OFFSET int_literal { $$ = new LimitDescription(kNoLimit, $4->ival); delete $4; }
| /* empty */ { $$ = nullptr; } | /* empty */ { $$ = nullptr; }
; ;

View File

@ -8,8 +8,8 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 1 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@ -47,6 +47,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t; typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t; typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t; typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else #else
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
@ -54,6 +55,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -84,17 +86,27 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */ #ifdef __cplusplus
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3 /* The "const" storage-class-modifier is valid. */
#define yynoreturn __attribute__((__noreturn__)) #define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else #else
#define yynoreturn #define yyconst
#endif #endif
/* Returned upon end-of-file. */ /* Returned upon end-of-file. */
@ -147,15 +159,7 @@ typedef void* yyscan_t;
/* Size of default input buffer. */ /* Size of default input buffer. */
#ifndef YY_BUF_SIZE #ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384 #define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif #endif
/* The state buf must be large enough to hold one state per character in the main buffer. /* The state buf must be large enough to hold one state per character in the main buffer.
@ -177,7 +181,6 @@ typedef size_t yy_size_t;
#define EOB_ACT_LAST_MATCH 2 #define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n) #define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */ /* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \ #define yyless(n) \
@ -207,12 +210,12 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB /* Size of input buffer in bytes, not including room for EOB
* characters. * characters.
*/ */
int yy_buf_size; yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB /* Number of characters read into yy_ch_buf, not including EOB
* characters. * characters.
*/ */
int yy_n_chars; yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it, /* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to * and can realloc() it to grow it, and should free() it to
@ -235,7 +238,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */ int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */ int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the /* Whether to try to fill the input buffer when we reach the
* end of it. * end of it.
*/ */
@ -291,7 +294,7 @@ static void hsql__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner
YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *hsql_alloc (yy_size_t ,yyscan_t yyscanner ); void *hsql_alloc (yy_size_t ,yyscan_t yyscanner );
void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner );
@ -323,7 +326,7 @@ void hsql_free (void * ,yyscan_t yyscanner );
/* Begin user sect3 */ /* Begin user sect3 */
#define hsql_wrap(yyscanner) (/*CONSTCOND*/1) #define hsql_wrap(n) 1
#define YY_SKIP_YYWRAP #define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR; typedef unsigned char YY_CHAR;
@ -335,14 +338,14 @@ typedef int yy_state_type;
static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
static int yy_get_next_buffer (yyscan_t yyscanner ); static int yy_get_next_buffer (yyscan_t yyscanner );
static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner ); static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the /* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext. * corresponding action - sets up yytext.
*/ */
#define YY_DO_BEFORE_ACTION \ #define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \ yyg->yytext_ptr = yy_bp; \
yyleng = (int) (yy_cp - yy_bp); \ yyleng = (yy_size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \ yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp; yyg->yy_c_buf_p = yy_cp;
@ -464,7 +467,7 @@ static yyconst flex_int16_t yy_accept[942] =
0 0
} ; } ;
static yyconst YY_CHAR yy_ec[256] = static yyconst flex_int32_t yy_ec[256] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -496,7 +499,7 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1 1, 1, 1, 1, 1
} ; } ;
static yyconst YY_CHAR yy_meta[68] = static yyconst flex_int32_t yy_meta[68] =
{ 0, { 0,
1, 1, 2, 1, 3, 1, 1, 1, 1, 4, 1, 1, 2, 1, 3, 1, 1, 1, 1, 4,
1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4,
@ -507,7 +510,7 @@ static yyconst YY_CHAR yy_meta[68] =
4, 4, 4, 4, 4, 4, 1 4, 4, 4, 4, 4, 4, 1
} ; } ;
static yyconst flex_uint16_t yy_base[949] = static yyconst flex_int16_t yy_base[949] =
{ 0, { 0,
0, 0, 67, 0, 454, 3713, 133, 135, 423, 0, 0, 0, 67, 0, 454, 3713, 133, 135, 423, 0,
3713, 426, 131, 420, 133, 132, 405, 399, 129, 129, 3713, 426, 131, 420, 133, 132, 405, 399, 129, 129,
@ -723,7 +726,7 @@ static yyconst flex_int16_t yy_def[949] =
0, 941, 941, 941, 941, 941, 941, 941 0, 941, 941, 941, 941, 941, 941, 941
} ; } ;
static yyconst flex_uint16_t yy_nxt[3781] = static yyconst flex_int16_t yy_nxt[3781] =
{ 0, { 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
@ -1597,7 +1600,7 @@ static yyconst flex_int16_t yy_chk[3781] =
/*************************** /***************************
** Section 3: Rules ** Section 3: Rules
***************************/ ***************************/
#line 1601 "flex_lexer.cpp" #line 1604 "flex_lexer.cpp"
#define INITIAL 0 #define INITIAL 0
#define COMMENT 1 #define COMMENT 1
@ -1627,8 +1630,8 @@ struct yyguts_t
size_t yy_buffer_stack_max; /**< capacity of stack. */ size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char; char yy_hold_char;
int yy_n_chars; yy_size_t yy_n_chars;
int yyleng_r; yy_size_t yyleng_r;
char *yy_c_buf_p; char *yy_c_buf_p;
int yy_init; int yy_init;
int yy_start; int yy_start;
@ -1679,23 +1682,19 @@ void hsql_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *hsql_get_in (yyscan_t yyscanner ); FILE *hsql_get_in (yyscan_t yyscanner );
void hsql_set_in (FILE * _in_str ,yyscan_t yyscanner ); void hsql_set_in (FILE * in_str ,yyscan_t yyscanner );
FILE *hsql_get_out (yyscan_t yyscanner ); FILE *hsql_get_out (yyscan_t yyscanner );
void hsql_set_out (FILE * _out_str ,yyscan_t yyscanner ); void hsql_set_out (FILE * out_str ,yyscan_t yyscanner );
int hsql_get_leng (yyscan_t yyscanner ); yy_size_t hsql_get_leng (yyscan_t yyscanner );
char *hsql_get_text (yyscan_t yyscanner ); char *hsql_get_text (yyscan_t yyscanner );
int hsql_get_lineno (yyscan_t yyscanner ); int hsql_get_lineno (yyscan_t yyscanner );
void hsql_set_lineno (int _line_number ,yyscan_t yyscanner ); void hsql_set_lineno (int line_number ,yyscan_t yyscanner );
int hsql_get_column (yyscan_t yyscanner );
void hsql_set_column (int _column_no ,yyscan_t yyscanner );
YYSTYPE * hsql_get_lval (yyscan_t yyscanner ); YYSTYPE * hsql_get_lval (yyscan_t yyscanner );
@ -1717,10 +1716,6 @@ extern int hsql_wrap (yyscan_t yyscanner );
#endif #endif
#endif #endif
#ifndef YY_NO_UNPUT
#endif
#ifndef yytext_ptr #ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif #endif
@ -1741,12 +1736,7 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */ /* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE #ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192 #define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif #endif
/* Copy whatever the last rule matched to the standard output. */ /* Copy whatever the last rule matched to the standard output. */
@ -1754,7 +1744,7 @@ static int input (yyscan_t yyscanner );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -1765,7 +1755,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \ { \
int c = '*'; \ int c = '*'; \
size_t n; \ yy_size_t n; \
for ( n = 0; n < max_size && \ for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \ buf[n] = (char) c; \
@ -1778,7 +1768,7 @@ static int input (yyscan_t yyscanner );
else \ else \
{ \ { \
errno=0; \ errno=0; \
while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \ { \
if( errno != EINTR) \ if( errno != EINTR) \
{ \ { \
@ -1835,7 +1825,7 @@ extern int hsql_lex \
/* Code executed at the end of each rule. */ /* Code executed at the end of each rule. */
#ifndef YY_BREAK #ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break; #define YY_BREAK break;
#endif #endif
#define YY_RULE_SETUP \ #define YY_RULE_SETUP \
@ -1845,11 +1835,16 @@ extern int hsql_lex \
*/ */
YY_DECL YY_DECL
{ {
yy_state_type yy_current_state; register yy_state_type yy_current_state;
char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
int yy_act; register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 51 "flex_lexer.l"
#line 1847 "flex_lexer.cpp"
yylval = yylval_param; yylval = yylval_param;
yylloc = yylloc_param; yylloc = yylloc_param;
@ -1880,13 +1875,7 @@ YY_DECL
hsql__load_buffer_state(yyscanner ); hsql__load_buffer_state(yyscanner );
} }
{ while ( 1 ) /* loops until end-of-file is reached */
#line 51 "flex_lexer.l"
#line 1888 "flex_lexer.cpp"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{ {
yy_cp = yyg->yy_c_buf_p; yy_cp = yyg->yy_c_buf_p;
@ -1902,7 +1891,7 @@ YY_DECL
yy_match: yy_match:
do do
{ {
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@ -1914,7 +1903,7 @@ yy_match:
if ( yy_current_state >= 942 ) if ( yy_current_state >= 942 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp; ++yy_cp;
} }
while ( yy_current_state != 941 ); while ( yy_current_state != 941 );
@ -2639,7 +2628,7 @@ YY_RULE_SETUP
#line 219 "flex_lexer.l" #line 219 "flex_lexer.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2643 "flex_lexer.cpp" #line 2632 "flex_lexer.cpp"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(COMMENT):
yyterminate(); yyterminate();
@ -2772,7 +2761,6 @@ case YY_STATE_EOF(COMMENT):
"fatal flex scanner internal error--no action found" ); "fatal flex scanner internal error--no action found" );
} /* end of action switch */ } /* end of action switch */
} /* end of scanning one token */ } /* end of scanning one token */
} /* end of user's declarations */
} /* end of hsql_lex */ } /* end of hsql_lex */
/* yy_get_next_buffer - try to read in a new buffer /* yy_get_next_buffer - try to read in a new buffer
@ -2785,9 +2773,9 @@ case YY_STATE_EOF(COMMENT):
static int yy_get_next_buffer (yyscan_t yyscanner) static int yy_get_next_buffer (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr; register char *source = yyg->yytext_ptr;
int number_to_move, i; register int number_to_move, i;
int ret_val; int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@ -2816,7 +2804,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */ /* Try to read more data. */
/* First move last chars to start of buffer. */ /* First move last chars to start of buffer. */
number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i ) for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++); *(dest++) = *(source++);
@ -2829,21 +2817,21 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else else
{ {
int num_to_read = yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 ) while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */ { /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset = int yy_c_buf_p_offset =
(int) (yyg->yy_c_buf_p - b->yy_ch_buf); (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer ) if ( b->yy_is_our_buffer )
{ {
int new_size = b->yy_buf_size * 2; yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 ) if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8; b->yy_buf_size += b->yy_buf_size / 8;
@ -2856,7 +2844,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
} }
else else
/* Can't grow it, we don't own it. */ /* Can't grow it, we don't own it. */
b->yy_ch_buf = NULL; b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf ) if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( YY_FATAL_ERROR(
@ -2898,9 +2886,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else else
ret_val = EOB_ACT_CONTINUE_SCAN; ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */ /* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hsql_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hsql_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
@ -2919,15 +2907,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
static yy_state_type yy_get_previous_state (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{ {
yy_state_type yy_current_state; register yy_state_type yy_current_state;
char *yy_cp; register char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_current_state = yyg->yy_start; yy_current_state = yyg->yy_start;
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{ {
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@ -2939,7 +2927,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( yy_current_state >= 942 ) if ( yy_current_state >= 942 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
} }
return yy_current_state; return yy_current_state;
@ -2952,11 +2940,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/ */
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{ {
int yy_is_jam; register int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
char *yy_cp = yyg->yy_c_buf_p; register char *yy_cp = yyg->yy_c_buf_p;
YY_CHAR yy_c = 1; register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@ -2968,17 +2956,12 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( yy_current_state >= 942 ) if ( yy_current_state >= 942 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 941); yy_is_jam = (yy_current_state == 941);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
#ifndef YY_NO_UNPUT
#endif
#ifndef YY_NO_INPUT #ifndef YY_NO_INPUT
#ifdef __cplusplus #ifdef __cplusplus
static int yyinput (yyscan_t yyscanner) static int yyinput (yyscan_t yyscanner)
@ -3004,7 +2987,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else else
{ /* need more input */ { /* need more input */
int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p; ++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) ) switch ( yy_get_next_buffer( yyscanner ) )
@ -3132,7 +3115,7 @@ static void hsql__load_buffer_state (yyscan_t yyscanner)
if ( ! b ) if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in hsql__create_buffer()" ); YY_FATAL_ERROR( "out of dynamic memory in hsql__create_buffer()" );
b->yy_buf_size = (yy_size_t)size; b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because /* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters. * we need to put in 2 end-of-buffer characters.
@ -3284,7 +3267,7 @@ void hsql_pop_buffer_state (yyscan_t yyscanner)
*/ */
static void hsql_ensure_buffer_stack (yyscan_t yyscanner) static void hsql_ensure_buffer_stack (yyscan_t yyscanner)
{ {
int num_to_alloc; yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) { if (!yyg->yy_buffer_stack) {
@ -3293,15 +3276,15 @@ static void hsql_ensure_buffer_stack (yyscan_t yyscanner)
* scanner will even need a stack. We use 2 instead of 1 to avoid an * scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call. * immediate realloc on the next call.
*/ */
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ num_to_alloc = 1;
yyg->yy_buffer_stack = (struct yy_buffer_state**)hsql_alloc yyg->yy_buffer_stack = (struct yy_buffer_state**)hsql_alloc
(num_to_alloc * sizeof(struct yy_buffer_state*) (num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
if ( ! yyg->yy_buffer_stack ) if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in hsql_ensure_buffer_stack()" ); YY_FATAL_ERROR( "out of dynamic memory in hsql_ensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_max = num_to_alloc;
yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_top = 0;
return; return;
@ -3310,7 +3293,7 @@ static void hsql_ensure_buffer_stack (yyscan_t yyscanner)
if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
/* Increase the buffer to prepare for a possible push. */ /* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */; int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size; num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
yyg->yy_buffer_stack = (struct yy_buffer_state**)hsql_realloc yyg->yy_buffer_stack = (struct yy_buffer_state**)hsql_realloc
@ -3330,7 +3313,7 @@ static void hsql_ensure_buffer_stack (yyscan_t yyscanner)
* @param base the character buffer * @param base the character buffer
* @param size the size in bytes of the character buffer * @param size the size in bytes of the character buffer
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
YY_BUFFER_STATE hsql__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) YY_BUFFER_STATE hsql__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{ {
@ -3340,7 +3323,7 @@ YY_BUFFER_STATE hsql__scan_buffer (char * base, yy_size_t size , yyscan_t yysc
base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR ) base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */ /* They forgot to leave room for the EOB's. */
return NULL; return 0;
b = (YY_BUFFER_STATE) hsql_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); b = (YY_BUFFER_STATE) hsql_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b ) if ( ! b )
@ -3349,7 +3332,7 @@ YY_BUFFER_STATE hsql__scan_buffer (char * base, yy_size_t size , yyscan_t yysc
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base; b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0; b->yy_is_our_buffer = 0;
b->yy_input_file = NULL; b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size; b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0; b->yy_is_interactive = 0;
b->yy_at_bol = 1; b->yy_at_bol = 1;
@ -3372,25 +3355,24 @@ YY_BUFFER_STATE hsql__scan_buffer (char * base, yy_size_t size , yyscan_t yysc
YY_BUFFER_STATE hsql__scan_string (yyconst char * yystr , yyscan_t yyscanner) YY_BUFFER_STATE hsql__scan_string (yyconst char * yystr , yyscan_t yyscanner)
{ {
return hsql__scan_bytes(yystr,(int) strlen(yystr) ,yyscanner); return hsql__scan_bytes(yystr,strlen(yystr) ,yyscanner);
} }
/** Setup the input buffer state to scan the given bytes. The next call to hsql_lex() will /** Setup the input buffer state to scan the given bytes. The next call to hsql_lex() will
* scan from a @e copy of @a bytes. * scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan * @param bytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
YY_BUFFER_STATE hsql__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) YY_BUFFER_STATE hsql__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
char *buf; char *buf;
yy_size_t n; yy_size_t n, i;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */ /* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2); n = _yybytes_len + 2;
buf = (char *) hsql_alloc(n ,yyscanner ); buf = (char *) hsql_alloc(n ,yyscanner );
if ( ! buf ) if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in hsql__scan_bytes()" ); YY_FATAL_ERROR( "out of dynamic memory in hsql__scan_bytes()" );
@ -3416,11 +3398,9 @@ YY_BUFFER_STATE hsql__scan_bytes (yyconst char * yybytes, int _yybytes_len , y
#define YY_EXIT_FAILURE 2 #define YY_EXIT_FAILURE 2
#endif #endif
static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; (void) fprintf( stderr, "%s\n", msg );
(void)yyg;
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE ); exit( YY_EXIT_FAILURE );
} }
@ -3458,7 +3438,7 @@ YY_EXTRA_TYPE hsql_get_extra (yyscan_t yyscanner)
int hsql_get_lineno (yyscan_t yyscanner) int hsql_get_lineno (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER) if (! YY_CURRENT_BUFFER)
return 0; return 0;
@ -3471,7 +3451,7 @@ int hsql_get_lineno (yyscan_t yyscanner)
int hsql_get_column (yyscan_t yyscanner) int hsql_get_column (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER) if (! YY_CURRENT_BUFFER)
return 0; return 0;
@ -3499,7 +3479,7 @@ FILE *hsql_get_out (yyscan_t yyscanner)
/** Get the length of the current token. /** Get the length of the current token.
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
*/ */
int hsql_get_leng (yyscan_t yyscanner) yy_size_t hsql_get_leng (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng; return yyleng;
@ -3526,51 +3506,51 @@ void hsql_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
} }
/** Set the current line number. /** Set the current line number.
* @param _line_number line number * @param line_number
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
*/ */
void hsql_set_lineno (int _line_number , yyscan_t yyscanner) void hsql_set_lineno (int line_number , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */ /* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER ) if (! YY_CURRENT_BUFFER )
YY_FATAL_ERROR( "hsql_set_lineno called with no buffer" ); yy_fatal_error( "hsql_set_lineno called with no buffer" , yyscanner);
yylineno = _line_number; yylineno = line_number;
} }
/** Set the current column. /** Set the current column.
* @param _column_no column number * @param line_number
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
*/ */
void hsql_set_column (int _column_no , yyscan_t yyscanner) void hsql_set_column (int column_no , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */ /* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER ) if (! YY_CURRENT_BUFFER )
YY_FATAL_ERROR( "hsql_set_column called with no buffer" ); yy_fatal_error( "hsql_set_column called with no buffer" , yyscanner);
yycolumn = _column_no; yycolumn = column_no;
} }
/** Set the input stream. This does not discard the current /** Set the input stream. This does not discard the current
* input buffer. * input buffer.
* @param _in_str A readable stream. * @param in_str A readable stream.
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
* @see hsql__switch_to_buffer * @see hsql__switch_to_buffer
*/ */
void hsql_set_in (FILE * _in_str , yyscan_t yyscanner) void hsql_set_in (FILE * in_str , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ; yyin = in_str ;
} }
void hsql_set_out (FILE * _out_str , yyscan_t yyscanner) void hsql_set_out (FILE * out_str , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ; yyout = out_str ;
} }
int hsql_get_debug (yyscan_t yyscanner) int hsql_get_debug (yyscan_t yyscanner)
@ -3579,10 +3559,10 @@ int hsql_get_debug (yyscan_t yyscanner)
return yy_flex_debug; return yy_flex_debug;
} }
void hsql_set_debug (int _bdebug , yyscan_t yyscanner) void hsql_set_debug (int bdebug , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ; yy_flex_debug = bdebug ;
} }
/* Accessor methods for yylval and yylloc */ /* Accessor methods for yylval and yylloc */
@ -3658,20 +3638,20 @@ int hsql_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
errno = EINVAL; errno = EINVAL;
return 1; return 1;
} }
*ptr_yy_globals = (yyscan_t) hsql_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); *ptr_yy_globals = (yyscan_t) hsql_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){ if (*ptr_yy_globals == NULL){
errno = ENOMEM; errno = ENOMEM;
return 1; return 1;
} }
/* By setting to 0xAA, we expose bugs in /* By setting to 0xAA, we expose bugs in
yy_init_globals. Leave at 0x00 for releases. */ yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
hsql_set_extra (yy_user_defined, *ptr_yy_globals); hsql_set_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals ); return yy_init_globals ( *ptr_yy_globals );
} }
@ -3682,10 +3662,10 @@ static int yy_init_globals (yyscan_t yyscanner)
* This function is called from hsql_lex_destroy(), so don't allocate here. * This function is called from hsql_lex_destroy(), so don't allocate here.
*/ */
yyg->yy_buffer_stack = NULL; yyg->yy_buffer_stack = 0;
yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0; yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = NULL; yyg->yy_c_buf_p = (char *) 0;
yyg->yy_init = 0; yyg->yy_init = 0;
yyg->yy_start = 0; yyg->yy_start = 0;
@ -3698,8 +3678,8 @@ static int yy_init_globals (yyscan_t yyscanner)
yyin = stdin; yyin = stdin;
yyout = stdout; yyout = stdout;
#else #else
yyin = NULL; yyin = (FILE *) 0;
yyout = NULL; yyout = (FILE *) 0;
#endif #endif
/* For future reference: Set errno on error, since we are called by /* For future reference: Set errno on error, since we are called by
@ -3745,10 +3725,7 @@ int hsql_lex_destroy (yyscan_t yyscanner)
#ifndef yytext_ptr #ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register int i;
(void)yyg;
int i;
for ( i = 0; i < n; ++i ) for ( i = 0; i < n; ++i )
s1[i] = s2[i]; s1[i] = s2[i];
} }
@ -3757,7 +3734,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#ifdef YY_NEED_STRLEN #ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{ {
int n; register int n;
for ( n = 0; s[n]; ++n ) for ( n = 0; s[n]; ++n )
; ;
@ -3767,16 +3744,11 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
void *hsql_alloc (yy_size_t size , yyscan_t yyscanner) void *hsql_alloc (yy_size_t size , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return (void *) malloc( size );
(void)yyg;
return malloc(size);
} }
void *hsql_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) void *hsql_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
/* The cast to (char *) in the following accommodates both /* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those * implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter * that use void* generic pointers. It works with the latter
@ -3784,13 +3756,11 @@ void *hsql_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
* any pointer type to void*, and deal with argument conversions * any pointer type to void*, and deal with argument conversions
* as though doing an assignment. * as though doing an assignment.
*/ */
return realloc(ptr, size); return (void *) realloc( (char *) ptr, size );
} }
void hsql_free (void * ptr , yyscan_t yyscanner) void hsql_free (void * ptr , yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
free( (char *) ptr ); /* see hsql_realloc() for (char *) cast */ free( (char *) ptr ); /* see hsql_realloc() for (char *) cast */
} }

View File

@ -12,8 +12,8 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 1 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@ -51,6 +51,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t; typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t; typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t; typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else #else
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
@ -58,6 +59,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -88,17 +90,27 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */ #ifdef __cplusplus
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3 /* The "const" storage-class-modifier is valid. */
#define yynoreturn __attribute__((__noreturn__)) #define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else #else
#define yynoreturn #define yyconst
#endif #endif
/* An opaque pointer. */ /* An opaque pointer. */
@ -120,15 +132,7 @@ typedef void* yyscan_t;
/* Size of default input buffer. */ /* Size of default input buffer. */
#ifndef YY_BUF_SIZE #ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384 #define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif #endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE #ifndef YY_TYPEDEF_YY_BUFFER_STATE
@ -153,12 +157,12 @@ struct yy_buffer_state
/* Size of input buffer in bytes, not including room for EOB /* Size of input buffer in bytes, not including room for EOB
* characters. * characters.
*/ */
int yy_buf_size; yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB /* Number of characters read into yy_ch_buf, not including EOB
* characters. * characters.
*/ */
int yy_n_chars; yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it, /* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to * and can realloc() it to grow it, and should free() it to
@ -181,7 +185,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */ int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */ int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the /* Whether to try to fill the input buffer when we reach the
* end of it. * end of it.
*/ */
@ -202,7 +206,7 @@ void hsql_pop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *hsql_alloc (yy_size_t ,yyscan_t yyscanner ); void *hsql_alloc (yy_size_t ,yyscan_t yyscanner );
void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner );
@ -210,7 +214,7 @@ void hsql_free (void * ,yyscan_t yyscanner );
/* Begin user sect3 */ /* Begin user sect3 */
#define hsql_wrap(yyscanner) (/*CONSTCOND*/1) #define hsql_wrap(n) 1
#define YY_SKIP_YYWRAP #define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r #define yytext_ptr yytext_r
@ -252,23 +256,19 @@ void hsql_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *hsql_get_in (yyscan_t yyscanner ); FILE *hsql_get_in (yyscan_t yyscanner );
void hsql_set_in (FILE * _in_str ,yyscan_t yyscanner ); void hsql_set_in (FILE * in_str ,yyscan_t yyscanner );
FILE *hsql_get_out (yyscan_t yyscanner ); FILE *hsql_get_out (yyscan_t yyscanner );
void hsql_set_out (FILE * _out_str ,yyscan_t yyscanner ); void hsql_set_out (FILE * out_str ,yyscan_t yyscanner );
int hsql_get_leng (yyscan_t yyscanner ); yy_size_t hsql_get_leng (yyscan_t yyscanner );
char *hsql_get_text (yyscan_t yyscanner ); char *hsql_get_text (yyscan_t yyscanner );
int hsql_get_lineno (yyscan_t yyscanner ); int hsql_get_lineno (yyscan_t yyscanner );
void hsql_set_lineno (int _line_number ,yyscan_t yyscanner ); void hsql_set_lineno (int line_number ,yyscan_t yyscanner );
int hsql_get_column (yyscan_t yyscanner );
void hsql_set_column (int _column_no ,yyscan_t yyscanner );
YYSTYPE * hsql_get_lval (yyscan_t yyscanner ); YYSTYPE * hsql_get_lval (yyscan_t yyscanner );
@ -304,12 +304,7 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
/* Amount of stuff to slurp up with each read. */ /* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE #ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192 #define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif #endif
/* Number of entries by which start-condition stack grows. */ /* Number of entries by which start-condition stack grows. */
@ -347,6 +342,6 @@ extern int hsql_lex \
#line 219 "flex_lexer.l" #line 219 "flex_lexer.l"
#line 351 "flex_lexer.h" #line 346 "flex_lexer.h"
#undef hsql_IN_HEADER #undef hsql_IN_HEADER
#endif /* hsql_HEADER_H */ #endif /* hsql_HEADER_H */

View File

@ -156,8 +156,8 @@ namespace hsql {
// LimitDescription // LimitDescription
LimitDescription::LimitDescription(int64_t limit, int64_t offset) : LimitDescription::LimitDescription(int64_t limit, int64_t offset) :
limit(limit), limit(limit >= 0 ? limit : kNoLimit),
offset(offset) {} offset(offset > 0 ? offset : kNoOffset) {}
// GroypByDescription // GroypByDescription
GroupByDescription::GroupByDescription() : GroupByDescription::GroupByDescription() :

View File

@ -438,4 +438,61 @@ TEST(JoinTypes) {
stmt = (SelectStatement*) result.getStatement(11); stmt = (SelectStatement*) result.getStatement(11);
ASSERT_NULL(stmt->fromTable->join); ASSERT_NULL(stmt->fromTable->join);
} }
TEST(SetLimitOffset) {
SelectStatement* stmt;
TEST_PARSE_SQL_QUERY("select a from t1 limit 1; \
select a from t1 limit 1 offset 1; \
select a from t1 limit 0; \
select a from t1 limit 0 offset 1; \
select a from t1 limit 1 offset 0; \
select a from t1 limit ALL offset 1; \
select a from t1 limit NULL offset 1; \
select a from t1 offset 1; \
select top 10 a from t1; \
select top 20 a from t1 limit 10;",
result, 10);
stmt = (SelectStatement*) result.getStatement(0);
ASSERT_EQ(stmt->limit->limit, 1);
ASSERT_EQ(stmt->limit->offset, kNoOffset);
stmt = (SelectStatement*) result.getStatement(1);
ASSERT_EQ(stmt->limit->limit, 1);
ASSERT_EQ(stmt->limit->offset, 1);
stmt = (SelectStatement*) result.getStatement(2);
ASSERT_EQ(stmt->limit->limit, 0);
ASSERT_EQ(stmt->limit->offset, kNoOffset);
stmt = (SelectStatement*) result.getStatement(3);
ASSERT_EQ(stmt->limit->limit, 0);
ASSERT_EQ(stmt->limit->offset, 1);
stmt = (SelectStatement*) result.getStatement(4);
ASSERT_EQ(stmt->limit->limit, 1);
ASSERT_EQ(stmt->limit->offset, kNoOffset);
stmt = (SelectStatement*) result.getStatement(5);
ASSERT_EQ(stmt->limit->limit, kNoLimit);
ASSERT_EQ(stmt->limit->offset, 1);
stmt = (SelectStatement*) result.getStatement(6);
ASSERT_EQ(stmt->limit->limit, kNoLimit);
ASSERT_EQ(stmt->limit->offset, 1);
stmt = (SelectStatement*) result.getStatement(7);
ASSERT_EQ(stmt->limit->limit, kNoLimit);
ASSERT_EQ(stmt->limit->offset, 1);
stmt = (SelectStatement*) result.getStatement(8);
ASSERT_EQ(stmt->limit->limit, 10);
ASSERT_EQ(stmt->limit->offset, kNoOffset);
stmt = (SelectStatement*) result.getStatement(9);
ASSERT_EQ(stmt->limit->limit, 10);
ASSERT_EQ(stmt->limit->offset, kNoOffset);
}