sql.c 90.4 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/*
** 2000-05-29
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Driver template for the LEMON parser generator.
**
** The "lemon" program processes an LALR(1) input grammar file, then uses
** this template to construct a parser.  The "lemon" program inserts text
** at each "%%" line.  Also, any "P-a-r-s-e" identifer prefix (without the
** interstitial "-" characters) contained in this template is changed into
** the value of the %name directive from the grammar.  Otherwise, the content
** of this template is copied straight through into the generate parser
** source file.
**
** The following is the concatenation of all %include directives from the
** input grammar file:
*/
#include <stdio.h>
/************ Begin %include sections from the grammar ************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>

#include "tsql.h"
#include "tutil.h"
/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols
** in a format understandable to "makeheaders".  This section is blank unless
** "lemon" is run with the "-m" command-line option.
***************** Begin makeheaders token definitions *************************/
/**************** End makeheaders token definitions ***************************/

/* The next sections is a series of control #defines.
** various aspects of the generated parser.
**    YYCODETYPE         is the data type used to store the integer codes
**                       that represent terminal and non-terminal symbols.
**                       "unsigned char" is used if there are fewer than
**                       256 symbols.  Larger types otherwise.
**    YYNOCODE           is a number of type YYCODETYPE that is not used for
**                       any terminal or nonterminal symbol.
**    YYFALLBACK         If defined, this indicates that one or more tokens
**                       (also known as: "terminal symbols") have fall-back
**                       values which should be used if the original symbol
**                       would not parse.  This permits keywords to sometimes
**                       be used as identifiers, for example.
**    YYACTIONTYPE       is the data type used for "action codes" - numbers
**                       that indicate what to do in response to the next
**                       token.
**    ParseTOKENTYPE     is the data type used for minor type for terminal
**                       symbols.  Background: A "minor type" is a semantic
**                       value associated with a terminal or non-terminal
**                       symbols.  For example, for an "ID" terminal symbol,
**                       the minor type might be the name of the identifier.
**                       Each non-terminal can have a different minor type.
**                       Terminal symbols all have the same minor type, though.
**                       This macros defines the minor type for terminal 
**                       symbols.
**    YYMINORTYPE        is the data type used for all minor types.
**                       This is typically a union of many types, one of
**                       which is ParseTOKENTYPE.  The entry in the union
**                       for terminal symbols is called "yy0".
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
**                       zero the stack is dynamically sized using realloc()
**    ParseARG_SDECL     A static variable declaration for the %extra_argument
**    ParseARG_PDECL     A parameter declaration for the %extra_argument
**    ParseARG_STORE     Code to store %extra_argument into yypParser
**    ParseARG_FETCH     Code to extract %extra_argument from yypParser
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
**    YYNSTATE           the combined number of states.
**    YYNRULE            the number of rules in the grammar
**    YY_MAX_SHIFT       Maximum value for shift actions
**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
**    YY_MIN_REDUCE      Maximum value for reduce actions
**    YY_ERROR_ACTION    The yy_action[] code for syntax error
**    YY_ACCEPT_ACTION   The yy_action[] code for accept
**    YY_NO_ACTION       The yy_action[] code for no-op
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 241
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SSQLToken
typedef union {
  int yyinit;
  ParseTOKENTYPE yy0;
  SQuerySQL* yy24;
  tSQLExprList* yy98;
  tFieldList* yy151;
104
  int64_t yy189;
H
hzcheng 已提交
105 106 107 108 109 110 111 112
  tVariantList* yy216;
  tVariant yy266;
  SCreateTableSQL* yy278;
  SLimitVal yy294;
  TAOS_FIELD yy343;
  tSQLExpr* yy370;
  int yy412;
  tSQLExprListList* yy434;
113
  SCreateDBInfo yy478;
H
hzcheng 已提交
114 115 116 117 118 119 120 121 122
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define ParseARG_SDECL SSqlInfo* pInfo;
#define ParseARG_PDECL ,SSqlInfo* pInfo
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1
123
#define YYNSTATE             218
124
#define YYNRULE              180
125 126 127 128 129 130 131 132
#define YY_MAX_SHIFT         217
#define YY_MIN_SHIFTREDUCE   348
#define YY_MAX_SHIFTREDUCE   527
#define YY_MIN_REDUCE        528
#define YY_MAX_REDUCE        707
#define YY_ERROR_ACTION      708
#define YY_ACCEPT_ACTION     709
#define YY_NO_ACTION         710
H
hzcheng 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
/************* End control #defines *******************************************/

/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
static const YYMINORTYPE yyzerominor = { 0 };

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage.  For production
** code the yytestcase() macro should be turned off.  But it is useful
** for testing.
*/
#ifndef yytestcase
# define yytestcase(X)
#endif


/* Next are the tables used to determine what action to take based on the
** current state and lookahead token.  These tables are used to implement
** functions that take a state number and lookahead value and return an
** action integer.  
**
** Suppose the action integer is N.  Then the action is determined as
** follows
**
**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead
**                                      token onto the stack and goto state N.
**
**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
**
**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
**     and YY_MAX_REDUCE

**   N == YY_ERROR_ACTION               A syntax error has occurred.
**
**   N == YY_ACCEPT_ACTION              The parser accepts its input.
**
**   N == YY_NO_ACTION                  No such action.  Denotes unused
**                                      slots in the yy_action[] table.
**
** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as
**
**      yy_action[ yy_shift_ofst[S] + X ]
**
** If the index value yy_shift_ofst[S]+X is out of range or if the value
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
** and that yy_default[S] should be used instead.  
**
** The formula above is for computing the action when the lookahead is
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
** YY_SHIFT_USE_DFLT.
**
** The following are the tables generated in this section:
**
**  yy_action[]        A single table containing all actions.
**  yy_lookahead[]     A table containing the lookahead for each entry in
**                     yy_action.  Used to detect hash collisions.
**  yy_shift_ofst[]    For each state, the offset into yy_action for
**                     shifting terminals.
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
204
#define YY_ACTTAB_COUNT (474)
H
hzcheng 已提交
205
static const YYACTIONTYPE yy_action[] = {
206 207 208 209 210 211
 /*     0 */   380,   31,   30,  709,  217,   29,   28,   27,  381,   68,
 /*    10 */    69,   75,   38,   40,  380,   32,   33,  212,  438,   70,
 /*    20 */    26,   54,  381,  183,   36,   34,   37,   35,  133,  216,
 /*    30 */   436,    7,   31,   30,   58,   99,   29,   28,   27,   38,
 /*    40 */    40,  432,   32,   33,  429,   10,  430,   26,  431,  115,
 /*    50 */   183,   36,   34,   37,   35,  443,   89,  139,  510,   31,
212
 /*    60 */    30,  113,  115,   29,   28,   27,   38,   40,  149,   32,
213 214 215
 /*    70 */    33,  509,  134,  151,   26,  115,   45,  183,   36,   34,
 /*    80 */    37,   35,   89,  138,  510,  112,   31,   30,  380,   53,
 /*    90 */    29,   28,   27,   46,  440,   40,  381,   32,   33,  465,
216
 /*   100 */    89,  178,   26,  114,  136,  183,   36,   34,   37,   35,
217 218 219 220
 /*   110 */   102,  103,   61,  478,   31,   30,  428,  146,   29,   28,
 /*   120 */    27,   20,   20,  180,  150,   55,   89,  205,  204,  428,
 /*   130 */   119,  433,  349,  350,  351,  352,  353,  354,  355,  356,
 /*   140 */   357,  358,  359,  464,  147,  148,  425,  425,  210,   32,
221
 /*   150 */    33,   29,   28,   27,   26,  199,  157,  183,   36,   34,
222
 /*   160 */    37,   35,  484,  165,  487,  162,   31,   30,  426,   56,
223
 /*   170 */    29,   28,   27,   17,  198,  197,  196,  195,  194,  193,
224 225 226 227 228 229 230 231 232
 /*   180 */   192,  191,  190,  189,  412,  506,  401,  402,  403,  404,
 /*   190 */   405,  406,  407,  408,  409,  410,  411,  143,  491,  113,
 /*   200 */   200,  482,   11,  485,   48,  488,   20,  143,  491,  416,
 /*   210 */   135,  482,  428,  485,   57,  488,  459,  460,  132,   49,
 /*   220 */   505,   20,   77,   76,  126,   23,  427,   20,  504,  140,
 /*   230 */   141,  424,  131,  182,  109,  107,   78,  208,  207,  140,
 /*   240 */   141,  143,  491,  441,  206,  482,  425,  485,  129,  488,
 /*   250 */   211,   22,  425,  514,  215,  214,  368,   24,  515,  450,
 /*   260 */   480,  451,   24,   42,  508,   15,  492,  142,   14,  171,
233
 /*   270 */    14,  130,  167,  140,  141,   36,   34,   37,   35,  128,
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
 /*   280 */   120,  422,   39,   31,   30,   42,  421,   29,   28,   27,
 /*   290 */    21,  490,   39,  483,  187,  486,  481,    2,   21,   67,
 /*   300 */    66,  490,    9,    8,  121,  434,  489,  435,   74,   73,
 /*   310 */   122,  123,  124,  125,  117,  524,  489,  111,  118,  116,
 /*   320 */   413,  475,  442,  474,   86,   98,   39,  144,  471,  470,
 /*   330 */   145,  457,  419,  209,  456,  490,  100,  101,  387,  188,
 /*   340 */   110,  203,  523,   64,  522,  520,  104,  168,   80,  105,
 /*   350 */   489,  378,  377,   71,  375,  374,  446,  152,  106,  372,
 /*   360 */   371,  170,   50,   47,  437,  370,  363,  172,  108,  176,
 /*   370 */   367,  365,   41,  181,   84,  445,  179,  458,  177,  175,
 /*   380 */   173,   25,   22,  202,  185,   90,   44,  213,  527,  153,
 /*   390 */   154,   51,  155,  156,  127,   59,   62,  526,  379,  373,
 /*   400 */   158,   79,   81,  369,  159,  423,  160,  161,    1,   96,
 /*   410 */    93,   91,   92,   94,  525,   95,   97,  163,  164,  518,
 /*   420 */   166,   12,   13,  169,   85,  447,   87,  137,  174,    4,
 /*   430 */    18,  452,   88,    5,  493,    3,   19,   16,  184,    6,
 /*   440 */   186,   60,  399,  398,  397,  396,  395,  394,  393,  392,
 /*   450 */   391,   42,  390,  389,  384,   21,  418,  201,  417,   63,
 /*   460 */   415,   52,  382,   72,  361,   43,  528,  530,  530,  530,
 /*   470 */   530,   82,   65,   83,
H
hzcheng 已提交
254 255 256
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */     1,   33,   34,  187,  188,   37,   38,   39,    9,   61,
257 258 259 260
 /*    10 */    62,   63,   13,   14,    1,   16,   17,   69,   91,   71,
 /*    20 */    21,   94,    9,   24,   25,   26,   27,   28,  189,  190,
 /*    30 */   214,   86,   33,   34,   89,   90,   37,   38,   39,   13,
 /*    40 */    14,    2,   16,   17,    5,  228,    7,   21,    9,  228,
H
hzcheng 已提交
261
 /*    50 */    24,   25,   26,   27,   28,  190,  190,  236,  237,   33,
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
 /*    60 */    34,  228,  228,   37,   38,   39,   13,   14,   60,   16,
 /*    70 */    17,  237,  239,   34,   21,  228,   91,   24,   25,   26,
 /*    80 */    27,   28,  190,  236,  237,  228,   33,   34,    1,   90,
 /*    90 */    37,   38,   39,  108,  229,   14,    9,   16,   17,  233,
 /*   100 */   190,  235,   21,  228,  197,   24,   25,   26,   27,   28,
 /*   110 */    61,   62,   63,   87,   33,   34,  209,  197,   37,   38,
 /*   120 */    39,  190,  190,  231,  116,  233,  190,  119,  120,  209,
 /*   130 */   228,   92,   45,   46,   47,   48,   49,   50,   51,   52,
 /*   140 */    53,   54,   55,  233,  213,  213,  215,  215,  190,   16,
 /*   150 */    17,   37,   38,   39,   21,   57,  115,   24,   25,   26,
 /*   160 */    27,   28,    5,  122,    7,  124,   33,   34,  210,  233,
 /*   170 */    37,   38,   39,   75,   76,   77,   78,   79,   80,   81,
 /*   180 */    82,   83,   84,   85,  196,  228,  198,  199,  200,  201,
 /*   190 */   202,  203,  204,  205,  206,  207,  208,    1,    2,  228,
 /*   200 */   197,    5,   44,    7,   91,    9,  190,    1,    2,    5,
 /*   210 */   239,    5,  209,    7,  216,    9,  101,  102,   60,  106,
 /*   220 */   228,  190,   64,   65,   66,  227,  209,  190,  228,   33,
 /*   230 */    34,  215,   74,   37,   61,   62,   63,   33,   34,   33,
 /*   240 */    34,    1,    2,   37,  213,    5,  215,    7,  228,    9,
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
 /*   250 */   213,   93,  215,   87,   57,   58,   59,   91,   87,   87,
 /*   260 */     1,   87,   91,   91,   87,   91,   87,   56,   91,  111,
 /*   270 */    91,  228,  114,   33,   34,   25,   26,   27,   28,  121,
 /*   280 */   228,   87,   86,   33,   34,   91,   87,   37,   38,   39,
 /*   290 */    91,   95,   86,    5,   87,    7,   37,   86,   91,  117,
 /*   300 */   118,   95,  117,  118,  228,    5,  110,    7,   67,   68,
 /*   310 */   228,  228,  228,  228,  228,  209,  110,  228,  228,  228,
 /*   320 */   209,  211,  190,  211,  190,  217,   86,  211,  211,  211,
 /*   330 */   211,  234,  212,  211,  234,   95,  190,  190,  190,  190,
 /*   340 */   190,  190,  190,  190,  190,  190,  190,  113,   56,  190,
 /*   350 */   110,  190,  190,  190,  190,  190,   95,  190,  190,  190,
 /*   360 */   190,  238,  105,  107,  226,  190,  190,  230,  190,  230,
 /*   370 */   190,  190,  104,   99,  191,  191,  103,  191,   98,   97,
 /*   380 */    96,  109,   93,   72,  191,  225,   77,   72,    5,  123,
 /*   390 */     5,  191,  123,   70,  191,  194,  194,    5,  193,  191,
 /*   400 */   123,  192,  192,  191,    5,  214,  123,   70,  195,  219,
 /*   410 */   222,  224,  223,  221,    5,  220,  218,  123,   70,   76,
 /*   420 */   115,   86,   86,  113,  112,   87,   86,    1,   86,  100,
 /*   430 */    91,   87,   86,  100,   87,   86,   91,   86,   88,   86,
 /*   440 */    88,   67,    9,    5,    5,    5,    5,    1,    5,    5,
 /*   450 */     5,   91,    5,    5,   73,   91,    5,   15,    5,  118,
 /*   460 */    87,   86,   73,   70,   56,   16,    0,  240,  240,  240,
303
 /*   470 */   240,   21,  118,   21,
H
hzcheng 已提交
304 305
};
#define YY_SHIFT_USE_DFLT (-74)
306
#define YY_SHIFT_COUNT (217)
H
hzcheng 已提交
307
#define YY_SHIFT_MIN   (-73)
308
#define YY_SHIFT_MAX   (466)
H
hzcheng 已提交
309
static const short yy_shift_ofst[] = {
310 311 312 313 314 315 316 317
 /*     0 */   158,   98,  196,  240,   13,   13,   13,   13,   13,   13,
 /*    10 */    -1,   87,  240,  240,  240,   39,   39,   39,   13,   13,
 /*    20 */    13,   13,  -74,  206,  240,  240,  240,  240,  240,  240,
 /*    30 */   240,  240,  240,  240,  240,  240,  240,  240,  240,  240,
 /*    40 */   240,  240,   39,   39,   39,  204,  204,  204,  204,  204,
 /*    50 */   204,  -55,  204,   13,   13,  115,  115,  -73,   13,   13,
 /*    60 */    13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
 /*    70 */    13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
318 319 320
 /*    80 */    13,   13,   13,   13,  234,  292,  292,  261,  261,  292,
 /*    90 */   257,  256,  268,  274,  273,  280,  282,  284,  272,  289,
 /*   100 */   292,  292,  311,  311,  292,  309,  292,  315,  292,  315,
321 322
 /*   110 */   -74,   26,   53,   53,   53,   53,   53,   81,  133,  250,
 /*   120 */   250,  250,  -32,  -32,  -32,  -32,  -52,    8,   41,  114,
323 324 325 326 327 328 329
 /*   130 */   114,   49,  173,  197,  166,  171,  172,  174,  177,  179,
 /*   140 */   157,  288,  259,  211,  -15,  113,  194,  199,  207,  182,
 /*   150 */   185,  300,  241,  383,  266,  385,  269,  323,  392,  277,
 /*   160 */   399,  283,  337,  409,  294,  348,  343,  305,  335,  336,
 /*   170 */   310,  312,  338,  340,  426,  342,  344,  346,  339,  329,
 /*   180 */   345,  333,  347,  349,  351,  350,  353,  352,  374,  433,
 /*   190 */   438,  439,  440,  441,  446,  443,  444,  445,  447,  448,
330 331
 /*   200 */   360,  381,  442,  449,  341,  354,  364,  451,  453,  373,
 /*   210 */   375,  364,  393,  389,  450,  452,  408,  466,
H
hzcheng 已提交
332
};
333 334 335
#define YY_REDUCE_USE_DFLT (-185)
#define YY_REDUCE_COUNT (110)
#define YY_REDUCE_MIN   (-184)
336
#define YY_REDUCE_MAX   (213)
H
hzcheng 已提交
337
static const short yy_reduce_ofst[] = {
338 339 340
 /*     0 */  -184,  -12, -179, -153, -134, -108,  -69,  -68,   31,   37,
 /*    10 */  -135, -161, -167,  -29, -166,  -93,  -80,    3,  -90,  -64,
 /*    20 */   -42,   16,   -2, -183, -143, -125,  -98,  -43,   -8,    0,
341 342 343 344 345 346 347 348 349
 /*    30 */    20,   43,   52,   76,   82,   83,   84,   85,   86,   89,
 /*    40 */    90,   91,   17,  106,  111,  110,  112,  116,  117,  118,
 /*    50 */   119,  120,  122,  132,  134,   97,  100,  108,  146,  147,
 /*    60 */   148,  149,  150,  151,  152,  153,  154,  155,  156,  159,
 /*    70 */   161,  162,  163,  164,  165,  167,  168,  169,  170,  175,
 /*    80 */   176,  178,  180,  181,  123,  183,  184,  137,  139,  186,
 /*    90 */   138,  160,  187,  189,  188,  192,  195,  190,  198,  191,
 /*   100 */   193,  200,  201,  202,  203,  205,  208,  209,  212,  210,
 /*   110 */   213,
H
hzcheng 已提交
350 351
};
static const YYACTIONTYPE yy_default[] = {
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
 /*     0 */   708,  566,  692,  692,  708,  708,  708,  708,  708,  708,
 /*    10 */   624,  540,  708,  708,  692,  708,  708,  708,  708,  708,
 /*    20 */   708,  708,  619,  708,  708,  708,  708,  708,  708,  708,
 /*    30 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*    40 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*    50 */   708,  708,  708,  708,  708,  641,  641,  708,  708,  708,
 /*    60 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*    70 */   708,  556,  708,  708,  708,  708,  708,  708,  708,  708,
 /*    80 */   708,  708,  708,  708,  708,  542,  542,  708,  708,  542,
 /*    90 */   648,  652,  646,  634,  642,  633,  629,  628,  656,  708,
 /*   100 */   542,  542,  565,  565,  542,  708,  542,  563,  542,  563,
 /*   110 */   580,  708,  696,  697,  657,  691,  647,  675,  674,  687,
 /*   120 */   681,  680,  679,  678,  677,  676,  708,  708,  708,  683,
 /*   130 */   682,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*   140 */   708,  708,  708,  659,  653,  649,  708,  708,  708,  708,
 /*   150 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*   160 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*   170 */   693,  708,  708,  708,  708,  708,  708,  708,  643,  708,
 /*   180 */   635,  708,  708,  708,  708,  708,  708,  600,  708,  708,
 /*   190 */   708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
 /*   200 */   568,  708,  708,  708,  708,  708,  701,  708,  708,  708,
 /*   210 */   594,  699,  708,  708,  546,  544,  708,  708,
H
hzcheng 已提交
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
};
/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.  
** If a construct like the following:
** 
**      %fallback ID X Y Z.
**
** appears in the grammar, then ID becomes a fallback token for X, Y,
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
** but it does not parse, the type of the token is changed to ID and
** the parse is retried before an error is thrown.
**
** This feature can be used, for example, to cause some keywords in a language
** to revert to identifiers if they keyword does not apply in the context where
** it appears.
*/
#ifdef YYFALLBACK
static const YYCODETYPE yyFallback[] = {
    0,  /*          $ => nothing */
    0,  /*         ID => nothing */
    1,  /*       BOOL => ID */
    1,  /*    TINYINT => ID */
    1,  /*   SMALLINT => ID */
    1,  /*    INTEGER => ID */
    1,  /*     BIGINT => ID */
    1,  /*      FLOAT => ID */
    1,  /*     DOUBLE => ID */
    1,  /*     STRING => ID */
    1,  /*  TIMESTAMP => ID */
    1,  /*     BINARY => ID */
    1,  /*      NCHAR => ID */
    0,  /*         OR => nothing */
    0,  /*        AND => nothing */
    0,  /*        NOT => nothing */
    0,  /*         EQ => nothing */
    0,  /*         NE => nothing */
    0,  /*     ISNULL => nothing */
    0,  /*    NOTNULL => nothing */
    0,  /*         IS => nothing */
    1,  /*       LIKE => ID */
    1,  /*       GLOB => ID */
    0,  /*    BETWEEN => nothing */
    0,  /*         IN => nothing */
    0,  /*         GT => nothing */
    0,  /*         GE => nothing */
    0,  /*         LT => nothing */
    0,  /*         LE => nothing */
    0,  /*     BITAND => nothing */
    0,  /*      BITOR => nothing */
    0,  /*     LSHIFT => nothing */
    0,  /*     RSHIFT => nothing */
    0,  /*       PLUS => nothing */
    0,  /*      MINUS => nothing */
    0,  /*     DIVIDE => nothing */
    0,  /*      TIMES => nothing */
    0,  /*       STAR => nothing */
    0,  /*      SLASH => nothing */
    0,  /*        REM => nothing */
    0,  /*     CONCAT => nothing */
    0,  /*     UMINUS => nothing */
    0,  /*      UPLUS => nothing */
    0,  /*     BITNOT => nothing */
    0,  /*       SHOW => nothing */
    0,  /*  DATABASES => nothing */
    0,  /*     MNODES => nothing */
    0,  /*     DNODES => nothing */
    0,  /*      USERS => nothing */
    0,  /*    MODULES => nothing */
    0,  /*    QUERIES => nothing */
    0,  /* CONNECTIONS => nothing */
    0,  /*    STREAMS => nothing */
    0,  /*    CONFIGS => nothing */
    0,  /*     SCORES => nothing */
    0,  /*     GRANTS => nothing */
    0,  /*        DOT => nothing */
    0,  /*     TABLES => nothing */
    0,  /*    STABLES => nothing */
    0,  /*    VGROUPS => nothing */
    0,  /*       DROP => nothing */
    0,  /*      TABLE => nothing */
    1,  /*   DATABASE => ID */
    0,  /*       USER => nothing */
    0,  /*        USE => nothing */
    0,  /*   DESCRIBE => nothing */
    0,  /*      ALTER => nothing */
    0,  /*       PASS => nothing */
    0,  /*  PRIVILEGE => nothing */
    0,  /*      DNODE => nothing */
    1,  /*         IP => ID */
    0,  /*      LOCAL => nothing */
    0,  /*         IF => nothing */
    0,  /*     EXISTS => nothing */
    0,  /*     CREATE => nothing */
    0,  /*       KEEP => nothing */
469
    0,  /*      CACHE => nothing */
H
hzcheng 已提交
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
    0,  /*    REPLICA => nothing */
    0,  /*       DAYS => nothing */
    0,  /*       ROWS => nothing */
    0,  /*    ABLOCKS => nothing */
    0,  /*    TBLOCKS => nothing */
    0,  /*      CTIME => nothing */
    0,  /*       CLOG => nothing */
    0,  /*       COMP => nothing */
    0,  /*  PRECISION => nothing */
    0,  /*         LP => nothing */
    0,  /*         RP => nothing */
    0,  /*       TAGS => nothing */
    0,  /*      USING => nothing */
    0,  /*         AS => nothing */
    0,  /*      COMMA => nothing */
    0,  /*       NULL => nothing */
    0,  /*     SELECT => nothing */
    0,  /*       FROM => nothing */
    0,  /*   VARIABLE => nothing */
    0,  /*   INTERVAL => nothing */
    0,  /*       FILL => nothing */
    0,  /*    SLIDING => nothing */
    0,  /*      ORDER => nothing */
    0,  /*         BY => nothing */
    1,  /*        ASC => ID */
    1,  /*       DESC => ID */
    0,  /*      GROUP => nothing */
    0,  /*     HAVING => nothing */
    0,  /*      LIMIT => nothing */
    1,  /*     OFFSET => ID */
    0,  /*     SLIMIT => nothing */
    0,  /*    SOFFSET => nothing */
    0,  /*      WHERE => nothing */
    1,  /*        NOW => ID */
    0,  /*     INSERT => nothing */
    0,  /*       INTO => nothing */
    0,  /*     VALUES => nothing */
    0,  /*      RESET => nothing */
    0,  /*      QUERY => nothing */
    0,  /*        ADD => nothing */
    0,  /*     COLUMN => nothing */
    0,  /*        TAG => nothing */
    0,  /*     CHANGE => nothing */
    0,  /*        SET => nothing */
    0,  /*       KILL => nothing */
    0,  /* CONNECTION => nothing */
    0,  /*      COLON => nothing */
    0,  /*     STREAM => nothing */
    1,  /*      ABORT => ID */
    1,  /*      AFTER => ID */
    1,  /*     ATTACH => ID */
    1,  /*     BEFORE => ID */
    1,  /*      BEGIN => ID */
    1,  /*    CASCADE => ID */
    1,  /*    CLUSTER => ID */
    1,  /*   CONFLICT => ID */
    1,  /*       COPY => ID */
    1,  /*   DEFERRED => ID */
    1,  /* DELIMITERS => ID */
    1,  /*     DETACH => ID */
    1,  /*       EACH => ID */
    1,  /*        END => ID */
    1,  /*    EXPLAIN => ID */
    1,  /*       FAIL => ID */
    1,  /*        FOR => ID */
    1,  /*     IGNORE => ID */
    1,  /*  IMMEDIATE => ID */
    1,  /*  INITIALLY => ID */
    1,  /*    INSTEAD => ID */
    1,  /*      MATCH => ID */
    1,  /*        KEY => ID */
    1,  /*         OF => ID */
    1,  /*      RAISE => ID */
    1,  /*    REPLACE => ID */
    1,  /*   RESTRICT => ID */
    1,  /*        ROW => ID */
    1,  /*  STATEMENT => ID */
    1,  /*    TRIGGER => ID */
    1,  /*       VIEW => ID */
    1,  /*        ALL => ID */
    1,  /*      COUNT => ID */
    1,  /*        SUM => ID */
    1,  /*        AVG => ID */
    1,  /*        MIN => ID */
    1,  /*        MAX => ID */
    1,  /*      FIRST => ID */
    1,  /*       LAST => ID */
    1,  /*        TOP => ID */
    1,  /*     BOTTOM => ID */
    1,  /*     STDDEV => ID */
    1,  /* PERCENTILE => ID */
    1,  /* APERCENTILE => ID */
    1,  /* LEASTSQUARES => ID */
    1,  /*  HISTOGRAM => ID */
    1,  /*       DIFF => ID */
    1,  /*     SPREAD => ID */
    1,  /*       WAVG => ID */
    1,  /*     INTERP => ID */
    1,  /*   LAST_ROW => ID */
    1,  /*       SEMI => ID */
    1,  /*       NONE => ID */
    1,  /*       PREV => ID */
    1,  /*     LINEAR => ID */
    1,  /*     IMPORT => ID */
    1,  /*     METRIC => ID */
    1,  /*     TBNAME => ID */
    1,  /*       JOIN => ID */
    1,  /*    METRICS => ID */
    1,  /*     STABLE => ID */
};
#endif /* YYFALLBACK */

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:
**
**   +  The state number for the parser at this level of the stack.
**
**   +  The value of the token stored at this level of the stack.
**      (In other words, the "major" token.)
**
**   +  The semantic value stored at this level of the stack.  This is
**      the information used by the action routines in the grammar.
**      It is sometimes called the "minor" token.
**
** After the "shift" half of a SHIFTREDUCE action, the stateno field
** actually contains the reduce action for the second half of the
** SHIFTREDUCE.
*/
struct yyStackEntry {
  YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */
  YYCODETYPE major;      /* The major token value.  This is the code
                         ** number for the token at this stack level */
  YYMINORTYPE minor;     /* The user-supplied minor token value.  This
                         ** is the value of the token  */
};
typedef struct yyStackEntry yyStackEntry;

/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
  int yyidx;                    /* Index of top element in stack */
#ifdef YYTRACKMAXSTACKDEPTH
  int yyidxMax;                 /* Maximum value of yyidx */
#endif
  int yyerrcnt;                 /* Shifts left before out of the error */
  ParseARG_SDECL                /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0
  int yystksz;                  /* Current side of the stack */
  yyStackEntry *yystack;        /* The parser's stack */
#else
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
#endif
};
typedef struct yyParser yyParser;

#ifndef NDEBUG
#include <stdio.h>
static FILE *yyTraceFILE = 0;
static char *yyTracePrompt = 0;
#endif /* NDEBUG */

#ifndef NDEBUG
/* 
** Turn parser tracing on by giving a stream to which to write the trace
** and a prompt to preface each trace message.  Tracing is turned off
** by making either argument NULL 
**
** Inputs:
** <ul>
** <li> A FILE* to which trace output should be written.
**      If NULL, then tracing is turned off.
** <li> A prefix string written at the beginning of every
**      line of trace output.  If NULL, then tracing is
**      turned off.
** </ul>
**
** Outputs:
** None.
*/
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
  yyTraceFILE = TraceFILE;
  yyTracePrompt = zTracePrompt;
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
}
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required.  The following table supplies these names */
static const char *const yyTokenName[] = { 
  "$",             "ID",            "BOOL",          "TINYINT",     
  "SMALLINT",      "INTEGER",       "BIGINT",        "FLOAT",       
  "DOUBLE",        "STRING",        "TIMESTAMP",     "BINARY",      
  "NCHAR",         "OR",            "AND",           "NOT",         
  "EQ",            "NE",            "ISNULL",        "NOTNULL",     
  "IS",            "LIKE",          "GLOB",          "BETWEEN",     
  "IN",            "GT",            "GE",            "LT",          
  "LE",            "BITAND",        "BITOR",         "LSHIFT",      
  "RSHIFT",        "PLUS",          "MINUS",         "DIVIDE",      
  "TIMES",         "STAR",          "SLASH",         "REM",         
  "CONCAT",        "UMINUS",        "UPLUS",         "BITNOT",      
  "SHOW",          "DATABASES",     "MNODES",        "DNODES",      
  "USERS",         "MODULES",       "QUERIES",       "CONNECTIONS", 
  "STREAMS",       "CONFIGS",       "SCORES",        "GRANTS",      
  "DOT",           "TABLES",        "STABLES",       "VGROUPS",     
  "DROP",          "TABLE",         "DATABASE",      "USER",        
  "USE",           "DESCRIBE",      "ALTER",         "PASS",        
  "PRIVILEGE",     "DNODE",         "IP",            "LOCAL",       
  "IF",            "EXISTS",        "CREATE",        "KEEP",        
680
  "CACHE",         "REPLICA",       "DAYS",          "ROWS",        
H
hzcheng 已提交
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
  "ABLOCKS",       "TBLOCKS",       "CTIME",         "CLOG",        
  "COMP",          "PRECISION",     "LP",            "RP",          
  "TAGS",          "USING",         "AS",            "COMMA",       
  "NULL",          "SELECT",        "FROM",          "VARIABLE",    
  "INTERVAL",      "FILL",          "SLIDING",       "ORDER",       
  "BY",            "ASC",           "DESC",          "GROUP",       
  "HAVING",        "LIMIT",         "OFFSET",        "SLIMIT",      
  "SOFFSET",       "WHERE",         "NOW",           "INSERT",      
  "INTO",          "VALUES",        "RESET",         "QUERY",       
  "ADD",           "COLUMN",        "TAG",           "CHANGE",      
  "SET",           "KILL",          "CONNECTION",    "COLON",       
  "STREAM",        "ABORT",         "AFTER",         "ATTACH",      
  "BEFORE",        "BEGIN",         "CASCADE",       "CLUSTER",     
  "CONFLICT",      "COPY",          "DEFERRED",      "DELIMITERS",  
  "DETACH",        "EACH",          "END",           "EXPLAIN",     
  "FAIL",          "FOR",           "IGNORE",        "IMMEDIATE",   
  "INITIALLY",     "INSTEAD",       "MATCH",         "KEY",         
  "OF",            "RAISE",         "REPLACE",       "RESTRICT",    
  "ROW",           "STATEMENT",     "TRIGGER",       "VIEW",        
  "ALL",           "COUNT",         "SUM",           "AVG",         
  "MIN",           "MAX",           "FIRST",         "LAST",        
  "TOP",           "BOTTOM",        "STDDEV",        "PERCENTILE",  
  "APERCENTILE",   "LEASTSQUARES",  "HISTOGRAM",     "DIFF",        
  "SPREAD",        "WAVG",          "INTERP",        "LAST_ROW",    
  "SEMI",          "NONE",          "PREV",          "LINEAR",      
  "IMPORT",        "METRIC",        "TBNAME",        "JOIN",        
  "METRICS",       "STABLE",        "error",         "program",     
  "cmd",           "dbPrefix",      "ids",           "cpxName",     
  "ifexists",      "alter_db_optr",  "ifnotexists",   "db_optr",     
710 711 712 713 714
  "keep",          "tagitemlist",   "tables",        "cache",       
  "replica",       "days",          "rows",          "ablocks",     
  "tblocks",       "ctime",         "clog",          "comp",        
  "prec",          "tagitem",       "typename",      "signed",      
  "create_table_args",  "columnlist",    "select",        "column",      
H
hzcheng 已提交
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
  "selcollist",    "from",          "where_opt",     "interval_opt",
  "fill_opt",      "sliding_opt",   "groupby_opt",   "orderby_opt", 
  "having_opt",    "slimit_opt",    "limit_opt",     "sclp",        
  "expr",          "as",            "tmvar",         "sortlist",    
  "sortitem",      "item",          "sortorder",     "grouplist",   
  "exprlist",      "expritem",      "insert_value_list",  "itemlist",    
};
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
 /*   0 */ "program ::= cmd",
 /*   1 */ "cmd ::= SHOW DATABASES",
 /*   2 */ "cmd ::= SHOW MNODES",
 /*   3 */ "cmd ::= SHOW DNODES",
 /*   4 */ "cmd ::= SHOW USERS",
 /*   5 */ "cmd ::= SHOW MODULES",
 /*   6 */ "cmd ::= SHOW QUERIES",
 /*   7 */ "cmd ::= SHOW CONNECTIONS",
 /*   8 */ "cmd ::= SHOW STREAMS",
 /*   9 */ "cmd ::= SHOW CONFIGS",
 /*  10 */ "cmd ::= SHOW SCORES",
 /*  11 */ "cmd ::= SHOW GRANTS",
 /*  12 */ "dbPrefix ::=",
 /*  13 */ "dbPrefix ::= ids DOT",
 /*  14 */ "cpxName ::=",
 /*  15 */ "cpxName ::= DOT ids",
 /*  16 */ "cmd ::= SHOW dbPrefix TABLES",
 /*  17 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids",
 /*  18 */ "cmd ::= SHOW dbPrefix STABLES",
 /*  19 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids",
 /*  20 */ "cmd ::= SHOW dbPrefix VGROUPS",
 /*  21 */ "cmd ::= DROP TABLE ifexists ids cpxName",
 /*  22 */ "cmd ::= DROP DATABASE ifexists ids",
 /*  23 */ "cmd ::= DROP USER ids",
 /*  24 */ "cmd ::= USE ids",
 /*  25 */ "cmd ::= DESCRIBE ids cpxName",
 /*  26 */ "cmd ::= ALTER USER ids PASS ids",
 /*  27 */ "cmd ::= ALTER USER ids PRIVILEGE ids",
 /*  28 */ "cmd ::= ALTER DNODE IP ids",
 /*  29 */ "cmd ::= ALTER DNODE IP ids ids",
 /*  30 */ "cmd ::= ALTER LOCAL ids",
 /*  31 */ "cmd ::= ALTER DATABASE ids alter_db_optr",
 /*  32 */ "ids ::= ID",
 /*  33 */ "ids ::= STRING",
 /*  34 */ "ifexists ::= IF EXISTS",
 /*  35 */ "ifexists ::=",
 /*  36 */ "ifnotexists ::= IF NOT EXISTS",
 /*  37 */ "ifnotexists ::=",
 /*  38 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr",
 /*  39 */ "cmd ::= CREATE USER ids PASS ids",
768 769 770
 /*  40 */ "keep ::= KEEP tagitemlist",
 /*  41 */ "tables ::= TABLES INTEGER",
 /*  42 */ "cache ::= CACHE INTEGER",
H
hzcheng 已提交
771
 /*  43 */ "replica ::= REPLICA INTEGER",
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
 /*  44 */ "days ::= DAYS INTEGER",
 /*  45 */ "rows ::= ROWS INTEGER",
 /*  46 */ "ablocks ::= ABLOCKS ID",
 /*  47 */ "tblocks ::= TBLOCKS INTEGER",
 /*  48 */ "ctime ::= CTIME INTEGER",
 /*  49 */ "clog ::= CLOG INTEGER",
 /*  50 */ "comp ::= COMP INTEGER",
 /*  51 */ "prec ::= PRECISION STRING",
 /*  52 */ "db_optr ::=",
 /*  53 */ "db_optr ::= db_optr tables",
 /*  54 */ "db_optr ::= db_optr cache",
 /*  55 */ "db_optr ::= db_optr replica",
 /*  56 */ "db_optr ::= db_optr days",
 /*  57 */ "db_optr ::= db_optr rows",
 /*  58 */ "db_optr ::= db_optr ablocks",
 /*  59 */ "db_optr ::= db_optr tblocks",
 /*  60 */ "db_optr ::= db_optr ctime",
 /*  61 */ "db_optr ::= db_optr clog",
 /*  62 */ "db_optr ::= db_optr comp",
 /*  63 */ "db_optr ::= db_optr prec",
 /*  64 */ "db_optr ::= db_optr keep",
 /*  65 */ "alter_db_optr ::= REPLICA tagitem",
H
hzcheng 已提交
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
 /*  66 */ "typename ::= ids",
 /*  67 */ "typename ::= ids LP signed RP",
 /*  68 */ "signed ::= INTEGER",
 /*  69 */ "signed ::= PLUS INTEGER",
 /*  70 */ "signed ::= MINUS INTEGER",
 /*  71 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args",
 /*  72 */ "create_table_args ::= LP columnlist RP",
 /*  73 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP",
 /*  74 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP",
 /*  75 */ "create_table_args ::= AS select",
 /*  76 */ "columnlist ::= columnlist COMMA column",
 /*  77 */ "columnlist ::= column",
 /*  78 */ "column ::= ids typename",
 /*  79 */ "tagitemlist ::= tagitemlist COMMA tagitem",
 /*  80 */ "tagitemlist ::= tagitem",
 /*  81 */ "tagitem ::= INTEGER",
 /*  82 */ "tagitem ::= FLOAT",
 /*  83 */ "tagitem ::= STRING",
 /*  84 */ "tagitem ::= BOOL",
 /*  85 */ "tagitem ::= NULL",
 /*  86 */ "tagitem ::= MINUS INTEGER",
 /*  87 */ "tagitem ::= MINUS FLOAT",
 /*  88 */ "cmd ::= select",
 /*  89 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
 /*  90 */ "sclp ::= selcollist COMMA",
 /*  91 */ "sclp ::=",
 /*  92 */ "selcollist ::= sclp expr as",
 /*  93 */ "selcollist ::= sclp STAR",
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903
 /*  94 */ "as ::= AS ids",
 /*  95 */ "as ::= ids",
 /*  96 */ "as ::=",
 /*  97 */ "from ::= FROM ids cpxName",
 /*  98 */ "tmvar ::= VARIABLE",
 /*  99 */ "interval_opt ::= INTERVAL LP tmvar RP",
 /* 100 */ "interval_opt ::=",
 /* 101 */ "fill_opt ::=",
 /* 102 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
 /* 103 */ "fill_opt ::= FILL LP ID RP",
 /* 104 */ "sliding_opt ::= SLIDING LP tmvar RP",
 /* 105 */ "sliding_opt ::=",
 /* 106 */ "orderby_opt ::=",
 /* 107 */ "orderby_opt ::= ORDER BY sortlist",
 /* 108 */ "sortlist ::= sortlist COMMA item sortorder",
 /* 109 */ "sortlist ::= item sortorder",
 /* 110 */ "item ::= ids cpxName",
 /* 111 */ "sortorder ::= ASC",
 /* 112 */ "sortorder ::= DESC",
 /* 113 */ "sortorder ::=",
 /* 114 */ "groupby_opt ::=",
 /* 115 */ "groupby_opt ::= GROUP BY grouplist",
 /* 116 */ "grouplist ::= grouplist COMMA item",
 /* 117 */ "grouplist ::= item",
 /* 118 */ "having_opt ::=",
 /* 119 */ "having_opt ::= HAVING expr",
 /* 120 */ "limit_opt ::=",
 /* 121 */ "limit_opt ::= LIMIT signed",
 /* 122 */ "limit_opt ::= LIMIT signed OFFSET signed",
 /* 123 */ "limit_opt ::= LIMIT signed COMMA signed",
 /* 124 */ "slimit_opt ::=",
 /* 125 */ "slimit_opt ::= SLIMIT signed",
 /* 126 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
 /* 127 */ "slimit_opt ::= SLIMIT signed COMMA signed",
 /* 128 */ "where_opt ::=",
 /* 129 */ "where_opt ::= WHERE expr",
 /* 130 */ "expr ::= LP expr RP",
 /* 131 */ "expr ::= ID",
 /* 132 */ "expr ::= ID DOT ID",
 /* 133 */ "expr ::= ID DOT STAR",
 /* 134 */ "expr ::= INTEGER",
 /* 135 */ "expr ::= MINUS INTEGER",
 /* 136 */ "expr ::= PLUS INTEGER",
 /* 137 */ "expr ::= FLOAT",
 /* 138 */ "expr ::= MINUS FLOAT",
 /* 139 */ "expr ::= PLUS FLOAT",
 /* 140 */ "expr ::= STRING",
 /* 141 */ "expr ::= NOW",
 /* 142 */ "expr ::= VARIABLE",
 /* 143 */ "expr ::= BOOL",
 /* 144 */ "expr ::= ID LP exprlist RP",
 /* 145 */ "expr ::= ID LP STAR RP",
 /* 146 */ "expr ::= expr AND expr",
 /* 147 */ "expr ::= expr OR expr",
 /* 148 */ "expr ::= expr LT expr",
 /* 149 */ "expr ::= expr GT expr",
 /* 150 */ "expr ::= expr LE expr",
 /* 151 */ "expr ::= expr GE expr",
 /* 152 */ "expr ::= expr NE expr",
 /* 153 */ "expr ::= expr EQ expr",
 /* 154 */ "expr ::= expr PLUS expr",
 /* 155 */ "expr ::= expr MINUS expr",
 /* 156 */ "expr ::= expr STAR expr",
 /* 157 */ "expr ::= expr SLASH expr",
 /* 158 */ "expr ::= expr REM expr",
 /* 159 */ "expr ::= expr LIKE expr",
 /* 160 */ "expr ::= expr IN LP exprlist RP",
 /* 161 */ "exprlist ::= exprlist COMMA expritem",
 /* 162 */ "exprlist ::= expritem",
 /* 163 */ "expritem ::= expr",
 /* 164 */ "expritem ::=",
 /* 165 */ "cmd ::= INSERT INTO cpxName insert_value_list",
 /* 166 */ "insert_value_list ::= VALUES LP itemlist RP",
 /* 167 */ "insert_value_list ::= insert_value_list VALUES LP itemlist RP",
 /* 168 */ "itemlist ::= itemlist COMMA expr",
 /* 169 */ "itemlist ::= expr",
 /* 170 */ "cmd ::= RESET QUERY CACHE",
 /* 171 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
 /* 172 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
 /* 173 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
 /* 174 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
 /* 175 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
904
 /* 176 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
905 906 907
 /* 177 */ "cmd ::= KILL CONNECTION IP COLON INTEGER",
 /* 178 */ "cmd ::= KILL STREAM IP COLON INTEGER COLON INTEGER",
 /* 179 */ "cmd ::= KILL QUERY IP COLON INTEGER COLON INTEGER",
H
hzcheng 已提交
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.
*/
static void yyGrowStack(yyParser *p){
  int newSize;
  yyStackEntry *pNew;

  newSize = p->yystksz*2 + 100;
  pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  if( pNew ){
    p->yystack = pNew;
    p->yystksz = newSize;
#ifndef NDEBUG
    if( yyTraceFILE ){
      fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
              yyTracePrompt, p->yystksz);
    }
#endif
  }
}
#endif

/* Datatype of the argument to the memory allocated passed as the
** second argument to ParseAlloc() below.  This can be changed by
** putting an appropriate #define in the %include section of the input
** grammar.
*/
#ifndef YYMALLOCARGTYPE
# define YYMALLOCARGTYPE size_t
#endif

/* 
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser.  This pointer is used in subsequent calls
** to Parse and ParseFree.
*/
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
  yyParser *pParser;
  pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
  if( pParser ){
    pParser->yyidx = -1;
#ifdef YYTRACKMAXSTACKDEPTH
    pParser->yyidxMax = 0;
#endif
#if YYSTACKDEPTH<=0
    pParser->yystack = NULL;
    pParser->yystksz = 0;
    yyGrowStack(pParser);
#endif
  }
  return pParser;
}

/* The following function deletes the "minor type" or semantic value
** associated with a symbol.  The symbol can be either a terminal
** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
** a pointer to the value to be deleted.  The code used to do the 
** deletions is derived from the %destructor and/or %token_destructor
** directives of the input grammar.
*/
static void yy_destructor(
  yyParser *yypParser,    /* The parser */
  YYCODETYPE yymajor,     /* Type code for object to destroy */
  YYMINORTYPE *yypminor   /* The object to be destroyed */
){
  ParseARG_FETCH;
  switch( yymajor ){
    /* Here is inserted the actions which take place when a
    ** terminal or non-terminal is destroyed.  This can happen
    ** when the symbol is popped from the stack during a
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are *not* used
    ** inside the C code.
    */
/********* Begin destructor definitions ***************************************/
    case 196: /* keep */
    case 197: /* tagitemlist */
    case 220: /* fill_opt */
    case 222: /* groupby_opt */
    case 223: /* orderby_opt */
    case 231: /* sortlist */
    case 235: /* grouplist */
{
tVariantListDestroy((yypminor->yy216));
}
      break;
1009
    case 214: /* select */
H
hzcheng 已提交
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
{
destroyQuerySql((yypminor->yy24));
}
      break;
    case 216: /* selcollist */
    case 227: /* sclp */
    case 236: /* exprlist */
    case 239: /* itemlist */
{
tSQLExprListDestroy((yypminor->yy98));
}
      break;
    case 218: /* where_opt */
    case 224: /* having_opt */
    case 228: /* expr */
    case 237: /* expritem */
{
tSQLExprDestroy((yypminor->yy370));
}
      break;
    case 232: /* sortitem */
{
tVariantDestroy(&(yypminor->yy266));
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

/*
** Pop the parser's stack once.
**
** If there is a destructor routine associated with the token which
** is popped from the stack, then call it.
*/
static void yy_pop_parser_stack(yyParser *pParser){
  yyStackEntry *yytos;
  assert( pParser->yyidx>=0 );
  yytos = &pParser->yystack[pParser->yyidx--];
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sPopping %s\n",
      yyTracePrompt,
      yyTokenName[yytos->major]);
  }
#endif
  yy_destructor(pParser, yytos->major, &yytos->minor);
}

/* 
** Deallocate and destroy a parser.  Destructors are called for
** all stack elements before shutting the parser down.
**
** If the YYPARSEFREENEVERNULL macro exists (for example because it
** is defined in a %include section of the input grammar) then it is
** assumed that the input pointer is never NULL.
*/
void ParseFree(
  void *p,                    /* The parser to be deleted */
  void (*freeProc)(void*)     /* Function used to reclaim memory */
){
  yyParser *pParser = (yyParser*)p;
#ifndef YYPARSEFREENEVERNULL
  if( pParser==0 ) return;
#endif
  while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
  free(pParser->yystack);
#endif
  (*freeProc)((void*)pParser);
}

/*
** Return the peak depth of the stack for a parser.
*/
#ifdef YYTRACKMAXSTACKDEPTH
int ParseStackPeak(void *p){
  yyParser *pParser = (yyParser*)p;
  return pParser->yyidxMax;
}
#endif

/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static int yy_find_shift_action(
  yyParser *pParser,        /* The parser */
  YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
  int stateno = pParser->yystack[pParser->yyidx].stateno;
 
  if( stateno>=YY_MIN_REDUCE ) return stateno;
  assert( stateno <= YY_SHIFT_COUNT );
  do{
    i = yy_shift_ofst[stateno];
    if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
    assert( iLookAhead!=YYNOCODE );
    i += iLookAhead;
    if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
      if( iLookAhead>0 ){
#ifdef YYFALLBACK
        YYCODETYPE iFallback;            /* Fallback token */
        if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
               && (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG
          if( yyTraceFILE ){
            fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
          }
#endif
          assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
          iLookAhead = iFallback;
          continue;
        }
#endif
#ifdef YYWILDCARD
        {
          int j = i - iLookAhead + YYWILDCARD;
          if( 
#if YY_SHIFT_MIN+YYWILDCARD<0
            j>=0 &&
#endif
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
            j<YY_ACTTAB_COUNT &&
#endif
            yy_lookahead[j]==YYWILDCARD
          ){
#ifndef NDEBUG
            if( yyTraceFILE ){
              fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
                 yyTracePrompt, yyTokenName[iLookAhead],
                 yyTokenName[YYWILDCARD]);
            }
#endif /* NDEBUG */
            return yy_action[j];
          }
        }
#endif /* YYWILDCARD */
      }
      return yy_default[stateno];
    }else{
      return yy_action[i];
    }
  }while(1);
}

/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
static int yy_find_reduce_action(
  int stateno,              /* Current state number */
  YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
#ifdef YYERRORSYMBOL
  if( stateno>YY_REDUCE_COUNT ){
    return yy_default[stateno];
  }
#else
  assert( stateno<=YY_REDUCE_COUNT );
#endif
  i = yy_reduce_ofst[stateno];
  assert( i!=YY_REDUCE_USE_DFLT );
  assert( iLookAhead!=YYNOCODE );
  i += iLookAhead;
#ifdef YYERRORSYMBOL
  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
    return yy_default[stateno];
  }
#else
  assert( i>=0 && i<YY_ACTTAB_COUNT );
  assert( yy_lookahead[i]==iLookAhead );
#endif
  return yy_action[i];
}

/*
** The following routine is called if the stack overflows.
*/
static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
   ParseARG_FETCH;
   yypParser->yyidx--;
#ifndef NDEBUG
   if( yyTraceFILE ){
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
   }
#endif
   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
   /* Here code is inserted which will execute if the parser
   ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/
/******** End %stack_overflow code ********************************************/
   ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
}

/*
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void yyTraceShift(yyParser *yypParser, int yyNewState){
  if( yyTraceFILE ){
    if( yyNewState<YYNSTATE ){
      fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
         yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
         yyNewState);
    }else{
      fprintf(yyTraceFILE,"%sShift '%s'\n",
         yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
    }
  }
}
#else
# define yyTraceShift(X,Y)
#endif

/*
** Perform a shift action.
*/
static void yy_shift(
  yyParser *yypParser,          /* The parser to be shifted */
  int yyNewState,               /* The new state to shift in */
  int yyMajor,                  /* The major token to shift in */
  YYMINORTYPE *yypMinor         /* Pointer to the minor token to shift in */
){
  yyStackEntry *yytos;
  yypParser->yyidx++;
#ifdef YYTRACKMAXSTACKDEPTH
  if( yypParser->yyidx>yypParser->yyidxMax ){
    yypParser->yyidxMax = yypParser->yyidx;
  }
#endif
#if YYSTACKDEPTH>0 
  if( yypParser->yyidx>=YYSTACKDEPTH ){
    yyStackOverflow(yypParser, yypMinor);
    return;
  }
#else
  if( yypParser->yyidx>=yypParser->yystksz ){
    yyGrowStack(yypParser);
    if( yypParser->yyidx>=yypParser->yystksz ){
      yyStackOverflow(yypParser, yypMinor);
      return;
    }
  }
#endif
  yytos = &yypParser->yystack[yypParser->yyidx];
  yytos->stateno = (YYACTIONTYPE)yyNewState;
  yytos->major = (YYCODETYPE)yyMajor;
  yytos->minor = *yypMinor;
  yyTraceShift(yypParser, yyNewState);
}

/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
  YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
  unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
} yyRuleInfo[] = {
  { 187, 1 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 188, 2 },
  { 189, 0 },
  { 189, 2 },
  { 191, 0 },
  { 191, 2 },
  { 188, 3 },
  { 188, 5 },
  { 188, 3 },
  { 188, 5 },
  { 188, 3 },
  { 188, 5 },
  { 188, 4 },
  { 188, 3 },
  { 188, 2 },
  { 188, 3 },
  { 188, 5 },
  { 188, 5 },
  { 188, 4 },
  { 188, 5 },
  { 188, 3 },
  { 188, 4 },
  { 190, 1 },
  { 190, 1 },
  { 192, 2 },
  { 192, 0 },
  { 194, 3 },
  { 194, 0 },
  { 188, 5 },
  { 188, 5 },
  { 196, 2 },
  { 198, 2 },
  { 199, 2 },
  { 200, 2 },
  { 201, 2 },
  { 202, 2 },
  { 203, 2 },
  { 204, 2 },
  { 205, 2 },
  { 206, 2 },
  { 207, 2 },
  { 208, 2 },
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
  { 195, 0 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 195, 2 },
  { 193, 2 },
H
hzcheng 已提交
1339
  { 210, 1 },
1340 1341 1342
  { 210, 4 },
  { 211, 1 },
  { 211, 2 },
H
hzcheng 已提交
1343
  { 211, 2 },
1344
  { 188, 6 },
H
hzcheng 已提交
1345
  { 212, 3 },
1346 1347 1348 1349 1350 1351
  { 212, 7 },
  { 212, 7 },
  { 212, 2 },
  { 213, 3 },
  { 213, 1 },
  { 215, 2 },
H
hzcheng 已提交
1352 1353
  { 197, 3 },
  { 197, 1 },
1354 1355 1356 1357 1358 1359 1360
  { 209, 1 },
  { 209, 1 },
  { 209, 1 },
  { 209, 1 },
  { 209, 1 },
  { 209, 2 },
  { 209, 2 },
H
hzcheng 已提交
1361
  { 188, 1 },
1362
  { 214, 12 },
H
hzcheng 已提交
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
  { 227, 2 },
  { 227, 0 },
  { 216, 3 },
  { 216, 2 },
  { 229, 2 },
  { 229, 1 },
  { 229, 0 },
  { 217, 3 },
  { 230, 1 },
  { 219, 4 },
  { 219, 0 },
  { 220, 0 },
  { 220, 6 },
  { 220, 4 },
  { 221, 4 },
  { 221, 0 },
  { 223, 0 },
  { 223, 3 },
  { 231, 4 },
  { 231, 2 },
1383
  { 233, 2 },
H
hzcheng 已提交
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
  { 234, 1 },
  { 234, 1 },
  { 234, 0 },
  { 222, 0 },
  { 222, 3 },
  { 235, 3 },
  { 235, 1 },
  { 224, 0 },
  { 224, 2 },
  { 226, 0 },
  { 226, 2 },
  { 226, 4 },
  { 226, 4 },
  { 225, 0 },
  { 225, 2 },
  { 225, 4 },
  { 225, 4 },
  { 218, 0 },
  { 218, 2 },
  { 228, 3 },
  { 228, 1 },
  { 228, 3 },
1406
  { 228, 3 },
H
hzcheng 已提交
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
  { 228, 1 },
  { 228, 2 },
  { 228, 2 },
  { 228, 1 },
  { 228, 2 },
  { 228, 2 },
  { 228, 1 },
  { 228, 1 },
  { 228, 1 },
  { 228, 1 },
  { 228, 4 },
  { 228, 4 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 3 },
  { 228, 5 },
  { 236, 3 },
  { 236, 1 },
  { 237, 1 },
  { 237, 0 },
  { 188, 4 },
  { 238, 4 },
  { 238, 5 },
  { 239, 3 },
  { 239, 1 },
  { 188, 3 },
  { 188, 7 },
  { 188, 7 },
  { 188, 7 },
  { 188, 7 },
  { 188, 8 },
1449
  { 188, 9 },
H
hzcheng 已提交
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607
  { 188, 5 },
  { 188, 7 },
  { 188, 7 },
};

static void yy_accept(yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    yysize = yyRuleInfo[yyruleno].nrhs;
    fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
      yyRuleName[yyruleno], yymsp[-yysize].stateno);
  }
#endif /* NDEBUG */
  yygotominor = yyzerominor;

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
/********** Begin reduce actions **********************************************/
      case 0: /* program ::= cmd */
{}
        break;
      case 1: /* cmd ::= SHOW DATABASES */
{ setDCLSQLElems(pInfo, SHOW_DATABASES, 0);}
        break;
      case 2: /* cmd ::= SHOW MNODES */
{ setDCLSQLElems(pInfo, SHOW_MNODES, 0);}
        break;
      case 3: /* cmd ::= SHOW DNODES */
{ setDCLSQLElems(pInfo, SHOW_DNODES, 0);}
        break;
      case 4: /* cmd ::= SHOW USERS */
{ setDCLSQLElems(pInfo, SHOW_USERS, 0);}
        break;
      case 5: /* cmd ::= SHOW MODULES */
{ setDCLSQLElems(pInfo, SHOW_MODULES, 0);  }
        break;
      case 6: /* cmd ::= SHOW QUERIES */
{ setDCLSQLElems(pInfo, SHOW_QUERIES, 0);  }
        break;
      case 7: /* cmd ::= SHOW CONNECTIONS */
{ setDCLSQLElems(pInfo, SHOW_CONNECTIONS, 0);}
        break;
      case 8: /* cmd ::= SHOW STREAMS */
{ setDCLSQLElems(pInfo, SHOW_STREAMS, 0);  }
        break;
      case 9: /* cmd ::= SHOW CONFIGS */
{ setDCLSQLElems(pInfo, SHOW_CONFIGS, 0);  }
        break;
      case 10: /* cmd ::= SHOW SCORES */
{ setDCLSQLElems(pInfo, SHOW_SCORES, 0);   }
        break;
      case 11: /* cmd ::= SHOW GRANTS */
{ setDCLSQLElems(pInfo, SHOW_GRANTS, 0);   }
        break;
      case 12: /* dbPrefix ::= */
      case 35: /* ifexists ::= */ yytestcase(yyruleno==35);
      case 37: /* ifnotexists ::= */ yytestcase(yyruleno==37);
{yygotominor.yy0.n = 0;}
        break;
      case 13: /* dbPrefix ::= ids DOT */
{yygotominor.yy0 = yymsp[-1].minor.yy0;  }
        break;
      case 14: /* cpxName ::= */
{yygotominor.yy0.n = 0;  }
        break;
      case 15: /* cpxName ::= DOT ids */
{yygotominor.yy0 = yymsp[0].minor.yy0; yygotominor.yy0.n += 1;    }
        break;
      case 16: /* cmd ::= SHOW dbPrefix TABLES */
{
    setDCLSQLElems(pInfo, SHOW_TABLES, 1, &yymsp[-1].minor.yy0);
}
        break;
      case 17: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */
{
    setDCLSQLElems(pInfo, SHOW_TABLES, 2, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 18: /* cmd ::= SHOW dbPrefix STABLES */
{
    setDCLSQLElems(pInfo, SHOW_STABLES, 1, &yymsp[-1].minor.yy0);
}
        break;
      case 19: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
{
    SSQLToken token;
    setDBName(&token, &yymsp[-3].minor.yy0);
    setDCLSQLElems(pInfo, SHOW_STABLES, 2, &token, &yymsp[0].minor.yy0);
}
        break;
      case 20: /* cmd ::= SHOW dbPrefix VGROUPS */
{
    SSQLToken token;
    setDBName(&token, &yymsp[-1].minor.yy0);
    setDCLSQLElems(pInfo, SHOW_VGROUPS, 1, &token);
}
        break;
      case 21: /* cmd ::= DROP TABLE ifexists ids cpxName */
{
    yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
    setDCLSQLElems(pInfo, DROP_TABLE, 2, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0);
}
        break;
      case 22: /* cmd ::= DROP DATABASE ifexists ids */
{ setDCLSQLElems(pInfo, DROP_DATABASE, 2, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); }
        break;
      case 23: /* cmd ::= DROP USER ids */
{ setDCLSQLElems(pInfo, DROP_USER, 1, &yymsp[0].minor.yy0);     }
        break;
      case 24: /* cmd ::= USE ids */
{ setDCLSQLElems(pInfo, USE_DATABASE, 1, &yymsp[0].minor.yy0);}
        break;
      case 25: /* cmd ::= DESCRIBE ids cpxName */
{
    yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
    setDCLSQLElems(pInfo, DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0);
}
        break;
      case 26: /* cmd ::= ALTER USER ids PASS ids */
{ setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);    }
        break;
      case 27: /* cmd ::= ALTER USER ids PRIVILEGE ids */
{ setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 28: /* cmd ::= ALTER DNODE IP ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);          }
        break;
      case 29: /* cmd ::= ALTER DNODE IP ids ids */
{ setDCLSQLElems(pInfo, ALTER_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);      }
        break;
      case 30: /* cmd ::= ALTER LOCAL ids */
{ setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &yymsp[0].minor.yy0);              }
        break;
      case 31: /* cmd ::= ALTER DATABASE ids alter_db_optr */
1608
{ SSQLToken t = {0};  setCreateDBSQL(pInfo, ALTER_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy478, &t);}
H
hzcheng 已提交
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
        break;
      case 32: /* ids ::= ID */
      case 33: /* ids ::= STRING */ yytestcase(yyruleno==33);
{yygotominor.yy0 = yymsp[0].minor.yy0; }
        break;
      case 34: /* ifexists ::= IF EXISTS */
      case 36: /* ifnotexists ::= IF NOT EXISTS */ yytestcase(yyruleno==36);
{yygotominor.yy0.n = 1;}
        break;
      case 38: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
1619
{ setCreateDBSQL(pInfo, CREATE_DATABASE, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy478, &yymsp[-2].minor.yy0);}
H
hzcheng 已提交
1620 1621 1622 1623
        break;
      case 39: /* cmd ::= CREATE USER ids PASS ids */
{ setDCLSQLElems(pInfo, CREATE_USER, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
        break;
1624 1625
      case 40: /* keep ::= KEEP tagitemlist */
{ yygotominor.yy216 = yymsp[0].minor.yy216; }
H
hzcheng 已提交
1626
        break;
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639
      case 41: /* tables ::= TABLES INTEGER */
      case 42: /* cache ::= CACHE INTEGER */ yytestcase(yyruleno==42);
      case 43: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==43);
      case 44: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==44);
      case 45: /* rows ::= ROWS INTEGER */ yytestcase(yyruleno==45);
      case 46: /* ablocks ::= ABLOCKS ID */ yytestcase(yyruleno==46);
      case 47: /* tblocks ::= TBLOCKS INTEGER */ yytestcase(yyruleno==47);
      case 48: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==48);
      case 49: /* clog ::= CLOG INTEGER */ yytestcase(yyruleno==49);
      case 50: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==50);
      case 51: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==51);
      case 52: /* db_optr ::= */ yytestcase(yyruleno==52);
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
H
hzcheng 已提交
1640
        break;
1641 1642 1643 1644 1645 1646 1647 1648
      case 53: /* db_optr ::= db_optr tables */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.tablesPerVnode = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 54: /* db_optr ::= db_optr cache */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 55: /* db_optr ::= db_optr replica */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
H
hzcheng 已提交
1649
        break;
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677
      case 56: /* db_optr ::= db_optr days */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 57: /* db_optr ::= db_optr rows */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.rowPerFileBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 58: /* db_optr ::= db_optr ablocks */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.numOfAvgCacheBlocks = strtod(yymsp[0].minor.yy0.z, NULL); }
        break;
      case 59: /* db_optr ::= db_optr tblocks */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.numOfBlocksPerTable = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 60: /* db_optr ::= db_optr ctime */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 61: /* db_optr ::= db_optr clog */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.commitLog = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 62: /* db_optr ::= db_optr comp */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
        break;
      case 63: /* db_optr ::= db_optr prec */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.precision = yymsp[0].minor.yy0; }
        break;
      case 64: /* db_optr ::= db_optr keep */
{ yygotominor.yy478 = yymsp[-1].minor.yy478; yygotominor.yy478.keep = yymsp[0].minor.yy216; }
        break;
      case 65: /* alter_db_optr ::= REPLICA tagitem */
H
hzcheng 已提交
1678
{
1679
    yygotominor.yy478.replica = yymsp[0].minor.yy266.i64Key;
H
hzcheng 已提交
1680 1681 1682 1683 1684 1685 1686
}
        break;
      case 66: /* typename ::= ids */
{ tSQLSetColumnType (&yygotominor.yy343, &yymsp[0].minor.yy0); }
        break;
      case 67: /* typename ::= ids LP signed RP */
{
1687
    yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy189;          // negative value of name length
H
hzcheng 已提交
1688 1689 1690 1691
    tSQLSetColumnType(&yygotominor.yy343, &yymsp[-3].minor.yy0);
}
        break;
      case 68: /* signed ::= INTEGER */
1692 1693
      case 69: /* signed ::= PLUS INTEGER */ yytestcase(yyruleno==69);
{ yygotominor.yy189 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
H
hzcheng 已提交
1694 1695
        break;
      case 70: /* signed ::= MINUS INTEGER */
1696
{ yygotominor.yy189 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
H
hzcheng 已提交
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790
        break;
      case 71: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{
    yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
    setCreatedMeterName(pInfo, &yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0);
}
        break;
      case 72: /* create_table_args ::= LP columnlist RP */
{
    yygotominor.yy278 = tSetCreateSQLElems(yymsp[-1].minor.yy151, NULL, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METER);
    setSQLInfo(pInfo, yygotominor.yy278, NULL, TSQL_CREATE_NORMAL_METER);
}
        break;
      case 73: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{
    yygotominor.yy278 = tSetCreateSQLElems(yymsp[-5].minor.yy151, yymsp[-1].minor.yy151, NULL, NULL, NULL, TSQL_CREATE_NORMAL_METRIC);
    setSQLInfo(pInfo, yygotominor.yy278, NULL, TSQL_CREATE_NORMAL_METRIC);
}
        break;
      case 74: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{
    yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
    yygotominor.yy278 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy216, NULL, TSQL_CREATE_METER_FROM_METRIC);
    setSQLInfo(pInfo, yygotominor.yy278, NULL, TSQL_CREATE_METER_FROM_METRIC);
}
        break;
      case 75: /* create_table_args ::= AS select */
{
    yygotominor.yy278 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM);
    setSQLInfo(pInfo, yygotominor.yy278, NULL, TSQL_CREATE_STREAM);
}
        break;
      case 76: /* columnlist ::= columnlist COMMA column */
{yygotominor.yy151 = tFieldListAppend(yymsp[-2].minor.yy151, &yymsp[0].minor.yy343);   }
        break;
      case 77: /* columnlist ::= column */
{yygotominor.yy151 = tFieldListAppend(NULL, &yymsp[0].minor.yy343);}
        break;
      case 78: /* column ::= ids typename */
{
    tSQLSetColumnInfo(&yygotominor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343);
}
        break;
      case 79: /* tagitemlist ::= tagitemlist COMMA tagitem */
{ yygotominor.yy216 = tVariantListAppend(yymsp[-2].minor.yy216, &yymsp[0].minor.yy266, -1);    }
        break;
      case 80: /* tagitemlist ::= tagitem */
{ yygotominor.yy216 = tVariantListAppend(NULL, &yymsp[0].minor.yy266, -1); }
        break;
      case 81: /* tagitem ::= INTEGER */
      case 82: /* tagitem ::= FLOAT */ yytestcase(yyruleno==82);
      case 83: /* tagitem ::= STRING */ yytestcase(yyruleno==83);
      case 84: /* tagitem ::= BOOL */ yytestcase(yyruleno==84);
{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yygotominor.yy266, &yymsp[0].minor.yy0); }
        break;
      case 85: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = TK_STRING; toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yygotominor.yy266, &yymsp[0].minor.yy0); }
        break;
      case 86: /* tagitem ::= MINUS INTEGER */
      case 87: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==87);
{
    yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
    yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
    toTSDBType(yymsp[-1].minor.yy0.type);
    tVariantCreate(&yygotominor.yy266, &yymsp[-1].minor.yy0);
}
        break;
      case 88: /* cmd ::= select */
{
    setSQLInfo(pInfo, yymsp[0].minor.yy24, NULL, TSQL_QUERY_METER);
}
        break;
      case 89: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{
  yygotominor.yy24 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy98, &yymsp[-9].minor.yy0, yymsp[-8].minor.yy370, yymsp[-4].minor.yy216, yymsp[-3].minor.yy216, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy216, &yymsp[0].minor.yy294, &yymsp[-1].minor.yy294);
}
        break;
      case 90: /* sclp ::= selcollist COMMA */
{yygotominor.yy98 = yymsp[-1].minor.yy98;}
        break;
      case 91: /* sclp ::= */
{yygotominor.yy98 = 0;}
        break;
      case 92: /* selcollist ::= sclp expr as */
{
   yygotominor.yy98 = tSQLExprListAppend(yymsp[-2].minor.yy98, yymsp[-1].minor.yy370, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
        break;
      case 93: /* selcollist ::= sclp STAR */
{
   tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
   yygotominor.yy98 = tSQLExprListAppend(yymsp[-1].minor.yy98, pNode, 0);
}
        break;
1791 1792
      case 94: /* as ::= AS ids */
      case 95: /* as ::= ids */ yytestcase(yyruleno==95);
H
hzcheng 已提交
1793 1794
{ yygotominor.yy0 = yymsp[0].minor.yy0;    }
        break;
1795
      case 96: /* as ::= */
H
hzcheng 已提交
1796 1797
{ yygotominor.yy0.n = 0;  }
        break;
1798
      case 97: /* from ::= FROM ids cpxName */
H
hzcheng 已提交
1799 1800
{yygotominor.yy0 = yymsp[-1].minor.yy0; yygotominor.yy0.n += yymsp[0].minor.yy0.n;}
        break;
1801
      case 98: /* tmvar ::= VARIABLE */
H
hzcheng 已提交
1802 1803
{yygotominor.yy0 = yymsp[0].minor.yy0;}
        break;
1804 1805
      case 99: /* interval_opt ::= INTERVAL LP tmvar RP */
      case 104: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==104);
H
hzcheng 已提交
1806 1807
{yygotominor.yy0 = yymsp[-1].minor.yy0;     }
        break;
1808 1809
      case 100: /* interval_opt ::= */
      case 105: /* sliding_opt ::= */ yytestcase(yyruleno==105);
1810 1811
{yygotominor.yy0.n = 0;   }
        break;
1812
      case 101: /* fill_opt ::= */
1813 1814
{yygotominor.yy216 = 0;     }
        break;
1815
      case 102: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
H
hzcheng 已提交
1816 1817 1818 1819 1820 1821 1822 1823 1824
{
    tVariant A = {0};
    toTSDBType(yymsp[-3].minor.yy0.type);
    tVariantCreate(&A, &yymsp[-3].minor.yy0);

    tVariantListInsert(yymsp[-1].minor.yy216, &A, -1, 0);
    yygotominor.yy216 = yymsp[-1].minor.yy216;
}
        break;
1825
      case 103: /* fill_opt ::= FILL LP ID RP */
H
hzcheng 已提交
1826 1827
{
    toTSDBType(yymsp[-1].minor.yy0.type);
1828
    yygotominor.yy216 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
H
hzcheng 已提交
1829 1830
}
        break;
1831 1832
      case 106: /* orderby_opt ::= */
      case 114: /* groupby_opt ::= */ yytestcase(yyruleno==114);
H
hzcheng 已提交
1833 1834
{yygotominor.yy216 = 0;}
        break;
1835 1836
      case 107: /* orderby_opt ::= ORDER BY sortlist */
      case 115: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==115);
H
hzcheng 已提交
1837 1838
{yygotominor.yy216 = yymsp[0].minor.yy216;}
        break;
1839
      case 108: /* sortlist ::= sortlist COMMA item sortorder */
H
hzcheng 已提交
1840 1841 1842 1843
{
    yygotominor.yy216 = tVariantListAppend(yymsp[-3].minor.yy216, &yymsp[-1].minor.yy266, yymsp[0].minor.yy412);
}
        break;
1844
      case 109: /* sortlist ::= item sortorder */
H
hzcheng 已提交
1845 1846 1847 1848
{
  yygotominor.yy216 = tVariantListAppend(NULL, &yymsp[-1].minor.yy266, yymsp[0].minor.yy412);
}
        break;
1849
      case 110: /* item ::= ids cpxName */
H
hzcheng 已提交
1850
{
1851 1852 1853 1854
  toTSDBType(yymsp[-1].minor.yy0.type);
  yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;

  tVariantCreate(&yygotominor.yy266, &yymsp[-1].minor.yy0);
H
hzcheng 已提交
1855 1856
}
        break;
1857
      case 111: /* sortorder ::= ASC */
H
hzcheng 已提交
1858 1859
{yygotominor.yy412 = TSQL_SO_ASC; }
        break;
1860
      case 112: /* sortorder ::= DESC */
H
hzcheng 已提交
1861 1862
{yygotominor.yy412 = TSQL_SO_DESC;}
        break;
1863
      case 113: /* sortorder ::= */
H
hzcheng 已提交
1864 1865
{yygotominor.yy412 = TSQL_SO_ASC;}
        break;
1866
      case 116: /* grouplist ::= grouplist COMMA item */
H
hzcheng 已提交
1867 1868 1869 1870
{
  yygotominor.yy216 = tVariantListAppend(yymsp[-2].minor.yy216, &yymsp[0].minor.yy266, -1);
}
        break;
1871
      case 117: /* grouplist ::= item */
H
hzcheng 已提交
1872 1873 1874 1875
{
  yygotominor.yy216 = tVariantListAppend(NULL, &yymsp[0].minor.yy266, -1);
}
        break;
1876 1877 1878
      case 118: /* having_opt ::= */
      case 128: /* where_opt ::= */ yytestcase(yyruleno==128);
      case 164: /* expritem ::= */ yytestcase(yyruleno==164);
H
hzcheng 已提交
1879 1880
{yygotominor.yy370 = 0;}
        break;
1881 1882 1883
      case 119: /* having_opt ::= HAVING expr */
      case 129: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==129);
      case 163: /* expritem ::= expr */ yytestcase(yyruleno==163);
H
hzcheng 已提交
1884 1885
{yygotominor.yy370 = yymsp[0].minor.yy370;}
        break;
1886 1887
      case 120: /* limit_opt ::= */
      case 124: /* slimit_opt ::= */ yytestcase(yyruleno==124);
H
hzcheng 已提交
1888 1889
{yygotominor.yy294.limit = -1; yygotominor.yy294.offset = 0;}
        break;
1890 1891 1892
      case 121: /* limit_opt ::= LIMIT signed */
      case 125: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==125);
{yygotominor.yy294.limit = yymsp[0].minor.yy189;  yygotominor.yy294.offset = 0;}
H
hzcheng 已提交
1893
        break;
1894 1895 1896
      case 122: /* limit_opt ::= LIMIT signed OFFSET signed */
      case 126: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==126);
{yygotominor.yy294.limit = yymsp[-2].minor.yy189;  yygotominor.yy294.offset = yymsp[0].minor.yy189;}
H
hzcheng 已提交
1897
        break;
1898 1899 1900
      case 123: /* limit_opt ::= LIMIT signed COMMA signed */
      case 127: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==127);
{yygotominor.yy294.limit = yymsp[0].minor.yy189;  yygotominor.yy294.offset = yymsp[-2].minor.yy189;}
H
hzcheng 已提交
1901
        break;
1902
      case 130: /* expr ::= LP expr RP */
H
hzcheng 已提交
1903 1904
{yygotominor.yy370 = yymsp[-1].minor.yy370; }
        break;
1905
      case 131: /* expr ::= ID */
H
hzcheng 已提交
1906 1907
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
        break;
1908
      case 132: /* expr ::= ID DOT ID */
H
hzcheng 已提交
1909 1910
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
        break;
1911
      case 133: /* expr ::= ID DOT STAR */
1912 1913
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
        break;
1914
      case 134: /* expr ::= INTEGER */
H
hzcheng 已提交
1915 1916
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
        break;
1917 1918
      case 135: /* expr ::= MINUS INTEGER */
      case 136: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==136);
H
hzcheng 已提交
1919 1920
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
        break;
1921
      case 137: /* expr ::= FLOAT */
H
hzcheng 已提交
1922 1923
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
        break;
1924 1925
      case 138: /* expr ::= MINUS FLOAT */
      case 139: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==139);
H
hzcheng 已提交
1926 1927
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
        break;
1928
      case 140: /* expr ::= STRING */
H
hzcheng 已提交
1929 1930
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
        break;
1931
      case 141: /* expr ::= NOW */
H
hzcheng 已提交
1932 1933
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
        break;
1934
      case 142: /* expr ::= VARIABLE */
H
hzcheng 已提交
1935 1936
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
        break;
1937
      case 143: /* expr ::= BOOL */
H
hzcheng 已提交
1938 1939
{yygotominor.yy370 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
        break;
1940
      case 144: /* expr ::= ID LP exprlist RP */
H
hzcheng 已提交
1941 1942 1943 1944
{
  yygotominor.yy370 = tSQLExprCreateFunction(yymsp[-1].minor.yy98, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
}
        break;
1945
      case 145: /* expr ::= ID LP STAR RP */
H
hzcheng 已提交
1946 1947 1948 1949
{
  yygotominor.yy370 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type);
}
        break;
1950
      case 146: /* expr ::= expr AND expr */
H
hzcheng 已提交
1951 1952
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_AND);}
        break;
1953
      case 147: /* expr ::= expr OR expr */
H
hzcheng 已提交
1954 1955
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_OR); }
        break;
1956
      case 148: /* expr ::= expr LT expr */
H
hzcheng 已提交
1957 1958
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LT);}
        break;
1959
      case 149: /* expr ::= expr GT expr */
H
hzcheng 已提交
1960 1961
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GT);}
        break;
1962
      case 150: /* expr ::= expr LE expr */
H
hzcheng 已提交
1963 1964
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LE);}
        break;
1965
      case 151: /* expr ::= expr GE expr */
H
hzcheng 已提交
1966 1967
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GE);}
        break;
1968
      case 152: /* expr ::= expr NE expr */
H
hzcheng 已提交
1969 1970
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NE);}
        break;
1971
      case 153: /* expr ::= expr EQ expr */
H
hzcheng 已提交
1972 1973
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_EQ);}
        break;
1974
      case 154: /* expr ::= expr PLUS expr */
H
hzcheng 已提交
1975 1976
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_PLUS);  }
        break;
1977
      case 155: /* expr ::= expr MINUS expr */
H
hzcheng 已提交
1978 1979
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MINUS); }
        break;
1980
      case 156: /* expr ::= expr STAR expr */
H
hzcheng 已提交
1981 1982
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_STAR);  }
        break;
1983
      case 157: /* expr ::= expr SLASH expr */
H
hzcheng 已提交
1984 1985
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_DIVIDE);}
        break;
1986
      case 158: /* expr ::= expr REM expr */
H
hzcheng 已提交
1987 1988
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_REM);   }
        break;
1989
      case 159: /* expr ::= expr LIKE expr */
H
hzcheng 已提交
1990 1991
{yygotominor.yy370 = tSQLExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LIKE);  }
        break;
1992
      case 160: /* expr ::= expr IN LP exprlist RP */
H
hzcheng 已提交
1993 1994
{yygotominor.yy370 = tSQLExprCreate(yymsp[-4].minor.yy370, (tSQLExpr*)yymsp[-1].minor.yy98, TK_IN); }
        break;
1995 1996
      case 161: /* exprlist ::= exprlist COMMA expritem */
      case 168: /* itemlist ::= itemlist COMMA expr */ yytestcase(yyruleno==168);
H
hzcheng 已提交
1997 1998
{yygotominor.yy98 = tSQLExprListAppend(yymsp[-2].minor.yy98,yymsp[0].minor.yy370,0);}
        break;
1999 2000
      case 162: /* exprlist ::= expritem */
      case 169: /* itemlist ::= expr */ yytestcase(yyruleno==169);
H
hzcheng 已提交
2001 2002
{yygotominor.yy98 = tSQLExprListAppend(0,yymsp[0].minor.yy370,0);}
        break;
2003
      case 165: /* cmd ::= INSERT INTO cpxName insert_value_list */
H
hzcheng 已提交
2004 2005 2006 2007
{
    tSetInsertSQLElems(pInfo, &yymsp[-1].minor.yy0, yymsp[0].minor.yy434);
}
        break;
2008
      case 166: /* insert_value_list ::= VALUES LP itemlist RP */
H
hzcheng 已提交
2009 2010
{yygotominor.yy434 = tSQLListListAppend(NULL, yymsp[-1].minor.yy98);}
        break;
2011
      case 167: /* insert_value_list ::= insert_value_list VALUES LP itemlist RP */
H
hzcheng 已提交
2012 2013
{yygotominor.yy434 = tSQLListListAppend(yymsp[-4].minor.yy434, yymsp[-1].minor.yy98);}
        break;
2014
      case 170: /* cmd ::= RESET QUERY CACHE */
H
hzcheng 已提交
2015 2016
{ setDCLSQLElems(pInfo, RESET_QUERY_CACHE, 0);}
        break;
2017
      case 171: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
H
hzcheng 已提交
2018 2019 2020 2021 2022 2023
{
    yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy151, NULL, ALTER_TABLE_ADD_COLUMN);
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_ADD_COLUMN);
}
        break;
2024
      case 172: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
H
hzcheng 已提交
2025 2026 2027 2028
{
    yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;

    toTSDBType(yymsp[0].minor.yy0.type);
2029
    tVariantList* K = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1);
H
hzcheng 已提交
2030 2031 2032 2033 2034

    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, NULL, K, ALTER_TABLE_DROP_COLUMN);
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN);
}
        break;
2035
      case 173: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
H
hzcheng 已提交
2036 2037 2038 2039 2040 2041
{
    yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy151, NULL, ALTER_TABLE_TAGS_ADD);
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_ADD);
}
        break;
2042
      case 174: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
H
hzcheng 已提交
2043 2044 2045 2046
{
    yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;

    toTSDBType(yymsp[0].minor.yy0.type);
2047
    tVariantList* A = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1);
H
hzcheng 已提交
2048 2049 2050 2051 2052

    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, NULL, A, ALTER_TABLE_TAGS_DROP);
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP);
}
        break;
2053
      case 175: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
H
hzcheng 已提交
2054 2055 2056 2057
{
    yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;

    toTSDBType(yymsp[-1].minor.yy0.type);
2058
    tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
H
hzcheng 已提交
2059 2060

    toTSDBType(yymsp[0].minor.yy0.type);
2061
    A = tVariantListAppendToken(A, &yymsp[0].minor.yy0, -1);
H
hzcheng 已提交
2062 2063 2064 2065 2066

    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-5].minor.yy0, NULL, A, ALTER_TABLE_TAGS_CHG);
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG);
}
        break;
2067
      case 176: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
H
hzcheng 已提交
2068
{
2069
    yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
H
hzcheng 已提交
2070 2071

    toTSDBType(yymsp[-2].minor.yy0.type);
2072
    tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
H
hzcheng 已提交
2073 2074
    A = tVariantListAppend(A, &yymsp[0].minor.yy266, -1);

2075
    SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, ALTER_TABLE_TAGS_SET);
H
hzcheng 已提交
2076 2077 2078
    setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_SET);
}
        break;
2079
      case 177: /* cmd ::= KILL CONNECTION IP COLON INTEGER */
H
hzcheng 已提交
2080 2081
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &yymsp[-2].minor.yy0);}
        break;
2082
      case 178: /* cmd ::= KILL STREAM IP COLON INTEGER COLON INTEGER */
H
hzcheng 已提交
2083 2084
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &yymsp[-4].minor.yy0);}
        break;
2085
      case 179: /* cmd ::= KILL QUERY IP COLON INTEGER COLON INTEGER */
H
hzcheng 已提交
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387
{yymsp[-4].minor.yy0.n += (yymsp[-3].minor.yy0.n + yymsp[-2].minor.yy0.n + yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &yymsp[-4].minor.yy0);}
        break;
      default:
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact <= YY_MAX_SHIFTREDUCE ){
    if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
    /* If the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
      yyTraceShift(yypParser, yyact);
    }else{
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YY_ACCEPT_ACTION );
    yy_accept(yypParser);
  }
}

/*
** The following code executes when the parse fails
*/
#ifndef YYNOERRORRECOVERY
static void yy_parse_failed(
  yyParser *yypParser           /* The parser */
){
  ParseARG_FETCH;
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  }
#endif
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
#endif /* YYNOERRORRECOVERY */

/*
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
  yyParser *yypParser,           /* The parser */
  int yymajor,                   /* The major type of the error token */
  YYMINORTYPE yyminor            /* The minor type of the error token */
){
  ParseARG_FETCH;
#define TOKEN (yyminor.yy0)
/************ Begin %syntax_error code ****************************************/

  pInfo->validSql = false;
  int32_t outputBufLen = tListLen(pInfo->pzErrMsg);
  int32_t len = 0;

  if(TOKEN.z) {
    char msg[] = "syntax error near \"%s\"";
    int32_t sqlLen = strlen(&TOKEN.z[0]);

    if (sqlLen + sizeof(msg)/sizeof(msg[0]) + 1 > outputBufLen) {
        char tmpstr[128] = {0};
        memcpy(tmpstr, &TOKEN.z[0], sizeof(tmpstr)/sizeof(tmpstr[0]) - 1);
        len = sprintf(pInfo->pzErrMsg, msg, tmpstr);
    } else {
        len = sprintf(pInfo->pzErrMsg, msg, &TOKEN.z[0]);
    }

  } else {
    len = sprintf(pInfo->pzErrMsg, "Incomplete SQL statement");
  }

  assert(len <= outputBufLen);
/************ End %syntax_error code ******************************************/
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
}

/*
** The following is executed when the parser accepts
*/
static void yy_accept(
  yyParser *yypParser           /* The parser */
){
  ParseARG_FETCH;
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  }
#endif
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser accepts */
/*********** Begin %parse_accept code *****************************************/

/*********** End %parse_accept code *******************************************/
  ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
}

/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "ParseAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
** user wants (and specified in the grammar) and is available for
** use by the action routines.
**
** Inputs:
** <ul>
** <li> A pointer to the parser (an opaque structure.)
** <li> The major token number.
** <li> The minor token number.
** <li> An option argument of a grammar-specified type.
** </ul>
**
** Outputs:
** None.
*/
void Parse(
  void *yyp,                   /* The parser */
  int yymajor,                 /* The major token code number */
  ParseTOKENTYPE yyminor       /* The value for the token */
  ParseARG_PDECL               /* Optional %extra_argument parameter */
){
  YYMINORTYPE yyminorunion;
  int yyact;            /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  int yyendofinput;     /* True if we are at the end of input */
#endif
#ifdef YYERRORSYMBOL
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
#endif
  yyParser *yypParser;  /* The parser */

  /* (re)initialize the parser, if necessary */
  yypParser = (yyParser*)yyp;
  if( yypParser->yyidx<0 ){
#if YYSTACKDEPTH<=0
    if( yypParser->yystksz <=0 ){
      /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
      yyminorunion = yyzerominor;
      yyStackOverflow(yypParser, &yyminorunion);
      return;
    }
#endif
    yypParser->yyidx = 0;
    yypParser->yyerrcnt = -1;
    yypParser->yystack[0].stateno = 0;
    yypParser->yystack[0].major = 0;
#ifndef NDEBUG
    if( yyTraceFILE ){
      fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
              yyTracePrompt);
    }
#endif
  }
  yyminorunion.yy0 = yyminor;
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
  yyendofinput = (yymajor==0);
#endif
  ParseARG_STORE;

#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
  }
#endif

  do{
    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
    if( yyact <= YY_MAX_SHIFTREDUCE ){
      if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
      yypParser->yyerrcnt--;
      yymajor = YYNOCODE;
    }else if( yyact <= YY_MAX_REDUCE ){
      yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
    }else{
      assert( yyact == YY_ERROR_ACTION );
#ifdef YYERRORSYMBOL
      int yymx;
#endif
#ifndef NDEBUG
      if( yyTraceFILE ){
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
      }
#endif
#ifdef YYERRORSYMBOL
      /* A syntax error has occurred.
      ** The response to an error depends upon whether or not the
      ** grammar defines an error token "ERROR".  
      **
      ** This is what we do if the grammar does define ERROR:
      **
      **  * Call the %syntax_error function.
      **
      **  * Begin popping the stack until we enter a state where
      **    it is legal to shift the error symbol, then shift
      **    the error symbol.
      **
      **  * Set the error count to three.
      **
      **  * Begin accepting and shifting new tokens.  No new error
      **    processing will occur until three tokens have been
      **    shifted successfully.
      **
      */
      if( yypParser->yyerrcnt<0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yymx = yypParser->yystack[yypParser->yyidx].major;
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
#ifndef NDEBUG
        if( yyTraceFILE ){
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
             yyTracePrompt,yyTokenName[yymajor]);
        }
#endif
        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
        yymajor = YYNOCODE;
      }else{
         while(
          yypParser->yyidx >= 0 &&
          yymx != YYERRORSYMBOL &&
          (yyact = yy_find_reduce_action(
                        yypParser->yystack[yypParser->yyidx].stateno,
                        YYERRORSYMBOL)) >= YY_MIN_REDUCE
        ){
          yy_pop_parser_stack(yypParser);
        }
        if( yypParser->yyidx < 0 || yymajor==0 ){
          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
          yy_parse_failed(yypParser);
          yymajor = YYNOCODE;
        }else if( yymx!=YYERRORSYMBOL ){
          YYMINORTYPE u2;
          u2.YYERRSYMDT = 0;
          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
        }
      }
      yypParser->yyerrcnt = 3;
      yyerrorhit = 1;
#elif defined(YYNOERRORRECOVERY)
      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
      ** do any kind of error recovery.  Instead, simply invoke the syntax
      ** error routine and continue going as if nothing had happened.
      **
      ** Applications can set this macro (for example inside %include) if
      ** they intend to abandon the parse upon the first syntax error seen.
      */
      yy_syntax_error(yypParser,yymajor,yyminorunion);
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
      yymajor = YYNOCODE;
      
#else  /* YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
      ** As before, subsequent error messages are suppressed until
      ** three input tokens have been successfully shifted.
      */
      if( yypParser->yyerrcnt<=0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yypParser->yyerrcnt = 3;
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
      if( yyendofinput ){
        yy_parse_failed(yypParser);
      }
      yymajor = YYNOCODE;
#endif
    }
  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
#ifndef NDEBUG
  if( yyTraceFILE ){
    int i;
    fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
    for(i=1; i<=yypParser->yyidx; i++)
      fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ', 
              yyTokenName[yypParser->yystack[i].major]);
    fprintf(yyTraceFILE,"]\n");
  }
#endif
  return;
}