diff options
42 files changed, 11000 insertions, 7415 deletions
diff --git a/ext/sqlite/Makefile.frag b/ext/sqlite/Makefile.frag index 02f5311fbc..b800d25041 100644 --- a/ext/sqlite/Makefile.frag +++ b/ext/sqlite/Makefile.frag @@ -1,6 +1,4 @@ -LEMON="@LEMON@" -  # sqlite has some generated source files; this specifies how to  # build them @@ -10,13 +8,13 @@ LEMON="@LEMON@"  $(srcdir)/libsqlite/src/opcodes.c: $(srcdir)/libsqlite/src/vdbe.c  	echo '/* Automatically generated file.  Do not edit */' >$@  	echo 'char *sqliteOpcodeNames[] = { "???", ' >>$@ -	grep '^case OP_' $< | \ +	grep '^case OP_' $(srcdir)/libsqlite/src/vdbe.c | \  	  sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >>$@  	echo '};' >>$@  $(srcdir)/libsqlite/src/opcodes.h: $(srcdir)/libsqlite/src/vdbe.c  	echo '/* Automatically generated file.  Do not edit */' >$@ -	grep '^case OP_' $< | \ +	grep '^case OP_' $(srcdir)/libsqlite/src/vdbe.c | \  	  sed -e 's/://' | \  	  awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>$@ diff --git a/ext/sqlite/config.m4 b/ext/sqlite/config.m4 index f404a5cc50..1ff186a626 100644 --- a/ext/sqlite/config.m4 +++ b/ext/sqlite/config.m4 @@ -1,5 +1,6 @@  dnl $Id$  dnl config.m4 for extension sqlite +dnl vim:et:ts=2:sw=2  PHP_ARG_WITH(sqlite, for sqlite support,  [  --with-sqlite           Include sqlite support]) @@ -7,86 +8,87 @@ PHP_ARG_WITH(sqlite, for sqlite support,  if test "$PHP_SQLITE" != "no"; then    if test "$PHP_SQLITE" != "yes"; then -	SEARCH_PATH="/usr/local /usr" -	SEARCH_FOR="/include/sqlite.h" -	if test -r $PHP_SQLITE/; then # path given as parameter -		SQLITE_DIR=$PHP_SQLITE -	else # search default path list -		AC_MSG_CHECKING([for sqlite files in default path]) -		for i in $SEARCH_PATH ; do -		if test -r $i/$SEARCH_FOR; then -			SQLITE_DIR=$i -			AC_MSG_RESULT(found in $i) -		fi -		done -	fi +    SEARCH_PATH="/usr/local /usr" +    SEARCH_FOR="/include/sqlite.h" +    if test -r $PHP_SQLITE/; then # path given as parameter +        SQLITE_DIR=$PHP_SQLITE +    else # search default path list +        AC_MSG_CHECKING([for sqlite files in default path]) +        for i in $SEARCH_PATH ; do +        if test -r $i/$SEARCH_FOR; then +            SQLITE_DIR=$i +            AC_MSG_RESULT(found in $i) +        fi +        done +    fi -	if test -z "$SQLITE_DIR"; then -		AC_MSG_RESULT([not found]) -		AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org]) -	fi - -	PHP_ADD_INCLUDE($SQLITE_DIR/include) - -	LIBNAME=sqlite -	LIBSYMBOL=sqlite_open - -	PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, -	[ -		PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SQLITE_DIR/lib, SQLITE_SHARED_LIBADD) -		AC_DEFINE(HAVE_SQLITELIB,1,[ ]) -	],[ -		AC_MSG_ERROR([wrong sqlite lib version or lib not found]) -	],[ -		-L$SQLITE_DIR/lib -lm -ldl -	]) +    if test -z "$SQLITE_DIR"; then +        AC_MSG_RESULT([not found]) +        AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org]) +    fi + +    PHP_ADD_INCLUDE($SQLITE_DIR/include) + +    LIBNAME=sqlite +    LIBSYMBOL=sqlite_open + +    PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, +    [ +        PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SQLITE_DIR/lib, SQLITE_SHARED_LIBADD) +        AC_DEFINE(HAVE_SQLITELIB,1,[ ]) +    ],[ +        AC_MSG_ERROR([wrong sqlite lib version or lib not found]) +    ],[ +        -L$SQLITE_DIR/lib -lm -ldl +    ]) -	PHP_SUBST(SQLITE_SHARED_LIBADD) -	PHP_NEW_EXTENSION(sqlite, sqlite.c libsqlite/src/encode.c, $ext_shared) +    PHP_SUBST(SQLITE_SHARED_LIBADD) +    PHP_NEW_EXTENSION(sqlite, sqlite.c libsqlite/src/encode.c, $ext_shared)    else -	# use bundled library - -	PHP_SQLITE_CFLAGS="-I@ext_srcdir@/libsqlite/src" - - -	sources="libsqlite/src/opcodes.c -		libsqlite/src/parse.c libsqlite/src/encode.c \ -		libsqlite/src/auth.c libsqlite/src/btree.c libsqlite/src/build.c \ -		libsqlite/src/delete.c libsqlite/src/expr.c libsqlite/src/func.c \ -		libsqlite/src/hash.c libsqlite/src/insert.c libsqlite/src/main.c \ -		libsqlite/src/os.c libsqlite/src/pager.c \ -		libsqlite/src/printf.c libsqlite/src/random.c \ -		libsqlite/src/select.c libsqlite/src/table.c libsqlite/src/tokenize.c \ -		libsqlite/src/update.c libsqlite/src/util.c libsqlite/src/vdbe.c \ -		libsqlite/src/where.c libsqlite/src/trigger.c" -	 -  	PHP_NEW_EXTENSION(sqlite, sqlite.c $sources, $ext_shared,,$PHP_SQLITE_CFLAGS) -	PHP_ADD_BUILD_DIR($ext_builddir/libsqlite) -	PHP_ADD_BUILD_DIR($ext_builddir/libsqlite/src) -	AC_CHECK_SIZEOF(char *,4) -	AC_DEFINE(SQLITE_PTR_SZ, SIZEOF_CHAR_P, [Size of a pointer]) -	AC_DEFINE(OS_UNIX, 1, [if this is unix]) -	AC_DEFINE(OS_WIN, 0, [if this is windows]) -	dnl use latin 1 for now; the utf-8 handling in funcs.c uses assert(), -	dnl which is a bit silly and something we want to avoid -	SQLITE_ENCODING="iso8859" -	dnl SQLITE_ENCODING="UTF-8" -	dnl AC_DEFINE(SQLITE_UTF8,1,[if SQLite should use utf-8 encoding]) -	AC_SUBST(SQLITE_ENCODING) - -	AC_PATH_PROG(LEMON,lemon,no) -	AC_SUBST(LEMON) - -	SQLITE_VERSION=`cat $ext_srcdir/libsqlite/VERSION` -	AC_SUBST(SQLITE_VERSION) - -	if test "$ext_shared" = "no"; then -	  echo '#include "php_config.h"' > $ext_srcdir/libsqlite/src/config.h -	else -	  echo "#include \"$abs_builddir/config.h\"" > $ext_srcdir/libsqlite/src/config.h -	fi -	 -	cat >> $ext_srcdir/libsqlite/src/config.h <<EOF +    # use bundled library + +    PHP_SQLITE_CFLAGS="-I@ext_srcdir@/libsqlite/src" + +    sources="libsqlite/src/opcodes.c +        libsqlite/src/parse.c libsqlite/src/encode.c \ +        libsqlite/src/auth.c libsqlite/src/btree.c libsqlite/src/build.c \ +        libsqlite/src/delete.c libsqlite/src/expr.c libsqlite/src/func.c \ +        libsqlite/src/hash.c libsqlite/src/insert.c libsqlite/src/main.c \ +        libsqlite/src/os.c libsqlite/src/pager.c \ +        libsqlite/src/printf.c libsqlite/src/random.c \ +        libsqlite/src/select.c libsqlite/src/table.c libsqlite/src/tokenize.c \ +        libsqlite/src/update.c libsqlite/src/util.c libsqlite/src/vdbe.c \ +        libsqlite/src/attach.c libsqlite/src/btree_rb.c libsqlite/src/pragma.c \ +        libsqlite/src/vacuum.c libsqlite/src/copy.c \ +        libsqlite/src/where.c libsqlite/src/trigger.c" +     +    PHP_NEW_EXTENSION(sqlite, sqlite.c $sources, $ext_shared,,$PHP_SQLITE_CFLAGS) +    PHP_ADD_BUILD_DIR($ext_builddir/libsqlite) +    PHP_ADD_BUILD_DIR($ext_builddir/libsqlite/src) +    AC_CHECK_SIZEOF(char *,4) +    AC_DEFINE(SQLITE_PTR_SZ, SIZEOF_CHAR_P, [Size of a pointer]) +    AC_DEFINE(OS_UNIX, 1, [if this is unix]) +    AC_DEFINE(OS_WIN, 0, [if this is windows]) +    dnl use latin 1 for now; the utf-8 handling in funcs.c uses assert(), +    dnl which is a bit silly and something we want to avoid +    SQLITE_ENCODING="iso8859" +    dnl SQLITE_ENCODING="UTF-8" +    dnl AC_DEFINE(SQLITE_UTF8,1,[if SQLite should use utf-8 encoding]) +    PHP_SUBST(SQLITE_ENCODING) + +    AC_PATH_PROG(LEMON,lemon,no) +    PHP_SUBST(LEMON) + +    SQLITE_VERSION=`cat $ext_srcdir/libsqlite/VERSION` +    PHP_SUBST(SQLITE_VERSION) + +    if test "$ext_shared" = "no"; then +      echo '#include "php_config.h"' > $ext_srcdir/libsqlite/src/config.h +    else +      echo "#include \"$abs_builddir/config.h\"" > $ext_srcdir/libsqlite/src/config.h +    fi +     +    cat >> $ext_srcdir/libsqlite/src/config.h <<EOF  #if ZTS  # define THREADSAFE 1  #endif @@ -95,9 +97,9 @@ if test "$PHP_SQLITE" != "no"; then  #endif  EOF -	sed -e s/--VERS--/`cat $ext_srcdir/libsqlite/VERSION`/ -e s/--ENCODING--/$SQLITE_ENCODING/ $ext_srcdir/libsqlite/src/sqlite.h.in >$ext_srcdir/libsqlite/src/sqlite.h +    sed -e s/--VERS--/`cat $ext_srcdir/libsqlite/VERSION`/ -e s/--ENCODING--/$SQLITE_ENCODING/ $ext_srcdir/libsqlite/src/sqlite.h.in >$ext_srcdir/libsqlite/src/sqlite.h -	PHP_ADD_MAKEFILE_FRAGMENT +    PHP_ADD_MAKEFILE_FRAGMENT    fi diff --git a/ext/sqlite/libsqlite/VERSION b/ext/sqlite/libsqlite/VERSION index 834f262953..1817afea41 100644 --- a/ext/sqlite/libsqlite/VERSION +++ b/ext/sqlite/libsqlite/VERSION @@ -1 +1 @@ -2.8.0 +2.8.2 diff --git a/ext/sqlite/libsqlite/src/attach.c b/ext/sqlite/libsqlite/src/attach.c new file mode 100644 index 0000000000..dd94c21182 --- /dev/null +++ b/ext/sqlite/libsqlite/src/attach.c @@ -0,0 +1,130 @@ +/* +** 2003 April 6 +** +** 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. +** +************************************************************************* +** This file contains code used to implement the ATTACH and DETACH commands. +** +** $Id$ +*/ +#include "sqliteInt.h" + +/* +** This routine is called by the parser to process an ATTACH statement: +** +**     ATTACH DATABASE filename AS dbname +** +** The pFilename and pDbname arguments are the tokens that define the +** filename and dbname in the ATTACH statement. +*/ +void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){ +  Db *aNew; +  int rc, i; +  char *zFile, *zName; +  sqlite *db; + +  if( pParse->explain ) return; +  db = pParse->db; +  if( db->file_format<4 ){ +    sqliteErrorMsg(pParse, "cannot attach auxiliary databases to an " +       "older format master database", 0); +    pParse->rc = SQLITE_ERROR; +    return; +  } +  if( db->nDb>=MAX_ATTACHED+2 ){ +    sqliteErrorMsg(pParse, "too many attached databases - max %d",  +       MAX_ATTACHED); +    pParse->rc = SQLITE_ERROR; +    return; +  } +  if( db->aDb==db->aDbStatic ){ +    aNew = sqliteMalloc( sizeof(db->aDb[0])*3 ); +    if( aNew==0 ) return; +    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2); +  }else{ +    aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) ); +    if( aNew==0 ) return; +  } +  db->aDb = aNew; +  aNew = &db->aDb[db->nDb++]; +  memset(aNew, 0, sizeof(*aNew)); +  sqliteHashInit(&aNew->tblHash, SQLITE_HASH_STRING, 0); +  sqliteHashInit(&aNew->idxHash, SQLITE_HASH_STRING, 0); +  sqliteHashInit(&aNew->trigHash, SQLITE_HASH_STRING, 0); +  sqliteHashInit(&aNew->aFKey, SQLITE_HASH_STRING, 1); +   +  zName = 0; +  sqliteSetNString(&zName, pDbname->z, pDbname->n, 0); +  if( zName==0 ) return; +  sqliteDequote(zName); +  for(i=0; i<db->nDb; i++){ +    if( db->aDb[i].zName && sqliteStrICmp(db->aDb[i].zName, zName)==0 ){ +      sqliteErrorMsg(pParse, "database %z is already in use", zName); +      db->nDb--; +      pParse->rc = SQLITE_ERROR; +      return; +    } +  } +  aNew->zName = zName; +  zFile = 0; +  sqliteSetNString(&zFile, pFilename->z, pFilename->n, 0); +  if( zFile==0 ) return; +  sqliteDequote(zFile); +  rc = sqliteBtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt); +  if( rc ){ +    sqliteErrorMsg(pParse, "unable to open database: %s", zFile); +  } +  sqliteFree(zFile); +  db->flags &= ~SQLITE_Initialized; +  if( pParse->nErr ) return; +  rc = sqliteInit(pParse->db, &pParse->zErrMsg); +  if( rc ){ +    sqliteResetInternalSchema(db, 0); +    pParse->nErr++; +    pParse->rc = SQLITE_ERROR; +  } +} + +/* +** This routine is called by the parser to process a DETACH statement: +** +**    DETACH DATABASE dbname +** +** The pDbname argument is the name of the database in the DETACH statement. +*/ +void sqliteDetach(Parse *pParse, Token *pDbname){ +  int i; +  sqlite *db; + +  if( pParse->explain ) return; +  db = pParse->db; +  for(i=0; i<db->nDb; i++){ +    if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue; +    if( strlen(db->aDb[i].zName)!=pDbname->n ) continue; +    if( sqliteStrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break; +  } +  if( i>=db->nDb ){ +    sqliteErrorMsg(pParse, "no such database: %T", pDbname); +    return; +  } +  if( i<2 ){ +    sqliteErrorMsg(pParse, "cannot detach database %T", pDbname); +    return; +  } +  sqliteBtreeClose(db->aDb[i].pBt); +  db->aDb[i].pBt = 0; +  sqliteFree(db->aDb[i].zName); +  sqliteResetInternalSchema(db, i); +  db->nDb--; +  if( i<db->nDb ){ +    db->aDb[i] = db->aDb[db->nDb]; +    memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0])); +    sqliteResetInternalSchema(db, i); +  } +} diff --git a/ext/sqlite/libsqlite/src/auth.c b/ext/sqlite/libsqlite/src/auth.c index 76518e705b..547cd18f14 100644 --- a/ext/sqlite/libsqlite/src/auth.c +++ b/ext/sqlite/libsqlite/src/auth.c @@ -28,15 +28,35 @@  ** Set or clear the access authorization function.  **  ** The access authorization function is be called during the compilation -** phase to verify that the user has read and/or write access permission +** phase to verify that the user has read and/or write access permission on  ** various fields of the database.  The first argument to the auth function  ** is a copy of the 3rd argument to this routine.  The second argument  ** to the auth function is one of these constants:  ** -**        SQLITE_READ_COLUMN -**        SQLITE_WRITE_COLUMN -**        SQLITE_DELETE_ROW -**        SQLITE_INSERT_ROW +**       SQLITE_COPY +**       SQLITE_CREATE_INDEX +**       SQLITE_CREATE_TABLE +**       SQLITE_CREATE_TEMP_INDEX +**       SQLITE_CREATE_TEMP_TABLE +**       SQLITE_CREATE_TEMP_TRIGGER +**       SQLITE_CREATE_TEMP_VIEW +**       SQLITE_CREATE_TRIGGER +**       SQLITE_CREATE_VIEW +**       SQLITE_DELETE +**       SQLITE_DROP_INDEX +**       SQLITE_DROP_TABLE +**       SQLITE_DROP_TEMP_INDEX +**       SQLITE_DROP_TEMP_TABLE +**       SQLITE_DROP_TEMP_TRIGGER +**       SQLITE_DROP_TEMP_VIEW +**       SQLITE_DROP_TRIGGER +**       SQLITE_DROP_VIEW +**       SQLITE_INSERT +**       SQLITE_PRAGMA +**       SQLITE_READ +**       SQLITE_SELECT +**       SQLITE_TRANSACTION +**       SQLITE_UPDATE  **  ** The third and fourth arguments to the auth function are the name of  ** the table and the column that are being accessed.  The auth function @@ -52,7 +72,7 @@  */  int sqlite_set_authorizer(    sqlite *db, -  int (*xAuth)(void*,int,const char*,const char*), +  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),    void *pArg  ){    db->xAuth = xAuth; @@ -76,8 +96,8 @@ static void sqliteAuthBadReturnCode(Parse *pParse, int rc){  /*  ** The pExpr should be a TK_COLUMN expression.  The table referred to -** is in pTabList with an offset of base.  Check to see if it is OK to read -** this particular column. +** is in pTabList or else it is the NEW or OLD table of a trigger.   +** Check to see if it is OK to read this particular column.  **  ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN   ** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY, @@ -86,17 +106,32 @@ static void sqliteAuthBadReturnCode(Parse *pParse, int rc){  void sqliteAuthRead(    Parse *pParse,        /* The parser context */    Expr *pExpr,          /* The expression to check authorization on */ -  SrcList *pTabList,    /* All table that pExpr might refer to */ -  int base              /* Offset of pTabList relative to pExpr */ +  SrcList *pTabList     /* All table that pExpr might refer to */  ){    sqlite *db = pParse->db;    int rc; -  Table *pTab; -  const char *zCol; +  Table *pTab;          /* The table being read */ +  const char *zCol;     /* Name of the column of the table */ +  int iSrc;             /* Index in pTabList->a[] of table being read */ +  const char *zDBase;   /* Name of database being accessed */ +    if( db->xAuth==0 ) return;    assert( pExpr->op==TK_COLUMN ); -  assert( pExpr->iTable>=base && pExpr->iTable<base+pTabList->nSrc ); -  pTab = pTabList->a[pExpr->iTable-base].pTab; +  for(iSrc=0; iSrc<pTabList->nSrc; iSrc++){ +    if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break; +  } +  if( iSrc>=0 && iSrc<pTabList->nSrc ){ +    pTab = pTabList->a[iSrc].pTab; +  }else{ +    /* This must be an attempt to read the NEW or OLD pseudo-tables +    ** of a trigger. +    */ +    TriggerStack *pStack; /* The stack of current triggers */ +    pStack = pParse->trigStack; +    assert( pStack!=0 ); +    assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx ); +    pTab = pStack->pTab; +  }    if( pTab==0 ) return;    if( pExpr->iColumn>=0 ){      assert( pExpr->iColumn<pTab->nCol ); @@ -107,12 +142,20 @@ void sqliteAuthRead(    }else{      zCol = "ROWID";    } -  rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol); +  assert( pExpr->iDb<db->nDb ); +  zDBase = db->aDb[pExpr->iDb].zName; +  rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase,  +                 pParse->zAuthContext);    if( rc==SQLITE_IGNORE ){      pExpr->op = TK_NULL;    }else if( rc==SQLITE_DENY ){ -    sqliteSetString(&pParse->zErrMsg,"access to ", -        pTab->zName, ".", zCol, " is prohibited", 0); +    if( db->nDb>2 || pExpr->iDb!=0 ){ +      sqliteSetString(&pParse->zErrMsg,"access to ", zDBase, ".", +          pTab->zName, ".", zCol, " is prohibited", 0); +    }else{ +      sqliteSetString(&pParse->zErrMsg,"access to ", pTab->zName, ".", +                      zCol, " is prohibited", 0); +    }      pParse->nErr++;      pParse->rc = SQLITE_AUTH;    }else if( rc!=SQLITE_OK ){ @@ -130,14 +173,16 @@ int sqliteAuthCheck(    Parse *pParse,    int code,    const char *zArg1, -  const char *zArg2 +  const char *zArg2, +  const char *zArg3  ){    sqlite *db = pParse->db;    int rc; +    if( db->xAuth==0 ){      return SQLITE_OK;    } -  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2); +  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);    if( rc==SQLITE_DENY ){      sqliteSetString(&pParse->zErrMsg, "not authorized", 0);      pParse->rc = SQLITE_AUTH; @@ -149,4 +194,32 @@ int sqliteAuthCheck(    return rc;  } +/* +** Push an authorization context.  After this routine is called, the +** zArg3 argument to authorization callbacks will be zContext until +** popped.  Or if pParse==0, this routine is a no-op. +*/ +void sqliteAuthContextPush( +  Parse *pParse, +  AuthContext *pContext,  +  const char *zContext +){ +  pContext->pParse = pParse; +  if( pParse ){ +    pContext->zAuthContext = pParse->zAuthContext; +    pParse->zAuthContext = zContext; +  } +} + +/* +** Pop an authorization context that was previously pushed +** by sqliteAuthContextPush +*/ +void sqliteAuthContextPop(AuthContext *pContext){ +  if( pContext->pParse ){ +    pContext->pParse->zAuthContext = pContext->zAuthContext; +    pContext->pParse = 0; +  } +} +  #endif /* SQLITE_OMIT_AUTHORIZATION */ diff --git a/ext/sqlite/libsqlite/src/btree.c b/ext/sqlite/libsqlite/src/btree.c index 41913fc551..30979d0e31 100644 --- a/ext/sqlite/libsqlite/src/btree.c +++ b/ext/sqlite/libsqlite/src/btree.c @@ -54,6 +54,10 @@  #include "btree.h"  #include <assert.h> +/* Forward declarations */ +static BtOps sqliteBtreeOps; +static BtCursorOps sqliteBtreeCursorOps; +  /*  ** Macros used for byteswapping.  B is a pointer to the Btree  ** structure.  This is needed to access the Btree.needSwab boolean @@ -61,7 +65,7 @@  ** X is an unsigned integer.  SWAB16 byte swaps a 16-bit integer.  ** SWAB32 byteswaps a 32-bit integer.  */ -#define SWAB16(B,X)   ((B)->needSwab? swab16(X) : (X)) +#define SWAB16(B,X)   ((B)->needSwab? swab16((u16)X) : ((u16)X))  #define SWAB32(B,X)   ((B)->needSwab? swab32(X) : (X))  #define SWAB_ADD(B,X,A) \     if((B)->needSwab){ X=swab32(swab32(X)+A); }else{ X += (A); } @@ -340,6 +344,7 @@ struct MemPage {  ** Everything we need to know about an open database  */  struct Btree { +  BtOps *pOps;          /* Function table */    Pager *pPager;        /* The page cache */    BtCursor *pCursor;    /* A list of all open cursors */    PageOne *page1;       /* First page of the database */ @@ -356,6 +361,7 @@ typedef Btree Bt;  ** MemPage.apCell[] of the entry.  */  struct BtCursor { +  BtCursorOps *pOps;        /* Function table */    Btree *pBt;               /* The Btree to which this cursor belongs */    BtCursor *pNext, *pPrev;  /* Forms a linked list of all cursors */    BtCursor *pShared;        /* Loop of cursors with the same root page */ @@ -375,6 +381,9 @@ struct BtCursor {  #define SKIP_PREV     2   /* The next sqliteBtreePrevious() is a no-op */  #define SKIP_INVALID  3   /* Calls to Next() and Previous() are invalid */ +/* Forward declarations */ +static int fileBtreeCloseCursor(BtCursor *pCur); +  /*  ** Routines for byte swapping.  */ @@ -527,7 +536,7 @@ static void freeSpace(Btree *pBt, MemPage *pPage, int start, int size){        if( idx + iSize + size == SWAB16(pBt, pFBlk->iNext) ){          pNext = (FreeBlk*)&pPage->u.aDisk[idx + iSize + size];          if( pBt->needSwab ){ -          pFBlk->iSize = swab16(swab16(pNext->iSize)+iSize+size); +          pFBlk->iSize = swab16((u16)swab16(pNext->iSize)+iSize+size);          }else{            pFBlk->iSize += pNext->iSize;          } @@ -709,6 +718,7 @@ int sqliteBtreeOpen(    pBt->pCursor = 0;    pBt->page1 = 0;    pBt->readOnly = sqlitepager_isreadonly(pBt->pPager); +  pBt->pOps = &sqliteBtreeOps;    *ppBtree = pBt;    return SQLITE_OK;  } @@ -716,9 +726,9 @@ int sqliteBtreeOpen(  /*  ** Close an open database and invalidate all cursors.  */ -int sqliteBtreeClose(Btree *pBt){ +static int fileBtreeClose(Btree *pBt){    while( pBt->pCursor ){ -    sqliteBtreeCloseCursor(pBt->pCursor); +    fileBtreeCloseCursor(pBt->pCursor);    }    sqlitepager_close(pBt->pPager);    sqliteFree(pBt); @@ -740,7 +750,7 @@ int sqliteBtreeClose(Btree *pBt){  ** Synchronous is on by default so database corruption is not  ** normally a worry.  */ -int sqliteBtreeSetCacheSize(Btree *pBt, int mxPage){ +static int fileBtreeSetCacheSize(Btree *pBt, int mxPage){    sqlitepager_set_cachesize(pBt->pPager, mxPage);    return SQLITE_OK;  } @@ -753,7 +763,7 @@ int sqliteBtreeSetCacheSize(Btree *pBt, int mxPage){  ** is a very low but non-zero probability of damage.  Level 3 reduces the  ** probability of damage to near zero but with a write performance reduction.  */ -int sqliteBtreeSetSafetyLevel(Btree *pBt, int level){ +static int fileBtreeSetSafetyLevel(Btree *pBt, int level){    sqlitepager_set_safety_level(pBt->pPager, level);    return SQLITE_OK;  } @@ -860,7 +870,7 @@ static int newDatabase(Btree *pBt){  **      sqliteBtreeDelete()  **      sqliteBtreeUpdateMeta()  */ -int sqliteBtreeBeginTrans(Btree *pBt){ +static int fileBtreeBeginTrans(Btree *pBt){    int rc;    if( pBt->inTrans ) return SQLITE_ERROR;    if( pBt->readOnly ) return SQLITE_READONLY; @@ -889,7 +899,7 @@ int sqliteBtreeBeginTrans(Btree *pBt){  ** This will release the write lock on the database file.  If there  ** are no active cursors, it also releases the read lock.  */ -int sqliteBtreeCommit(Btree *pBt){ +static int fileBtreeCommit(Btree *pBt){    int rc;    rc = pBt->readOnly ? SQLITE_OK : sqlitepager_commit(pBt->pPager);    pBt->inTrans = 0; @@ -907,7 +917,7 @@ int sqliteBtreeCommit(Btree *pBt){  ** This will release the write lock on the database file.  If there  ** are no active cursors, it also releases the read lock.  */ -int sqliteBtreeRollback(Btree *pBt){ +static int fileBtreeRollback(Btree *pBt){    int rc;    BtCursor *pCur;    if( pBt->inTrans==0 ) return SQLITE_OK; @@ -934,7 +944,7 @@ int sqliteBtreeRollback(Btree *pBt){  ** Only one checkpoint may be active at a time.  It is an error to try  ** to start a new checkpoint if another checkpoint is already active.  */ -int sqliteBtreeBeginCkpt(Btree *pBt){ +static int fileBtreeBeginCkpt(Btree *pBt){    int rc;    if( !pBt->inTrans || pBt->inCkpt ){      return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; @@ -949,7 +959,7 @@ int sqliteBtreeBeginCkpt(Btree *pBt){  ** Commit a checkpoint to transaction currently in progress.  If no  ** checkpoint is active, this is a no-op.  */ -int sqliteBtreeCommitCkpt(Btree *pBt){ +static int fileBtreeCommitCkpt(Btree *pBt){    int rc;    if( pBt->inCkpt && !pBt->readOnly ){      rc = sqlitepager_ckpt_commit(pBt->pPager); @@ -968,7 +978,7 @@ int sqliteBtreeCommitCkpt(Btree *pBt){  ** to use a cursor that was open at the beginning of this operation  ** will result in an error.  */ -int sqliteBtreeRollbackCkpt(Btree *pBt){ +static int fileBtreeRollbackCkpt(Btree *pBt){    int rc;    BtCursor *pCur;    if( pBt->inCkpt==0 || pBt->readOnly ) return SQLITE_OK; @@ -1019,7 +1029,7 @@ int sqliteBtreeRollbackCkpt(Btree *pBt){  ** root page of a b-tree.  If it is not, then the cursor acquired  ** will not work correctly.  */ -int sqliteBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){ +static int fileBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){    int rc;    BtCursor *pCur, *pRing; @@ -1044,6 +1054,7 @@ int sqliteBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){    if( rc!=SQLITE_OK ){      goto create_cursor_exception;    } +  pCur->pOps = &sqliteBtreeCursorOps;    pCur->pBt = pBt;    pCur->wrFlag = wrFlag;    pCur->idx = 0; @@ -1079,7 +1090,7 @@ create_cursor_exception:  ** Close a cursor.  The read lock on the database file is released  ** when the last cursor is closed.  */ -int sqliteBtreeCloseCursor(BtCursor *pCur){ +static int fileBtreeCloseCursor(BtCursor *pCur){    Btree *pBt = pCur->pBt;    if( pCur->pPrev ){      pCur->pPrev->pNext = pCur->pNext; @@ -1132,7 +1143,7 @@ static void releaseTempCursor(BtCursor *pCur){  ** pointing to an entry (which can happen, for example, if  ** the database is empty) then *pSize is set to 0.  */ -int sqliteBtreeKeySize(BtCursor *pCur, int *pSize){ +static int fileBtreeKeySize(BtCursor *pCur, int *pSize){    Cell *pCell;    MemPage *pPage; @@ -1221,7 +1232,7 @@ static int getPayload(BtCursor *pCur, int offset, int amt, char *zBuf){  ** is raised.  The change was made in an effort to boost performance  ** by eliminating unneeded tests.  */ -int sqliteBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){ +static int fileBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){    MemPage *pPage;    assert( amt>=0 ); @@ -1243,7 +1254,7 @@ int sqliteBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){  ** pointing to an entry (which can happen, for example, if  ** the database is empty) then *pSize is set to 0.  */ -int sqliteBtreeDataSize(BtCursor *pCur, int *pSize){ +static int fileBtreeDataSize(BtCursor *pCur, int *pSize){    Cell *pCell;    MemPage *pPage; @@ -1266,7 +1277,7 @@ int sqliteBtreeDataSize(BtCursor *pCur, int *pSize){  ** amount requested if there are not enough bytes in the data  ** to satisfy the request.  */ -int sqliteBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){ +static int fileBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){    Cell *pCell;    MemPage *pPage; @@ -1304,7 +1315,7 @@ int sqliteBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){  ** keys must be exactly the same length. (The length of the pCur key  ** is the actual key length minus nIgnore bytes.)  */ -int sqliteBtreeKeyCompare( +static int fileBtreeKeyCompare(    BtCursor *pCur,       /* Pointer to entry to compare against */    const void *pKey,     /* Key to compare against entry that pCur points to */    int nKey,             /* Number of bytes in pKey */ @@ -1389,6 +1400,7 @@ static int moveToChild(BtCursor *pCur, int newPgno){    sqlitepager_unref(pCur->pPage);    pCur->pPage = pNewPage;    pCur->idx = 0; +  if( pNewPage->nCell<1 ) return SQLITE_CORRUPT;    return SQLITE_OK;  } @@ -1502,7 +1514,7 @@ static int moveToRightmost(BtCursor *pCur){  ** on success.  Set *pRes to 0 if the cursor actually points to something  ** or set *pRes to 1 if the table is empty.  */ -int sqliteBtreeFirst(BtCursor *pCur, int *pRes){ +static int fileBtreeFirst(BtCursor *pCur, int *pRes){    int rc;    if( pCur->pPage==0 ) return SQLITE_ABORT;    rc = moveToRoot(pCur); @@ -1521,7 +1533,7 @@ int sqliteBtreeFirst(BtCursor *pCur, int *pRes){  ** on success.  Set *pRes to 0 if the cursor actually points to something  ** or set *pRes to 1 if the table is empty.  */ -int sqliteBtreeLast(BtCursor *pCur, int *pRes){ +static int fileBtreeLast(BtCursor *pCur, int *pRes){    int rc;    if( pCur->pPage==0 ) return SQLITE_ABORT;    rc = moveToRoot(pCur); @@ -1560,7 +1572,8 @@ int sqliteBtreeLast(BtCursor *pCur, int *pRes){  **     *pRes>0      The cursor is left pointing at an entry that  **                  is larger than pKey.  */ -int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){ +static +int fileBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){    int rc;    if( pCur->pPage==0 ) return SQLITE_ABORT;    pCur->eSkip = SKIP_NONE; @@ -1575,7 +1588,7 @@ int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){      upr = pPage->nCell-1;      while( lwr<=upr ){        pCur->idx = (lwr+upr)/2; -      rc = sqliteBtreeKeyCompare(pCur, pKey, nKey, 0, &c); +      rc = fileBtreeKeyCompare(pCur, pKey, nKey, 0, &c);        if( rc ) return rc;        if( c==0 ){          pCur->iMatch = c; @@ -1613,7 +1626,7 @@ int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){  ** was already pointing to the last entry in the database before  ** this routine was called, then set *pRes=1.  */ -int sqliteBtreeNext(BtCursor *pCur, int *pRes){ +static int fileBtreeNext(BtCursor *pCur, int *pRes){    int rc;    MemPage *pPage = pCur->pPage;    assert( pRes!=0 ); @@ -1668,7 +1681,7 @@ int sqliteBtreeNext(BtCursor *pCur, int *pRes){  ** was already pointing to the first entry in the database before  ** this routine was called, then set *pRes=1.  */ -int sqliteBtreePrevious(BtCursor *pCur, int *pRes){ +static int fileBtreePrevious(BtCursor *pCur, int *pRes){    int rc;    Pgno pgno;    MemPage *pPage; @@ -2594,7 +2607,7 @@ static int checkReadLocks(BtCursor *pCur){  ** define what database the record should be inserted into.  The cursor  ** is left pointing at the new record.  */ -int sqliteBtreeInsert( +static int fileBtreeInsert(    BtCursor *pCur,                /* Insert data into the table of this cursor */    const void *pKey, int nKey,    /* The key of the new record */    const void *pData, int nData   /* The data of the new record */ @@ -2620,7 +2633,7 @@ int sqliteBtreeInsert(    if( checkReadLocks(pCur) ){      return SQLITE_LOCKED; /* The table pCur points to has a read lock */    } -  rc = sqliteBtreeMoveto(pCur, pKey, nKey, &loc); +  rc = fileBtreeMoveto(pCur, pKey, nKey, &loc);    if( rc ) return rc;    pPage = pCur->pPage;    assert( pPage->isInit ); @@ -2662,7 +2675,7 @@ int sqliteBtreeInsert(  ** sqliteBtreePrevious() will always leave the cursor pointing at the  ** entry immediately before the one that was deleted.  */ -int sqliteBtreeDelete(BtCursor *pCur){ +static int fileBtreeDelete(BtCursor *pCur){    MemPage *pPage = pCur->pPage;    Cell *pCell;    int rc; @@ -2705,7 +2718,7 @@ int sqliteBtreeDelete(BtCursor *pCur){      int szNext;      int notUsed;      getTempCursor(pCur, &leafCur); -    rc = sqliteBtreeNext(&leafCur, ¬Used); +    rc = fileBtreeNext(&leafCur, ¬Used);      if( rc!=SQLITE_OK ){        return SQLITE_CORRUPT;      } @@ -2745,11 +2758,12 @@ int sqliteBtreeDelete(BtCursor *pCur){  ** number for the root page of the new table.  **  ** In the current implementation, BTree tables and BTree indices are the  -** the same.  But in the future, we may change this so that BTree tables +** the same.  In the future, we may change this so that BTree tables  ** are restricted to having a 4-byte integer key and arbitrary data and  ** BTree indices are restricted to having an arbitrary key and no data. +** But for now, this routine also serves to create indices.  */ -int sqliteBtreeCreateTable(Btree *pBt, int *piTable){ +static int fileBtreeCreateTable(Btree *pBt, int *piTable){    MemPage *pRoot;    Pgno pgnoRoot;    int rc; @@ -2770,19 +2784,6 @@ int sqliteBtreeCreateTable(Btree *pBt, int *piTable){  }  /* -** Create a new BTree index.  Write into *piTable the page -** number for the root page of the new index. -** -** In the current implementation, BTree tables and BTree indices are the  -** the same.  But in the future, we may change this so that BTree tables -** are restricted to having a 4-byte integer key and arbitrary data and -** BTree indices are restricted to having an arbitrary key and no data. -*/ -int sqliteBtreeCreateIndex(Btree *pBt, int *piIndex){ -  return sqliteBtreeCreateTable(pBt, piIndex); -} - -/*  ** Erase the given database page and all its children.  Return  ** the page to the freelist.  */ @@ -2825,7 +2826,7 @@ static int clearDatabasePage(Btree *pBt, Pgno pgno, int freePageFlag){  /*  ** Delete all information from a single table in the database.  */ -int sqliteBtreeClearTable(Btree *pBt, int iTable){ +static int fileBtreeClearTable(Btree *pBt, int iTable){    int rc;    BtCursor *pCur;    if( !pBt->inTrans ){ @@ -2839,7 +2840,7 @@ int sqliteBtreeClearTable(Btree *pBt, int iTable){    }    rc = clearDatabasePage(pBt, (Pgno)iTable, 0);    if( rc ){ -    sqliteBtreeRollback(pBt); +    fileBtreeRollback(pBt);    }    return rc;  } @@ -2849,7 +2850,7 @@ int sqliteBtreeClearTable(Btree *pBt, int iTable){  ** the freelist.  Except, the root of the principle table (the one on  ** page 2) is never added to the freelist.  */ -int sqliteBtreeDropTable(Btree *pBt, int iTable){ +static int fileBtreeDropTable(Btree *pBt, int iTable){    int rc;    MemPage *pPage;    BtCursor *pCur; @@ -2863,7 +2864,7 @@ int sqliteBtreeDropTable(Btree *pBt, int iTable){    }    rc = sqlitepager_get(pBt->pPager, (Pgno)iTable, (void**)&pPage);    if( rc ) return rc; -  rc = sqliteBtreeClearTable(pBt, iTable); +  rc = fileBtreeClearTable(pBt, iTable);    if( rc ) return rc;    if( iTable>2 ){      rc = freePage(pBt, pPage, iTable); @@ -2874,10 +2875,109 @@ int sqliteBtreeDropTable(Btree *pBt, int iTable){    return rc;    } +#if 0 /* UNTESTED */ +/* +** Copy all cell data from one database file into another. +** pages back the freelist. +*/ +static int copyCell(Btree *pBtFrom, BTree *pBtTo, Cell *pCell){ +  Pager *pFromPager = pBtFrom->pPager; +  OverflowPage *pOvfl; +  Pgno ovfl, nextOvfl; +  Pgno *pPrev; +  int rc = SQLITE_OK; +  MemPage *pNew, *pPrevPg; +  Pgno new; + +  if( NKEY(pBtTo, pCell->h) + NDATA(pBtTo, pCell->h) <= MX_LOCAL_PAYLOAD ){ +    return SQLITE_OK; +  } +  pPrev = &pCell->ovfl; +  pPrevPg = 0; +  ovfl = SWAB32(pBtTo, pCell->ovfl); +  while( ovfl && rc==SQLITE_OK ){ +    rc = sqlitepager_get(pFromPager, ovfl, (void**)&pOvfl); +    if( rc ) return rc; +    nextOvfl = SWAB32(pBtFrom, pOvfl->iNext); +    rc = allocatePage(pBtTo, &pNew, &new, 0); +    if( rc==SQLITE_OK ){ +      rc = sqlitepager_write(pNew); +      if( rc==SQLITE_OK ){ +        memcpy(pNew, pOvfl, SQLITE_PAGE_SIZE); +        *pPrev = SWAB32(pBtTo, new); +        if( pPrevPg ){ +          sqlitepager_unref(pPrevPg); +        } +        pPrev = &pOvfl->iNext; +        pPrevPg = pNew; +      } +    } +    sqlitepager_unref(pOvfl); +    ovfl = nextOvfl; +  } +  if( pPrevPg ){ +    sqlitepager_unref(pPrevPg); +  } +  return rc; +} +#endif + + +#if 0 /* UNTESTED */ +/* +** Copy a page of data from one database over to another. +*/ +static int copyDatabasePage( +  Btree *pBtFrom, +  Pgno pgnoFrom, +  Btree *pBtTo, +  Pgno *pTo +){ +  MemPage *pPageFrom, *pPage; +  Pgno to; +  int rc; +  Cell *pCell; +  int idx; + +  rc = sqlitepager_get(pBtFrom->pPager, pgno, (void**)&pPageFrom); +  if( rc ) return rc; +  rc = allocatePage(pBt, &pPage, pTo, 0); +  if( rc==SQLITE_OK ){ +    rc = sqlitepager_write(pPage); +  } +  if( rc==SQLITE_OK ){ +    memcpy(pPage, pPageFrom, SQLITE_PAGE_SIZE); +    idx = SWAB16(pBt, pPage->u.hdr.firstCell); +    while( idx>0 ){ +      pCell = (Cell*)&pPage->u.aDisk[idx]; +      idx = SWAB16(pBt, pCell->h.iNext); +      if( pCell->h.leftChild ){ +        Pgno newChld; +        rc = copyDatabasePage(pBtFrom, SWAB32(pBtFrom, pCell->h.leftChild), +                              pBtTo, &newChld); +        if( rc ) return rc; +        pCell->h.leftChild = SWAB32(pBtFrom, newChld); +      } +      rc = copyCell(pBtFrom, pBtTo, pCell); +      if( rc ) return rc; +    } +    if( pPage->u.hdr.rightChild ){ +      Pgno newChld; +      rc = copyDatabasePage(pBtFrom, SWAB32(pBtFrom, pPage->u.hdr.rightChild),  +                            pBtTo, &newChld); +      if( rc ) return rc; +      pPage->u.hdr.rightChild = SWAB32(pBtTo, newChild); +    } +  } +  sqlitepager_unref(pPage); +  return rc; +} +#endif +  /*  ** Read the meta-information out of a database file.  */ -int sqliteBtreeGetMeta(Btree *pBt, int *aMeta){ +static int fileBtreeGetMeta(Btree *pBt, int *aMeta){    PageOne *pP1;    int rc;    int i; @@ -2895,7 +2995,7 @@ int sqliteBtreeGetMeta(Btree *pBt, int *aMeta){  /*  ** Write meta-information back into the database.  */ -int sqliteBtreeUpdateMeta(Btree *pBt, int *aMeta){ +static int fileBtreeUpdateMeta(Btree *pBt, int *aMeta){    PageOne *pP1;    int rc, i;    if( !pBt->inTrans ){ @@ -2921,7 +3021,7 @@ int sqliteBtreeUpdateMeta(Btree *pBt, int *aMeta){  ** is used for debugging and testing only.  */  #ifdef SQLITE_TEST -int sqliteBtreePageDump(Btree *pBt, int pgno, int recursive){ +static int fileBtreePageDump(Btree *pBt, int pgno, int recursive){    int rc;    MemPage *pPage;    int i, j; @@ -2982,10 +3082,10 @@ int sqliteBtreePageDump(Btree *pBt, int pgno, int recursive){      idx = SWAB16(pBt, pPage->u.hdr.firstCell);      while( idx>0 && idx<SQLITE_PAGE_SIZE-MIN_CELL_SIZE ){        Cell *pCell = (Cell*)&pPage->u.aDisk[idx]; -      sqliteBtreePageDump(pBt, SWAB32(pBt, pCell->h.leftChild), 1); +      fileBtreePageDump(pBt, SWAB32(pBt, pCell->h.leftChild), 1);        idx = SWAB16(pBt, pCell->h.iNext);      } -    sqliteBtreePageDump(pBt, SWAB32(pBt, pPage->u.hdr.rightChild), 1); +    fileBtreePageDump(pBt, SWAB32(pBt, pPage->u.hdr.rightChild), 1);    }    sqlitepager_unref(pPage);    return SQLITE_OK; @@ -3008,7 +3108,7 @@ int sqliteBtreePageDump(Btree *pBt, int pgno, int recursive){  **  ** This routine is used for testing and debugging only.  */ -int sqliteBtreeCursorDump(BtCursor *pCur, int *aResult){ +static int fileBtreeCursorDump(BtCursor *pCur, int *aResult){    int cnt, idx;    MemPage *pPage = pCur->pPage;    Btree *pBt = pCur->pBt; @@ -3040,7 +3140,7 @@ int sqliteBtreeCursorDump(BtCursor *pCur, int *aResult){  ** Return the pager associated with a BTree.  This routine is used for  ** testing and debugging only.  */ -Pager *sqliteBtreePager(Btree *pBt){ +static Pager *fileBtreePager(Btree *pBt){    return pBt->pPager;  }  #endif @@ -3129,7 +3229,7 @@ static void checkList(        FreelistInfo *pInfo = (FreelistInfo*)pOvfl->aPayload;        int n = SWAB32(pCheck->pBt, pInfo->nFree);        for(i=0; i<n; i++){ -        checkRef(pCheck, SWAB32(pCheck->pBt, pInfo->aFree[i]), zMsg); +        checkRef(pCheck, SWAB32(pCheck->pBt, pInfo->aFree[i]), zContext);        }        N -= n;      } @@ -3320,7 +3420,7 @@ static int checkTreePage(  ** and a pointer to that error message is returned.  The calling function  ** is responsible for freeing the error message when it is done.  */ -char *sqliteBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){ +char *fileBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){    int i;    int nRef;    IntegrityCk sCheck; @@ -3380,3 +3480,104 @@ char *sqliteBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){    sqliteFree(sCheck.anRef);    return sCheck.zErrMsg;  } + +/* +** Return the full pathname of the underlying database file. +*/ +static const char *fileBtreeGetFilename(Btree *pBt){ +  assert( pBt->pPager!=0 ); +  return sqlitepager_filename(pBt->pPager); +} + +/* +** Copy the complete content of pBtFrom into pBtTo.  A transaction +** must be active for both files. +** +** The size of file pBtFrom may be reduced by this operation. +** If anything goes wrong, the transaction on pBtFrom is rolled back. +*/ +static int fileBtreeCopyFile(Btree *pBtTo, Btree *pBtFrom){ +  int rc = SQLITE_OK; +  Pgno i, nPage, nToPage; + +  if( !pBtTo->inTrans || !pBtFrom->inTrans ) return SQLITE_ERROR; +  if( pBtTo->needSwab!=pBtFrom->needSwab ) return SQLITE_ERROR; +  if( pBtTo->pCursor ) return SQLITE_BUSY; +  memcpy(pBtTo->page1, pBtFrom->page1, SQLITE_PAGE_SIZE); +  rc = sqlitepager_overwrite(pBtTo->pPager, 1, pBtFrom->page1); +  nToPage = sqlitepager_pagecount(pBtTo->pPager); +  nPage = sqlitepager_pagecount(pBtFrom->pPager); +  for(i=2; rc==SQLITE_OK && i<=nPage; i++){ +    void *pPage; +    rc = sqlitepager_get(pBtFrom->pPager, i, &pPage); +    if( rc ) break; +    rc = sqlitepager_overwrite(pBtTo->pPager, i, pPage); +    if( rc ) break; +    sqlitepager_unref(pPage); +  } +  for(i=nPage+1; rc==SQLITE_OK && i<=nToPage; i++){ +    void *pPage; +    rc = sqlitepager_get(pBtTo->pPager, i, &pPage); +    if( rc ) break; +    rc = sqlitepager_write(pPage); +    sqlitepager_unref(pPage); +    sqlitepager_dont_write(pBtTo->pPager, i); +  } +  if( !rc && nPage<nToPage ){ +    rc = sqlitepager_truncate(pBtTo->pPager, nPage); +  } +  if( rc ){ +    fileBtreeRollback(pBtTo); +  } +  return rc;   +} + +/* +** The following tables contain pointers to all of the interface +** routines for this implementation of the B*Tree backend.  To +** substitute a different implemention of the backend, one has merely +** to provide pointers to alternative functions in similar tables. +*/ +static BtOps sqliteBtreeOps = { +    fileBtreeClose, +    fileBtreeSetCacheSize, +    fileBtreeSetSafetyLevel, +    fileBtreeBeginTrans, +    fileBtreeCommit, +    fileBtreeRollback, +    fileBtreeBeginCkpt, +    fileBtreeCommitCkpt, +    fileBtreeRollbackCkpt, +    fileBtreeCreateTable, +    fileBtreeCreateTable,  /* Really sqliteBtreeCreateIndex() */ +    fileBtreeDropTable, +    fileBtreeClearTable, +    fileBtreeCursor, +    fileBtreeGetMeta, +    fileBtreeUpdateMeta, +    fileBtreeIntegrityCheck, +    fileBtreeGetFilename, +    fileBtreeCopyFile, +#ifdef SQLITE_TEST +    fileBtreePageDump, +    fileBtreePager +#endif +}; +static BtCursorOps sqliteBtreeCursorOps = { +    fileBtreeMoveto, +    fileBtreeDelete, +    fileBtreeInsert, +    fileBtreeFirst, +    fileBtreeLast, +    fileBtreeNext, +    fileBtreePrevious, +    fileBtreeKeySize, +    fileBtreeKey, +    fileBtreeKeyCompare, +    fileBtreeDataSize, +    fileBtreeData, +    fileBtreeCloseCursor, +#ifdef SQLITE_TEST +    fileBtreeCursorDump, +#endif +}; diff --git a/ext/sqlite/libsqlite/src/btree.h b/ext/sqlite/libsqlite/src/btree.h index 84c80c5eff..064b7f97dd 100644 --- a/ext/sqlite/libsqlite/src/btree.h +++ b/ext/sqlite/libsqlite/src/btree.h @@ -18,54 +18,139 @@  #ifndef _BTREE_H_  #define _BTREE_H_ +/* +** Forward declarations of structure +*/  typedef struct Btree Btree;  typedef struct BtCursor BtCursor; +typedef struct BtOps BtOps; +typedef struct BtCursorOps BtCursorOps; -int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); -int sqliteBtreeClose(Btree*); -int sqliteBtreeSetCacheSize(Btree*, int); -int sqliteBtreeSetSafetyLevel(Btree*, int); -int sqliteBtreeBeginTrans(Btree*); -int sqliteBtreeCommit(Btree*); -int sqliteBtreeRollback(Btree*); -int sqliteBtreeBeginCkpt(Btree*); -int sqliteBtreeCommitCkpt(Btree*); -int sqliteBtreeRollbackCkpt(Btree*); - -int sqliteBtreeCreateTable(Btree*, int*); -int sqliteBtreeCreateIndex(Btree*, int*); -int sqliteBtreeDropTable(Btree*, int); -int sqliteBtreeClearTable(Btree*, int); +/* +** An instance of the following structure contains pointers to all +** methods against an open BTree.  Alternative BTree implementations +** (examples: file based versus in-memory) can be created by substituting +** different methods.  Users of the BTree cannot tell the difference. +** +** In C++ we could do this by defining a virtual base class and then +** creating subclasses for each different implementation.  But this is +** C not C++ so we have to be a little more explicit. +*/ +struct BtOps { +    int (*Close)(Btree*); +    int (*SetCacheSize)(Btree*, int); +    int (*SetSafetyLevel)(Btree*, int); +    int (*BeginTrans)(Btree*); +    int (*Commit)(Btree*); +    int (*Rollback)(Btree*); +    int (*BeginCkpt)(Btree*); +    int (*CommitCkpt)(Btree*); +    int (*RollbackCkpt)(Btree*); +    int (*CreateTable)(Btree*, int*); +    int (*CreateIndex)(Btree*, int*); +    int (*DropTable)(Btree*, int); +    int (*ClearTable)(Btree*, int); +    int (*Cursor)(Btree*, int iTable, int wrFlag, BtCursor **ppCur); +    int (*GetMeta)(Btree*, int*); +    int (*UpdateMeta)(Btree*, int*); +    char *(*IntegrityCheck)(Btree*, int*, int); +    const char *(*GetFilename)(Btree*); +    int (*Copyfile)(Btree*,Btree*); +#ifdef SQLITE_TEST +    int (*PageDump)(Btree*, int, int); +    struct Pager *(*Pager)(Btree*); +#endif +}; -int sqliteBtreeCursor(Btree*, int iTable, int wrFlag, BtCursor **ppCur); -int sqliteBtreeMoveto(BtCursor*, const void *pKey, int nKey, int *pRes); -int sqliteBtreeDelete(BtCursor*); -int sqliteBtreeInsert(BtCursor*, const void *pKey, int nKey, -                                 const void *pData, int nData); -int sqliteBtreeFirst(BtCursor*, int *pRes); -int sqliteBtreeLast(BtCursor*, int *pRes); -int sqliteBtreeNext(BtCursor*, int *pRes); -int sqliteBtreePrevious(BtCursor*, int *pRes); -int sqliteBtreeKeySize(BtCursor*, int *pSize); -int sqliteBtreeKey(BtCursor*, int offset, int amt, char *zBuf); -int sqliteBtreeKeyCompare(BtCursor*, const void *pKey, int nKey, -                          int nIgnore, int *pRes); -int sqliteBtreeDataSize(BtCursor*, int *pSize); -int sqliteBtreeData(BtCursor*, int offset, int amt, char *zBuf); -int sqliteBtreeCloseCursor(BtCursor*); +/* +** An instance of this structure defines all of the methods that can +** be executed against a cursor. +*/ +struct BtCursorOps { +    int (*Moveto)(BtCursor*, const void *pKey, int nKey, int *pRes); +    int (*Delete)(BtCursor*); +    int (*Insert)(BtCursor*, const void *pKey, int nKey, +                             const void *pData, int nData); +    int (*First)(BtCursor*, int *pRes); +    int (*Last)(BtCursor*, int *pRes); +    int (*Next)(BtCursor*, int *pRes); +    int (*Previous)(BtCursor*, int *pRes); +    int (*KeySize)(BtCursor*, int *pSize); +    int (*Key)(BtCursor*, int offset, int amt, char *zBuf); +    int (*KeyCompare)(BtCursor*, const void *pKey, int nKey, +                                 int nIgnore, int *pRes); +    int (*DataSize)(BtCursor*, int *pSize); +    int (*Data)(BtCursor*, int offset, int amt, char *zBuf); +    int (*CloseCursor)(BtCursor*); +#ifdef SQLITE_TEST +    int (*CursorDump)(BtCursor*, int*); +#endif +}; +/* +** The number of 4-byte "meta" values contained on the first page of each +** database file. +*/  #define SQLITE_N_BTREE_META 10 -int sqliteBtreeGetMeta(Btree*, int*); -int sqliteBtreeUpdateMeta(Btree*, int*); -char *sqliteBtreeIntegrityCheck(Btree*, int*, int); +int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); +int sqliteRBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); + +#define btOps(pBt) (*((BtOps **)(pBt))) +#define btCOps(pCur) (*((BtCursorOps **)(pCur))) + +#define sqliteBtreeClose(pBt)              (btOps(pBt)->Close(pBt)) +#define sqliteBtreeSetCacheSize(pBt, sz)   (btOps(pBt)->SetCacheSize(pBt, sz)) +#define sqliteBtreeSetSafetyLevel(pBt, sl) (btOps(pBt)->SetSafetyLevel(pBt, sl)) +#define sqliteBtreeBeginTrans(pBt)         (btOps(pBt)->BeginTrans(pBt)) +#define sqliteBtreeCommit(pBt)             (btOps(pBt)->Commit(pBt)) +#define sqliteBtreeRollback(pBt)           (btOps(pBt)->Rollback(pBt)) +#define sqliteBtreeBeginCkpt(pBt)          (btOps(pBt)->BeginCkpt(pBt)) +#define sqliteBtreeCommitCkpt(pBt)         (btOps(pBt)->CommitCkpt(pBt)) +#define sqliteBtreeRollbackCkpt(pBt)       (btOps(pBt)->RollbackCkpt(pBt)) +#define sqliteBtreeCreateTable(pBt,piTable)\ +                (btOps(pBt)->CreateTable(pBt,piTable)) +#define sqliteBtreeCreateIndex(pBt, piIndex)\ +                (btOps(pBt)->CreateIndex(pBt, piIndex)) +#define sqliteBtreeDropTable(pBt, iTable) (btOps(pBt)->DropTable(pBt, iTable)) +#define sqliteBtreeClearTable(pBt, iTable)\ +                (btOps(pBt)->ClearTable(pBt, iTable)) +#define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)\ +                (btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur)) +#define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)\ +                (btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes)) +#define sqliteBtreeDelete(pCur)           (btCOps(pCur)->Delete(pCur)) +#define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData) \ +                (btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData)) +#define sqliteBtreeFirst(pCur, pRes)      (btCOps(pCur)->First(pCur, pRes)) +#define sqliteBtreeLast(pCur, pRes)       (btCOps(pCur)->Last(pCur, pRes)) +#define sqliteBtreeNext(pCur, pRes)       (btCOps(pCur)->Next(pCur, pRes)) +#define sqliteBtreePrevious(pCur, pRes)   (btCOps(pCur)->Previous(pCur, pRes)) +#define sqliteBtreeKeySize(pCur, pSize)   (btCOps(pCur)->KeySize(pCur, pSize) ) +#define sqliteBtreeKey(pCur, offset, amt, zBuf)\ +                (btCOps(pCur)->Key(pCur, offset, amt, zBuf)) +#define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)\ +                (btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes)) +#define sqliteBtreeDataSize(pCur, pSize)  (btCOps(pCur)->DataSize(pCur, pSize)) +#define sqliteBtreeData(pCur, offset, amt, zBuf)\ +                (btCOps(pCur)->Data(pCur, offset, amt, zBuf)) +#define sqliteBtreeCloseCursor(pCur)      (btCOps(pCur)->CloseCursor(pCur)) +#define sqliteBtreeGetMeta(pBt, aMeta)    (btOps(pBt)->GetMeta(pBt, aMeta)) +#define sqliteBtreeUpdateMeta(pBt, aMeta) (btOps(pBt)->UpdateMeta(pBt, aMeta)) +#define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)\ +                (btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot)) +#define sqliteBtreeGetFilename(pBt)       (btOps(pBt)->GetFilename(pBt)) +#define sqliteBtreeCopyFile(pBt1, pBt2)   (btOps(pBt1)->Copyfile(pBt1, pBt2))  #ifdef SQLITE_TEST -int sqliteBtreePageDump(Btree*, int, int); -int sqliteBtreeCursorDump(BtCursor*, int*); -struct Pager *sqliteBtreePager(Btree*); +#define sqliteBtreePageDump(pBt, pgno, recursive)\ +                (btOps(pBt)->PageDump(pBt, pgno, recursive)) +#define sqliteBtreeCursorDump(pCur, aResult)\ +                (btCOps(pCur)->CursorDump(pCur, aResult)) +#define sqliteBtreePager(pBt)             (btOps(pBt)->Pager(pBt))  int btree_native_byte_order; -#endif +#endif /* SQLITE_TEST */ +  #endif /* _BTREE_H_ */ diff --git a/ext/sqlite/libsqlite/src/btree_rb.c b/ext/sqlite/libsqlite/src/btree_rb.c new file mode 100644 index 0000000000..d4c63a5b8b --- /dev/null +++ b/ext/sqlite/libsqlite/src/btree_rb.c @@ -0,0 +1,1412 @@ +/* +** 2003 Feb 4 +** +** 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. +** +************************************************************************* +** $Id$ +** +** This file implements an in-core database using Red-Black balanced +** binary trees. +** +** It was contributed to SQLite by anonymous on 2003-Feb-04 23:24:49 UTC. +*/ +#include "btree.h" +#include "sqliteInt.h" +#include <assert.h> + +/* +** Omit this whole file if the SQLITE_OMIT_INMEMORYDB macro is +** defined.  This allows a lot of code to be omitted for installations +** that do not need it. +*/ +#ifndef SQLITE_OMIT_INMEMORYDB + + +typedef struct BtRbTree BtRbTree; +typedef struct BtRbNode BtRbNode; +typedef struct BtRollbackOp BtRollbackOp; +typedef struct Rbtree Rbtree; +typedef struct RbtCursor RbtCursor; + +/* Forward declarations */ +static BtOps sqliteRbtreeOps; +static BtCursorOps sqliteRbtreeCursorOps; + +/* + * During each transaction (or checkpoint), a linked-list of + * "rollback-operations" is accumulated. If the transaction is rolled back, + * then the list of operations must be executed (to restore the database to + * it's state before the transaction started). If the transaction is to be + * committed, just delete the list. + * + * Each operation is represented as follows, depending on the value of eOp: + * + * ROLLBACK_INSERT  ->  Need to insert (pKey, pData) into table iTab. + * ROLLBACK_DELETE  ->  Need to delete the record (pKey) into table iTab. + * ROLLBACK_CREATE  ->  Need to create table iTab. + * ROLLBACK_DROP    ->  Need to drop table iTab. + */ +struct BtRollbackOp { +  u8 eOp; +  int iTab; +  int nKey;  +  void *pKey; +  int nData; +  void *pData; +  BtRollbackOp *pNext; +}; + +/* +** Legal values for BtRollbackOp.eOp: +*/ +#define ROLLBACK_INSERT 1 /* Insert a record */ +#define ROLLBACK_DELETE 2 /* Delete a record */ +#define ROLLBACK_CREATE 3 /* Create a table */ +#define ROLLBACK_DROP   4 /* Drop a table */ + +struct Rbtree { +  BtOps *pOps;    /* Function table */ +  int aMetaData[SQLITE_N_BTREE_META]; + +  int next_idx;   /* next available table index */ +  Hash tblHash;   /* All created tables, by index */ +  u8 isAnonymous; /* True if this Rbtree is to be deleted when closed */ +  u8 eTransState; /* State of this Rbtree wrt transactions */ + +  BtRollbackOp *pTransRollback;  +  BtRollbackOp *pCheckRollback; +  BtRollbackOp *pCheckRollbackTail; +}; + +/* +** Legal values for Rbtree.eTransState. +*/ +#define TRANS_NONE           0  /* No transaction is in progress */ +#define TRANS_INTRANSACTION  1  /* A transaction is in progress */ +#define TRANS_INCHECKPOINT   2  /* A checkpoint is in progress  */ +#define TRANS_ROLLBACK       3  /* We are currently rolling back a checkpoint or +                                 * transaction. */ + +struct RbtCursor { +  BtCursorOps *pOps;        /* Function table */ +  Rbtree    *pRbtree; +  BtRbTree *pTree; +  int       iTree;          /* Index of pTree in pRbtree */ +  BtRbNode *pNode; +  u8 eSkip;                 /* Determines if next step operation is a no-op */ +}; + +/* +** Legal values for RbtCursor.eSkip. +*/ +#define SKIP_NONE     0   /* Always step the cursor */ +#define SKIP_NEXT     1   /* The next sqliteRbtreeNext() is a no-op */ +#define SKIP_PREV     2   /* The next sqliteRbtreePrevious() is a no-op */ +#define SKIP_INVALID  3   /* Calls to Next() and Previous() are invalid */ + +struct BtRbTree { +  BtRbNode *pHead;   /* Head of the tree, or NULL */ +}; + +struct BtRbNode { +  int nKey; +  void *pKey; +  int nData; +  void *pData; +  u8 isBlack;        /* true for a black node, 0 for a red node */ +  BtRbNode *pParent; /* Nodes parent node, NULL for the tree head */ +  BtRbNode *pLeft;   /* Nodes left child, or NULL */ +  BtRbNode *pRight;  /* Nodes right child, or NULL */ + +  int nBlackHeight;  /* Only used during the red-black integrity check */ +}; + +/* Forward declarations */ +static int memRbtreeMoveto( +  RbtCursor* pCur, +  const void *pKey, +  int nKey, +  int *pRes +); +static int memRbtreeClearTable(Rbtree* tree, int n); +static int memRbtreeNext(RbtCursor* pCur, int *pRes); +static int memRbtreeLast(RbtCursor* pCur, int *pRes); +static int memRbtreePrevious(RbtCursor* pCur, int *pRes); + +/* + * The key-compare function for the red-black trees. Returns as follows: + * + * (key1 < key2)             -1 + * (key1 == key2)             0  + * (key1 > key2)              1 + * + * Keys are compared using memcmp(). If one key is an exact prefix of the + * other, then the shorter key is less than the longer key. + */ +static int key_compare(void const*pKey1, int nKey1, void const*pKey2, int nKey2) +{ +  int mcmp = memcmp(pKey1, pKey2, (nKey1 <= nKey2)?nKey1:nKey2); +  if( mcmp == 0){ +    if( nKey1 == nKey2 ) return 0; +    return ((nKey1 < nKey2)?-1:1); +  } +  return ((mcmp>0)?1:-1); +} + +/* + * Perform the LEFT-rotate transformation on node X of tree pTree. This + * transform is part of the red-black balancing code. + * + *        |                   | + *        X                   Y + *       / \                 / \ + *      a   Y               X   c + *         / \             / \ + *        b   c           a   b + * + *      BEFORE              AFTER + */ +static void leftRotate(BtRbTree *pTree, BtRbNode *pX) +{ +  BtRbNode *pY; +  BtRbNode *pb; +  pY = pX->pRight; +  pb = pY->pLeft; + +  pY->pParent = pX->pParent; +  if( pX->pParent ){ +    if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY; +    else pX->pParent->pRight = pY; +  } +  pY->pLeft = pX; +  pX->pParent = pY; +  pX->pRight = pb; +  if( pb ) pb->pParent = pX; +  if( pTree->pHead == pX ) pTree->pHead = pY; +} + +/* + * Perform the RIGHT-rotate transformation on node X of tree pTree. This + * transform is part of the red-black balancing code. + * + *        |                   | + *        X                   Y + *       / \                 / \ + *      Y   c               a   X + *     / \                     / \ + *    a   b                   b   c + * + *      BEFORE              AFTER + */ +static void rightRotate(BtRbTree *pTree, BtRbNode *pX) +{ +  BtRbNode *pY; +  BtRbNode *pb; +  pY = pX->pLeft; +  pb = pY->pRight; + +  pY->pParent = pX->pParent; +  if( pX->pParent ){ +    if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY; +    else pX->pParent->pRight = pY; +  } +  pY->pRight = pX; +  pX->pParent = pY; +  pX->pLeft = pb; +  if( pb ) pb->pParent = pX; +  if( pTree->pHead == pX ) pTree->pHead = pY; +} + +/* + * A string-manipulation helper function for check_redblack_tree(). If (orig == + * NULL) a copy of val is returned. If (orig != NULL) then a copy of the * + * concatenation of orig and val is returned. The original orig is deleted + * (using sqliteFree()). + */ +static char *append_val(char * orig, char const * val) +{ +  if( !orig ){ +    return sqliteStrDup( val ); +  } else{ +    char * ret = 0; +    sqliteSetString(&ret, orig, val, 0); +    sqliteFree( orig ); +    return ret; +  } +  assert(0); +} + +/* + * Append a string representation of the entire node to orig and return it. + * This is used to produce debugging information if check_redblack_tree() finds + * a problem with a red-black binary tree. + */ +static char *append_node(char * orig, BtRbNode *pNode, int indent) +{ +  char buf[128]; +  int i; + +  for( i=0; i<indent; i++ ){ +      orig = append_val(orig, " "); +  } + +  sprintf(buf, "%p", pNode); +  orig = append_val(orig, buf); + +  if( pNode ){ +    indent += 3; +    if( pNode->isBlack ){ +      orig = append_val(orig, " B \n"); +    }else{ +      orig = append_val(orig, " R \n"); +    } +    orig = append_node( orig, pNode->pLeft, indent ); +    orig = append_node( orig, pNode->pRight, indent ); +  }else{ +    orig = append_val(orig, "\n"); +  } +  return orig; +} + +/* + * Print a representation of a node to stdout. This function is only included + * so you can call it from within a debugger if things get really bad. + */ +static void print_node(BtRbNode *pNode) +{ +    char * str = append_node(0, pNode, 0); +    printf(str); +} + +/*  + * Check the following properties of the red-black tree: + * (1) - If a node is red, both of it's children are black + * (2) - Each path from a given node to a leaf (NULL) node passes thru the + *       same number of black nodes  + * + * If there is a problem, append a description (using append_val() ) to *msg. + */ +static void check_redblack_tree(BtRbTree * tree, char ** msg) +{ +  BtRbNode *pNode; + +  /* 0 -> came from parent  +   * 1 -> came from left +   * 2 -> came from right */ +  int prev_step = 0; + +  pNode = tree->pHead; +  while( pNode ){ +    switch( prev_step ){ +      case 0: +        if( pNode->pLeft ){ +          pNode = pNode->pLeft; +        }else{  +          prev_step = 1; +        } +        break; +      case 1: +        if( pNode->pRight ){ +          pNode = pNode->pRight; +          prev_step = 0; +        }else{ +          prev_step = 2; +        } +        break; +      case 2: +        /* Check red-black property (1) */ +        if( !pNode->isBlack && +            ( (pNode->pLeft && !pNode->pLeft->isBlack) || +              (pNode->pRight && !pNode->pRight->isBlack) ) +          ){ +          char buf[128]; +          sprintf(buf, "Red node with red child at %p\n", pNode); +          *msg = append_val(*msg, buf); +          *msg = append_node(*msg, tree->pHead, 0); +          *msg = append_val(*msg, "\n"); +        } + +        /* Check red-black property (2) */ +        {  +          int leftHeight = 0; +          int rightHeight = 0; +          if( pNode->pLeft ){ +            leftHeight += pNode->pLeft->nBlackHeight; +            leftHeight += (pNode->pLeft->isBlack?1:0); +          } +          if( pNode->pRight ){ +            rightHeight += pNode->pRight->nBlackHeight; +            rightHeight += (pNode->pRight->isBlack?1:0); +          } +          if( leftHeight != rightHeight ){ +            char buf[128]; +            sprintf(buf, "Different black-heights at %p\n", pNode); +            *msg = append_val(*msg, buf); +            *msg = append_node(*msg, tree->pHead, 0); +            *msg = append_val(*msg, "\n"); +          } +          pNode->nBlackHeight = leftHeight; +        } + +        if( pNode->pParent ){ +          if( pNode == pNode->pParent->pLeft ) prev_step = 1; +          else prev_step = 2; +        } +        pNode = pNode->pParent; +        break; +      default: assert(0); +    } +  } +}  + +/* + * Node pX has just been inserted into pTree (by code in sqliteRbtreeInsert()). + * It is possible that pX is a red node with a red parent, which is a violation + * of the red-black tree properties. This function performs rotations and  + * color changes to rebalance the tree + */ +static void do_insert_balancing(BtRbTree *pTree, BtRbNode *pX) +{ +  /* In the first iteration of this loop, pX points to the red node just +   * inserted in the tree. If the parent of pX exists (pX is not the root +   * node) and is red, then the properties of the red-black tree are +   * violated. +   * +   * At the start of any subsequent iterations, pX points to a red node +   * with a red parent. In all other respects the tree is a legal red-black +   * binary tree. */ +  while( pX != pTree->pHead && !pX->pParent->isBlack ){ +    BtRbNode *pUncle; +    BtRbNode *pGrandparent; + +    /* Grandparent of pX must exist and must be black. */ +    pGrandparent = pX->pParent->pParent; +    assert( pGrandparent ); +    assert( pGrandparent->isBlack ); + +    /* Uncle of pX may or may not exist. */ +    if( pX->pParent == pGrandparent->pLeft )  +      pUncle = pGrandparent->pRight; +    else  +      pUncle = pGrandparent->pLeft; + +    /* If the uncle of pX exists and is red, we do the following: +     *       |                 | +     *      G(b)              G(r) +     *      /  \              /  \         +     *   U(r)   P(r)       U(b)  P(b) +     *            \                \ +     *           X(r)              X(r) +     * +     *     BEFORE             AFTER +     * pX is then set to G. If the parent of G is red, then the while loop +     * will run again.  */ +    if( pUncle && !pUncle->isBlack ){ +      pGrandparent->isBlack = 0; +      pUncle->isBlack = 1; +      pX->pParent->isBlack = 1; +      pX = pGrandparent; +    }else{ + +      if( pX->pParent == pGrandparent->pLeft ){ +        if( pX == pX->pParent->pRight ){ +          /* If pX is a right-child, do the following transform, essentially +           * to change pX into a left-child:  +           *       |                  |  +           *      G(b)               G(b) +           *      /  \               /  \         +           *   P(r)   U(b)        X(r)  U(b) +           *      \                / +           *     X(r)            P(r) <-- new X +           * +           *     BEFORE             AFTER +           */ +          pX = pX->pParent; +          leftRotate(pTree, pX); +        } + +        /* Do the following transform, which balances the tree :)  +         *       |                  |  +         *      G(b)               P(b) +         *      /  \               /  \         +         *   P(r)   U(b)        X(r)  G(r) +         *    /                         \ +         *  X(r)                        U(b) +         * +         *     BEFORE             AFTER +         */ +        assert( pGrandparent == pX->pParent->pParent ); +        pGrandparent->isBlack = 0; +        pX->pParent->isBlack = 1; +        rightRotate( pTree, pGrandparent ); + +      }else{ +        /* This code is symetric to the illustrated case above. */ +        if( pX == pX->pParent->pLeft ){ +          pX = pX->pParent; +          rightRotate(pTree, pX); +        } +        assert( pGrandparent == pX->pParent->pParent ); +        pGrandparent->isBlack = 0; +        pX->pParent->isBlack = 1; +        leftRotate( pTree, pGrandparent ); +      } +    } +  } +  pTree->pHead->isBlack = 1; +} + +/* + * A child of pParent, which in turn had child pX, has just been removed from  + * pTree (the figure below depicts the operation, Z is being removed). pParent + * or pX, or both may be NULL.   + *                |           | + *                P           P + *               / \         / \ + *              Z           X + *             / \ + *            X  nil + * + * This function is only called if Z was black. In this case the red-black tree + * properties have been violated, and pX has an "extra black". This function  + * performs rotations and color-changes to re-balance the tree. + */ +static  +void do_delete_balancing(BtRbTree *pTree, BtRbNode *pX, BtRbNode *pParent) +{ +  BtRbNode *pSib;  + +  /* TODO: Comment this code! */ +  while( pX != pTree->pHead && (!pX || pX->isBlack) ){ +    if( pX == pParent->pLeft ){ +      pSib = pParent->pRight; +      if( pSib && !(pSib->isBlack) ){ +        pSib->isBlack = 1; +        pParent->isBlack = 0; +        leftRotate(pTree, pParent); +        pSib = pParent->pRight; +      } +      if( !pSib ){ +        pX = pParent; +      }else if(  +          (!pSib->pLeft  || pSib->pLeft->isBlack) && +          (!pSib->pRight || pSib->pRight->isBlack) ) { +        pSib->isBlack = 0; +        pX = pParent; +      }else{ +        if( (!pSib->pRight || pSib->pRight->isBlack) ){ +          if( pSib->pLeft ) pSib->pLeft->isBlack = 1; +          pSib->isBlack = 0; +          rightRotate( pTree, pSib ); +          pSib = pParent->pRight; +        } +        pSib->isBlack = pParent->isBlack; +        pParent->isBlack = 1; +        if( pSib->pRight ) pSib->pRight->isBlack = 1; +        leftRotate(pTree, pParent); +        pX = pTree->pHead; +      } +    }else{ +      pSib = pParent->pLeft; +      if( pSib && !(pSib->isBlack) ){ +        pSib->isBlack = 1; +        pParent->isBlack = 0; +        rightRotate(pTree, pParent); +        pSib = pParent->pLeft; +      } +      if( !pSib ){ +        pX = pParent; +      }else if(  +          (!pSib->pLeft  || pSib->pLeft->isBlack) && +          (!pSib->pRight || pSib->pRight->isBlack) ){ +        pSib->isBlack = 0; +        pX = pParent; +      }else{ +        if( (!pSib->pLeft || pSib->pLeft->isBlack) ){ +          if( pSib->pRight ) pSib->pRight->isBlack = 1; +          pSib->isBlack = 0; +          leftRotate( pTree, pSib ); +          pSib = pParent->pLeft; +        } +        pSib->isBlack = pParent->isBlack; +        pParent->isBlack = 1; +        if( pSib->pLeft ) pSib->pLeft->isBlack = 1; +        rightRotate(pTree, pParent); +        pX = pTree->pHead; +      } +    } +    pParent = pX->pParent; +  } +  if( pX ) pX->isBlack = 1; +} + +/* + * Create table n in tree pRbtree. Table n must not exist. + */ +static void btreeCreateTable(Rbtree* pRbtree, int n) +{ +  BtRbTree *pNewTbl = sqliteMalloc(sizeof(BtRbTree)); +  sqliteHashInsert(&pRbtree->tblHash, 0, n, pNewTbl); +} + +/* + * Log a single "rollback-op" for the given Rbtree. See comments for struct + * BtRollbackOp. + */ +static void btreeLogRollbackOp(Rbtree* pRbtree, BtRollbackOp *pRollbackOp) +{ +  assert( pRbtree->eTransState == TRANS_INCHECKPOINT || +      pRbtree->eTransState == TRANS_INTRANSACTION ); +  if( pRbtree->eTransState == TRANS_INTRANSACTION ){ +    pRollbackOp->pNext = pRbtree->pTransRollback; +    pRbtree->pTransRollback = pRollbackOp; +  } +  if( pRbtree->eTransState == TRANS_INCHECKPOINT ){ +    if( !pRbtree->pCheckRollback ){ +      pRbtree->pCheckRollbackTail = pRollbackOp; +    } +    pRollbackOp->pNext = pRbtree->pCheckRollback; +    pRbtree->pCheckRollback = pRollbackOp; +  } +} + +int sqliteRbtreeOpen( +  const char *zFilename, +  int mode, +  int nPg, +  Rbtree **ppRbtree +){ +  *ppRbtree = (Rbtree *)sqliteMalloc(sizeof(Rbtree)); +  sqliteHashInit(&(*ppRbtree)->tblHash, SQLITE_HASH_INT, 0); + +  /* Create a binary tree for the SQLITE_MASTER table at location 2 */ +  btreeCreateTable(*ppRbtree, 2); +  (*ppRbtree)->next_idx = 3; +  (*ppRbtree)->pOps = &sqliteRbtreeOps; +  /* Set file type to 4; this is so that "attach ':memory:' as ...."  does not +  ** think that the database in uninitialised and refuse to attach +  */ +  (*ppRbtree)->aMetaData[2] = 4; +   +  return SQLITE_OK; +} + +/* + * Create a new table in the supplied Rbtree. Set *n to the new table number. + * Return SQLITE_OK if the operation is a success. + */ +static int memRbtreeCreateTable(Rbtree* tree, int* n) +{ +  assert( tree->eTransState != TRANS_NONE ); + +  *n = tree->next_idx++; +  btreeCreateTable(tree, *n); + +  /* Set up the rollback structure (if we are not doing this as part of a +   * rollback) */ +  if( tree->eTransState != TRANS_ROLLBACK ){ +    BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp)); +    pRollbackOp->eOp = ROLLBACK_DROP; +    pRollbackOp->iTab = *n; +    btreeLogRollbackOp(tree, pRollbackOp); +  } + +  return SQLITE_OK; +} + +/* + * Delete table n from the supplied Rbtree.  + */ +static int memRbtreeDropTable(Rbtree* tree, int n) +{ +  BtRbTree *pTree; +  assert( tree->eTransState != TRANS_NONE ); + +  memRbtreeClearTable(tree, n); +  pTree = sqliteHashInsert(&tree->tblHash, 0, n, 0); +  assert(pTree); +  sqliteFree(pTree); + +  if( tree->eTransState != TRANS_ROLLBACK ){ +    BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp)); +    pRollbackOp->eOp = ROLLBACK_CREATE; +    pRollbackOp->iTab = n; +    btreeLogRollbackOp(tree, pRollbackOp); +  } + +  return SQLITE_OK; +} + +static int memRbtreeKeyCompare(RbtCursor* pCur, const void *pKey, int nKey, +                                 int nIgnore, int *pRes) +{ +  assert(pCur); + +  if( !pCur->pNode ) { +    *pRes = -1; +  } else { +    if( (pCur->pNode->nKey - nIgnore) < 0 ){ +      *pRes = -1; +    }else{ +      *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey-nIgnore,  +          pKey, nKey); +    } +  } +  return SQLITE_OK; +} + +/* + * Get a new cursor for table iTable of the supplied Rbtree. The wrFlag + * parameter is ignored, all cursors are capable of write-operations.  + * + * Note that RbtCursor.eSkip and RbtCursor.pNode both initialize to 0. + */ +static int memRbtreeCursor( +  Rbtree* tree, +  int iTable, +  int wrFlag, +  RbtCursor **ppCur +){ +  assert(tree); +  *ppCur = sqliteMalloc(sizeof(RbtCursor)); +  (*ppCur)->pTree  = sqliteHashFind(&tree->tblHash, 0, iTable); +  (*ppCur)->pRbtree = tree; +  (*ppCur)->iTree  = iTable; +  (*ppCur)->pOps = &sqliteRbtreeCursorOps; + +  assert( (*ppCur)->pTree ); +  return SQLITE_OK; +} + +/* + * Insert a new record into the Rbtree.  The key is given by (pKey,nKey) + * and the data is given by (pData,nData).  The cursor is used only to + * define what database the record should be inserted into.  The cursor + * is left pointing at the new record. + * + * If the key exists already in the tree, just replace the data.  + */ +static int memRbtreeInsert( +  RbtCursor* pCur, +  const void *pKey, +  int nKey, +  const void *pDataInput, +  int nData +){ +  void * pData; +  int match; + +  /* It is illegal to call sqliteRbtreeInsert() if we are +  ** not in a transaction */ +  assert( pCur->pRbtree->eTransState != TRANS_NONE ); + +  /* Take a copy of the input data now, in case we need it for the  +   * replace case */ +  pData = sqliteMalloc(nData); +  memcpy(pData, pDataInput, nData); + +  /* Move the cursor to a node near the key to be inserted. If the key already +   * exists in the table, then (match == 0). In this case we can just replace +   * the data associated with the entry, we don't need to manipulate the tree. +   *  +   * If there is no exact match, then the cursor points at what would be either +   * the predecessor (match == -1) or successor (match == 1) of the +   * searched-for key, were it to be inserted. The new node becomes a child of +   * this node. +   *  +   * The new node is initially red. +   */ +  memRbtreeMoveto( pCur, pKey, nKey, &match); +  if( match ){ +    BtRbNode *pNode = sqliteMalloc(sizeof(BtRbNode)); +    pNode->nKey = nKey; +    pNode->pKey = sqliteMalloc(nKey); +    memcpy(pNode->pKey, pKey, nKey); +    pNode->nData = nData; +    pNode->pData = pData;  +    if( pCur->pNode ){ +      switch( match ){ +        case -1: +          assert( !pCur->pNode->pRight ); +          pNode->pParent = pCur->pNode; +          pCur->pNode->pRight = pNode; +          break; +        case 1: +          assert( !pCur->pNode->pLeft ); +          pNode->pParent = pCur->pNode; +          pCur->pNode->pLeft = pNode; +          break; +        default: +          assert(0); +      } +    }else{ +      pCur->pTree->pHead = pNode; +    } + +    /* Point the cursor at the node just inserted, as per SQLite requirements */ +    pCur->pNode = pNode; + +    /* A new node has just been inserted, so run the balancing code */ +    do_insert_balancing(pCur->pTree, pNode); + +    /* Set up a rollback-op in case we have to roll this operation back */ +    if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ +      BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); +      pOp->eOp = ROLLBACK_DELETE; +      pOp->iTab = pCur->iTree; +      pOp->nKey = pNode->nKey; +      pOp->pKey = sqliteMalloc( pOp->nKey ); +      memcpy( pOp->pKey, pNode->pKey, pOp->nKey ); +      btreeLogRollbackOp(pCur->pRbtree, pOp); +    } + +  }else{  +    /* No need to insert a new node in the tree, as the key already exists. +     * Just clobber the current nodes data. */ + +    /* Set up a rollback-op in case we have to roll this operation back */ +    if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ +      BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); +      pOp->iTab = pCur->iTree; +      pOp->nKey = pCur->pNode->nKey; +      pOp->pKey = sqliteMalloc( pOp->nKey ); +      memcpy( pOp->pKey, pCur->pNode->pKey, pOp->nKey ); +      pOp->nData = pCur->pNode->nData; +      pOp->pData = pCur->pNode->pData; +      pOp->eOp = ROLLBACK_INSERT; +      btreeLogRollbackOp(pCur->pRbtree, pOp); +    }else{ +      sqliteFree( pCur->pNode->pData ); +    } + +    /* Actually clobber the nodes data */ +    pCur->pNode->pData = pData; +    pCur->pNode->nData = nData; +  } + +  return SQLITE_OK; +} + +/* Move the cursor so that it points to an entry near pKey. +** Return a success code. +** +**     *pRes<0      The cursor is left pointing at an entry that +**                  is smaller than pKey or if the table is empty +**                  and the cursor is therefore left point to nothing. +** +**     *pRes==0     The cursor is left pointing at an entry that +**                  exactly matches pKey. +** +**     *pRes>0      The cursor is left pointing at an entry that +**                  is larger than pKey. +*/ +static int memRbtreeMoveto( +  RbtCursor* pCur, +  const void *pKey, +  int nKey, +  int *pRes +){ +  BtRbNode *pTmp = 0; + +  pCur->pNode = pCur->pTree->pHead; +  *pRes = -1; +  while( pCur->pNode && *pRes ) { +    *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey, pKey, nKey); +    pTmp = pCur->pNode; +    switch( *pRes ){ +      case 1:    /* cursor > key */ +        pCur->pNode = pCur->pNode->pLeft; +        break; +      case -1:   /* cursor < key */ +        pCur->pNode = pCur->pNode->pRight; +        break; +    } +  }  + +  /* If (pCur->pNode == NULL), then we have failed to find a match. Set +   * pCur->pNode to pTmp, which is either NULL (if the tree is empty) or the +   * last node traversed in the search. In either case the relation ship +   * between pTmp and the searched for key is already stored in *pRes. pTmp is +   * either the successor or predecessor of the key we tried to move to. */ +  if( !pCur->pNode ) pCur->pNode = pTmp; +  pCur->eSkip = SKIP_NONE; + +  return SQLITE_OK; +} + + +/* +** Delete the entry that the cursor is pointing to. +** +** The cursor is left pointing at either the next or the previous +** entry.  If the cursor is left pointing to the next entry, then  +** the pCur->eSkip flag is set to SKIP_NEXT which forces the next call to  +** sqliteRbtreeNext() to be a no-op.  That way, you can always call +** sqliteRbtreeNext() after a delete and the cursor will be left +** pointing to the first entry after the deleted entry.  Similarly, +** pCur->eSkip is set to SKIP_PREV is the cursor is left pointing to +** the entry prior to the deleted entry so that a subsequent call to +** sqliteRbtreePrevious() will always leave the cursor pointing at the +** entry immediately before the one that was deleted. +*/ +static int memRbtreeDelete(RbtCursor* pCur) +{ +  BtRbNode *pZ;      /* The one being deleted */ +  BtRbNode *pChild;  /* The child of the spliced out node */ + +  /* It is illegal to call sqliteRbtreeDelete() if we are +  ** not in a transaction */ +  assert( pCur->pRbtree->eTransState != TRANS_NONE ); + +  pZ = pCur->pNode; +  if( !pZ ){ +    return SQLITE_OK; +  } + +  /* If we are not currently doing a rollback, set up a rollback op for this  +   * deletion */ +  if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ +    BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) ); +    pOp->iTab = pCur->iTree; +    pOp->nKey = pZ->nKey; +    pOp->pKey = pZ->pKey; +    pOp->nData = pZ->nData; +    pOp->pData = pZ->pData; +    pOp->eOp = ROLLBACK_INSERT; +    btreeLogRollbackOp(pCur->pRbtree, pOp); +  } + +  /* First do a standard binary-tree delete (node pZ is to be deleted). How +   * to do this depends on how many children pZ has: +   * +   * If pZ has no children or one child, then splice out pZ.  If pZ has two +   * children, splice out the successor of pZ and replace the key and data of +   * pZ with the key and data of the spliced out successor.  */ +  if( pZ->pLeft && pZ->pRight ){ +    BtRbNode *pTmp; +    int dummy; +    pCur->eSkip = SKIP_NONE; +    memRbtreeNext(pCur, &dummy); +    assert( dummy == 0 ); +    if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ +      sqliteFree(pZ->pKey); +      sqliteFree(pZ->pData); +    } +    pZ->pData = pCur->pNode->pData; +    pZ->nData = pCur->pNode->nData; +    pZ->pKey = pCur->pNode->pKey; +    pZ->nKey = pCur->pNode->nKey; +    pTmp = pZ; +    pZ = pCur->pNode; +    pCur->pNode = pTmp; +    pCur->eSkip = SKIP_NEXT; +  }else{ +    int res; +    pCur->eSkip = SKIP_NONE; +    memRbtreeNext(pCur, &res); +    pCur->eSkip = SKIP_NEXT; +    if( res ){ +      memRbtreeLast(pCur, &res); +      memRbtreePrevious(pCur, &res); +      pCur->eSkip = SKIP_PREV; +    } +    if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ +        sqliteFree(pZ->pKey); +        sqliteFree(pZ->pData); +    } +  } + +  /* pZ now points at the node to be spliced out. This block does the  +   * splicing. */ +  { +    BtRbNode **ppParentSlot = 0; +    assert( !pZ->pLeft || !pZ->pRight ); /* pZ has at most one child */ +    pChild = ((pZ->pLeft)?pZ->pLeft:pZ->pRight); +    if( pZ->pParent ){ +      assert( pZ == pZ->pParent->pLeft || pZ == pZ->pParent->pRight ); +      ppParentSlot = ((pZ == pZ->pParent->pLeft) +          ?&pZ->pParent->pLeft:&pZ->pParent->pRight); +      *ppParentSlot = pChild; +    }else{ +      pCur->pTree->pHead = pChild; +    } +    if( pChild ) pChild->pParent = pZ->pParent; +  } + +  /* pZ now points at the spliced out node. pChild is the only child of pZ, or +   * NULL if pZ has no children. If pZ is black, and not the tree root, then we +   * will have violated the "same number of black nodes in every path to a +   * leaf" property of the red-black tree. The code in do_delete_balancing() +   * repairs this. */ +  if( pZ->isBlack ){  +    do_delete_balancing(pCur->pTree, pChild, pZ->pParent); +  } + +  sqliteFree(pZ); +  return SQLITE_OK; +} + +/* + * Empty table n of the Rbtree. + */ +static int memRbtreeClearTable(Rbtree* tree, int n) +{ +  BtRbTree *pTree; +  BtRbNode *pNode; + +  pTree = sqliteHashFind(&tree->tblHash, 0, n); +  assert(pTree); + +  pNode = pTree->pHead; +  while( pNode ){ +    if( pNode->pLeft ){ +      pNode = pNode->pLeft; +    } +    else if( pNode->pRight ){ +      pNode = pNode->pRight; +    } +    else { +      BtRbNode *pTmp = pNode->pParent; +      if( tree->eTransState == TRANS_ROLLBACK ){ +        sqliteFree( pNode->pKey ); +        sqliteFree( pNode->pData ); +      }else{ +        BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp)); +        pRollbackOp->eOp = ROLLBACK_INSERT; +        pRollbackOp->iTab = n; +        pRollbackOp->nKey = pNode->nKey; +        pRollbackOp->pKey = pNode->pKey; +        pRollbackOp->nData = pNode->nData; +        pRollbackOp->pData = pNode->pData; +        btreeLogRollbackOp(tree, pRollbackOp); +      } +      sqliteFree( pNode ); +      if( pTmp ){ +        if( pTmp->pLeft == pNode ) pTmp->pLeft = 0; +        else if( pTmp->pRight == pNode ) pTmp->pRight = 0; +      } +      pNode = pTmp; +    } +  } + +  pTree->pHead = 0; +  return SQLITE_OK; +} + +static int memRbtreeFirst(RbtCursor* pCur, int *pRes) +{ +  if( pCur->pTree->pHead ){ +    pCur->pNode = pCur->pTree->pHead; +    while( pCur->pNode->pLeft ){ +      pCur->pNode = pCur->pNode->pLeft; +    } +  } +  if( pCur->pNode ){ +    *pRes = 0; +  }else{ +    *pRes = 1; +  } +  pCur->eSkip = SKIP_NONE; +  return SQLITE_OK; +} + +static int memRbtreeLast(RbtCursor* pCur, int *pRes) +{ +  if( pCur->pTree->pHead ){ +    pCur->pNode = pCur->pTree->pHead; +    while( pCur->pNode->pRight ){ +      pCur->pNode = pCur->pNode->pRight; +    } +  } +  if( pCur->pNode ){ +    *pRes = 0; +  }else{ +    *pRes = 1; +  } +  pCur->eSkip = SKIP_NONE; +  return SQLITE_OK; +} + +/* +** Advance the cursor to the next entry in the database.  If +** successful then set *pRes=0.  If the cursor +** was already pointing to the last entry in the database before +** this routine was called, then set *pRes=1. +*/ +static int memRbtreeNext(RbtCursor* pCur, int *pRes) +{ +  if( pCur->pNode && pCur->eSkip != SKIP_NEXT ){ +    if( pCur->pNode->pRight ){ +      pCur->pNode = pCur->pNode->pRight; +      while( pCur->pNode->pLeft ) +        pCur->pNode = pCur->pNode->pLeft; +    }else{ +      BtRbNode * pX = pCur->pNode; +      pCur->pNode = pX->pParent; +      while( pCur->pNode && (pCur->pNode->pRight == pX) ){ +        pX = pCur->pNode; +        pCur->pNode = pX->pParent; +      } +    } +  } +  pCur->eSkip = SKIP_NONE; + +  if( !pCur->pNode ){ +    *pRes = 1; +  }else{ +    *pRes = 0; +  } + +  return SQLITE_OK; +} + +static int memRbtreePrevious(RbtCursor* pCur, int *pRes) +{ +  if( pCur->pNode && pCur->eSkip != SKIP_PREV ){ +    if( pCur->pNode->pLeft ){ +      pCur->pNode = pCur->pNode->pLeft; +      while( pCur->pNode->pRight ) +        pCur->pNode = pCur->pNode->pRight; +    }else{ +      BtRbNode * pX = pCur->pNode; +      pCur->pNode = pX->pParent; +      while( pCur->pNode && (pCur->pNode->pLeft == pX) ){ +        pX = pCur->pNode; +        pCur->pNode = pX->pParent; +      } +    } +  } +  pCur->eSkip = SKIP_NONE; + +  if( !pCur->pNode ){ +    *pRes = 1; +  }else{ +    *pRes = 0; +  } + +  return SQLITE_OK; +} + +static int memRbtreeKeySize(RbtCursor* pCur, int *pSize) +{ +  if( pCur->pNode ){ +    *pSize = pCur->pNode->nKey; +  }else{ +    *pSize = 0; +  } +  return SQLITE_OK; +} + +static int memRbtreeKey(RbtCursor* pCur, int offset, int amt, char *zBuf) +{ +  if( !pCur->pNode ) return 0; +  if( !pCur->pNode->pKey || ((amt + offset) <= pCur->pNode->nKey) ){ +    memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, amt); +    return amt; +  }else{ +    memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, pCur->pNode->nKey-offset); +    return pCur->pNode->nKey-offset; +  } +  assert(0); +} + +static int memRbtreeDataSize(RbtCursor* pCur, int *pSize) +{ +  if( pCur->pNode ){ +    *pSize = pCur->pNode->nData; +  }else{ +    *pSize = 0; +  } +  return SQLITE_OK; +} + +static int memRbtreeData(RbtCursor *pCur, int offset, int amt, char *zBuf) +{ +  if( !pCur->pNode ) return 0; +  if( (amt + offset) <= pCur->pNode->nData ){ +    memcpy(zBuf, ((char*)pCur->pNode->pData)+offset, amt); +    return amt; +  }else{ +    memcpy(zBuf, ((char*)pCur->pNode->pData)+offset ,pCur->pNode->nData-offset); +    return pCur->pNode->nData-offset; +  } +  assert(0); +} + +static int memRbtreeCloseCursor(RbtCursor* pCur) +{ +  sqliteFree(pCur); +  return SQLITE_OK; +} + +static int memRbtreeGetMeta(Rbtree* tree, int* aMeta) +{ +  memcpy( aMeta, tree->aMetaData, sizeof(int) * SQLITE_N_BTREE_META ); +  return SQLITE_OK; +} + +static int memRbtreeUpdateMeta(Rbtree* tree, int* aMeta) +{ +  memcpy( tree->aMetaData, aMeta, sizeof(int) * SQLITE_N_BTREE_META ); +  return SQLITE_OK; +} + +/* + * Check that each table in the Rbtree meets the requirements for a red-black + * binary tree. If an error is found, return an explanation of the problem in  + * memory obtained from sqliteMalloc(). Parameters aRoot and nRoot are ignored.  + */ +static char *memRbtreeIntegrityCheck(Rbtree* tree, int* aRoot, int nRoot) +{ +  char * msg = 0; +  HashElem *p; + +  for(p=sqliteHashFirst(&tree->tblHash); p; p=sqliteHashNext(p)){ +    BtRbTree *pTree = sqliteHashData(p); +    check_redblack_tree(pTree, &msg); +  } + +  return msg; +} + +/* + * Close the supplied Rbtree. Delete everything associated with it. + */ +static int memRbtreeClose(Rbtree* tree) +{ +  HashElem *p; +  while( (p=sqliteHashFirst(&tree->tblHash))!=0 ){ +    tree->eTransState = TRANS_ROLLBACK; +    memRbtreeDropTable(tree, sqliteHashKeysize(p)); +  } +  sqliteHashClear(&tree->tblHash); +  sqliteFree(tree); +  return SQLITE_OK; +} + +static int memRbtreeSetCacheSize(Rbtree* tree, int sz) +{ +  return SQLITE_OK; +} + +static int memRbtreeSetSafetyLevel(Rbtree *pBt, int level){ +  return SQLITE_OK; +} + +static int memRbtreeBeginTrans(Rbtree* tree) +{ +  if( tree->eTransState != TRANS_NONE )  +    return SQLITE_ERROR; + +  assert( tree->pTransRollback == 0 ); +  tree->eTransState = TRANS_INTRANSACTION; +  return SQLITE_OK; +} + +/* +** Delete a linked list of BtRollbackOp structures. +*/ +static void deleteRollbackList(BtRollbackOp *pOp){ +  while( pOp ){ +    BtRollbackOp *pTmp = pOp->pNext; +    sqliteFree(pOp->pData); +    sqliteFree(pOp->pKey); +    sqliteFree(pOp); +    pOp = pTmp; +  } +} + +static int memRbtreeCommit(Rbtree* tree){ +  /* Just delete pTransRollback and pCheckRollback */ +  deleteRollbackList(tree->pCheckRollback); +  deleteRollbackList(tree->pTransRollback); +  tree->pTransRollback = 0; +  tree->pCheckRollback = 0; +  tree->pCheckRollbackTail = 0; +  tree->eTransState = TRANS_NONE; +  return SQLITE_OK; +} + +/* + * Execute and delete the supplied rollback-list on pRbtree. + */ +static void execute_rollback_list(Rbtree *pRbtree, BtRollbackOp *pList) +{ +  BtRollbackOp *pTmp; +  RbtCursor cur; +  int res; + +  cur.pRbtree = pRbtree; +  while( pList ){ +    switch( pList->eOp ){ +      case ROLLBACK_INSERT: +        cur.pTree  = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab ); +        assert(cur.pTree); +        cur.iTree  = pList->iTab; +        cur.eSkip  = SKIP_NONE; +        memRbtreeInsert( &cur, pList->pKey, +            pList->nKey, pList->pData, pList->nData ); +        break; +      case ROLLBACK_DELETE: +        cur.pTree  = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab ); +        assert(cur.pTree); +        cur.iTree  = pList->iTab; +        cur.eSkip  = SKIP_NONE; +        memRbtreeMoveto(&cur, pList->pKey, pList->nKey, &res); +        assert(res == 0); +        memRbtreeDelete( &cur ); +        break; +      case ROLLBACK_CREATE: +        btreeCreateTable(pRbtree, pList->iTab); +        break; +      case ROLLBACK_DROP: +        memRbtreeDropTable(pRbtree, pList->iTab); +        break; +      default: +        assert(0); +    } +    sqliteFree(pList->pKey); +    sqliteFree(pList->pData); +    pTmp = pList->pNext; +    sqliteFree(pList); +    pList = pTmp; +  } +} + +static int memRbtreeRollback(Rbtree* tree) +{ +  tree->eTransState = TRANS_ROLLBACK; +  execute_rollback_list(tree, tree->pCheckRollback); +  execute_rollback_list(tree, tree->pTransRollback); +  tree->pTransRollback = 0; +  tree->pCheckRollback = 0; +  tree->pCheckRollbackTail = 0; +  tree->eTransState = TRANS_NONE; +  return SQLITE_OK; +} + +static int memRbtreeBeginCkpt(Rbtree* tree) +{ +  if( tree->eTransState != TRANS_INTRANSACTION )  +    return SQLITE_ERROR; + +  assert( tree->pCheckRollback == 0 ); +  assert( tree->pCheckRollbackTail == 0 ); +  tree->eTransState = TRANS_INCHECKPOINT; +  return SQLITE_OK; +} + +static int memRbtreeCommitCkpt(Rbtree* tree) +{ +  if( tree->eTransState == TRANS_INCHECKPOINT ){  +    if( tree->pCheckRollback ){ +      tree->pCheckRollbackTail->pNext = tree->pTransRollback; +      tree->pTransRollback = tree->pCheckRollback; +      tree->pCheckRollback = 0; +      tree->pCheckRollbackTail = 0; +    } +    tree->eTransState = TRANS_INTRANSACTION; +  } +  return SQLITE_OK; +} + +static int memRbtreeRollbackCkpt(Rbtree* tree) +{ +  if( tree->eTransState != TRANS_INCHECKPOINT ) return SQLITE_OK; +  tree->eTransState = TRANS_ROLLBACK; +  execute_rollback_list(tree, tree->pCheckRollback); +  tree->pCheckRollback = 0; +  tree->pCheckRollbackTail = 0; +  tree->eTransState = TRANS_INTRANSACTION; +  return SQLITE_OK; +  return SQLITE_OK; +} + +#ifdef SQLITE_TEST +static int memRbtreePageDump(Rbtree* tree, int pgno, int rec) +{ +  assert(!"Cannot call sqliteRbtreePageDump"); +  return SQLITE_OK; +} + +static int memRbtreeCursorDump(RbtCursor* pCur, int* aRes) +{ +  assert(!"Cannot call sqliteRbtreeCursorDump"); +  return SQLITE_OK; +} + +static struct Pager *memRbtreePager(Rbtree* tree) +{ +  assert(!"Cannot call sqliteRbtreePager"); +  return SQLITE_OK; +} +#endif + +/* +** Return the full pathname of the underlying database file. +*/ +static const char *memRbtreeGetFilename(Rbtree *pBt){ +  return 0;  /* A NULL return indicates there is no underlying file */ +} + +/* +** The copy file function is not implemented for the in-memory database +*/ +static int memRbtreeCopyFile(Rbtree *pBt, Rbtree *pBt2){ +  return SQLITE_INTERNAL;  /* Not implemented */ +} + +static BtOps sqliteRbtreeOps = { +    (int(*)(Btree*)) memRbtreeClose, +    (int(*)(Btree*,int)) memRbtreeSetCacheSize, +    (int(*)(Btree*,int)) memRbtreeSetSafetyLevel, +    (int(*)(Btree*)) memRbtreeBeginTrans, +    (int(*)(Btree*)) memRbtreeCommit, +    (int(*)(Btree*)) memRbtreeRollback, +    (int(*)(Btree*)) memRbtreeBeginCkpt, +    (int(*)(Btree*)) memRbtreeCommitCkpt, +    (int(*)(Btree*)) memRbtreeRollbackCkpt, +    (int(*)(Btree*,int*)) memRbtreeCreateTable, +    (int(*)(Btree*,int*)) memRbtreeCreateTable, +    (int(*)(Btree*,int)) memRbtreeDropTable, +    (int(*)(Btree*,int)) memRbtreeClearTable, +    (int(*)(Btree*,int,int,BtCursor**)) memRbtreeCursor, +    (int(*)(Btree*,int*)) memRbtreeGetMeta, +    (int(*)(Btree*,int*)) memRbtreeUpdateMeta, +    (char*(*)(Btree*,int*,int)) memRbtreeIntegrityCheck, +    (const char*(*)(Btree*)) memRbtreeGetFilename, +    (int(*)(Btree*,Btree*)) memRbtreeCopyFile, + +#ifdef SQLITE_TEST +    (int(*)(Btree*,int,int)) memRbtreePageDump, +    (struct Pager*(*)(Btree*)) memRbtreePager +#endif +}; + +static BtCursorOps sqliteRbtreeCursorOps = { +    (int(*)(BtCursor*,const void*,int,int*)) memRbtreeMoveto, +    (int(*)(BtCursor*)) memRbtreeDelete, +    (int(*)(BtCursor*,const void*,int,const void*,int)) memRbtreeInsert, +    (int(*)(BtCursor*,int*)) memRbtreeFirst, +    (int(*)(BtCursor*,int*)) memRbtreeLast, +    (int(*)(BtCursor*,int*)) memRbtreeNext, +    (int(*)(BtCursor*,int*)) memRbtreePrevious, +    (int(*)(BtCursor*,int*)) memRbtreeKeySize, +    (int(*)(BtCursor*,int,int,char*)) memRbtreeKey, +    (int(*)(BtCursor*,const void*,int,int,int*)) memRbtreeKeyCompare, +    (int(*)(BtCursor*,int*)) memRbtreeDataSize, +    (int(*)(BtCursor*,int,int,char*)) memRbtreeData, +    (int(*)(BtCursor*)) memRbtreeCloseCursor, +#ifdef SQLITE_TEST +    (int(*)(BtCursor*,int*)) memRbtreeCursorDump, +#endif + +}; + +#endif /* SQLITE_OMIT_INMEMORYDB */ diff --git a/ext/sqlite/libsqlite/src/build.c b/ext/sqlite/libsqlite/src/build.c index afa3f16025..76077ac943 100644 --- a/ext/sqlite/libsqlite/src/build.c +++ b/ext/sqlite/libsqlite/src/build.c @@ -18,8 +18,6 @@  **     CREATE INDEX  **     DROP INDEX  **     creating ID lists -**     COPY -**     VACUUM  **     BEGIN TRANSACTION  **     COMMIT  **     ROLLBACK @@ -38,6 +36,7 @@  */  void sqliteBeginParse(Parse *pParse, int explainFlag){    sqlite *db = pParse->db; +  int i;    pParse->explain = explainFlag;    if((db->flags & SQLITE_Initialized)==0 && pParse->initFlag==0 ){      int rc = sqliteInit(db, &pParse->zErrMsg); @@ -46,6 +45,12 @@ void sqliteBeginParse(Parse *pParse, int explainFlag){        pParse->nErr++;      }    } +  for(i=0; i<db->nDb; i++){ +    DbClearProperty(db, i, DB_Locked); +    if( !db->aDb[i].inTrans ){ +      DbClearProperty(db, i, DB_Cookie); +    } +  }  }  /* @@ -85,7 +90,7 @@ void sqliteExec(Parse *pParse){      if( pParse->useCallback ){        if( pParse->explain ){          rc = sqliteVdbeList(v); -        db->next_cookie = db->schema_cookie; +        db->next_cookie = db->aDb[0].schema_cookie;        }else{          sqliteVdbeExec(v);        } @@ -98,7 +103,6 @@ void sqliteExec(Parse *pParse){        pParse->rc = pParse->nErr ? SQLITE_ERROR : SQLITE_DONE;      }      pParse->colNamesSet = 0; -    pParse->schemaVerified = 0;    }else if( pParse->useCallback==0 ){      pParse->rc = SQLITE_ERROR;    } @@ -111,22 +115,82 @@ void sqliteExec(Parse *pParse){  /*  ** Locate the in-memory structure that describes   ** a particular database table given the name -** of that table.  Return NULL if not found. +** of that table and (optionally) the name of the database +** containing the table.  Return NULL if not found. +** +** See also sqliteLocateTable().  */ -Table *sqliteFindTable(sqlite *db, const char *zName){ +Table *sqliteFindTable(sqlite *db, const char *zName, const char *zDatabase){ +  Table *p = 0; +  int i; +  for(i=0; i<db->nDb; i++){ +    int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */ +    if( zDatabase!=0 && sqliteStrICmp(zDatabase, db->aDb[j].zName) ) continue; +    p = sqliteHashFind(&db->aDb[j].tblHash, zName, strlen(zName)+1); +    if( p ) break; +  } +  return p; +} + +/* +** Locate the in-memory structure that describes  +** a particular database table given the name +** of that table and (optionally) the name of the database +** containing the table.  Return NULL if not found. +** +** If pParse->useDb is not negative, then the table must be +** located in that database.  If a different database is specified, +** an error message is generated into pParse->zErrMsg. +*/ +Table *sqliteLocateTable(Parse *pParse, const char *zName, const char *zDbase){ +  sqlite *db; +  const char *zUse;    Table *p; -  p = sqliteHashFind(&db->tblHash, zName, strlen(zName)+1); +  db = pParse->db; +  if( pParse->useDb<0 ){ +    p = sqliteFindTable(db, zName, zDbase); +  }else { +    assert( pParse->useDb<db->nDb ); +    assert( db->aDb[pParse->useDb].pBt!=0 ); +    zUse = db->aDb[pParse->useDb].zName; +    if( zDbase && pParse->useDb!=1 && sqliteStrICmp(zDbase, zUse)!=0 ){ +      sqliteErrorMsg(pParse,"cannot use database %s in this context", zDbase); +      return 0; +    } +    p = sqliteFindTable(db, zName, zUse); +    if( p==0 && pParse->useDb==1 && zDbase==0 ){ +      p = sqliteFindTable(db, zName, 0); +    } +  } +  if( p==0 ){ +    if( zDbase ){ +      sqliteErrorMsg(pParse, "no such table: %s.%s", zDbase, zName); +    }else if( (pParse->useDb==0 || pParse->useDb>=2)  +               && sqliteFindTable(db, zName, 0)!=0 ){ +      sqliteErrorMsg(pParse, "table \"%s\" is not in database \"%s\"", +         zName, zUse); +    }else{ +      sqliteErrorMsg(pParse, "no such table: %s", zName); +    } +  }    return p;  }  /*  ** Locate the in-memory structure that describes  -** a particular index given the name of that index. +** a particular index given the name of that index +** and the name of the database that contains the index.  ** Return NULL if not found.  */ -Index *sqliteFindIndex(sqlite *db, const char *zName){ -  Index *p; -  p = sqliteHashFind(&db->idxHash, zName, strlen(zName)+1); +Index *sqliteFindIndex(sqlite *db, const char *zName, const char *zDb){ +  Index *p = 0; +  int i; +  for(i=0; i<db->nDb; i++){ +    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */ +    if( zDb && sqliteStrICmp(zDb, db->aDb[j].zName) ) continue; +    p = sqliteHashFind(&db->aDb[j].idxHash, zName, strlen(zName)+1); +    if( p ) break; +  }    return p;  } @@ -140,10 +204,13 @@ Index *sqliteFindIndex(sqlite *db, const char *zName){  */  static void sqliteDeleteIndex(sqlite *db, Index *p){    Index *pOld; +    assert( db!=0 && p->zName!=0 ); -  pOld = sqliteHashInsert(&db->idxHash, p->zName, strlen(p->zName)+1, 0); +  pOld = sqliteHashInsert(&db->aDb[p->iDb].idxHash, p->zName, +                          strlen(p->zName)+1, 0);    if( pOld!=0 && pOld!=p ){ -    sqliteHashInsert(&db->idxHash, pOld->zName, strlen(pOld->zName)+1, pOld); +    sqliteHashInsert(&db->aDb[p->iDb].idxHash, pOld->zName, +                     strlen(pOld->zName)+1, pOld);    }    sqliteFree(p);  } @@ -171,29 +238,67 @@ void sqliteUnlinkAndDeleteIndex(sqlite *db, Index *pIndex){  ** database connection.  This routine is called to reclaim memory  ** before the connection closes.  It is also called during a rollback  ** if there were schema changes during the transaction. +** +** If iDb<=0 then reset the internal schema tables for all database +** files.  If iDb>=2 then reset the internal schema for only the +** single file indicates.  */ -void sqliteResetInternalSchema(sqlite *db){ +void sqliteResetInternalSchema(sqlite *db, int iDb){    HashElem *pElem;    Hash temp1;    Hash temp2; +  int i, j; + +  assert( iDb>=0 && iDb<db->nDb ); +  db->flags &= ~SQLITE_Initialized; +  for(i=iDb; i<db->nDb; i++){ +    Db *pDb = &db->aDb[i]; +    temp1 = pDb->tblHash; +    temp2 = pDb->trigHash; +    sqliteHashInit(&pDb->trigHash, SQLITE_HASH_STRING, 0); +    sqliteHashClear(&pDb->aFKey); +    sqliteHashClear(&pDb->idxHash); +    for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ +      Trigger *pTrigger = sqliteHashData(pElem); +      sqliteDeleteTrigger(pTrigger); +    } +    sqliteHashClear(&temp2); +    sqliteHashInit(&pDb->tblHash, SQLITE_HASH_STRING, 0); +    for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ +      Table *pTab = sqliteHashData(pElem); +      sqliteDeleteTable(db, pTab); +    } +    sqliteHashClear(&temp1); +    DbClearProperty(db, i, DB_SchemaLoaded); +    if( iDb>0 ) return; +  } +  assert( iDb==0 ); +  db->flags &= ~SQLITE_InternChanges; -  sqliteHashClear(&db->aFKey); -  temp1 = db->tblHash; -  temp2 = db->trigHash; -  sqliteHashInit(&db->trigHash, SQLITE_HASH_STRING, 0); -  sqliteHashClear(&db->idxHash); -  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ -    Trigger *pTrigger = sqliteHashData(pElem); -    sqliteDeleteTrigger(pTrigger); -  } -  sqliteHashClear(&temp2); -  sqliteHashInit(&db->tblHash, SQLITE_HASH_STRING, 0); -  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ -    Table *pTab = sqliteHashData(pElem); -    sqliteDeleteTable(db, pTab); -  } -  sqliteHashClear(&temp1); -  db->flags &= ~(SQLITE_Initialized|SQLITE_InternChanges); +  /* If one or more of the auxiliary database files has been closed, +  ** then remove then from the auxiliary database list.  We take the +  ** opportunity to do this here since we have just deleted all of the +  ** schema hash tables and therefore do not have to make any changes +  ** to any of those tables. +  */ +  for(i=j=2; i<db->nDb; i++){ +    if( db->aDb[i].pBt==0 ){ +      sqliteFree(db->aDb[i].zName); +      db->aDb[i].zName = 0; +      continue; +    } +    if( j<i ){ +      db->aDb[j] = db->aDb[i]; +    } +    j++; +  } +  memset(&db->aDb[j], 0, (db->nDb-j)*sizeof(db->aDb[j])); +  db->nDb = j; +  if( db->nDb<=2 && db->aDb!=db->aDbStatic ){ +    memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0])); +    sqliteFree(db->aDb); +    db->aDb = db->aDbStatic; +  }  }  /* @@ -203,7 +308,7 @@ void sqliteResetInternalSchema(sqlite *db){  */  void sqliteRollbackInternalChanges(sqlite *db){    if( db->flags & SQLITE_InternChanges ){ -    sqliteResetInternalSchema(db); +    sqliteResetInternalSchema(db, 0);    }  } @@ -211,7 +316,7 @@ void sqliteRollbackInternalChanges(sqlite *db){  ** This routine is called when a commit occurs.  */  void sqliteCommitInternalChanges(sqlite *db){ -  db->schema_cookie = db->next_cookie; +  db->aDb[0].schema_cookie = db->next_cookie;    db->flags &= ~SQLITE_InternChanges;  } @@ -241,6 +346,7 @@ void sqliteDeleteTable(sqlite *db, Table *pTable){    */    for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){      pNext = pIndex->pNext; +    assert( pIndex->iDb==pTable->iDb || (pTable->iDb==0 && pIndex->iDb==1) );      sqliteDeleteIndex(db, pIndex);    } @@ -249,7 +355,9 @@ void sqliteDeleteTable(sqlite *db, Table *pTable){    */    for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){      pNextFKey = pFKey->pNextFrom; -    assert( sqliteHashFind(&db->aFKey,pFKey->zTo,strlen(pFKey->zTo)+1)!=pFKey ); +    assert( pTable->iDb<db->nDb ); +    assert( sqliteHashFind(&db->aDb[pTable->iDb].aFKey, +                           pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey );      sqliteFree(pFKey);    } @@ -273,14 +381,15 @@ void sqliteDeleteTable(sqlite *db, Table *pTable){  static void sqliteUnlinkAndDeleteTable(sqlite *db, Table *p){    Table *pOld;    FKey *pF1, *pF2; +  int i = p->iDb;    assert( db!=0 ); -  pOld = sqliteHashInsert(&db->tblHash, p->zName, strlen(p->zName)+1, 0); +  pOld = sqliteHashInsert(&db->aDb[i].tblHash, p->zName, strlen(p->zName)+1, 0);    assert( pOld==0 || pOld==p );    for(pF1=p->pFKey; pF1; pF1=pF1->pNextFrom){      int nTo = strlen(pF1->zTo) + 1; -    pF2 = sqliteHashFind(&db->aFKey, pF1->zTo, nTo); +    pF2 = sqliteHashFind(&db->aDb[i].aFKey, pF1->zTo, nTo);      if( pF2==pF1 ){ -      sqliteHashInsert(&db->aFKey, pF1->zTo, nTo, pF1->pNextTo); +      sqliteHashInsert(&db->aDb[i].aFKey, pF1->zTo, nTo, pF1->pNextTo);      }else{        while( pF2 && pF2->pNextTo!=pF1 ){ pF2=pF2->pNextTo; }        if( pF2 ){ @@ -310,13 +419,8 @@ char *sqliteTableNameFromToken(Token *pName){  ** on cursor 0.  */  void sqliteOpenMasterTable(Vdbe *v, int isTemp){ -  if( isTemp ){ -    sqliteVdbeAddOp(v, OP_OpenWrAux, 0, 2); -    sqliteVdbeChangeP3(v, -1, TEMP_MASTER_NAME, P3_STATIC); -  }else{ -    sqliteVdbeAddOp(v, OP_OpenWrite, 0, 2); -    sqliteVdbeChangeP3(v, -1, MASTER_NAME, P3_STATIC); -  } +  sqliteVdbeAddOp(v, OP_Integer, isTemp, 0); +  sqliteVdbeAddOp(v, OP_OpenWrite, 0, 2);  }  /* @@ -348,17 +452,21 @@ void sqliteStartTable(    char *zName;    sqlite *db = pParse->db;    Vdbe *v; +  int iDb;    pParse->sFirstToken = *pStart;    zName = sqliteTableNameFromToken(pName);    if( zName==0 ) return; +  if( pParse->iDb==1 ) isTemp = 1;  #ifndef SQLITE_OMIT_AUTHORIZATION -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0) ){ -    sqliteFree(zName); -    return; -  } +  assert( (isTemp & 1)==isTemp );    {      int code; +    char *zDb = isTemp ? "temp" : "main"; +    if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ +      sqliteFree(zName); +      return; +    }      if( isView ){        if( isTemp ){          code = SQLITE_CREATE_TEMP_VIEW; @@ -372,7 +480,7 @@ void sqliteStartTable(          code = SQLITE_CREATE_TABLE;        }      } -    if( sqliteAuthCheck(pParse, code, zName, 0) ){ +    if( sqliteAuthCheck(pParse, code, zName, 0, zDb) ){        sqliteFree(zName);        return;      } @@ -383,8 +491,8 @@ void sqliteStartTable(    /* Before trying to create a temporary table, make sure the Btree for    ** holding temporary tables is open.    */ -  if( isTemp && db->pBeTemp==0 ){ -    int rc = sqliteBtreeOpen(0, 0, MAX_PAGES, &db->pBeTemp); +  if( isTemp && db->aDb[1].pBt==0 && !pParse->explain ){ +    int rc = sqliteBtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt);      if( rc!=SQLITE_OK ){        sqliteSetString(&pParse->zErrMsg, "unable to open a temporary database "          "file for storing temporary tables", 0); @@ -392,7 +500,7 @@ void sqliteStartTable(        return;      }      if( db->flags & SQLITE_InTrans ){ -      rc = sqliteBtreeBeginTrans(db->pBeTemp); +      rc = sqliteBtreeBeginTrans(db->aDb[1].pBt);        if( rc!=SQLITE_OK ){          sqliteSetNString(&pParse->zErrMsg, "unable to get a write lock on "            "the temporary database file", 0); @@ -407,26 +515,19 @@ void sqliteStartTable(    **    ** If we are re-reading the sqlite_master table because of a schema    ** change and a new permanent table is found whose name collides with -  ** an existing temporary table, then ignore the new permanent table. -  ** We will continue parsing, but the pParse->nameClash flag will be set -  ** so we will know to discard the table record once parsing has finished. +  ** an existing temporary table, that is not an error.    */ -  pTable = sqliteFindTable(db, zName); -  if( pTable!=0 ){ -    if( pTable->isTemp && pParse->initFlag ){ -      pParse->nameClash = 1; -    }else{ -      sqliteSetNString(&pParse->zErrMsg, "table ", 0, pName->z, pName->n, -          " already exists", 0, 0); -      sqliteFree(zName); -      pParse->nErr++; -      return; -    } -  }else{ -    pParse->nameClash = 0; +  pTable = sqliteFindTable(db, zName, 0); +  iDb = isTemp ? 1 : pParse->iDb; +  if( pTable!=0 && (pTable->iDb==iDb || !pParse->initFlag) ){ +    sqliteSetNString(&pParse->zErrMsg, "table ", 0, pName->z, pName->n, +        " already exists", 0, 0); +    sqliteFree(zName); +    pParse->nErr++; +    return;    } -  if( (pIdx = sqliteFindIndex(db, zName))!=0 && -          (!pIdx->pTable->isTemp || !pParse->initFlag) ){ +  if( (pIdx = sqliteFindIndex(db, zName, 0))!=0 && +          (pIdx->iDb==0 || !pParse->initFlag) ){      sqliteSetString(&pParse->zErrMsg, "there is already an index named ",          zName, 0);      sqliteFree(zName); @@ -443,7 +544,7 @@ void sqliteStartTable(    pTable->aCol = 0;    pTable->iPKey = -1;    pTable->pIndex = 0; -  pTable->isTemp = isTemp; +  pTable->iDb = iDb;    if( pParse->pNewTable ) sqliteDeleteTable(db, pParse->pNewTable);    pParse->pNewTable = pTable; @@ -606,12 +707,12 @@ void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){    Table *pTab = pParse->pNewTable;    char *zType = 0;    int iCol = -1; -  if( pTab==0 ) return; +  if( pTab==0 ) goto primary_key_exit;    if( pTab->hasPrimKey ){      sqliteSetString(&pParse->zErrMsg, "table \"", pTab->zName,           "\" has more than one primary key", 0);      pParse->nErr++; -    return; +    goto primary_key_exit;    }    pTab->hasPrimKey = 1;    if( pList==0 ){ @@ -629,8 +730,13 @@ void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){      pTab->iPKey = iCol;      pTab->keyConf = onError;    }else{ -    sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0); +    sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0, 0); +    pList = 0;    } + +primary_key_exit: +  sqliteIdListDelete(pList); +  return;  }  /* @@ -708,8 +814,8 @@ void sqliteAddCollateType(Parse *pParse, int collType){  ** 1 chance in 2^32.  So we're safe enough.  */  void sqliteChangeCookie(sqlite *db, Vdbe *v){ -  if( db->next_cookie==db->schema_cookie ){ -    db->next_cookie = db->schema_cookie + sqliteRandomByte() + 1; +  if( db->next_cookie==db->aDb[0].schema_cookie ){ +    db->next_cookie = db->aDb[0].schema_cookie + sqliteRandomByte() + 1;      db->flags |= SQLITE_InternChanges;      sqliteVdbeAddOp(v, OP_Integer, db->next_cookie, 0);      sqliteVdbeAddOp(v, OP_SetCookie, 0, 0); @@ -778,7 +884,7 @@ static char *createTableStmt(Table *p){    n += 35 + 6*p->nCol;    zStmt = sqliteMallocRaw( n );    if( zStmt==0 ) return 0; -  strcpy(zStmt, p->isTemp ? "CREATE TEMP TABLE " : "CREATE TABLE "); +  strcpy(zStmt, p->iDb==1 ? "CREATE TEMP TABLE " : "CREATE TABLE ");    k = strlen(zStmt);    identPut(zStmt, &k, p->zName);    zStmt[k++] = '('; @@ -859,7 +965,7 @@ void sqliteEndTable(Parse *pParse, Token *pEnd, Select *pSelect){      if( v==0 ) return;      if( p->pSelect==0 ){        /* A regular table */ -      sqliteVdbeAddOp(v, OP_CreateTable, 0, p->isTemp); +      sqliteVdbeAddOp(v, OP_CreateTable, 0, p->iDb);        sqliteVdbeChangeP3(v, -1, (char *)&p->tnum, P3_POINTER);      }else{        /* A view */ @@ -891,13 +997,13 @@ void sqliteEndTable(Parse *pParse, Token *pEnd, Select *pSelect){      }      sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0); -    if( !p->isTemp ){ +    if( !p->iDb ){        sqliteChangeCookie(db, v);      }      sqliteVdbeAddOp(v, OP_Close, 0, 0);      if( pSelect ){ -      int op = p->isTemp ? OP_OpenWrAux : OP_OpenWrite; -      sqliteVdbeAddOp(v, op, 1, 0); +      sqliteVdbeAddOp(v, OP_Integer, p->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, 1, 0);        pParse->nTab = 2;        sqliteSelect(pParse, pSelect, SRT_Table, 1, 0, 0, 0);      } @@ -906,19 +1012,19 @@ void sqliteEndTable(Parse *pParse, Token *pEnd, Select *pSelect){    /* Add the table to the in-memory representation of the database.    */ -  assert( pParse->nameClash==0 || pParse->initFlag==1 ); -  if( pParse->explain==0 && pParse->nameClash==0 && pParse->nErr==0 ){ +  if( pParse->explain==0 && pParse->nErr==0 ){      Table *pOld;      FKey *pFKey; -    pOld = sqliteHashInsert(&db->tblHash, p->zName, strlen(p->zName)+1, p); +    pOld = sqliteHashInsert(&db->aDb[p->iDb].tblHash,  +                            p->zName, strlen(p->zName)+1, p);      if( pOld ){        assert( p==pOld );  /* Malloc must have failed inside HashInsert() */        return;      }      for(pFKey=p->pFKey; pFKey; pFKey=pFKey->pNextFrom){        int nTo = strlen(pFKey->zTo) + 1; -      pFKey->pNextTo = sqliteHashFind(&db->aFKey, pFKey->zTo, nTo); -      sqliteHashInsert(&db->aFKey, pFKey->zTo, nTo, pFKey); +      pFKey->pNextTo = sqliteHashFind(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo); +      sqliteHashInsert(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo, pFKey);      }      pParse->pNewTable = 0;      db->nTable++; @@ -1038,7 +1144,7 @@ int sqliteViewGetColumnNames(Parse *pParse, Table *pTable){      pSelTab->nCol = 0;      pSelTab->aCol = 0;      sqliteDeleteTable(0, pSelTab); -    pParse->db->flags |= SQLITE_UnresetViews; +    DbSetProperty(pParse->db, pTable->iDb, DB_UnresetViews);    }else{      pTable->nCol = 0;      nErr++; @@ -1072,18 +1178,18 @@ static void sqliteViewResetColumnNames(Table *pTable){  }  /* -** Clear the column names from every VIEW. +** Clear the column names from every VIEW in database idx.  */ -void sqliteViewResetAll(sqlite *db){ +static void sqliteViewResetAll(sqlite *db, int idx){    HashElem *i; -  if( (db->flags & SQLITE_UnresetViews)==0 ) return; -  for(i=sqliteHashFirst(&db->tblHash); i; i=sqliteHashNext(i)){ +  if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; +  for(i=sqliteHashFirst(&db->aDb[idx].tblHash); i; i=sqliteHashNext(i)){      Table *pTab = sqliteHashData(i);      if( pTab->pSelect ){        sqliteViewResetColumnNames(pTab);      }    } -  db->flags &= ~SQLITE_UnresetViews; +  DbClearProperty(db, idx, DB_UnresetViews);  }  /* @@ -1095,7 +1201,7 @@ Table *sqliteTableFromToken(Parse *pParse, Token *pTok){    Table *pTab;    zName = sqliteTableNameFromToken(pTok);    if( zName==0 ) return 0; -  pTab = sqliteFindTable(pParse->db, zName); +  pTab = sqliteFindTable(pParse->db, zName, 0);    sqliteFree(zName);    if( pTab==0 ){      sqliteSetNString(&pParse->zErrMsg, "no such table: ", 0,  @@ -1114,33 +1220,38 @@ void sqliteDropTable(Parse *pParse, Token *pName, int isView){    Vdbe *v;    int base;    sqlite *db = pParse->db; +  int iDb;    if( pParse->nErr || sqlite_malloc_failed ) return;    pTable = sqliteTableFromToken(pParse, pName);    if( pTable==0 ) return; +  iDb = pTable->iDb; +  assert( iDb>=0 && iDb<db->nDb );  #ifndef SQLITE_OMIT_AUTHORIZATION -  if( sqliteAuthCheck(pParse, SQLITE_DELETE, SCHEMA_TABLE(pTable->isTemp),0)){ -    return; -  }    {      int code; +    const char *zTab = SCHEMA_TABLE(pTable->iDb); +    const char *zDb = db->aDb[pTable->iDb].zName; +    if( sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){ +      return; +    }      if( isView ){ -      if( pTable->isTemp ){ +      if( iDb==1 ){          code = SQLITE_DROP_TEMP_VIEW;        }else{          code = SQLITE_DROP_VIEW;        }      }else{ -      if( pTable->isTemp ){ +      if( iDb==1 ){          code = SQLITE_DROP_TEMP_TABLE;        }else{          code = SQLITE_DROP_TABLE;        }      } -    if( sqliteAuthCheck(pParse, code, pTable->zName, 0) ){ +    if( sqliteAuthCheck(pParse, code, pTable->zName, 0, zDb) ){        return;      } -    if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0) ){ +    if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0, zDb) ){        return;      }    } @@ -1181,31 +1292,44 @@ void sqliteDropTable(Parse *pParse, Token *pName, int isView){      };      Index *pIdx;      Trigger *pTrigger; -    sqliteBeginWriteOperation(pParse, 0, pTable->isTemp); -    sqliteOpenMasterTable(v, pTable->isTemp); +    sqliteBeginWriteOperation(pParse, 0, pTable->iDb); +      /* Drop all triggers associated with the table being dropped */      pTrigger = pTable->pTrigger;      while( pTrigger ){ -      Token tt; -      tt.z = pTable->pTrigger->name; -      tt.n = strlen(pTable->pTrigger->name); -      sqliteDropTrigger(pParse, &tt, 1); +      SrcList *pNm; +      assert( pTrigger->iDb==pTable->iDb || pTrigger->iDb==1 ); +      pNm = sqliteSrcListAppend(0, 0, 0); +      pNm->a[0].zName = sqliteStrDup(pTrigger->name); +      pNm->a[0].zDatabase = sqliteStrDup(db->aDb[pTable->iDb].zName); +      sqliteDropTrigger(pParse, pNm, 1);        if( pParse->explain ){          pTrigger = pTrigger->pNext;        }else{          pTrigger = pTable->pTrigger;        }      } + +    /* Drop all SQLITE_MASTER entries that refer to the table */ +    sqliteOpenMasterTable(v, pTable->iDb);      base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable);      sqliteVdbeChangeP3(v, base+1, pTable->zName, 0); -    if( !pTable->isTemp ){ + +    /* Drop all SQLITE_TEMP_MASTER entries that refer to the table */ +    if( pTable->iDb!=1 ){ +      sqliteOpenMasterTable(v, 1); +      base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable); +      sqliteVdbeChangeP3(v, base+1, pTable->zName, 0); +    } + +    if( pTable->iDb==0 ){        sqliteChangeCookie(db, v);      }      sqliteVdbeAddOp(v, OP_Close, 0, 0);      if( !isView ){ -      sqliteVdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->isTemp); +      sqliteVdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->iDb);        for(pIdx=pTable->pIndex; pIdx; pIdx=pIdx->pNext){ -        sqliteVdbeAddOp(v, OP_Destroy, pIdx->tnum, pTable->isTemp); +        sqliteVdbeAddOp(v, OP_Destroy, pIdx->tnum, pIdx->iDb);        }      }      sqliteEndWriteOperation(pParse); @@ -1220,7 +1344,7 @@ void sqliteDropTable(Parse *pParse, Token *pName, int isView){      sqliteUnlinkAndDeleteTable(db, pTable);      db->flags |= SQLITE_InternChanges;    } -  sqliteViewResetAll(db); +  sqliteViewResetAll(db, iDb);  }  /* @@ -1403,9 +1527,10 @@ void sqliteDeferForeignKey(Parse *pParse, int isDeferred){  void sqliteCreateIndex(    Parse *pParse,   /* All information about this parse */    Token *pName,    /* Name of the index.  May be NULL */ -  Token *pTable,   /* Name of the table to index.  Use pParse->pNewTable if 0 */ +  SrcList *pTable, /* Name of the table to index.  Use pParse->pNewTable if 0 */    IdList *pList,   /* A list of columns to be indexed */    int onError,     /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ +  int isTemp,      /* True if this is a temporary index */    Token *pStart,   /* The CREATE token that begins a CREATE TABLE statement */    Token *pEnd      /* The ")" that closes the CREATE INDEX statement */  ){ @@ -1415,7 +1540,6 @@ void sqliteCreateIndex(    int i, j;    Token nullId;             /* Fake token for an empty ID list */    sqlite *db = pParse->db; -  int hideName = 0;         /* Do not put table name in the hash table */    if( pParse->nErr || sqlite_malloc_failed ) goto exit_create_index; @@ -1424,15 +1548,22 @@ void sqliteCreateIndex(    */    if( pTable!=0 ){      assert( pName!=0 ); -    pTab =  sqliteTableFromToken(pParse, pTable); +    assert( pTable->nSrc==1 ); +    pTab =  sqliteSrcListLookup(pParse, pTable);    }else{      assert( pName==0 );      pTab =  pParse->pNewTable;    }    if( pTab==0 || pParse->nErr ) goto exit_create_index;    if( pTab->readOnly ){ +    sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, +      " may not be indexed", 0); +    pParse->nErr++; +    goto exit_create_index; +  } +  if( !isTemp && pTab->iDb>=2 && pParse->initFlag==0 ){      sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName,  -      " may not have new indices added", 0); +      " may not have non-temporary indices added", 0);      pParse->nErr++;      goto exit_create_index;    } @@ -1441,16 +1572,8 @@ void sqliteCreateIndex(      pParse->nErr++;      goto exit_create_index;    } - -  /* If this index is created while re-reading the schema from sqlite_master -  ** but the table associated with this index is a temporary table, it can -  ** only mean that the table that this index is really associated with is -  ** one whose name is hidden behind a temporary table with the same name. -  ** Since its table has been suppressed, we need to also suppress the -  ** index. -  */ -  if( pParse->initFlag && !pParse->isTemp && pTab->isTemp ){ -    goto exit_create_index; +  if( pTab->iDb==1 ){ +    isTemp = 1;    }    /* @@ -1460,40 +1583,30 @@ void sqliteCreateIndex(    ** Exception:  If we are reading the names of permanent indices from the    ** sqlite_master table (because some other process changed the schema) and    ** one of the index names collides with the name of a temporary table or -  ** index, then we will continue to process this index, but we will not -  ** store its name in the hash table.  Set the hideName flag to accomplish -  ** this. +  ** index, then we will continue to process this index.    **    ** If pName==0 it means that we are    ** dealing with a primary key or UNIQUE constraint.  We have to invent our    ** own name.    */ -  if( pName ){ +  if( pName && !pParse->initFlag ){      Index *pISameName;    /* Another index with the same name */      Table *pTSameName;    /* A table with same name as the index */ -    zName = sqliteTableNameFromToken(pName); +    zName = sqliteStrNDup(pName->z, pName->n);      if( zName==0 ) goto exit_create_index; -    if( (pISameName = sqliteFindIndex(db, zName))!=0 ){ -      if( pISameName->pTable->isTemp && pParse->initFlag ){ -        hideName = 1; -      }else{ -        sqliteSetString(&pParse->zErrMsg, "index ", zName,  -           " already exists", 0); -        pParse->nErr++; -        goto exit_create_index; -      } +    if( (pISameName = sqliteFindIndex(db, zName, 0))!=0 ){ +      sqliteSetString(&pParse->zErrMsg, "index ", zName,  +         " already exists", 0); +      pParse->nErr++; +      goto exit_create_index;      } -    if( (pTSameName = sqliteFindTable(db, zName))!=0 ){ -      if( pTSameName->isTemp && pParse->initFlag ){ -        hideName = 1; -      }else{ -        sqliteSetString(&pParse->zErrMsg, "there is already a table named ", -           zName, 0); -        pParse->nErr++; -        goto exit_create_index; -      } +    if( (pTSameName = sqliteFindTable(db, zName, 0))!=0 ){ +      sqliteSetString(&pParse->zErrMsg, "there is already a table named ", +         zName, 0); +      pParse->nErr++; +      goto exit_create_index;      } -  }else{ +  }else if( pName==0 ){      char zBuf[30];      int n;      Index *pLoop; @@ -1502,19 +1615,26 @@ void sqliteCreateIndex(      zName = 0;      sqliteSetString(&zName, "(", pTab->zName, " autoindex ", zBuf, 0);      if( zName==0 ) goto exit_create_index; -    hideName = sqliteFindIndex(db, zName)!=0; +  }else{ +    zName = sqliteStrNDup(pName->z, pName->n);    }    /* Check for authorization to create an index.    */  #ifndef SQLITE_OMIT_AUTHORIZATION -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(pTab->isTemp), 0) ){ -    goto exit_create_index; -  } -  i = SQLITE_CREATE_INDEX; -  if( pTab->isTemp ) i = SQLITE_CREATE_TEMP_INDEX; -  if( sqliteAuthCheck(pParse, i, zName, pTab->zName) ){ -    goto exit_create_index; +  { +    const char *zDb = db->aDb[pTab->iDb].zName; + +    assert( isTemp==0 || isTemp==1 ); +    assert( pTab->iDb==pParse->iDb || isTemp==1 ); +    if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ +      goto exit_create_index; +    } +    i = SQLITE_CREATE_INDEX; +    if( isTemp ) i = SQLITE_CREATE_TEMP_INDEX; +    if( sqliteAuthCheck(pParse, i, zName, pTab->zName, zDb) ){ +      goto exit_create_index; +    }    }  #endif @@ -1540,8 +1660,9 @@ void sqliteCreateIndex(    strcpy(pIndex->zName, zName);    pIndex->pTable = pTab;    pIndex->nColumn = pList->nId; -  pIndex->onError = pIndex->isUnique = onError; +  pIndex->onError = onError;    pIndex->autoIndex = pName==0; +  pIndex->iDb = isTemp ? 1 : pParse->iDb;    /* Scan the names of the columns of the table to be indexed and    ** load the column indices into the Index structure.  Report an error @@ -1564,9 +1685,10 @@ void sqliteCreateIndex(    /* Link the new Index structure to its table and to the other    ** in-memory database structures.     */ -  if( !pParse->explain && !hideName ){ +  if( !pParse->explain ){      Index *p; -    p = sqliteHashInsert(&db->idxHash, pIndex->zName, strlen(zName)+1, pIndex); +    p = sqliteHashInsert(&db->aDb[isTemp].idxHash,  +                         pIndex->zName, strlen(zName)+1, pIndex);      if( p ){        assert( p==pIndex );  /* Malloc must have failed */        sqliteFree(pIndex); @@ -1622,7 +1744,6 @@ void sqliteCreateIndex(      int lbl1, lbl2;      int i;      int addr; -    int isTemp = pTab->isTemp;      v = sqliteGetVdbe(pParse);      if( v==0 ) goto exit_create_index; @@ -1642,11 +1763,8 @@ void sqliteCreateIndex(      pIndex->tnum = 0;      if( pTable ){        sqliteVdbeAddOp(v, OP_Dup, 0, 0); -      if( isTemp ){ -        sqliteVdbeAddOp(v, OP_OpenWrAux, 1, 0); -      }else{ -        sqliteVdbeAddOp(v, OP_OpenWrite, 1, 0); -      } +      sqliteVdbeAddOp(v, OP_Integer, isTemp, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, 1, 0);      }      addr = sqliteVdbeAddOp(v, OP_String, 0, 0);      if( pStart && pEnd ){ @@ -1656,13 +1774,19 @@ void sqliteCreateIndex(      sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0);      if( pTable ){ -      sqliteVdbeAddOp(v, isTemp ? OP_OpenAux : OP_Open, 2, pTab->tnum); +      sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenRead, 2, pTab->tnum);        sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC);        lbl2 = sqliteVdbeMakeLabel(v);        sqliteVdbeAddOp(v, OP_Rewind, 2, lbl2);        lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0);        for(i=0; i<pIndex->nColumn; i++){ -        sqliteVdbeAddOp(v, OP_Column, 2, pIndex->aiColumn[i]); +        int iCol = pIndex->aiColumn[i]; +        if( pTab->iPKey==iCol ){ +          sqliteVdbeAddOp(v, OP_Dup, i, 0); +        }else{ +          sqliteVdbeAddOp(v, OP_Column, 2, iCol); +        }        }        sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0);        if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex); @@ -1685,6 +1809,7 @@ void sqliteCreateIndex(    /* Clean up before exiting */  exit_create_index:    sqliteIdListDelete(pList); +  sqliteSrcListDelete(pTable);    sqliteFree(zName);    return;  } @@ -1693,39 +1818,40 @@ exit_create_index:  ** This routine will drop an existing named index.  This routine  ** implements the DROP INDEX statement.  */ -void sqliteDropIndex(Parse *pParse, Token *pName){ +void sqliteDropIndex(Parse *pParse, SrcList *pName){    Index *pIndex; -  char *zName;    Vdbe *v;    sqlite *db = pParse->db;    if( pParse->nErr || sqlite_malloc_failed ) return; -  zName = sqliteTableNameFromToken(pName); -  if( zName==0 ) return; -  pIndex = sqliteFindIndex(db, zName); -  sqliteFree(zName); +  assert( pName->nSrc==1 ); +  pIndex = sqliteFindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);    if( pIndex==0 ){ -    sqliteSetNString(&pParse->zErrMsg, "no such index: ", 0,  -        pName->z, pName->n, 0); -    pParse->nErr++; -    return; +    sqliteErrorMsg(pParse, "no such index: %S", pName, 0); +    goto exit_drop_index;    }    if( pIndex->autoIndex ){ -    sqliteSetString(&pParse->zErrMsg, "index associated with UNIQUE " +    sqliteErrorMsg(pParse, "index associated with UNIQUE "        "or PRIMARY KEY constraint cannot be dropped", 0); -    pParse->nErr++; -    return; +    goto exit_drop_index; +  } +  if( pIndex->iDb>1 ){ +    sqliteErrorMsg(pParse, "cannot alter schema of attached " +       "databases", 0); +    goto exit_drop_index;    }  #ifndef SQLITE_OMIT_AUTHORIZATION    {      int code = SQLITE_DROP_INDEX;      Table *pTab = pIndex->pTable; -    if( sqliteAuthCheck(pParse, SQLITE_DELETE, SCHEMA_TABLE(pTab->isTemp), 0) ){ -      return; +    const char *zDb = db->aDb[pIndex->iDb].zName; +    const char *zTab = SCHEMA_TABLE(pIndex->iDb); +    if( sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){ +      goto exit_drop_index;      } -    if( pTab->isTemp ) code = SQLITE_DROP_TEMP_INDEX; -    if( sqliteAuthCheck(pParse, code, pIndex->zName, pTab->zName) ){ -      return; +    if( pIndex->iDb ) code = SQLITE_DROP_TEMP_INDEX; +    if( sqliteAuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){ +      goto exit_drop_index;      }    }  #endif @@ -1745,17 +1871,16 @@ void sqliteDropIndex(Parse *pParse, Token *pName){        { OP_Delete,     0, 0,       0}, /* 8 */      };      int base; -    Table *pTab = pIndex->pTable; -    sqliteBeginWriteOperation(pParse, 0, pTab->isTemp); -    sqliteOpenMasterTable(v, pTab->isTemp); +    sqliteBeginWriteOperation(pParse, 0, pIndex->iDb); +    sqliteOpenMasterTable(v, pIndex->iDb);      base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex);      sqliteVdbeChangeP3(v, base+1, pIndex->zName, 0); -    if( !pTab->isTemp ){ +    if( pIndex->iDb==0 ){        sqliteChangeCookie(db, v);      }      sqliteVdbeAddOp(v, OP_Close, 0, 0); -    sqliteVdbeAddOp(v, OP_Destroy, pIndex->tnum, pTab->isTemp); +    sqliteVdbeAddOp(v, OP_Destroy, pIndex->tnum, pIndex->iDb);      sqliteEndWriteOperation(pParse);    } @@ -1765,6 +1890,9 @@ void sqliteDropIndex(Parse *pParse, Token *pName){      sqliteUnlinkAndDeleteIndex(db, pIndex);      db->flags |= SQLITE_InternChanges;    } + +exit_drop_index: +  sqliteSrcListDelete(pName);  }  /* @@ -1807,25 +1935,53 @@ IdList *sqliteIdListAppend(IdList *pList, Token *pToken){  ** need be.  A new entry is created in the SrcList even if pToken is NULL.  **  ** A new SrcList is returned, or NULL if malloc() fails. +** +** If pDatabase is not null, it means that the table has an optional +** database name prefix.  Like this:  "database.table".  The pDatabase +** points to the table name and the pTable points to the database name. +** The SrcList.a[].zName field is filled with the table name which might +** come from pTable (if pDatabase is NULL) or from pDatabase.   +** SrcList.a[].zDatabase is filled with the database name from pTable, +** or with NULL if no database is specified. +** +** In other words, if call like this: +** +**         sqliteSrcListAppend(A,B,0); +** +** Then B is a table name and the database name is unspecified.  If called +** like this: +** +**         sqliteSrcListAppend(A,B,C); +** +** Then C is the table name and B is the database name.  */ -SrcList *sqliteSrcListAppend(SrcList *pList, Token *pToken){ +SrcList *sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){    if( pList==0 ){ -    pList = sqliteMalloc( sizeof(IdList) ); +    pList = sqliteMalloc( sizeof(SrcList) );      if( pList==0 ) return 0;    } -  if( (pList->nSrc & 7)==0 ){ -    struct SrcList_item *a; -    a = sqliteRealloc(pList->a, (pList->nSrc+8)*sizeof(pList->a[0]) ); -    if( a==0 ){ +  if( (pList->nSrc & 7)==1 ){ +    SrcList *pNew; +    pNew = sqliteRealloc(pList, +               sizeof(*pList) + (pList->nSrc+8)*sizeof(pList->a[0]) ); +    if( pNew==0 ){        sqliteSrcListDelete(pList);        return 0;      } -    pList->a = a; +    pList = pNew;    }    memset(&pList->a[pList->nSrc], 0, sizeof(pList->a[0])); -  if( pToken ){ +  if( pDatabase && pDatabase->z==0 ){ +    pDatabase = 0; +  } +  if( pDatabase && pTable ){ +    Token *pTemp = pDatabase; +    pDatabase = pTable; +    pTable = pTemp; +  } +  if( pTable ){      char **pz = &pList->a[pList->nSrc].zName; -    sqliteSetNString(pz, pToken->z, pToken->n, 0); +    sqliteSetNString(pz, pTable->z, pTable->n, 0);      if( *pz==0 ){        sqliteSrcListDelete(pList);        return 0; @@ -1833,11 +1989,34 @@ SrcList *sqliteSrcListAppend(SrcList *pList, Token *pToken){        sqliteDequote(*pz);      }    } +  if( pDatabase ){ +    char **pz = &pList->a[pList->nSrc].zDatabase; +    sqliteSetNString(pz, pDatabase->z, pDatabase->n, 0); +    if( *pz==0 ){ +      sqliteSrcListDelete(pList); +      return 0; +    }else{ +      sqliteDequote(*pz); +    } +  } +  pList->a[pList->nSrc].iCursor = -1;    pList->nSrc++;    return pList;  }  /* +** Assign cursors to all tables in a SrcList +*/ +void sqliteSrcListAssignCursors(Parse *pParse, SrcList *pList){ +  int i; +  for(i=0; i<pList->nSrc; i++){ +    if( pList->a[i].iCursor<0 ){ +      pList->a[i].iCursor = pParse->nTab++; +    } +  } +} + +/*  ** Add an alias to the last identifier on the given identifier list.  */  void sqliteSrcListAddAlias(SrcList *pList, Token *pToken){ @@ -1881,6 +2060,7 @@ void sqliteSrcListDelete(SrcList *pList){    int i;    if( pList==0 ) return;    for(i=0; i<pList->nSrc; i++){ +    sqliteFree(pList->a[i].zDatabase);      sqliteFree(pList->a[i].zName);      sqliteFree(pList->a[i].zAlias);      if( pList->a[i].pTab && pList->a[i].pTab->isTransient ){ @@ -1890,137 +2070,20 @@ void sqliteSrcListDelete(SrcList *pList){      sqliteExprDelete(pList->a[i].pOn);      sqliteIdListDelete(pList->a[i].pUsing);    } -  sqliteFree(pList->a);    sqliteFree(pList);  }  /* -** The COPY command is for compatibility with PostgreSQL and specificially -** for the ability to read the output of pg_dump.  The format is as -** follows: -** -**    COPY table FROM file [USING DELIMITERS string] -** -** "table" is an existing table name.  We will read lines of code from -** file to fill this table with data.  File might be "stdin".  The optional -** delimiter string identifies the field separators.  The default is a tab. -*/ -void sqliteCopy( -  Parse *pParse,       /* The parser context */ -  Token *pTableName,   /* The name of the table into which we will insert */ -  Token *pFilename,    /* The file from which to obtain information */ -  Token *pDelimiter,   /* Use this as the field delimiter */ -  int onError          /* What to do if a constraint fails */ -){ -  Table *pTab; -  char *zTab; -  int i; -  Vdbe *v; -  int addr, end; -  Index *pIdx; -  char *zFile = 0; -  sqlite *db = pParse->db; - - -  zTab = sqliteTableNameFromToken(pTableName); -  if( sqlite_malloc_failed || zTab==0 ) goto copy_cleanup; -  pTab = sqliteTableNameToTable(pParse, zTab); -  sqliteFree(zTab); -  if( pTab==0 ) goto copy_cleanup; -  zFile = sqliteStrNDup(pFilename->z, pFilename->n); -  sqliteDequote(zFile); -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, zFile) -      || sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile) ){ -    goto copy_cleanup; -  } -  v = sqliteGetVdbe(pParse); -  if( v ){ -    int openOp; -    sqliteBeginWriteOperation(pParse, 1, pTab->isTemp); -    addr = sqliteVdbeAddOp(v, OP_FileOpen, 0, 0); -    sqliteVdbeChangeP3(v, addr, pFilename->z, pFilename->n); -    sqliteVdbeDequoteP3(v, addr); -    openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; -    sqliteVdbeAddOp(v, openOp, 0, pTab->tnum); -    sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); -    for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ -      sqliteVdbeAddOp(v, openOp, i, pIdx->tnum); -      sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC); -    } -    if( db->flags & SQLITE_CountRows ){ -      sqliteVdbeAddOp(v, OP_Integer, 0, 0);  /* Initialize the row count */ -    } -    end = sqliteVdbeMakeLabel(v); -    addr = sqliteVdbeAddOp(v, OP_FileRead, pTab->nCol, end); -    if( pDelimiter ){ -      sqliteVdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n); -      sqliteVdbeDequoteP3(v, addr); -    }else{ -      sqliteVdbeChangeP3(v, addr, "\t", 1); -    } -    if( pTab->iPKey>=0 ){ -      sqliteVdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0); -      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); -    }else{ -      sqliteVdbeAddOp(v, OP_NewRecno, 0, 0); -    } -    for(i=0; i<pTab->nCol; i++){ -      if( i==pTab->iPKey ){ -        /* The integer primary key column is filled with NULL since its -        ** value is always pulled from the record number */ -        sqliteVdbeAddOp(v, OP_String, 0, 0); -      }else{ -        sqliteVdbeAddOp(v, OP_FileColumn, i, 0); -      } -    } -    sqliteGenerateConstraintChecks(pParse, pTab, 0, 0, 0, 0, onError, addr); -    sqliteCompleteInsertion(pParse, pTab, 0, 0, 0, 0); -    if( (db->flags & SQLITE_CountRows)!=0 ){ -      sqliteVdbeAddOp(v, OP_AddImm, 1, 0);  /* Increment row count */ -    } -    sqliteVdbeAddOp(v, OP_Goto, 0, addr); -    sqliteVdbeResolveLabel(v, end); -    sqliteVdbeAddOp(v, OP_Noop, 0, 0); -    sqliteEndWriteOperation(pParse); -    if( db->flags & SQLITE_CountRows ){ -      sqliteVdbeAddOp(v, OP_ColumnName, 0, 0); -      sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC); -      sqliteVdbeAddOp(v, OP_Callback, 1, 0); -    } -  } -   -copy_cleanup: -  sqliteFree(zFile); -  return; -} - -/* -** The non-standard VACUUM command is used to clean up the database, -** collapse free space, etc.  It is modelled after the VACUUM command -** in PostgreSQL. -** -** In version 1.0.x of SQLite, the VACUUM command would call -** gdbm_reorganize() on all the database tables.  But beginning -** with 2.0.0, SQLite no longer uses GDBM so this command has -** become a no-op. -*/ -void sqliteVacuum(Parse *pParse, Token *pTableName){ -  /* Do nothing */ -} - -/*  ** Begin a transaction  */  void sqliteBeginTransaction(Parse *pParse, int onError){    sqlite *db; -  if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; +  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;    if( pParse->nErr || sqlite_malloc_failed ) return; -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0) ) return; +  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ) return;    if( db->flags & SQLITE_InTrans ){ -    pParse->nErr++; -    sqliteSetString(&pParse->zErrMsg, "cannot start a transaction " -       "within a transaction", 0); +    sqliteErrorMsg(pParse, "cannot start a transaction within a transaction");      return;    }    sqliteBeginWriteOperation(pParse, 0, 0); @@ -2034,13 +2097,11 @@ void sqliteBeginTransaction(Parse *pParse, int onError){  void sqliteCommitTransaction(Parse *pParse){    sqlite *db; -  if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; +  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;    if( pParse->nErr || sqlite_malloc_failed ) return; -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0) ) return; +  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ) return;    if( (db->flags & SQLITE_InTrans)==0 ){ -    pParse->nErr++; -    sqliteSetString(&pParse->zErrMsg,  -       "cannot commit - no transaction is active", 0); +    sqliteErrorMsg(pParse, "cannot commit - no transaction is active");      return;    }    db->flags &= ~SQLITE_InTrans; @@ -2055,13 +2116,11 @@ void sqliteRollbackTransaction(Parse *pParse){    sqlite *db;    Vdbe *v; -  if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; +  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;    if( pParse->nErr || sqlite_malloc_failed ) return; -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0) ) return; +  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ) return;    if( (db->flags & SQLITE_InTrans)==0 ){ -    pParse->nErr++; -    sqliteSetString(&pParse->zErrMsg, -       "cannot rollback - no transaction is active", 0); +    sqliteErrorMsg(pParse, "cannot rollback - no transaction is active");      return;     }    v = sqliteGetVdbe(pParse); @@ -2073,6 +2132,21 @@ void sqliteRollbackTransaction(Parse *pParse){  }  /* +** Generate VDBE code that will verify the schema cookie for all +** named database files. +*/ +void sqliteCodeVerifySchema(Parse *pParse, int iDb){ +  sqlite *db = pParse->db; +  Vdbe *v = sqliteGetVdbe(pParse); +  assert( iDb>=0 && iDb<db->nDb ); +  assert( db->aDb[iDb].pBt!=0 ); +  if( iDb!=1 && !DbHasProperty(db, iDb, DB_Cookie) ){ +    sqliteVdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie); +    DbSetProperty(db, iDb, DB_Cookie); +  } +} + +/*  ** Generate VDBE code that prepares for doing an operation that  ** might change the database.  ** @@ -2085,485 +2159,50 @@ void sqliteRollbackTransaction(Parse *pParse){  ** can be checked before any changes are made to the database, it is never  ** necessary to undo a write and the checkpoint should not be set.  ** -** The tempOnly flag indicates that only temporary tables will be changed -** during this write operation.  The primary database table is not -** write-locked.  Only the temporary database file gets a write lock. -** Other processes can continue to read or write the primary database file. +** Only database iDb and the temp database are made writable by this call. +** If iDb==0, then the main and temp databases are made writable.   If +** iDb==1 then only the temp database is made writable.  If iDb>1 then the +** specified auxiliary database and the temp database are made writable.  */ -void sqliteBeginWriteOperation(Parse *pParse, int setCheckpoint, int tempOnly){ +void sqliteBeginWriteOperation(Parse *pParse, int setCheckpoint, int iDb){    Vdbe *v; +  sqlite *db = pParse->db; +  if( DbHasProperty(db, iDb, DB_Locked) ) return;    v = sqliteGetVdbe(pParse);    if( v==0 ) return; -  if( pParse->trigStack ) return; /* if this is in a trigger */ -  if( (pParse->db->flags & SQLITE_InTrans)==0 ){ -    sqliteVdbeAddOp(v, OP_Transaction, tempOnly, 0); -    if( !tempOnly ){ -      sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0); -      pParse->schemaVerified = 1; +  if( !db->aDb[iDb].inTrans ){ +    sqliteVdbeAddOp(v, OP_Transaction, iDb, 0); +    DbSetProperty(db, iDb, DB_Locked); +    sqliteCodeVerifySchema(pParse, iDb); +    if( iDb!=1 ){ +      sqliteBeginWriteOperation(pParse, setCheckpoint, 1);      }    }else if( setCheckpoint ){ -    sqliteVdbeAddOp(v, OP_Checkpoint, 0, 0); +    sqliteVdbeAddOp(v, OP_Checkpoint, iDb, 0); +    DbSetProperty(db, iDb, DB_Locked);    }  }  /*  ** Generate code that concludes an operation that may have changed -** the database.  This is a companion function to BeginWriteOperation(). -** If a transaction was started, then commit it.  If a checkpoint was -** started then commit that. +** the database.  If a statement transaction was started, then emit +** an OP_Commit that will cause the changes to be committed to disk. +** +** Note that checkpoints are automatically committed at the end of +** a statement.  Note also that there can be multiple calls to  +** sqliteBeginWriteOperation() but there should only be a single +** call to sqliteEndWriteOperation() at the conclusion of the statement.  */  void sqliteEndWriteOperation(Parse *pParse){    Vdbe *v; +  sqlite *db = pParse->db;    if( pParse->trigStack ) return; /* if this is in a trigger */    v = sqliteGetVdbe(pParse);    if( v==0 ) return; -  if( pParse->db->flags & SQLITE_InTrans ){ -    /* Do Nothing */ +  if( db->flags & SQLITE_InTrans ){ +    /* A BEGIN has executed.  Do not commit until we see an explicit +    ** COMMIT statement. */    }else{      sqliteVdbeAddOp(v, OP_Commit, 0, 0);    }  } - - -/* -** Interpret the given string as a boolean value. -*/ -static int getBoolean(char *z){ -  static char *azTrue[] = { "yes", "on", "true" }; -  int i; -  if( z[0]==0 ) return 0; -  if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){ -    return atoi(z); -  } -  for(i=0; i<sizeof(azTrue)/sizeof(azTrue[0]); i++){ -    if( sqliteStrICmp(z,azTrue[i])==0 ) return 1; -  } -  return 0; -} - -/* -** Interpret the given string as a safety level.  Return 0 for OFF, -** 1 for ON or NORMAL and 2 for FULL. -** -** Note that the values returned are one less that the values that -** should be passed into sqliteBtreeSetSafetyLevel().  The is done -** to support legacy SQL code.  The safety level used to be boolean -** and older scripts may have used numbers 0 for OFF and 1 for ON. -*/ -static int getSafetyLevel(char *z){ -  static const struct { -    const char *zWord; -    int val; -  } aKey[] = { -    { "no",    0 }, -    { "off",   0 }, -    { "false", 0 }, -    { "yes",   1 }, -    { "on",    1 }, -    { "true",  1 }, -    { "full",  2 }, -  }; -  int i; -  if( z[0]==0 ) return 1; -  if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){ -    return atoi(z); -  } -  for(i=0; i<sizeof(aKey)/sizeof(aKey[0]); i++){ -    if( sqliteStrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val; -  } -  return 1; -} - -/* -** Process a pragma statement.   -** -** Pragmas are of this form: -** -**      PRAGMA id = value -** -** The identifier might also be a string.  The value is a string, and -** identifier, or a number.  If minusFlag is true, then the value is -** a number that was preceded by a minus sign. -*/ -void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ -  char *zLeft = 0; -  char *zRight = 0; -  sqlite *db = pParse->db; - -  zLeft = sqliteStrNDup(pLeft->z, pLeft->n); -  sqliteDequote(zLeft); -  if( minusFlag ){ -    zRight = 0; -    sqliteSetNString(&zRight, "-", 1, pRight->z, pRight->n, 0); -  }else{ -    zRight = sqliteStrNDup(pRight->z, pRight->n); -    sqliteDequote(zRight); -  } -  if( sqliteAuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight) ){ -    sqliteFree(zLeft); -    sqliteFree(zRight); -    return; -  } -  -  /* -  **  PRAGMA default_cache_size -  **  PRAGMA default_cache_size=N -  ** -  ** The first form reports the current persistent setting for the -  ** page cache size.  The value returned is the maximum number of -  ** pages in the page cache.  The second form sets both the current -  ** page cache size value and the persistent page cache size value -  ** stored in the database file. -  ** -  ** The default cache size is stored in meta-value 2 of page 1 of the -  ** database file.  The cache size is actually the absolute value of -  ** this memory location.  The sign of meta-value 2 determines the -  ** synchronous setting.  A negative value means synchronous is off -  ** and a positive value means synchronous is on. -  */ -  if( sqliteStrICmp(zLeft,"default_cache_size")==0 ){ -    static VdbeOp getCacheSize[] = { -      { OP_ReadCookie,  0, 2,        0}, -      { OP_AbsValue,    0, 0,        0}, -      { OP_Dup,         0, 0,        0}, -      { OP_Integer,     0, 0,        0}, -      { OP_Ne,          0, 6,        0}, -      { OP_Integer,     MAX_PAGES,0, 0}, -      { OP_ColumnName,  0, 0,        "cache_size"}, -      { OP_Callback,    1, 0,        0}, -    }; -    Vdbe *v = sqliteGetVdbe(pParse); -    if( v==0 ) return; -    if( pRight->z==pLeft->z ){ -      sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); -    }else{ -      int addr; -      int size = atoi(zRight); -      if( size<0 ) size = -size; -      sqliteBeginWriteOperation(pParse, 0, 0); -      sqliteVdbeAddOp(v, OP_Integer, size, 0); -      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); -      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); -      sqliteVdbeAddOp(v, OP_Ge, 0, addr+3); -      sqliteVdbeAddOp(v, OP_Negative, 0, 0); -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); -      sqliteEndWriteOperation(pParse); -      db->cache_size = db->cache_size<0 ? -size : size; -      sqliteBtreeSetCacheSize(db->pBe, db->cache_size); -    } -  }else - -  /* -  **  PRAGMA cache_size -  **  PRAGMA cache_size=N -  ** -  ** The first form reports the current local setting for the -  ** page cache size.  The local setting can be different from -  ** the persistent cache size value that is stored in the database -  ** file itself.  The value returned is the maximum number of -  ** pages in the page cache.  The second form sets the local -  ** page cache size value.  It does not change the persistent -  ** cache size stored on the disk so the cache size will revert -  ** to its default value when the database is closed and reopened. -  ** N should be a positive integer. -  */ -  if( sqliteStrICmp(zLeft,"cache_size")==0 ){ -    static VdbeOp getCacheSize[] = { -      { OP_ColumnName,  0, 0,        "cache_size"}, -      { OP_Callback,    1, 0,        0}, -    }; -    Vdbe *v = sqliteGetVdbe(pParse); -    if( v==0 ) return; -    if( pRight->z==pLeft->z ){ -      int size = db->cache_size;; -      if( size<0 ) size = -size; -      sqliteVdbeAddOp(v, OP_Integer, size, 0); -      sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); -    }else{ -      int size = atoi(zRight); -      if( size<0 ) size = -size; -      if( db->cache_size<0 ) size = -size; -      db->cache_size = size; -      sqliteBtreeSetCacheSize(db->pBe, db->cache_size); -    } -  }else - -  /* -  **  PRAGMA default_synchronous -  **  PRAGMA default_synchronous=ON|OFF|NORMAL|FULL -  ** -  ** The first form returns the persistent value of the "synchronous" setting -  ** that is stored in the database.  This is the synchronous setting that -  ** is used whenever the database is opened unless overridden by a separate -  ** "synchronous" pragma.  The second form changes the persistent and the -  ** local synchronous setting to the value given. -  ** -  ** If synchronous is OFF, SQLite does not attempt any fsync() systems calls -  ** to make sure data is committed to disk.  Write operations are very fast, -  ** but a power failure can leave the database in an inconsistent state. -  ** If synchronous is ON or NORMAL, SQLite will do an fsync() system call to -  ** make sure data is being written to disk.  The risk of corruption due to -  ** a power loss in this mode is negligible but non-zero.  If synchronous -  ** is FULL, extra fsync()s occur to reduce the risk of corruption to near -  ** zero, but with a write performance penalty.  The default mode is NORMAL. -  */ -  if( sqliteStrICmp(zLeft,"default_synchronous")==0 ){ -    static VdbeOp getSync[] = { -      { OP_ColumnName,  0, 0,        "synchronous"}, -      { OP_ReadCookie,  0, 3,        0}, -      { OP_Dup,         0, 0,        0}, -      { OP_If,          0, 0,        0},  /* 3 */ -      { OP_ReadCookie,  0, 2,        0}, -      { OP_Integer,     0, 0,        0}, -      { OP_Lt,          0, 5,        0}, -      { OP_AddImm,      1, 0,        0}, -      { OP_Callback,    1, 0,        0}, -      { OP_Halt,        0, 0,        0}, -      { OP_AddImm,     -1, 0,        0},  /* 10 */ -      { OP_Callback,    1, 0,        0} -    }; -    Vdbe *v = sqliteGetVdbe(pParse); -    if( v==0 ) return; -    if( pRight->z==pLeft->z ){ -      int addr = sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); -      sqliteVdbeChangeP2(v, addr+3, addr+10); -    }else{ -      int addr; -      int size = db->cache_size; -      if( size<0 ) size = -size; -      sqliteBeginWriteOperation(pParse, 0, 0); -      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); -      sqliteVdbeAddOp(v, OP_Dup, 0, 0); -      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); -      sqliteVdbeAddOp(v, OP_Ne, 0, addr+3); -      sqliteVdbeAddOp(v, OP_AddImm, MAX_PAGES, 0); -      sqliteVdbeAddOp(v, OP_AbsValue, 0, 0); -      db->safety_level = getSafetyLevel(zRight)+1; -      if( db->safety_level==1 ){ -        sqliteVdbeAddOp(v, OP_Negative, 0, 0); -        size = -size; -      } -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); -      sqliteVdbeAddOp(v, OP_Integer, db->safety_level, 0); -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 3); -      sqliteEndWriteOperation(pParse); -      db->cache_size = size; -      sqliteBtreeSetCacheSize(db->pBe, db->cache_size); -      sqliteBtreeSetSafetyLevel(db->pBe, db->safety_level); -    } -  }else - -  /* -  **   PRAGMA synchronous -  **   PRAGMA synchronous=OFF|ON|NORMAL|FULL -  ** -  ** Return or set the local value of the synchronous flag.  Changing -  ** the local value does not make changes to the disk file and the -  ** default value will be restored the next time the database is -  ** opened. -  */ -  if( sqliteStrICmp(zLeft,"synchronous")==0 ){ -    static VdbeOp getSync[] = { -      { OP_ColumnName,  0, 0,        "synchronous"}, -      { OP_Callback,    1, 0,        0}, -    }; -    Vdbe *v = sqliteGetVdbe(pParse); -    if( v==0 ) return; -    if( pRight->z==pLeft->z ){ -      sqliteVdbeAddOp(v, OP_Integer, db->safety_level-1, 0); -      sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); -    }else{ -      int size = db->cache_size; -      if( size<0 ) size = -size; -      db->safety_level = getSafetyLevel(zRight)+1; -      if( db->safety_level==1 ) size = -size; -      db->cache_size = size; -      sqliteBtreeSetCacheSize(db->pBe, db->cache_size); -      sqliteBtreeSetSafetyLevel(db->pBe, db->safety_level); -    } -  }else - -  if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){ -    if( getBoolean(zRight) ){ -      always_code_trigger_setup = 1; -    }else{ -      always_code_trigger_setup = 0; -    } -  }else - -  if( sqliteStrICmp(zLeft, "vdbe_trace")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_VdbeTrace; -    }else{ -      db->flags &= ~SQLITE_VdbeTrace; -    } -  }else - -  if( sqliteStrICmp(zLeft, "full_column_names")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_FullColNames; -    }else{ -      db->flags &= ~SQLITE_FullColNames; -    } -  }else - -  if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_ReportTypes; -    }else{ -      db->flags &= ~SQLITE_ReportTypes; -    } -  }else - -  if( sqliteStrICmp(zLeft, "result_set_details")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_ResultDetails; -    }else{ -      db->flags &= ~SQLITE_ResultDetails; -    } -  }else - -  if( sqliteStrICmp(zLeft, "count_changes")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_CountRows; -    }else{ -      db->flags &= ~SQLITE_CountRows; -    } -  }else - -  if( sqliteStrICmp(zLeft, "empty_result_callbacks")==0 ){ -    if( getBoolean(zRight) ){ -      db->flags |= SQLITE_NullCallback; -    }else{ -      db->flags &= ~SQLITE_NullCallback; -    } -  }else - -  if( sqliteStrICmp(zLeft, "table_info")==0 ){ -    Table *pTab; -    Vdbe *v; -    pTab = sqliteFindTable(db, zRight); -    if( pTab ) v = sqliteGetVdbe(pParse); -    if( pTab && v ){ -      static VdbeOp tableInfoPreface[] = { -        { OP_ColumnName,  0, 0,       "cid"}, -        { OP_ColumnName,  1, 0,       "name"}, -        { OP_ColumnName,  2, 0,       "type"}, -        { OP_ColumnName,  3, 0,       "notnull"}, -        { OP_ColumnName,  4, 0,       "dflt_value"}, -      }; -      int i; -      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); -      sqliteViewGetColumnNames(pParse, pTab); -      for(i=0; i<pTab->nCol; i++){ -        sqliteVdbeAddOp(v, OP_Integer, i, 0); -        sqliteVdbeAddOp(v, OP_String, 0, 0); -        sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zName, P3_STATIC); -        sqliteVdbeAddOp(v, OP_String, 0, 0); -        sqliteVdbeChangeP3(v, -1,  -           pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", P3_STATIC); -        sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0); -        sqliteVdbeAddOp(v, OP_String, 0, 0); -        sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC); -        sqliteVdbeAddOp(v, OP_Callback, 5, 0); -      } -    } -  }else - -  if( sqliteStrICmp(zLeft, "index_info")==0 ){ -    Index *pIdx; -    Table *pTab; -    Vdbe *v; -    pIdx = sqliteFindIndex(db, zRight); -    if( pIdx ) v = sqliteGetVdbe(pParse); -    if( pIdx && v ){ -      static VdbeOp tableInfoPreface[] = { -        { OP_ColumnName,  0, 0,       "seqno"}, -        { OP_ColumnName,  1, 0,       "cid"}, -        { OP_ColumnName,  2, 0,       "name"}, -      }; -      int i; -      pTab = pIdx->pTable; -      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); -      for(i=0; i<pIdx->nColumn; i++){ -        int cnum = pIdx->aiColumn[i]; -        sqliteVdbeAddOp(v, OP_Integer, i, 0); -        sqliteVdbeAddOp(v, OP_Integer, cnum, 0); -        sqliteVdbeAddOp(v, OP_String, 0, 0); -        assert( pTab->nCol>cnum ); -        sqliteVdbeChangeP3(v, -1, pTab->aCol[cnum].zName, P3_STATIC); -        sqliteVdbeAddOp(v, OP_Callback, 3, 0); -      } -    } -  }else - -  if( sqliteStrICmp(zLeft, "index_list")==0 ){ -    Index *pIdx; -    Table *pTab; -    Vdbe *v; -    pTab = sqliteFindTable(db, zRight); -    if( pTab ){ -      v = sqliteGetVdbe(pParse); -      pIdx = pTab->pIndex; -    } -    if( pTab && pIdx && v ){ -      int i = 0;  -      static VdbeOp indexListPreface[] = { -        { OP_ColumnName,  0, 0,       "seq"}, -        { OP_ColumnName,  1, 0,       "name"}, -        { OP_ColumnName,  2, 0,       "unique"}, -      }; - -      sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); -      while(pIdx){ -        sqliteVdbeAddOp(v, OP_Integer, i, 0); -        sqliteVdbeAddOp(v, OP_String, 0, 0); -        sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC); -        sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0); -        sqliteVdbeAddOp(v, OP_Callback, 3, 0); -        ++i; -        pIdx = pIdx->pNext; -      } -    } -  }else - -#ifndef NDEBUG -  if( sqliteStrICmp(zLeft, "parser_trace")==0 ){ -    extern void sqliteParserTrace(FILE*, char *); -    if( getBoolean(zRight) ){ -      sqliteParserTrace(stdout, "parser: "); -    }else{ -      sqliteParserTrace(0, 0); -    } -  }else -#endif - -  if( sqliteStrICmp(zLeft, "integrity_check")==0 ){ -    static VdbeOp checkDb[] = { -      { OP_SetInsert,   0, 0,        "2"}, -      { OP_Open,        0, 2,        0}, -      { OP_Rewind,      0, 6,        0}, -      { OP_Column,      0, 3,        0},    /* 3 */ -      { OP_SetInsert,   0, 0,        0}, -      { OP_Next,        0, 3,        0}, -      { OP_IntegrityCk, 0, 0,        0},    /* 6 */ -      { OP_ColumnName,  0, 0,        "integrity_check"}, -      { OP_Callback,    1, 0,        0}, -      { OP_SetInsert,   1, 0,        "2"}, -      { OP_OpenAux,     1, 2,        0}, -      { OP_Rewind,      1, 15,       0}, -      { OP_Column,      1, 3,        0},    /* 12 */ -      { OP_SetInsert,   1, 0,        0}, -      { OP_Next,        1, 12,       0}, -      { OP_IntegrityCk, 1, 1,        0},    /* 15 */ -      { OP_Callback,    1, 0,        0}, -    }; -    Vdbe *v = sqliteGetVdbe(pParse); -    if( v==0 ) return; -    sqliteVdbeAddOpList(v, ArraySize(checkDb), checkDb); -  }else - -  {} -  sqliteFree(zLeft); -  sqliteFree(zRight); -} diff --git a/ext/sqlite/libsqlite/src/copy.c b/ext/sqlite/libsqlite/src/copy.c new file mode 100644 index 0000000000..ac2d8ecd37 --- /dev/null +++ b/ext/sqlite/libsqlite/src/copy.c @@ -0,0 +1,119 @@ +/* +** 2003 April 6 +** +** 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. +** +************************************************************************* +** This file contains code used to implement the COPY command. +** +** $Id$ +*/ +#include "sqliteInt.h" + +/* +** The COPY command is for compatibility with PostgreSQL and specificially +** for the ability to read the output of pg_dump.  The format is as +** follows: +** +**    COPY table FROM file [USING DELIMITERS string] +** +** "table" is an existing table name.  We will read lines of code from +** file to fill this table with data.  File might be "stdin".  The optional +** delimiter string identifies the field separators.  The default is a tab. +*/ +void sqliteCopy( +  Parse *pParse,       /* The parser context */ +  SrcList *pTableName, /* The name of the table into which we will insert */ +  Token *pFilename,    /* The file from which to obtain information */ +  Token *pDelimiter,   /* Use this as the field delimiter */ +  int onError          /* What to do if a constraint fails */ +){ +  Table *pTab; +  int i; +  Vdbe *v; +  int addr, end; +  Index *pIdx; +  char *zFile = 0; +  const char *zDb; +  sqlite *db = pParse->db; + + +  if( sqlite_malloc_failed  ) goto copy_cleanup; +  assert( pTableName->nSrc==1 ); +  pTab = sqliteSrcListLookup(pParse, pTableName); +  if( pTab==0 || sqliteIsReadOnly(pParse, pTab, 0) ) goto copy_cleanup; +  zFile = sqliteStrNDup(pFilename->z, pFilename->n); +  sqliteDequote(zFile); +  assert( pTab->iDb<db->nDb ); +  zDb = db->aDb[pTab->iDb].zName; +  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) +      || sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile, zDb) ){ +    goto copy_cleanup; +  } +  v = sqliteGetVdbe(pParse); +  if( v ){ +    sqliteBeginWriteOperation(pParse, 1, pTab->iDb); +    addr = sqliteVdbeAddOp(v, OP_FileOpen, 0, 0); +    sqliteVdbeChangeP3(v, addr, pFilename->z, pFilename->n); +    sqliteVdbeDequoteP3(v, addr); +    sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenWrite, 0, pTab->tnum); +    sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); +    for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ +      assert( pIdx->iDb==1 || pIdx->iDb==pTab->iDb ); +      sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, i, pIdx->tnum); +      sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC); +    } +    if( db->flags & SQLITE_CountRows ){ +      sqliteVdbeAddOp(v, OP_Integer, 0, 0);  /* Initialize the row count */ +    } +    end = sqliteVdbeMakeLabel(v); +    addr = sqliteVdbeAddOp(v, OP_FileRead, pTab->nCol, end); +    if( pDelimiter ){ +      sqliteVdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n); +      sqliteVdbeDequoteP3(v, addr); +    }else{ +      sqliteVdbeChangeP3(v, addr, "\t", 1); +    } +    if( pTab->iPKey>=0 ){ +      sqliteVdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0); +      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); +    }else{ +      sqliteVdbeAddOp(v, OP_NewRecno, 0, 0); +    } +    for(i=0; i<pTab->nCol; i++){ +      if( i==pTab->iPKey ){ +        /* The integer primary key column is filled with NULL since its +        ** value is always pulled from the record number */ +        sqliteVdbeAddOp(v, OP_String, 0, 0); +      }else{ +        sqliteVdbeAddOp(v, OP_FileColumn, i, 0); +      } +    } +    sqliteGenerateConstraintChecks(pParse, pTab, 0, 0, 0, 0, onError, addr); +    sqliteCompleteInsertion(pParse, pTab, 0, 0, 0, 0, -1); +    if( (db->flags & SQLITE_CountRows)!=0 ){ +      sqliteVdbeAddOp(v, OP_AddImm, 1, 0);  /* Increment row count */ +    } +    sqliteVdbeAddOp(v, OP_Goto, 0, addr); +    sqliteVdbeResolveLabel(v, end); +    sqliteVdbeAddOp(v, OP_Noop, 0, 0); +    sqliteEndWriteOperation(pParse); +    if( db->flags & SQLITE_CountRows ){ +      sqliteVdbeAddOp(v, OP_ColumnName, 0, 0); +      sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC); +      sqliteVdbeAddOp(v, OP_Callback, 1, 0); +    } +  } +   +copy_cleanup: +  sqliteSrcListDelete(pTableName); +  sqliteFree(zFile); +  return; +} diff --git a/ext/sqlite/libsqlite/src/delete.c b/ext/sqlite/libsqlite/src/delete.c index a235b6c589..20c07be47e 100644 --- a/ext/sqlite/libsqlite/src/delete.c +++ b/ext/sqlite/libsqlite/src/delete.c @@ -16,53 +16,38 @@  */  #include "sqliteInt.h" -  /* -** Given a table name, find the corresponding table and make sure the -** table is writeable.  Generate an error and return NULL if not.  If -** everything checks out, return a pointer to the Table structure. +** Look up every table that is named in pSrc.  If any table is not found, +** add an error message to pParse->zErrMsg and return NULL.  If all tables +** are found, return a pointer to the last table.  */ -Table *sqliteTableNameToTable(Parse *pParse, const char *zTab){ -  Table *pTab; -  pTab = sqliteFindTable(pParse->db, zTab); -  if( pTab==0 ){ -    sqliteSetString(&pParse->zErrMsg, "no such table: ", zTab, 0); -    pParse->nErr++; -    return 0; -  } -  if( pTab->readOnly || pTab->pSelect ){ -    sqliteSetString(&pParse->zErrMsg,  -      pTab->pSelect ? "view " : "table ", -      zTab, -      " may not be modified", 0); -    pParse->nErr++; -    return 0;       +Table *sqliteSrcListLookup(Parse *pParse, SrcList *pSrc){ +  Table *pTab = 0; +  int i; +  for(i=0; i<pSrc->nSrc; i++){ +    const char *zTab = pSrc->a[i].zName; +    const char *zDb = pSrc->a[i].zDatabase; +    pTab = sqliteLocateTable(pParse, zTab, zDb); +    pSrc->a[i].pTab = pTab;    }    return pTab;  }  /* -** Given a table name, check to make sure the table exists, is writable -** and is not a view.  If everything is OK, construct an SrcList holding -** the table and return a pointer to the SrcList.  The calling function -** is responsible for freeing the SrcList when it has finished with it. -** If there is an error, leave a message on pParse->zErrMsg and return -** NULL. +** Check to make sure the given table is writable.  If it is not +** writable, generate an error message and return 1.  If it is +** writable return 0;  */ -SrcList *sqliteTableTokenToSrcList(Parse *pParse, Token *pTableName){ -  Table *pTab; -  SrcList *pTabList; - -  pTabList = sqliteSrcListAppend(0, pTableName); -  if( pTabList==0 ) return 0; -  assert( pTabList->nSrc==1 ); -  pTab = sqliteTableNameToTable(pParse, pTabList->a[0].zName); -  if( pTab==0 ){ -    sqliteSrcListDelete(pTabList); -    return 0; +int sqliteIsReadOnly(Parse *pParse, Table *pTab, int viewOk){ +  if( pTab->readOnly ){ +    sqliteErrorMsg(pParse, "table %s may not be modified", pTab->zName); +    return 1; +  } +  if( !viewOk && pTab->pSelect ){ +    sqliteErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName); +    return 1;    } -  pTabList->a[0].pTab = pTab; -  return pTabList; +  return 0;  }  /* @@ -70,62 +55,59 @@ SrcList *sqliteTableTokenToSrcList(Parse *pParse, Token *pTableName){  */  void sqliteDeleteFrom(    Parse *pParse,         /* The parser context */ -  Token *pTableName,     /* The table from which we should delete things */ +  SrcList *pTabList,     /* The table from which we should delete things */    Expr *pWhere           /* The WHERE clause.  May be null */  ){    Vdbe *v;               /* The virtual database engine */    Table *pTab;           /* The table from which records will be deleted */ -  char *zTab;            /* Name of the table from which we are deleting */ -  SrcList *pTabList;     /* A fake FROM clause holding just pTab */ +  const char *zDb;       /* Name of database holding pTab */    int end, addr;         /* A couple addresses of generated code */    int i;                 /* Loop counter */    WhereInfo *pWInfo;     /* Information about the WHERE clause */    Index *pIdx;           /* For looping over indices of the table */ -  int base;              /* Index of the first available table cursor */ +  int iCur;              /* VDBE Cursor number for pTab */    sqlite *db;            /* Main database structure */ -  int openOp;            /* Opcode used to open a cursor to the table */ +  int isView;            /* True if attempting to delete from a view */ +  AuthContext sContext;  /* Authorization context */ -  int row_triggers_exist = 0; -  int oldIdx = -1; +  int row_triggers_exist = 0;  /* True if any triggers exist */ +  int before_triggers;         /* True if there are BEFORE triggers */ +  int after_triggers;          /* True if there are AFTER triggers */ +  int oldIdx = -1;             /* Cursor for the OLD table of AFTER triggers */ +  sContext.pParse = 0;    if( pParse->nErr || sqlite_malloc_failed ){      pTabList = 0;      goto delete_from_cleanup;    }    db = pParse->db; - -  /* Check for the special case of a VIEW with one or more ON DELETE triggers  -  ** defined  -  */ -  zTab = sqliteTableNameFromToken(pTableName); -  if( zTab != 0 ){ -    pTab = sqliteFindTable(pParse->db, zTab); -    if( pTab ){ -      row_triggers_exist =  -        sqliteTriggersExist(pParse, pTab->pTrigger,  -            TK_DELETE, TK_BEFORE, TK_ROW, 0) || -        sqliteTriggersExist(pParse, pTab->pTrigger,  -            TK_DELETE, TK_AFTER, TK_ROW, 0); -    } -    sqliteFree(zTab); -    if( row_triggers_exist &&  pTab->pSelect ){ -      /* Just fire VIEW triggers */ -      sqliteViewTriggers(pParse, pTab, pWhere, OE_Replace, 0); -      return; -    } -  } +  assert( pTabList->nSrc==1 );    /* Locate the table which we want to delete.  This table has to be    ** put in an SrcList structure because some of the subroutines we    ** will be calling are designed to work with multiple tables and expect    ** an SrcList* parameter instead of just a Table* parameter.    */ -  pTabList = sqliteTableTokenToSrcList(pParse, pTableName); -  if( pTabList==0 ) goto delete_from_cleanup; -  assert( pTabList->nSrc==1 ); -  pTab = pTabList->a[0].pTab; -  assert( pTab->pSelect==0 );  /* This table is not a view */ -  if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0) ){ +  pTab = sqliteSrcListLookup(pParse, pTabList); +  if( pTab==0 )  goto delete_from_cleanup; +  before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,  +                         TK_DELETE, TK_BEFORE, TK_ROW, 0); +  after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,  +                         TK_DELETE, TK_AFTER, TK_ROW, 0); +  row_triggers_exist = before_triggers || after_triggers; +  isView = pTab->pSelect!=0; +  if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){ +    goto delete_from_cleanup; +  } +  assert( pTab->iDb<db->nDb ); +  zDb = db->aDb[pTab->iDb].zName; +  if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){ +    goto delete_from_cleanup; +  } + +  /* If pTab is really a view, make sure it has been initialized. +  */ +  if( isView && sqliteViewGetColumnNames(pParse, pTab) ){      goto delete_from_cleanup;    } @@ -137,9 +119,10 @@ void sqliteDeleteFrom(    /* Resolve the column names in all the expressions.    */ -  base = pParse->nTab++; +  assert( pTabList->nSrc==1 ); +  iCur = pTabList->a[0].iCursor = pParse->nTab++;    if( pWhere ){ -    if( sqliteExprResolveIds(pParse, base, pTabList, 0, pWhere) ){ +    if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){        goto delete_from_cleanup;      }      if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ @@ -147,14 +130,28 @@ void sqliteDeleteFrom(      }    } +  /* Start the view context +  */ +  if( isView ){ +    sqliteAuthContextPush(pParse, &sContext, pTab->zName); +  } +    /* Begin generating code.    */    v = sqliteGetVdbe(pParse);    if( v==0 ){      goto delete_from_cleanup;    } -  sqliteBeginWriteOperation(pParse, row_triggers_exist, -       !row_triggers_exist && pTab->isTemp); +  sqliteBeginWriteOperation(pParse, row_triggers_exist, pTab->iDb); + +  /* If we are trying to delete from a view, construct that view into +  ** a temporary table. +  */ +  if( isView ){ +    Select *pView = sqliteSelectDup(pTab->pSelect); +    sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0); +    sqliteSelectDelete(pView); +  }    /* Initialize the counter of the number of rows deleted, if    ** we are counting rows. @@ -173,17 +170,21 @@ void sqliteDeleteFrom(        ** entries in the table. */        int endOfLoop = sqliteVdbeMakeLabel(v);        int addr; -      openOp = pTab->isTemp ? OP_OpenAux : OP_Open; -      sqliteVdbeAddOp(v, openOp, base, pTab->tnum); -      sqliteVdbeAddOp(v, OP_Rewind, base, sqliteVdbeCurrentAddr(v)+2); +      if( !isView ){ +        sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +        sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum); +      } +      sqliteVdbeAddOp(v, OP_Rewind, iCur, sqliteVdbeCurrentAddr(v)+2);        addr = sqliteVdbeAddOp(v, OP_AddImm, 1, 0); -      sqliteVdbeAddOp(v, OP_Next, base, addr); +      sqliteVdbeAddOp(v, OP_Next, iCur, addr);        sqliteVdbeResolveLabel(v, endOfLoop); -      sqliteVdbeAddOp(v, OP_Close, base, 0); +      sqliteVdbeAddOp(v, OP_Close, iCur, 0);      } -    sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->isTemp); -    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ -      sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pTab->isTemp); +    if( !isView ){ +      sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb); +      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ +        sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb); +      }      }    } @@ -193,7 +194,7 @@ void sqliteDeleteFrom(    else{      /* Begin the database scan      */ -    pWInfo = sqliteWhereBegin(pParse, base, pTabList, pWhere, 1, 0); +    pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0);      if( pWInfo==0 ) goto delete_from_cleanup;      /* Remember the key of every item to be deleted. @@ -207,6 +208,12 @@ void sqliteDeleteFrom(      */      sqliteWhereEnd(pWInfo); +    /* Open the pseudo-table used to store OLD if there are triggers. +    */ +    if( row_triggers_exist ){ +      sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0); +    } +      /* Delete every item whose key was written to the list during the      ** database scan.  We have to delete items after the scan is complete      ** because deleting an item can change the scan order. @@ -220,60 +227,59 @@ void sqliteDeleteFrom(      if( row_triggers_exist ){        addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);        sqliteVdbeAddOp(v, OP_Dup, 0, 0); - -      openOp = pTab->isTemp ? OP_OpenAux : OP_Open; -      sqliteVdbeAddOp(v, openOp, base, pTab->tnum); -      sqliteVdbeAddOp(v, OP_MoveTo, base, 0); -      sqliteVdbeAddOp(v, OP_OpenTemp, oldIdx, 0); - -      sqliteVdbeAddOp(v, OP_Integer, 13, 0); -      for(i = 0; i<pTab->nCol; i++){ -        if( i==pTab->iPKey ){  -          sqliteVdbeAddOp(v, OP_Recno, base, 0); -	} else { -          sqliteVdbeAddOp(v, OP_Column, base, i); -	} +      if( !isView ){ +        sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +        sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);        } -      sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); +      sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0); + +      sqliteVdbeAddOp(v, OP_Recno, iCur, 0); +      sqliteVdbeAddOp(v, OP_RowData, iCur, 0);        sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0); -      sqliteVdbeAddOp(v, OP_Close, base, 0); -      sqliteVdbeAddOp(v, OP_Rewind, oldIdx, 0); +      if( !isView ){ +        sqliteVdbeAddOp(v, OP_Close, iCur, 0); +      }        sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1,             oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,  	  addr);      } -    /* Open cursors for the table we are deleting from and all its -    ** indices.  If there are row triggers, this happens inside the -    ** OP_ListRead loop because the cursor have to all be closed -    ** before the trigger fires.  If there are no row triggers, the -    ** cursors are opened only once on the outside the loop. -    */ -    pParse->nTab = base + 1; -    openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; -    sqliteVdbeAddOp(v, openOp, base, pTab->tnum); -    for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ -      sqliteVdbeAddOp(v, openOp, pParse->nTab++, pIdx->tnum); -    } +    if( !isView ){ +      /* Open cursors for the table we are deleting from and all its +      ** indices.  If there are row triggers, this happens inside the +      ** OP_ListRead loop because the cursor have to all be closed +      ** before the trigger fires.  If there are no row triggers, the +      ** cursors are opened only once on the outside the loop. +      */ +      pParse->nTab = iCur + 1; +      sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, iCur, pTab->tnum); +      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ +        sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +        sqliteVdbeAddOp(v, OP_OpenWrite, pParse->nTab++, pIdx->tnum); +      } -    /* This is the beginning of the delete loop when there are no -    ** row triggers */ -    if( !row_triggers_exist ){  -      addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end); -    } +      /* This is the beginning of the delete loop when there are no +      ** row triggers */ +      if( !row_triggers_exist ){  +        addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end); +      } -    /* Delete the row */ -    sqliteGenerateRowDelete(db, v, pTab, base, pParse->trigStack==0); +      /* Delete the row */ +      sqliteGenerateRowDelete(db, v, pTab, iCur, pParse->trigStack==0); +    }      /* If there are row triggers, close all cursors then invoke      ** the AFTER triggers      */      if( row_triggers_exist ){ -      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ -        sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum); +      if( !isView ){ +        for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ +          sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum); +        } +        sqliteVdbeAddOp(v, OP_Close, iCur, 0);        } -      sqliteVdbeAddOp(v, OP_Close, base, 0);        sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1,             oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,  	  addr); @@ -287,10 +293,10 @@ void sqliteDeleteFrom(      /* Close the cursors after the loop if there are no row triggers */      if( !row_triggers_exist ){        for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ -        sqliteVdbeAddOp(v, OP_Close, base + i, pIdx->tnum); +        sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);        } -      sqliteVdbeAddOp(v, OP_Close, base, 0); -      pParse->nTab = base; +      sqliteVdbeAddOp(v, OP_Close, iCur, 0); +      pParse->nTab = iCur;      }    }    sqliteEndWriteOperation(pParse); @@ -305,6 +311,7 @@ void sqliteDeleteFrom(    }  delete_from_cleanup: +  sqliteAuthContextPop(&sContext);    sqliteSrcListDelete(pTabList);    sqliteExprDelete(pWhere);    return; @@ -334,13 +341,13 @@ void sqliteGenerateRowDelete(    sqlite *db,        /* The database containing the index */    Vdbe *v,           /* Generate code into this VDBE */    Table *pTab,       /* Table containing the row to be deleted */ -  int base,          /* Cursor number for the table */ +  int iCur,          /* Cursor number for the table */    int count          /* Increment the row change counter */  ){    int addr; -  addr = sqliteVdbeAddOp(v, OP_NotExists, base, 0); -  sqliteGenerateRowIndexDelete(db, v, pTab, base, 0); -  sqliteVdbeAddOp(v, OP_Delete, base, count); +  addr = sqliteVdbeAddOp(v, OP_NotExists, iCur, 0); +  sqliteGenerateRowIndexDelete(db, v, pTab, iCur, 0); +  sqliteVdbeAddOp(v, OP_Delete, iCur, count);    sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));  } @@ -352,19 +359,19 @@ void sqliteGenerateRowDelete(  ** These are the requirements:  **  **   1.  A read/write cursor pointing to pTab, the table containing the row -**       to be deleted, must be opened as cursor number "base". +**       to be deleted, must be opened as cursor number "iCur".  **  **   2.  Read/write cursors for all indices of pTab must be open as -**       cursor number base+i for the i-th index. +**       cursor number iCur+i for the i-th index.  ** -**   3.  The "base" cursor must be pointing to the row that is to be +**   3.  The "iCur" cursor must be pointing to the row that is to be  **       deleted.  */  void sqliteGenerateRowIndexDelete(    sqlite *db,        /* The database containing the index */    Vdbe *v,           /* Generate code into this VDBE */    Table *pTab,       /* Table containing the row to be deleted */ -  int base,          /* Cursor number for the table */ +  int iCur,          /* Cursor number for the table */    char *aIdxUsed     /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */  ){    int i; @@ -373,17 +380,17 @@ void sqliteGenerateRowIndexDelete(    for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){      int j;      if( aIdxUsed!=0 && aIdxUsed[i-1]==0 ) continue; -    sqliteVdbeAddOp(v, OP_Recno, base, 0); +    sqliteVdbeAddOp(v, OP_Recno, iCur, 0);      for(j=0; j<pIdx->nColumn; j++){        int idx = pIdx->aiColumn[j];        if( idx==pTab->iPKey ){          sqliteVdbeAddOp(v, OP_Dup, j, 0);        }else{ -        sqliteVdbeAddOp(v, OP_Column, base, idx); +        sqliteVdbeAddOp(v, OP_Column, iCur, idx);        }      }      sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);      if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx); -    sqliteVdbeAddOp(v, OP_IdxDelete, base+i, 0); +    sqliteVdbeAddOp(v, OP_IdxDelete, iCur+i, 0);    }  } diff --git a/ext/sqlite/libsqlite/src/encode.c b/ext/sqlite/libsqlite/src/encode.c index 6ad100ce5b..71dfe71741 100644 --- a/ext/sqlite/libsqlite/src/encode.c +++ b/ext/sqlite/libsqlite/src/encode.c @@ -20,6 +20,86 @@  #include <string.h>  /* +** How This Encoder Works +** +** The output is allowed to contain any character except 0x27 (') and +** 0x00.  This is accomplished by using an escape character to encode +** 0x27 and 0x00 as a two-byte sequence.  The escape character is always +** 0x01.  An 0x00 is encoded as the two byte sequence 0x01 0x01.  The +** 0x27 character is encoded as the two byte sequence 0x01 0x03.  Finally, +** the escape character itself is encoded as the two-character sequence +** 0x01 0x02. +** +** To summarize, the encoder works by using an escape sequences as follows: +** +**       0x00  ->  0x01 0x01 +**       0x01  ->  0x01 0x02 +**       0x27  ->  0x01 0x03 +** +** If that were all the encoder did, it would work, but in certain cases +** it could double the size of the encoded string.  For example, to +** encode a string of 100 0x27 character would require 100 instances of +** the 0x01 0x03 escape sequence resulting in a 200-character output. +** We would prefer to keep the size of the encoded string smaller than +** this. +** +** To minimize the encoding size, we first add a fixed offset value to each  +** byte in the sequence.  The addition is module 256.  (That is to say, if +** the sum of the original character value and the offset exceeds 256, then +** the higher order bits are truncated.)  The offset is chosen to minimize +** the number of characters in the string that need to be escaped.  For +** example, in the case above where the string was composed of 100 0x27 +** characters, the offset might be 0x01.  Each of the 0x27 characters would +** then be converted into an 0x28 character which would not need to be +** escaped at all and so the 100 character input string would be converted +** into just 100 characters of output.  Actually 101 characters of output -  +** we have to record the offset used as the first byte in the sequence so +** that the string can be decoded.  Since the offset value is stored as +** part of the output string and the output string is not allowed to contain +** characters 0x00 or 0x27, the offset cannot be 0x00 or 0x27. +** +** Here, then, are the encoding steps: +** +**     (1)   Choose an offset value and make it the first character of +**           output. +** +**     (2)   Copy each input character into the output buffer, one by +**           one, adding the offset value as you copy. +** +**     (3)   If the value of an input character plus offset is 0x00, replace +**           that one character by the two-character sequence 0x01 0x01. +**           If the sum is 0x01, replace it with 0x01 0x02.  If the sum +**           is 0x27, replace it with 0x01 0x03. +** +**     (4)   Put a 0x00 terminator at the end of the output. +** +** Decoding is obvious: +** +**     (5)   Copy encoded characters except the first into the decode  +**           buffer.  Set the first encoded character aside for use as +**           the offset in step 7 below. +** +**     (6)   Convert each 0x01 0x01 sequence into a single character 0x00. +**           Convert 0x01 0x02 into 0x01.  Convert 0x01 0x03 into 0x27. +** +**     (7)   Subtract the offset value that was the first character of +**           the encoded buffer from all characters in the output buffer. +** +** The only tricky part is step (1) - how to compute an offset value to +** minimize the size of the output buffer.  This is accomplished to testing +** all offset values and picking the one that results in the fewest number +** of escapes.  To do that, we first scan the entire input and count the +** number of occurances of each character value in the input.  Suppose +** the number of 0x00 characters is N(0), the number of occurances of 0x01 +** is N(1), and so forth up to the number of occurances of 0xff is N(256). +** An offset of 0 is not allowed so we don't have to test it.  The number +** of escapes required for an offset of 1 is N(1)+N(2)+N(40).  The number +** of escapes required for an offset of 2 is N(2)+N(3)+N(41).  And so forth. +** In this way we find the offset that gives the minimum number of escapes, +** and thus minimizes the length of the output string. +*/ + +/*  ** Encode a binary buffer "in" of size n bytes so that it contains  ** no instances of characters '\'' or '\000'.  The output is   ** null-terminated and can be used as a string value in an INSERT diff --git a/ext/sqlite/libsqlite/src/expr.c b/ext/sqlite/libsqlite/src/expr.c index 478bfebb0a..2a380dd538 100644 --- a/ext/sqlite/libsqlite/src/expr.c +++ b/ext/sqlite/libsqlite/src/expr.c @@ -184,16 +184,17 @@ ExprList *sqliteExprListDup(ExprList *p){  SrcList *sqliteSrcListDup(SrcList *p){    SrcList *pNew;    int i; +  int nByte;    if( p==0 ) return 0; -  pNew = sqliteMalloc( sizeof(*pNew) ); +  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0); +  pNew = sqliteMalloc( nByte );    if( pNew==0 ) return 0;    pNew->nSrc = p->nSrc; -  pNew->a = sqliteMalloc( p->nSrc*sizeof(p->a[0]) ); -  if( pNew->a==0 && p->nSrc != 0 ) return 0;    for(i=0; i<p->nSrc; i++){      pNew->a[i].zName = sqliteStrDup(p->a[i].zName);      pNew->a[i].zAlias = sqliteStrDup(p->a[i].zAlias);      pNew->a[i].jointype = p->a[i].jointype; +    pNew->a[i].iCursor = p->a[i].iCursor;      pNew->a[i].pTab = 0;      pNew->a[i].pSelect = sqliteSelectDup(p->a[i].pSelect);      pNew->a[i].pOn = sqliteExprDup(p->a[i].pOn); @@ -299,7 +300,9 @@ int sqliteExprIsConstant(Expr *p){      case TK_ID:      case TK_COLUMN:      case TK_DOT: +    case TK_FUNCTION:        return 0; +    case TK_NULL:      case TK_STRING:      case TK_INTEGER:      case TK_FLOAT: @@ -400,13 +403,16 @@ int sqliteIsRowid(const char *z){  */  int sqliteExprResolveIds(    Parse *pParse,     /* The parser context */ -  int base,          /* VDBE cursor number for first entry in pTabList */    SrcList *pTabList, /* List of tables used to resolve column names */    ExprList *pEList,  /* List of expressions used to resolve "AS" */    Expr *pExpr        /* The expression to be analyzed. */  ){ +  int i; +    if( pExpr==0 || pTabList==0 ) return 0; -  assert( base+pTabList->nSrc<=pParse->nTab ); +  for(i=0; i<pTabList->nSrc; i++){ +    assert( pTabList->a[i].iCursor>=0 && pTabList->a[i].iCursor<pParse->nTab ); +  }    switch( pExpr->op ){      /* Double-quoted strings (ex: "abc") are used as identifiers if      ** possible.  Otherwise they remain as strings.  Single-quoted @@ -428,8 +434,9 @@ int sqliteExprResolveIds(      */      case TK_ID: {        int cnt = 0;      /* Number of matches */ -      int i;            /* Loop counter */        char *z; +      int iDb = -1; +        assert( pExpr->token.z );        z = sqliteStrNDup(pExpr->token.z, pExpr->token.n);        sqliteDequote(z); @@ -438,11 +445,13 @@ int sqliteExprResolveIds(          int j;          Table *pTab = pTabList->a[i].pTab;          if( pTab==0 ) continue; +        iDb = pTab->iDb;          assert( pTab->nCol>0 );          for(j=0; j<pTab->nCol; j++){            if( sqliteStrICmp(pTab->aCol[j].zName, z)==0 ){              cnt++; -            pExpr->iTable = i + base; +            pExpr->iTable = pTabList->a[i].iCursor; +            pExpr->iDb = pTab->iDb;              if( j==pTab->iPKey ){                /* Substitute the record number for the INTEGER PRIMARY KEY */                pExpr->iColumn = -1; @@ -468,41 +477,51 @@ int sqliteExprResolveIds(            }          }         } -      if( cnt==0 && sqliteIsRowid(z) ){ +      if( cnt==0 && iDb>=0 && sqliteIsRowid(z) ){          pExpr->iColumn = -1; -        pExpr->iTable = base; +        pExpr->iTable = pTabList->a[0].iCursor; +        pExpr->iDb = iDb;          cnt = 1 + (pTabList->nSrc>1);          pExpr->op = TK_COLUMN;          pExpr->dataType = SQLITE_SO_NUM;        }        sqliteFree(z);        if( cnt==0 && pExpr->token.z[0]!='"' ){ -        sqliteSetNString(&pParse->zErrMsg, "no such column: ", -1,   -          pExpr->token.z, pExpr->token.n, 0); -        pParse->nErr++; +        sqliteErrorMsg(pParse, "no such column: %T", &pExpr->token);          return 1;        }else if( cnt>1 ){ -        sqliteSetNString(&pParse->zErrMsg, "ambiguous column name: ", -1,   -          pExpr->token.z, pExpr->token.n, 0); -        pParse->nErr++; +        sqliteErrorMsg(pParse, "ambiguous column name: %T", &pExpr->token);          return 1;        }        if( pExpr->op==TK_COLUMN ){ -        sqliteAuthRead(pParse, pExpr, pTabList, base); +        sqliteAuthRead(pParse, pExpr, pTabList);        }        break;       } -    /* A table name and column name:  ID.ID */ +    /* A table name and column name:     ID.ID +    ** Or a database, table and column:  ID.ID.ID +    */      case TK_DOT: {        int cnt = 0;             /* Number of matches */        int cntTab = 0;          /* Number of matching tables */        int i;                   /* Loop counter */        Expr *pLeft, *pRight;    /* Left and right subbranches of the expr */        char *zLeft, *zRight;    /* Text of an identifier */ +      char *zDb;               /* Name of database holding table */ +      sqlite *db = pParse->db; -      pLeft = pExpr->pLeft;        pRight = pExpr->pRight; +      if( pRight->op==TK_ID ){ +        pLeft = pExpr->pLeft; +        zDb = 0; +      }else{ +        Expr *pDb = pExpr->pLeft; +        assert( pDb && pDb->op==TK_ID && pDb->token.z ); +        zDb = sqliteStrNDup(pDb->token.z, pDb->token.n); +        pLeft = pRight->pLeft; +        pRight = pRight->pRight; +      }        assert( pLeft && pLeft->op==TK_ID && pLeft->token.z );        assert( pRight && pRight->op==TK_ID && pRight->token.z );        zLeft = sqliteStrNDup(pLeft->token.z, pLeft->token.n); @@ -510,8 +529,10 @@ int sqliteExprResolveIds(        if( zLeft==0 || zRight==0 ){          sqliteFree(zLeft);          sqliteFree(zRight); +        sqliteFree(zDb);          return 1;        } +      sqliteDequote(zDb);        sqliteDequote(zLeft);        sqliteDequote(zRight);        pExpr->iTable = -1; @@ -523,21 +544,25 @@ int sqliteExprResolveIds(          assert( pTab->nCol>0 );          if( pTabList->a[i].zAlias ){            zTab = pTabList->a[i].zAlias; +          if( sqliteStrICmp(zTab, zLeft)!=0 ) continue;          }else{            zTab = pTab->zName; +          if( zTab==0 || sqliteStrICmp(zTab, zLeft)!=0 ) continue; +          if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){ +            continue; +          } +        } +        if( 0==(cntTab++) ){ +          pExpr->iTable = pTabList->a[i].iCursor; +          pExpr->iDb = pTab->iDb;          } -        if( zTab==0 || sqliteStrICmp(zTab, zLeft)!=0 ) continue; -        if( 0==(cntTab++) ) pExpr->iTable = i + base;          for(j=0; j<pTab->nCol; j++){            if( sqliteStrICmp(pTab->aCol[j].zName, zRight)==0 ){              cnt++; -            pExpr->iTable = i + base; -            if( j==pTab->iPKey ){ -              /* Substitute the record number for the INTEGER PRIMARY KEY */ -              pExpr->iColumn = -1; -            }else{ -              pExpr->iColumn = j; -            } +            pExpr->iTable = pTabList->a[i].iCursor; +            pExpr->iDb = pTab->iDb; +            /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ +            pExpr->iColumn = j==pTab->iPKey ? -1 : j;              pExpr->dataType = pTab->aCol[j].sortOrder & SQLITE_SO_TYPEMASK;            }          } @@ -550,11 +575,15 @@ int sqliteExprResolveIds(          int t = 0;          if( pTriggerStack->newIdx != -1 && sqliteStrICmp("new", zLeft) == 0 ){            pExpr->iTable = pTriggerStack->newIdx; +          assert( pTriggerStack->pTab ); +          pExpr->iDb = pTriggerStack->pTab->iDb;            cntTab++;            t = 1;          }          if( pTriggerStack->oldIdx != -1 && sqliteStrICmp("old", zLeft) == 0 ){            pExpr->iTable = pTriggerStack->oldIdx; +          assert( pTriggerStack->pTab ); +          pExpr->iDb = pTriggerStack->pTab->iDb;            cntTab++;            t = 1;          } @@ -565,7 +594,7 @@ int sqliteExprResolveIds(            for(j=0; j < pTab->nCol; j++) {              if( sqliteStrICmp(pTab->aCol[j].zName, zRight)==0 ){                cnt++; -              pExpr->iColumn = j; +              pExpr->iColumn = j==pTab->iPKey ? -1 : j;                pExpr->dataType = pTab->aCol[j].sortOrder & SQLITE_SO_TYPEMASK;              }            } @@ -577,34 +606,31 @@ int sqliteExprResolveIds(          pExpr->iColumn = -1;          pExpr->dataType = SQLITE_SO_NUM;        } +      sqliteFree(zDb);        sqliteFree(zLeft);        sqliteFree(zRight);        if( cnt==0 ){ -        sqliteSetNString(&pParse->zErrMsg, "no such column: ", -1,   -          pLeft->token.z, pLeft->token.n, ".", 1,  -          pRight->token.z, pRight->token.n, 0); -        pParse->nErr++; +        sqliteErrorMsg(pParse, "no such column: %T.%T", +               &pLeft->token, &pRight->token);          return 1;        }else if( cnt>1 ){ -        sqliteSetNString(&pParse->zErrMsg, "ambiguous column name: ", -1,   -          pLeft->token.z, pLeft->token.n, ".", 1, -          pRight->token.z, pRight->token.n, 0); -        pParse->nErr++; +        sqliteErrorMsg(pParse, "ambiguous column name: %T.%T", +          &pLeft->token, &pRight->token);          return 1;        } -      sqliteExprDelete(pLeft); +      sqliteExprDelete(pExpr->pLeft);        pExpr->pLeft = 0; -      sqliteExprDelete(pRight); +      sqliteExprDelete(pExpr->pRight);        pExpr->pRight = 0;        pExpr->op = TK_COLUMN; -      sqliteAuthRead(pParse, pExpr, pTabList, base); +      sqliteAuthRead(pParse, pExpr, pTabList);        break;      }      case TK_IN: {        Vdbe *v = sqliteGetVdbe(pParse);        if( v==0 ) return 1; -      if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pExpr->pLeft) ){ +      if( sqliteExprResolveIds(pParse, pTabList, pEList, pExpr->pLeft) ){          return 1;        }        if( pExpr->pSelect ){ @@ -627,9 +653,8 @@ int sqliteExprResolveIds(          for(i=0; i<pExpr->pList->nExpr; i++){            Expr *pE2 = pExpr->pList->a[i].pExpr;            if( !sqliteExprIsConstant(pE2) ){ -            sqliteSetString(&pParse->zErrMsg, -              "right-hand side of IN operator must be constant", 0); -            pParse->nErr++; +            sqliteErrorMsg(pParse, +              "right-hand side of IN operator must be constant");              return 1;            }            if( sqliteExprCheck(pParse, pE2, 0, 0) ){ @@ -675,11 +700,11 @@ int sqliteExprResolveIds(      /* For all else, just recursively walk the tree */      default: {        if( pExpr->pLeft -      && sqliteExprResolveIds(pParse, base, pTabList, pEList, pExpr->pLeft) ){ +      && sqliteExprResolveIds(pParse, pTabList, pEList, pExpr->pLeft) ){          return 1;        }        if( pExpr->pRight  -      && sqliteExprResolveIds(pParse, base, pTabList, pEList, pExpr->pRight) ){ +      && sqliteExprResolveIds(pParse, pTabList, pEList, pExpr->pRight) ){          return 1;        }        if( pExpr->pList ){ @@ -687,7 +712,7 @@ int sqliteExprResolveIds(          ExprList *pList = pExpr->pList;          for(i=0; i<pList->nExpr; i++){            Expr *pArg = pList->a[i].pExpr; -          if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pArg) ){ +          if( sqliteExprResolveIds(pParse, pTabList, pEList, pArg) ){              return 1;            }          } @@ -1199,8 +1224,8 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){      }      case TK_RAISE: {        if( !pParse->trigStack ){ -        sqliteSetNString(&pParse->zErrMsg,  -		"RAISE() may only be used within a trigger-program", -1, 0); +        sqliteErrorMsg(pParse, +                       "RAISE() may only be used within a trigger-program");          pParse->nErr++;  	return;        } diff --git a/ext/sqlite/libsqlite/src/func.c b/ext/sqlite/libsqlite/src/func.c index a865de0873..a1662abae2 100644 --- a/ext/sqlite/libsqlite/src/func.c +++ b/ext/sqlite/libsqlite/src/func.c @@ -255,6 +255,46 @@ static void versionFunc(sqlite_func *context, int argc, const char **argv){    sqlite_set_result_string(context, sqlite_version, -1);  } +#ifdef SQLITE_SOUNDEX +/* +** Compute the soundex encoding of a word. +*/ +static void soundexFunc(sqlite_func *context, int argc, const char **argv){ +  char zResult[8]; +  const char *zIn; +  int i, j; +  static const unsigned char iCode[] = { +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0, +    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0, +    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0, +    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0, +  }; +  assert( argc==1 ); +  zIn = argv[0]; +  for(i=0; zIn[i] && !isalpha(zIn[i]); i++){} +  if( zIn[i] ){ +    zResult[0] = toupper(zIn[i]); +    for(j=1; j<4 && zIn[i]; i++){ +      int code = iCode[zIn[i]&0x7f]; +      if( code>0 ){ +        zResult[j++] = code + '0'; +      } +    } +    while( j<4 ){ +      zResult[j++] = '0'; +    } +    zResult[j] = 0; +    sqlite_set_result_string(context, zResult, 4); +  }else{ +    sqlite_set_result_string(context, zResult, "?000", 4); +  } +} +#endif +  #ifdef SQLITE_TEST  /*  ** This function generates a string of random characters.  Used for @@ -284,8 +324,7 @@ static void randStr(sqlite_func *context, int argc, const char **argv){    }    n = iMin;    if( iMax>iMin ){ -    r = sqliteRandomInteger(); -    if( r<0 ) r = -r; +    r = sqliteRandomInteger() & 0x7fffffff;      n += r%(iMax + 1 - iMin);    }    r = 0; @@ -490,6 +529,9 @@ void sqliteRegisterBuiltinFunctions(sqlite *db){      { "glob",       2, SQLITE_NUMERIC, globFunc   },      { "nullif",     2, SQLITE_ARGS,    nullifFunc },      { "sqlite_version",0,SQLITE_TEXT,  versionFunc}, +#ifdef SQLITE_SOUNDEX +    { "soundex",    1, SQLITE_TEXT,    soundexFunc}, +#endif  #ifdef SQLITE_TEST      { "randstr",    2, SQLITE_TEXT,    randStr    },  #endif diff --git a/ext/sqlite/libsqlite/src/hash.c b/ext/sqlite/libsqlite/src/hash.c index 60de7aa1e2..aa3bb81c44 100644 --- a/ext/sqlite/libsqlite/src/hash.c +++ b/ext/sqlite/libsqlite/src/hash.c @@ -108,8 +108,7 @@ static int binHash(const void *pKey, int nKey){    while( nKey-- > 0 ){      h = (h<<3) ^ h ^ *(z++);    } -  if( h<0 ) h = -h; -  return h; +  return h & 0x7fffffff;  }  static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){    if( n1!=n2 ) return n2-n1; diff --git a/ext/sqlite/libsqlite/src/insert.c b/ext/sqlite/libsqlite/src/insert.c index f625ffc942..313764f51e 100644 --- a/ext/sqlite/libsqlite/src/insert.c +++ b/ext/sqlite/libsqlite/src/insert.c @@ -85,22 +85,22 @@  */  void sqliteInsert(    Parse *pParse,        /* Parser context */ -  Token *pTableName,    /* Name of table into which we are inserting */ +  SrcList *pTabList,    /* Name of table into which we are inserting */    ExprList *pList,      /* List of values to be inserted */    Select *pSelect,      /* A SELECT statement to use as the data source */    IdList *pColumn,      /* Column names corresponding to IDLIST. */    int onError           /* How to handle constraint errors */  ){    Table *pTab;          /* The table to insert into */ -  char *zTab = 0;       /* Name of the table into which we are inserting */ +  char *zTab;           /* Name of the table into which we are inserting */ +  const char *zDb;      /* Name of the database holding this table */    int i, j, idx;        /* Loop counters */    Vdbe *v;              /* Generate code into this virtual machine */    Index *pIdx;          /* For looping over indices of the table */    int nColumn;          /* Number of columns in the data */ -  int base;             /* First available cursor */ +  int base;             /* VDBE Cursor number for pTab */    int iCont, iBreak;    /* Beginning and end of the loop over srcTab */    sqlite *db;           /* The main database structure */ -  int openOp;           /* Opcode used to open cursors */    int keyColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */    int endOfLoop;        /* Label for the end of the insertion loop */    int useTempTable;     /* Store SELECT results in intermediate table */ @@ -109,24 +109,28 @@ void sqliteInsert(    int iCleanup;         /* Address of the cleanup code */    int iInsertBlock;     /* Address of the subroutine used to insert data */    int iCntMem;          /* Memory cell used for the row counter */ +  int isView;           /* True if attempting to insert into a view */    int row_triggers_exist = 0; /* True if there are FOR EACH ROW triggers */ -  int newIdx = -1; +  int before_triggers;        /* True if there are BEFORE triggers */ +  int after_triggers;         /* True if there are AFTER triggers */ +  int newIdx = -1;            /* Cursor for the NEW table */    if( pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup;    db = pParse->db;    /* Locate the table into which we will be inserting new information.    */ -  zTab = sqliteTableNameFromToken(pTableName); +  assert( pTabList->nSrc==1 ); +  zTab = pTabList->a[0].zName;    if( zTab==0 ) goto insert_cleanup; -  pTab = sqliteFindTable(pParse->db, zTab); +  pTab = sqliteSrcListLookup(pParse, pTabList);    if( pTab==0 ){ -    sqliteSetString(&pParse->zErrMsg, "no such table: ", zTab, 0); -    pParse->nErr++;      goto insert_cleanup;    } -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0) ){ +  assert( pTab->iDb<db->nDb ); +  zDb = db->aDb[pTab->iDb].zName; +  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){      goto insert_cleanup;    } @@ -134,37 +138,28 @@ void sqliteInsert(    *  (a) the table is not read-only,     *  (b) that if it is a view then ON INSERT triggers exist    */ -  row_triggers_exist =  -    sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT,  -        TK_BEFORE, TK_ROW, 0) || -    sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, TK_AFTER, TK_ROW, 0); -  if( pTab->readOnly || (pTab->pSelect && !row_triggers_exist) ){ -    sqliteSetString(&pParse->zErrMsg,  -      pTab->pSelect ? "view " : "table ", -      zTab, -      " may not be modified", 0); -    pParse->nErr++; +  before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT,  +                                       TK_BEFORE, TK_ROW, 0); +  after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, +                                       TK_AFTER, TK_ROW, 0); +  row_triggers_exist = before_triggers || after_triggers; +  isView = pTab->pSelect!=0; +  if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){      goto insert_cleanup;    } -  sqliteFree(zTab); -  zTab = 0; -    if( pTab==0 ) goto insert_cleanup;    /* If pTab is really a view, make sure it has been initialized.    */ -  if( pTab->pSelect ){ -    if( sqliteViewGetColumnNames(pParse, pTab) ){ -      goto insert_cleanup; -    } +  if( isView && sqliteViewGetColumnNames(pParse, pTab) ){ +    goto insert_cleanup;    }    /* Allocate a VDBE    */    v = sqliteGetVdbe(pParse);    if( v==0 ) goto insert_cleanup; -  sqliteBeginWriteOperation(pParse, pSelect || row_triggers_exist, -         !row_triggers_exist && pTab->isTemp); +  sqliteBeginWriteOperation(pParse, pSelect || row_triggers_exist, pTab->iDb);    /* if there are row triggers, allocate a temp table for new.* references. */    if( row_triggers_exist ){ @@ -183,7 +178,6 @@ void sqliteInsert(      /* Data is coming from a SELECT.  Generate code to implement that SELECT      */      int rc, iInitCode; -    int opCode;      iInitCode = sqliteVdbeAddOp(v, OP_Goto, 0, 0);      iSelectLoop = sqliteVdbeCurrentAddr(v);      iInsertBlock = sqliteVdbeMakeLabel(v); @@ -197,9 +191,23 @@ void sqliteInsert(      /* Set useTempTable to TRUE if the result of the SELECT statement      ** should be written into a temporary table.  Set to FALSE if each      ** row of the SELECT can be written directly into the result table. +    ** +    ** A temp table must be used if the table being updated is also one +    ** of the tables being read by the SELECT statement.  Also use a  +    ** temp table in the case of row triggers.      */ -    opCode = pTab->isTemp ? OP_OpenTemp : OP_Open; -    useTempTable = row_triggers_exist || sqliteVdbeFindOp(v,opCode,pTab->tnum); +    if( row_triggers_exist ){ +      useTempTable = 1; +    }else{ +      int addr = sqliteVdbeFindOp(v, OP_OpenRead, pTab->tnum); +      useTempTable = 0; +      if( addr>0 ){ +        VdbeOp *pOp = sqliteVdbeGetOp(v, addr-2); +        if( pOp->opcode==OP_Integer && pOp->p1==pTab->iDb ){ +          useTempTable = 1; +        } +      } +    }      if( useTempTable ){        /* Generate the subroutine that SELECT calls to process each row of @@ -236,7 +244,7 @@ void sqliteInsert(      nColumn = pList->nExpr;      dummy.nSrc = 0;      for(i=0; i<nColumn; i++){ -      if( sqliteExprResolveIds(pParse, 0, &dummy, 0, pList->a[i].pExpr) ){ +      if( sqliteExprResolveIds(pParse, &dummy, 0, pList->a[i].pExpr) ){          goto insert_cleanup;        }        if( sqliteExprCheck(pParse, pList->a[i].pExpr, 0, 0) ){ @@ -249,24 +257,13 @@ void sqliteInsert(    ** of columns to be inserted into the table.    */    if( pColumn==0 && nColumn!=pTab->nCol ){ -    char zNum1[30]; -    char zNum2[30]; -    sprintf(zNum1,"%d", nColumn); -    sprintf(zNum2,"%d", pTab->nCol); -    sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, -       " has ", zNum2, " columns but ", -       zNum1, " values were supplied", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse,  +       "table %S has %d columns but %d values were supplied", +       pTabList, 0, pTab->nCol, nColumn);      goto insert_cleanup;    }    if( pColumn!=0 && nColumn!=pColumn->nId ){ -    char zNum1[30]; -    char zNum2[30]; -    sprintf(zNum1,"%d", nColumn); -    sprintf(zNum2,"%d", pColumn->nId); -    sqliteSetString(&pParse->zErrMsg, zNum1, " values for ", -       zNum2, " columns", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);      goto insert_cleanup;    } @@ -296,8 +293,8 @@ void sqliteInsert(          }        }        if( j>=pTab->nCol ){ -        sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, -           " has no column named ", pColumn->a[i].zName, 0); +        sqliteErrorMsg(pParse, "table %S has no column named %s", +            pTabList, 0, pColumn->a[i].zName);          pParse->nErr++;          goto insert_cleanup;        } @@ -315,7 +312,7 @@ void sqliteInsert(    /* Open the temp table for FOR EACH ROW triggers    */    if( row_triggers_exist ){ -    sqliteVdbeAddOp(v, OP_OpenTemp, newIdx, 0); +    sqliteVdbeAddOp(v, OP_OpenPseudo, newIdx, 0);    }    /* Initialize the count of rows to be inserted @@ -329,11 +326,12 @@ void sqliteInsert(    /* Open tables and indices if there are no row triggers */    if( !row_triggers_exist ){      base = pParse->nTab; -    openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; -    sqliteVdbeAddOp(v, openOp, base, pTab->tnum); +    sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenWrite, base, pTab->tnum);      sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC);      for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ -      sqliteVdbeAddOp(v, openOp, idx+base, pIdx->tnum); +      sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, idx+base, pIdx->tnum);        sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);      }      pParse->nTab += idx; @@ -353,11 +351,33 @@ void sqliteInsert(      sqliteVdbeResolveLabel(v, iInsertBlock);    } +  /* Run the BEFORE and INSTEAD OF triggers, if there are any +  */    endOfLoop = sqliteVdbeMakeLabel(v); -  if( row_triggers_exist ){ +  if( before_triggers ){ + +    /* build the NEW.* reference row.  Note that if there is an INTEGER +    ** PRIMARY KEY into which a NULL is being inserted, that NULL will be +    ** translated into a unique ID for the row.  But on a BEFORE trigger, +    ** we do not know what the unique ID will be (because the insert has +    ** not happened yet) so we substitute a rowid of -1 +    */ +    if( keyColumn<0 ){ +      sqliteVdbeAddOp(v, OP_Integer, -1, 0); +    }else if( useTempTable ){ +      sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn); +    }else if( pSelect ){ +      sqliteVdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1); +    }else{ +      sqliteExprCode(pParse, pList->a[keyColumn].pExpr); +      sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3); +      sqliteVdbeAddOp(v, OP_Pop, 1, 0); +      sqliteVdbeAddOp(v, OP_Integer, -1, 0); +      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); +    } -    /* build the new.* reference row */ -    sqliteVdbeAddOp(v, OP_Integer, 13, 0); +    /* Create the new column data +    */      for(i=0; i<pTab->nCol; i++){        if( pColumn==0 ){          j = i; @@ -379,26 +399,28 @@ void sqliteInsert(      }      sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); -    sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0); -    /* Fire BEFORE triggers */ -    if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab, newIdx, -1,  -        onError, endOfLoop) ){ +    /* Fire BEFORE or INSTEAD OF triggers */ +    if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab,  +        newIdx, -1, onError, endOfLoop) ){        goto insert_cleanup;      } +  } -    /* Open the tables and indices for the INSERT */ -    if( !pTab->pSelect ){ -      base = pParse->nTab; -      openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; -      sqliteVdbeAddOp(v, openOp, base, pTab->tnum); -      sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); -      for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ -        sqliteVdbeAddOp(v, openOp, idx+base, pIdx->tnum); -        sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC); -      } -      pParse->nTab += idx; +  /* If any triggers exists, the opening of tables and indices is deferred +  ** until now. +  */ +  if( row_triggers_exist && !isView ){ +    base = pParse->nTab; +    sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenWrite, base, pTab->tnum); +    sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); +    for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ +      sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenWrite, idx+base, pIdx->tnum); +      sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);      } +    pParse->nTab += idx;    }    /* Push the record number for the new entry onto the stack.  The @@ -406,7 +428,7 @@ void sqliteInsert(    ** except when the table has an INTEGER PRIMARY KEY column, in which    ** case the record number is the same as that column.     */ -  if( !pTab->pSelect ){ +  if( !isView ){      if( keyColumn>=0 ){        if( useTempTable ){          sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn); @@ -461,18 +483,19 @@ void sqliteInsert(      ** do the insertion.      */      sqliteGenerateConstraintChecks(pParse, pTab, base, 0,0,0,onError,endOfLoop); -    sqliteCompleteInsertion(pParse, pTab, base, 0,0,0); +    sqliteCompleteInsertion(pParse, pTab, base, 0,0,0, +                            after_triggers ? newIdx : -1); +  } -    /* Update the count of rows that are inserted -    */ -    if( (db->flags & SQLITE_CountRows)!=0 ){ -      sqliteVdbeAddOp(v, OP_MemIncr, iCntMem, 0); -    } +  /* Update the count of rows that are inserted +  */ +  if( (db->flags & SQLITE_CountRows)!=0 ){ +    sqliteVdbeAddOp(v, OP_MemIncr, iCntMem, 0);    }    if( row_triggers_exist ){      /* Close all tables opened */ -    if( !pTab->pSelect ){ +    if( !isView ){        sqliteVdbeAddOp(v, OP_Close, base, 0);        for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){          sqliteVdbeAddOp(v, OP_Close, idx+base, 0); @@ -520,9 +543,9 @@ void sqliteInsert(    }  insert_cleanup: +  sqliteSrcListDelete(pTabList);    if( pList ) sqliteExprListDelete(pList);    if( pSelect ) sqliteSelectDelete(pSelect); -  if ( zTab ) sqliteFree(zTab);    sqliteIdListDelete(pColumn);  } @@ -532,7 +555,7 @@ insert_cleanup:  ** When this routine is called, the stack contains (from bottom to top)  ** the following values:  ** -**    1.  The recno of the row to be updated before it is updated.  This +**    1.  The recno of the row to be updated before the update.  This  **        value is omitted unless we are doing an UPDATE that involves a  **        change to the record number.  ** @@ -644,9 +667,10 @@ void sqliteGenerateConstraintChecks(      if( onError==OE_None ) continue;      if( overrideError!=OE_Default ){        onError = overrideError; -    }else if( onError==OE_Default ){ +    }else if( pParse->db->onError!=OE_Default ){        onError = pParse->db->onError; -      if( onError==OE_Default ) onError = OE_Abort; +    }else if( onError==OE_Default ){ +      onError = OE_Abort;      }      if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){        onError = OE_Abort; @@ -694,9 +718,10 @@ void sqliteGenerateConstraintChecks(      onError = pTab->keyConf;      if( overrideError!=OE_Default ){        onError = overrideError; -    }else if( onError==OE_Default ){ +    }else if( pParse->db->onError!=OE_Default ){        onError = pParse->db->onError; -      if( onError==OE_Default ) onError = OE_Abort; +    }else if( onError==OE_Default ){ +      onError = OE_Abort;      }      if( onError!=OE_Replace ){        if( isUpdate ){ @@ -735,10 +760,12 @@ void sqliteGenerateConstraintChecks(    ** index and making sure that duplicate entries do not already exist.    ** Add the new records to the indices as we go.    */ -  extra = 0; -  for(extra=(-1), iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ -    if( aIdxUsed && aIdxUsed[iCur]==0 ) continue; -    extra++;     +  extra = -1; +  for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ +    if( aIdxUsed && aIdxUsed[iCur]==0 ) continue;  /* Skip unused indices */ +    extra++; + +    /* Create a key for accessing the index entry */      sqliteVdbeAddOp(v, OP_Dup, nCol+extra, 1);      for(i=0; i<pIdx->nColumn; i++){        int idx = pIdx->aiColumn[i]; @@ -750,16 +777,23 @@ void sqliteGenerateConstraintChecks(      }      jumpInst1 = sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);      if( pParse->db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx); + +    /* Find out what action to take in case there is an indexing conflict */      onError = pIdx->onError; -    if( onError==OE_None ) continue; +    if( onError==OE_None ) continue;  /* pIdx is not a UNIQUE index */      if( overrideError!=OE_Default ){        onError = overrideError; -    }else if( onError==OE_Default ){ +    }else if( pParse->db->onError!=OE_Default ){        onError = pParse->db->onError; -      if( onError==OE_Default ) onError = OE_Abort; +    }else if( onError==OE_Default ){ +      onError = OE_Abort;      } + +    /* Check to see if the new index entry will be unique */      sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1);      jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0); + +    /* Generate code that executes if the new index entry is not unique */      switch( onError ){        case OE_Rollback:        case OE_Abort: @@ -809,7 +843,8 @@ void sqliteCompleteInsertion(    int base,           /* Index of a read/write cursor pointing at pTab */    char *aIdxUsed,     /* Which indices are used.  NULL means all are used */    int recnoChng,      /* True if the record number will change */ -  int isUpdate        /* True for UPDATE, False for INSERT */ +  int isUpdate,       /* True for UPDATE, False for INSERT */ +  int newIdx          /* Index of NEW table for triggers.  -1 if none */  ){    int i;    Vdbe *v; @@ -825,6 +860,11 @@ void sqliteCompleteInsertion(      sqliteVdbeAddOp(v, OP_IdxPut, base+i+1, 0);    }    sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); +  if( newIdx>=0 ){ +    sqliteVdbeAddOp(v, OP_Dup, 1, 0); +    sqliteVdbeAddOp(v, OP_Dup, 1, 0); +    sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); +  }    sqliteVdbeAddOp(v, OP_PutIntKey, base, pParse->trigStack?0:1);    if( isUpdate && recnoChng ){      sqliteVdbeAddOp(v, OP_Pop, 1, 0); diff --git a/ext/sqlite/libsqlite/src/main.c b/ext/sqlite/libsqlite/src/main.c index b708b00c2a..ebba7cbc57 100644 --- a/ext/sqlite/libsqlite/src/main.c +++ b/ext/sqlite/libsqlite/src/main.c @@ -29,6 +29,13 @@ typedef struct {    char **pzErrMsg;    /* Error message stored here */  } InitData; +/* +** Fill the InitData structure with an error message that indicates +** that the database is corrupt. +*/ +static void corruptSchema(InitData *pData){ +  sqliteSetString(pData->pzErrMsg, "malformed database schema", 0); +}  /*  ** This is the callback routine for the code that initializes the @@ -40,7 +47,8 @@ typedef struct {  **     argv[1] = table or index name or meta statement type.  **     argv[2] = root page number for table or index.  NULL for meta.  **     argv[3] = SQL text for a CREATE TABLE or CREATE INDEX statement. -**     argv[4] = "1" for temporary files, "0" for main database +**     argv[4] = "1" for temporary files, "0" for main database, "2" or more +**               for auxiliary database files.  **  */  static @@ -49,15 +57,19 @@ int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){    Parse sParse;    int nErr = 0; -  /* TODO: Do some validity checks on all fields.  In particular, -  ** make sure fields do not contain NULLs. Otherwise we might core -  ** when attempting to initialize from a corrupt database file. */ -    assert( argc==5 ); +  if( argv[0]==0 ){ +    corruptSchema(pData); +    return 1; +  }    switch( argv[0][0] ){      case 'v':      case 'i':      case 't': {  /* CREATE TABLE, CREATE INDEX, or CREATE VIEW statements */ +      if( argv[2]==0 || argv[4]==0 ){ +        corruptSchema(pData); +        return 1; +      }        if( argv[3] && argv[3][0] ){          /* Call the parser to process a CREATE TABLE, INDEX or VIEW.          ** But because sParse.initFlag is set to 1, no VDBE code is generated @@ -67,7 +79,8 @@ int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){          memset(&sParse, 0, sizeof(sParse));          sParse.db = pData->db;          sParse.initFlag = 1; -        sParse.isTemp = argv[4][0] - '0'; +        sParse.iDb = atoi(argv[4]); +        sParse.useDb = -1;          sParse.newTnum = atoi(argv[2]);          sParse.useCallback = 1;          sqliteRunParser(&sParse, argv[3], pData->pzErrMsg); @@ -78,7 +91,12 @@ int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){          ** been created when we processed the CREATE TABLE.  All we have          ** to do here is record the root page number for that index.          */ -        Index *pIndex = sqliteFindIndex(pData->db, argv[1]); +        int iDb; +        Index *pIndex; + +        iDb = atoi(argv[4]); +        assert( iDb>=0 && iDb<pData->db->nDb ); +        pIndex = sqliteFindIndex(pData->db, argv[1], pData->db->aDb[iDb].zName);          if( pIndex==0 || pIndex->tnum!=0 ){            /* This can occur if there exists an index on a TEMP table which            ** has the same name as another index on a permanent index.  Since @@ -118,7 +136,7 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){    Trigger *pTrig;    char *zErr = 0; -  pTab = sqliteFindTable(pData->db, argv[0]); +  pTab = sqliteFindTable(pData->db, argv[0], 0);    assert( pTab!=0 );    assert( sqliteStrICmp(pTab->zName, argv[0])==0 );    if( pTab ){ @@ -141,7 +159,7 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){    ** cause the structure that pTab points to be deleted.  In case that    ** happened, we need to refetch pTab.    */ -  pTab = sqliteFindTable(pData->db, argv[0]); +  pTab = sqliteFindTable(pData->db, argv[0], 0);    if( pTab ){      assert( sqliteStrICmp(pTab->zName, argv[0])==0 );      pTab->pTrigger = pTrig;  /* Re-enable triggers */ @@ -153,22 +171,19 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){  /*  ** Attempt to read the database schema and initialize internal -** data structures.  Return one of the SQLITE_ error codes to +** data structures for a single database file.  The index of the +** database file is given by iDb.  iDb==0 is used for the main +** database.  iDb==1 should never be used.  iDb>=2 is used for +** auxiliary databases.  Return one of the SQLITE_ error codes to  ** indicate success or failure. -** -** After the database is initialized, the SQLITE_Initialized -** bit is set in the flags field of the sqlite structure.  An -** attempt is made to initialize the database as soon as it -** is opened.  If that fails (perhaps because another process -** has the sqlite_master table locked) than another attempt -** is made the first time the database is accessed.  */ -int sqliteInit(sqlite *db, char **pzErrMsg){ +static int sqliteInitOne(sqlite *db, int iDb, char **pzErrMsg){    int rc;    BtCursor *curMain;    int size;    Table *pTab;    char *azArg[6]; +  char zDbNum[30];    int meta[SQLITE_N_BTREE_META];    Parse sParse;    InitData initData; @@ -223,103 +238,161 @@ int sqliteInit(sqlite *db, char **pzErrMsg){       "WHERE type='index'"; +  assert( iDb>=0 && iDb!=1 && iDb<db->nDb ); +    /* Construct the schema tables: sqlite_master and sqlite_temp_master    */    azArg[0] = "table";    azArg[1] = MASTER_NAME;    azArg[2] = "2";    azArg[3] = master_schema; -  azArg[4] = "0"; +  sprintf(zDbNum, "%d", iDb); +  azArg[4] = zDbNum;    azArg[5] = 0;    initData.db = db;    initData.pzErrMsg = pzErrMsg;    sqliteInitCallback(&initData, 5, azArg, 0); -  pTab = sqliteFindTable(db, MASTER_NAME); +  pTab = sqliteFindTable(db, MASTER_NAME, "main");    if( pTab ){      pTab->readOnly = 1;    } -  azArg[1] = TEMP_MASTER_NAME; -  azArg[3] = temp_master_schema; -  azArg[4] = "1"; -  sqliteInitCallback(&initData, 5, azArg, 0); -  pTab = sqliteFindTable(db, TEMP_MASTER_NAME); -  if( pTab ){ -    pTab->readOnly = 1; +  if( iDb==0 ){ +    azArg[1] = TEMP_MASTER_NAME; +    azArg[3] = temp_master_schema; +    azArg[4] = "1"; +    sqliteInitCallback(&initData, 5, azArg, 0); +    pTab = sqliteFindTable(db, TEMP_MASTER_NAME, "temp"); +    if( pTab ){ +      pTab->readOnly = 1; +    }    }    /* Create a cursor to hold the database open    */ -  if( db->pBe==0 ) return SQLITE_OK; -  rc = sqliteBtreeCursor(db->pBe, 2, 0, &curMain); +  if( db->aDb[iDb].pBt==0 ) return SQLITE_OK; +  rc = sqliteBtreeCursor(db->aDb[iDb].pBt, 2, 0, &curMain);    if( rc ){      sqliteSetString(pzErrMsg, sqlite_error_string(rc), 0); -    sqliteResetInternalSchema(db);      return rc;    }    /* Get the database meta information    */ -  rc = sqliteBtreeGetMeta(db->pBe, meta); +  rc = sqliteBtreeGetMeta(db->aDb[iDb].pBt, meta);    if( rc ){      sqliteSetString(pzErrMsg, sqlite_error_string(rc), 0); -    sqliteResetInternalSchema(db);      sqliteBtreeCloseCursor(curMain);      return rc;    } -  db->schema_cookie = meta[1]; -  db->next_cookie = db->schema_cookie; -  db->file_format = meta[2]; -  size = meta[3]; -  if( size==0 ){ size = MAX_PAGES; } -  db->cache_size = size; -  sqliteBtreeSetCacheSize(db->pBe, size); -  db->safety_level = meta[4]; -  if( db->safety_level==0 ) db->safety_level = 2; -  sqliteBtreeSetSafetyLevel(db->pBe, db->safety_level); - -  /* -  **     file_format==1    Version 2.1.0. -  **     file_format==2    Version 2.2.0. Add support for INTEGER PRIMARY KEY. -  **     file_format==3    Version 2.6.0. Fix empty-string index bug. -  **     file_format==4    Version 2.7.0. Add support for separate numeric and -  **                       text datatypes. -  */ -  if( db->file_format==0 ){ -    /* This happens if the database was initially empty */ -    db->file_format = 4; -  }else if( db->file_format>4 ){ -    sqliteBtreeCloseCursor(curMain); -    sqliteSetString(pzErrMsg, "unsupported file format", 0); -    return SQLITE_ERROR; +  db->aDb[iDb].schema_cookie = meta[1]; +  if( iDb==0 ){ +    db->next_cookie = meta[1]; +    db->file_format = meta[2]; +    size = meta[3]; +    if( size==0 ){ size = MAX_PAGES; } +    db->cache_size = size; +    db->safety_level = meta[4]; +    if( db->safety_level==0 ) db->safety_level = 2; + +    /* +    **  file_format==1    Version 2.1.0. +    **  file_format==2    Version 2.2.0. Add support for INTEGER PRIMARY KEY. +    **  file_format==3    Version 2.6.0. Fix empty-string index bug. +    **  file_format==4    Version 2.7.0. Add support for separate numeric and +    **                    text datatypes. +    */ +    if( db->file_format==0 ){ +      /* This happens if the database was initially empty */ +      db->file_format = 4; +    }else if( db->file_format>4 ){ +      sqliteBtreeCloseCursor(curMain); +      sqliteSetString(pzErrMsg, "unsupported file format", 0); +      return SQLITE_ERROR; +    } +  }else if( db->file_format!=meta[2] || db->file_format<4 ){ +    assert( db->file_format>=4 ); +    if( meta[2]==0 ){ +      sqliteSetString(pzErrMsg, "cannot attach empty database: ", +         db->aDb[iDb].zName, 0); +    }else{ +      sqliteSetString(pzErrMsg, "incompatible file format in auxiliary " +         "database: ", db->aDb[iDb].zName, 0); +    } +    sqliteBtreeClose(db->aDb[iDb].pBt); +    db->aDb[iDb].pBt = 0; +    return SQLITE_FORMAT;    } +  sqliteBtreeSetCacheSize(db->aDb[iDb].pBt, size); +  sqliteBtreeSetSafetyLevel(db->aDb[iDb].pBt, meta[4]==0 ? 2 : meta[4]);    /* Read the schema information out of the schema tables    */    memset(&sParse, 0, sizeof(sParse));    sParse.db = db; -  sParse.pBe = db->pBe;    sParse.xCallback = sqliteInitCallback;    sParse.pArg = (void*)&initData;    sParse.initFlag = 1; +  sParse.useDb = -1;    sParse.useCallback = 1; -  sqliteRunParser(&sParse, -      db->file_format>=2 ? init_script : older_init_script, -      pzErrMsg); +  if( iDb==0 ){ +    sqliteRunParser(&sParse, +        db->file_format>=2 ? init_script : older_init_script, +        pzErrMsg); +  }else{ +    char *zSql = 0; +    sqliteSetString(&zSql,  +       "SELECT type, name, rootpage, sql, ", zDbNum, " FROM \"", +       db->aDb[iDb].zName, "\".sqlite_master", 0); +    sqliteRunParser(&sParse, zSql, pzErrMsg); +    sqliteFree(zSql); +  } +  sqliteBtreeCloseCursor(curMain);    if( sqlite_malloc_failed ){      sqliteSetString(pzErrMsg, "out of memory", 0);      sParse.rc = SQLITE_NOMEM; -    sqliteBtreeRollback(db->pBe); -    sqliteResetInternalSchema(db); +    sqliteResetInternalSchema(db, 0);    }    if( sParse.rc==SQLITE_OK ){ +    DbSetProperty(db, iDb, DB_SchemaLoaded); +    if( iDb==0 ){ +      DbSetProperty(db, 1, DB_SchemaLoaded); +    } +  }else{ +    sqliteResetInternalSchema(db, iDb); +  } +  return sParse.rc; +} + +/* +** Initialize all database files - the main database file, the file +** used to store temporary tables, and any additional database files +** created using ATTACH statements.  Return a success code.  If an +** error occurs, write an error message into *pzErrMsg. +** +** After the database is initialized, the SQLITE_Initialized +** bit is set in the flags field of the sqlite structure.  An +** attempt is made to initialize the database as soon as it +** is opened.  If that fails (perhaps because another process +** has the sqlite_master table locked) than another attempt +** is made the first time the database is accessed. +*/ +int sqliteInit(sqlite *db, char **pzErrMsg){ +  int i, rc; +   +  assert( (db->flags & SQLITE_Initialized)==0 ); +  rc = SQLITE_OK; +  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ +    if( DbHasProperty(db, i, DB_SchemaLoaded) ) continue; +    assert( i!=1 );  /* Should have been initialized together with 0 */ +    rc = sqliteInitOne(db, i, pzErrMsg); +  } +  if( rc==SQLITE_OK ){      db->flags |= SQLITE_Initialized;      sqliteCommitInternalChanges(db);    }else{      db->flags &= ~SQLITE_Initialized; -    sqliteResetInternalSchema(db);    } -  sqliteBtreeCloseCursor(curMain); -  return sParse.rc; +  return rc;  }  /* @@ -349,23 +422,27 @@ const char sqlite_encoding[] = "iso8859";  */  sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){    sqlite *db; -  int rc; +  int rc, i;    /* Allocate the sqlite data structure */    db = sqliteMalloc( sizeof(sqlite) );    if( pzErrMsg ) *pzErrMsg = 0;    if( db==0 ) goto no_mem_on_open; -  sqliteHashInit(&db->tblHash, SQLITE_HASH_STRING, 0); -  sqliteHashInit(&db->idxHash, SQLITE_HASH_STRING, 0); -  sqliteHashInit(&db->trigHash, SQLITE_HASH_STRING, 0); -  sqliteHashInit(&db->aFunc, SQLITE_HASH_STRING, 1); -  sqliteHashInit(&db->aFKey, SQLITE_HASH_STRING, 1);    db->onError = OE_Default;    db->priorNewRowid = 0;    db->magic = SQLITE_MAGIC_BUSY; +  db->nDb = 2; +  db->aDb = db->aDbStatic; +  sqliteHashInit(&db->aFunc, SQLITE_HASH_STRING, 1); +  for(i=0; i<db->nDb; i++){ +    sqliteHashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0); +    sqliteHashInit(&db->aDb[i].idxHash, SQLITE_HASH_STRING, 0); +    sqliteHashInit(&db->aDb[i].trigHash, SQLITE_HASH_STRING, 0); +    sqliteHashInit(&db->aDb[i].aFKey, SQLITE_HASH_STRING, 1); +  }    /* Open the backend database driver */ -  rc = sqliteBtreeOpen(zFilename, 0, MAX_PAGES, &db->pBe); +  rc = sqliteBtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);    if( rc!=SQLITE_OK ){      switch( rc ){        default: { @@ -376,6 +453,8 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){      sqliteStrRealloc(pzErrMsg);      return 0;    } +  db->aDb[0].zName = "main"; +  db->aDb[1].zName = "temp";    /* Attempt to read the schema */    sqliteRegisterBuiltinFunctions(db); @@ -412,9 +491,9 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){        &initData,        &zErr);      if( rc==SQLITE_OK ){ -      sqliteBtreeGetMeta(db->pBe, meta); +      sqliteBtreeGetMeta(db->aDb[0].pBt, meta);        meta[2] = 4; -      sqliteBtreeUpdateMeta(db->pBe, meta); +      sqliteBtreeUpdateMeta(db->aDb[0].pBt, meta);        sqlite_exec(db, "COMMIT", 0, 0, 0);      }      if( rc!=SQLITE_OK ){ @@ -457,17 +536,26 @@ int sqlite_changes(sqlite *db){  */  void sqlite_close(sqlite *db){    HashElem *i; +  int j;    db->want_to_close = 1;    if( sqliteSafetyCheck(db) || sqliteSafetyOn(db) ){      /* printf("DID NOT CLOSE\n"); fflush(stdout); */      return;    }    db->magic = SQLITE_MAGIC_CLOSED; -  sqliteBtreeClose(db->pBe); -  sqliteResetInternalSchema(db); -  if( db->pBeTemp ){ -    sqliteBtreeClose(db->pBeTemp); +  for(j=0; j<db->nDb; j++){ +    if( db->aDb[j].pBt ){ +      sqliteBtreeClose(db->aDb[j].pBt); +      db->aDb[j].pBt = 0; +    } +    if( j>=2 ){ +      sqliteFree(db->aDb[j].zName); +      db->aDb[j].zName = 0; +    }    } +  sqliteResetInternalSchema(db, 0); +  assert( db->nDb<=2 ); +  assert( db->aDb==db->aDbStatic );    for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){      FuncDef *pFunc, *pNext;      for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){ @@ -476,120 +564,21 @@ void sqlite_close(sqlite *db){      }    }    sqliteHashClear(&db->aFunc); -  sqliteHashClear(&db->aFKey);    sqliteFree(db);  }  /* -** Return TRUE if the given SQL string ends in a semicolon. -** -** Special handling is require for CREATE TRIGGER statements. -** Whenever the CREATE TRIGGER keywords are seen, the statement -** must end with ";END;". +** Rollback all database files.  */ -int sqlite_complete(const char *zSql){ -  int isComplete = 1; -  int requireEnd = 0; -  int seenText = 0; -  int seenCreate = 0; -  while( *zSql ){ -    switch( *zSql ){ -      case ';': { -        isComplete = 1; -        seenText = 1; -        seenCreate = 0; -        break; -      } -      case ' ': -      case '\t': -      case '\n': -      case '\f': { -        break; -      } -      case '[': { -        isComplete = 0; -        seenText = 1; -        seenCreate = 0; -        zSql++; -        while( *zSql && *zSql!=']' ){ zSql++; } -        if( *zSql==0 ) return 0; -        break; -      } -      case '"': -      case '\'': { -        int c = *zSql; -        isComplete = 0; -        seenText = 1; -        seenCreate = 0; -        zSql++; -        while( *zSql && *zSql!=c ){ zSql++; } -        if( *zSql==0 ) return 0; -        break; -      } -      case '-': { -        if( zSql[1]!='-' ){ -          isComplete = 0; -          seenCreate = 0; -          break; -        } -        while( *zSql && *zSql!='\n' ){ zSql++; } -        if( *zSql==0 ) return seenText && isComplete && requireEnd==0; -        break; -      } -      case 'c': -      case 'C': { -        seenText = 1; -        if( !isComplete ) break; -        isComplete = 0; -        if( sqliteStrNICmp(zSql, "create", 6)!=0 ) break; -        if( !isspace(zSql[6]) ) break; -        zSql += 5; -        seenCreate = 1; -        while( isspace(zSql[1]) ) zSql++; -        if( sqliteStrNICmp(&zSql[1],"trigger", 7)!=0 ) break; -        zSql += 7; -        requireEnd++; -        break; -      } -      case 't': -      case 'T': { -        seenText = 1; -        if( !seenCreate ) break; -        seenCreate = 0; -        isComplete = 0; -        if( sqliteStrNICmp(zSql, "trigger", 7)!=0 ) break; -        if( !isspace(zSql[7]) ) break; -        zSql += 6; -        requireEnd++; -        break; -      } -      case 'e': -      case 'E': { -        seenCreate = 0; -        seenText = 1; -        if( !isComplete ) break; -        isComplete = 0; -        if( requireEnd==0 ) break; -        if( sqliteStrNICmp(zSql, "end", 3)!=0 ) break; -        zSql += 2; -        while( isspace(zSql[1]) ) zSql++; -        if( zSql[1]==';' ){ -          zSql++; -          isComplete = 1; -          requireEnd--; -        } -        break; -      } -      default: { -        seenCreate = 0; -        seenText = 1; -        isComplete = 0; -        break; -      } +void sqliteRollbackAll(sqlite *db){ +  int i; +  for(i=0; i<db->nDb; i++){ +    if( db->aDb[i].pBt ){ +      sqliteBtreeRollback(db->aDb[i].pBt); +      db->aDb[i].inTrans = 0;      } -    zSql++;    } -  return seenText && isComplete && requireEnd==0; +  sqliteRollbackInternalChanges(db);  }  /* @@ -632,21 +621,18 @@ static int sqliteMain(    if( db->pVdbe==0 ){ db->nChange = 0; }    memset(&sParse, 0, sizeof(sParse));    sParse.db = db; -  sParse.pBe = db->pBe;    sParse.xCallback = xCallback;    sParse.pArg = pArg; +  sParse.useDb = -1;    sParse.useCallback = ppVm==0; -#ifndef SQLITE_OMIT_TRACE    if( db->xTrace ) db->xTrace(db->pTraceArg, zSql); -#endif    sqliteRunParser(&sParse, zSql, pzErrMsg);    if( sqlite_malloc_failed ){      sqliteSetString(pzErrMsg, "out of memory", 0);      sParse.rc = SQLITE_NOMEM; -    sqliteBtreeRollback(db->pBe); -    if( db->pBeTemp ) sqliteBtreeRollback(db->pBeTemp); +    sqliteRollbackAll(db); +    sqliteResetInternalSchema(db, 0);      db->flags &= ~SQLITE_InTrans; -    sqliteResetInternalSchema(db);    }    if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;    if( sParse.rc!=SQLITE_OK && pzErrMsg && *pzErrMsg==0 ){ @@ -654,7 +640,7 @@ static int sqliteMain(    }    sqliteStrRealloc(pzErrMsg);    if( sParse.rc==SQLITE_SCHEMA ){ -    sqliteResetInternalSchema(db); +    sqliteResetInternalSchema(db, 0);    }    if( sParse.useCallback==0 ){      assert( ppVm ); @@ -937,53 +923,69 @@ int sqlite_function_type(sqlite *db, const char *zName, int dataType){  ** sqlite_exec().  */  void *sqlite_trace(sqlite *db, void (*xTrace)(void*,const char*), void *pArg){ -#ifndef SQLITE_OMIT_TRACE    void *pOld = db->pTraceArg;    db->xTrace = xTrace;    db->pTraceArg = pArg;    return pOld; -#else -  return 0; -#endif  } -  /* -** Attempt to open the file named in the argument as the auxiliary database -** file.  The auxiliary database file is used to store TEMP tables.  But -** by using this API, it is possible to trick SQLite into opening two -** separate databases and acting on them as if they were one. +** This routine is called to create a connection to a database BTree +** driver.  If zFilename is the name of a file, then that file is +** opened and used.  If zFilename is the magic name ":memory:" then +** the database is stored in memory (and is thus forgotten as soon as +** the connection is closed.)  If zFilename is NULL then the database +** is for temporary use only and is deleted as soon as the connection +** is closed.  ** -** This routine closes the existing auxiliary database file, which will -** cause any previously created TEMP tables to be dropped. +** A temporary database can be either a disk file (that is automatically +** deleted when the file is closed) or a set of red-black trees held in memory, +** depending on the values of the TEMP_STORE compile-time macro and the +** db->temp_store variable, according to the following chart:  ** -** The zName parameter can be a NULL pointer or an empty string to cause -** a temporary file to be opened and automatically deleted when closed. +**       TEMP_STORE     db->temp_store     Location of temporary database +**       ----------     --------------     ------------------------------ +**           0               any             file +**           1                1              file +**           1                2              memory +**           1                0              file +**           2                1              file +**           2                2              memory +**           2                0              memory +**           3               any             memory  */ -int sqlite_open_aux_file(sqlite *db, const char *zName, char **pzErrMsg){ -  int rc; -  if( zName && zName[0]==0 ) zName = 0; -  if( sqliteSafetyOn(db) ) goto openaux_misuse; -  sqliteResetInternalSchema(db); -  if( db->pBeTemp!=0 ){ -    sqliteBtreeClose(db->pBeTemp); -  } -  rc = sqliteBtreeOpen(zName, 0, MAX_PAGES, &db->pBeTemp); -  if( rc ){ -    if( zName==0 ) zName = "a temporary file"; -    sqliteSetString(pzErrMsg, "unable to open ", zName,  -      ": ", sqlite_error_string(rc), 0); -    sqliteStrRealloc(pzErrMsg); -    sqliteSafetyOff(db); -    return rc; +int sqliteBtreeFactory( +  const sqlite *db,	    /* Main database when opening aux otherwise 0 */ +  const char *zFilename,    /* Name of the file containing the BTree database */ +  int omitJournal,          /* if TRUE then do not journal this file */ +  int nCache,               /* How many pages in the page cache */ +  Btree **ppBtree){         /* Pointer to new Btree object written here */ + +  assert( ppBtree != 0); + +#ifndef SQLITE_OMIT_INMEMORYDB +  if( zFilename==0 ){ +    if (TEMP_STORE == 0) { +      /* Always use file based temporary DB */ +      return sqliteBtreeOpen(0, omitJournal, nCache, ppBtree); +    } else if (TEMP_STORE == 1 || TEMP_STORE == 2) { +      /* Switch depending on compile-time and/or runtime settings. */ +      int location = db->temp_store==0 ? TEMP_STORE : db->temp_store; + +      if (location == 1) { +        return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree); +      } else { +        return sqliteRbtreeOpen(0, 0, 0, ppBtree); +      } +    } else { +      /* Always use in-core DB */ +      return sqliteRbtreeOpen(0, 0, 0, ppBtree); +    } +  }else if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){ +    return sqliteRbtreeOpen(0, 0, 0, ppBtree); +  }else +#endif +  { +    return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree);    } -  rc = sqliteInit(db, pzErrMsg); -  if( sqliteSafetyOff(db) ) goto openaux_misuse; -  sqliteStrRealloc(pzErrMsg); -  return rc; - -openaux_misuse: -  sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), 0); -  sqliteStrRealloc(pzErrMsg); -  return SQLITE_MISUSE;  } diff --git a/ext/sqlite/libsqlite/src/opcodes.c b/ext/sqlite/libsqlite/src/opcodes.c index 0e611abcd3..1363a0fa31 100644 --- a/ext/sqlite/libsqlite/src/opcodes.c +++ b/ext/sqlite/libsqlite/src/opcodes.c @@ -60,12 +60,10 @@ char *sqliteOpcodeNames[] = { "???",    "ReadCookie",     "SetCookie",     "VerifyCookie",  -  "OpenAux",  -  "OpenWrAux",  +  "OpenRead",     "OpenWrite",  -  "Open",     "OpenTemp",  -  "RenameCursor",  +  "OpenPseudo",     "Close",     "MoveLt",     "MoveTo",  @@ -79,6 +77,7 @@ char *sqliteOpcodeNames[] = { "???",    "PutStrKey",     "Delete",     "KeyAsData",  +  "RowData",     "Column",     "Recno",     "FullKey",  diff --git a/ext/sqlite/libsqlite/src/opcodes.h b/ext/sqlite/libsqlite/src/opcodes.h index 5e0a9f8056..ccd7da4ae3 100644 --- a/ext/sqlite/libsqlite/src/opcodes.h +++ b/ext/sqlite/libsqlite/src/opcodes.h @@ -59,72 +59,71 @@  #define OP_ReadCookie                   58  #define OP_SetCookie                    59  #define OP_VerifyCookie                 60 -#define OP_OpenAux                      61 -#define OP_OpenWrAux                    62 -#define OP_OpenWrite                    63 -#define OP_Open                         64 -#define OP_OpenTemp                     65 -#define OP_RenameCursor                 66 -#define OP_Close                        67 -#define OP_MoveLt                       68 -#define OP_MoveTo                       69 -#define OP_Distinct                     70 -#define OP_NotFound                     71 -#define OP_Found                        72 -#define OP_IsUnique                     73 -#define OP_NotExists                    74 -#define OP_NewRecno                     75 -#define OP_PutIntKey                    76 -#define OP_PutStrKey                    77 -#define OP_Delete                       78 -#define OP_KeyAsData                    79 -#define OP_Column                       80 -#define OP_Recno                        81 -#define OP_FullKey                      82 -#define OP_NullRow                      83 -#define OP_Last                         84 -#define OP_Rewind                       85 -#define OP_Prev                         86 -#define OP_Next                         87 -#define OP_IdxPut                       88 -#define OP_IdxDelete                    89 -#define OP_IdxRecno                     90 -#define OP_IdxLT                        91 -#define OP_IdxGT                        92 -#define OP_IdxGE                        93 -#define OP_Destroy                      94 -#define OP_Clear                        95 -#define OP_CreateIndex                  96 -#define OP_CreateTable                  97 -#define OP_IntegrityCk                  98 -#define OP_ListWrite                    99 -#define OP_ListRewind                  100 -#define OP_ListRead                    101 -#define OP_ListReset                   102 -#define OP_ListPush                    103 -#define OP_ListPop                     104 -#define OP_SortPut                     105 -#define OP_SortMakeRec                 106 -#define OP_SortMakeKey                 107 -#define OP_Sort                        108 -#define OP_SortNext                    109 -#define OP_SortCallback                110 -#define OP_SortReset                   111 -#define OP_FileOpen                    112 -#define OP_FileRead                    113 -#define OP_FileColumn                  114 -#define OP_MemStore                    115 -#define OP_MemLoad                     116 -#define OP_MemIncr                     117 -#define OP_AggReset                    118 -#define OP_AggInit                     119 -#define OP_AggFunc                     120 -#define OP_AggFocus                    121 -#define OP_AggSet                      122 -#define OP_AggGet                      123 -#define OP_AggNext                     124 -#define OP_SetInsert                   125 -#define OP_SetFound                    126 -#define OP_SetNotFound                 127 -#define OP_SetFirst                    128 -#define OP_SetNext                     129 +#define OP_OpenRead                     61 +#define OP_OpenWrite                    62 +#define OP_OpenTemp                     63 +#define OP_OpenPseudo                   64 +#define OP_Close                        65 +#define OP_MoveLt                       66 +#define OP_MoveTo                       67 +#define OP_Distinct                     68 +#define OP_NotFound                     69 +#define OP_Found                        70 +#define OP_IsUnique                     71 +#define OP_NotExists                    72 +#define OP_NewRecno                     73 +#define OP_PutIntKey                    74 +#define OP_PutStrKey                    75 +#define OP_Delete                       76 +#define OP_KeyAsData                    77 +#define OP_RowData                      78 +#define OP_Column                       79 +#define OP_Recno                        80 +#define OP_FullKey                      81 +#define OP_NullRow                      82 +#define OP_Last                         83 +#define OP_Rewind                       84 +#define OP_Prev                         85 +#define OP_Next                         86 +#define OP_IdxPut                       87 +#define OP_IdxDelete                    88 +#define OP_IdxRecno                     89 +#define OP_IdxLT                        90 +#define OP_IdxGT                        91 +#define OP_IdxGE                        92 +#define OP_Destroy                      93 +#define OP_Clear                        94 +#define OP_CreateIndex                  95 +#define OP_CreateTable                  96 +#define OP_IntegrityCk                  97 +#define OP_ListWrite                    98 +#define OP_ListRewind                   99 +#define OP_ListRead                    100 +#define OP_ListReset                   101 +#define OP_ListPush                    102 +#define OP_ListPop                     103 +#define OP_SortPut                     104 +#define OP_SortMakeRec                 105 +#define OP_SortMakeKey                 106 +#define OP_Sort                        107 +#define OP_SortNext                    108 +#define OP_SortCallback                109 +#define OP_SortReset                   110 +#define OP_FileOpen                    111 +#define OP_FileRead                    112 +#define OP_FileColumn                  113 +#define OP_MemStore                    114 +#define OP_MemLoad                     115 +#define OP_MemIncr                     116 +#define OP_AggReset                    117 +#define OP_AggInit                     118 +#define OP_AggFunc                     119 +#define OP_AggFocus                    120 +#define OP_AggSet                      121 +#define OP_AggGet                      122 +#define OP_AggNext                     123 +#define OP_SetInsert                   124 +#define OP_SetFound                    125 +#define OP_SetNotFound                 126 +#define OP_SetFirst                    127 +#define OP_SetNext                     128 diff --git a/ext/sqlite/libsqlite/src/os.c b/ext/sqlite/libsqlite/src/os.c index d0b50dc4f1..46f22a4341 100644 --- a/ext/sqlite/libsqlite/src/os.c +++ b/ext/sqlite/libsqlite/src/os.c @@ -31,8 +31,12 @@  # ifndef O_NOFOLLOW  #  define O_NOFOLLOW 0  # endif +# ifndef O_BINARY +#  define O_BINARY 0 +# endif  #endif +  #if OS_WIN  # include <winbase.h>  #endif @@ -48,6 +52,16 @@  #endif  /* +** The DJGPP compiler environment looks mostly like Unix, but it +** lacks the fcntl() system call.  So redefine fcntl() to be something +** that always succeeds.  This means that locking does not occur under +** DJGPP.  But its DOS - what did you expect? +*/ +#ifdef __DJGPP__ +# define fcntl(A,B,C) 0 +#endif + +/*  ** Macros for performance tracing.  Normally turned off  */  #if 0 @@ -268,6 +282,31 @@ int sqliteOsFileExists(const char *zFilename){  } +#if 0 /* NOT USED */ +/* +** Change the name of an existing file. +*/ +int sqliteOsFileRename(const char *zOldName, const char *zNewName){ +#if OS_UNIX +  if( link(zOldName, zNewName) ){ +    return SQLITE_ERROR; +  } +  unlink(zOldName); +  return SQLITE_OK; +#endif +#if OS_WIN +  if( !MoveFile(zOldName, zNewName) ){ +    return SQLITE_ERROR; +  } +  return SQLITE_OK; +#endif +#if OS_MAC +  /**** FIX ME ***/ +  return SQLITE_ERROR; +#endif +} +#endif /* NOT USED */ +  /*  ** Attempt to open a file for both reading and writing.  If that  ** fails, try opening it read-only.  If the file does not exist, @@ -287,9 +326,9 @@ int sqliteOsOpenReadWrite(    int *pReadonly  ){  #if OS_UNIX -  id->fd = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE, 0644); +  id->fd = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE|O_BINARY, 0644);    if( id->fd<0 ){ -    id->fd = open(zFilename, O_RDONLY|O_LARGEFILE); +    id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY);      if( id->fd<0 ){        return SQLITE_CANTOPEN;       } @@ -411,7 +450,8 @@ int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){    if( access(zFilename, 0)==0 ){      return SQLITE_CANTOPEN;    } -  id->fd = open(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE, 0600); +  id->fd = open(zFilename, +                O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, 0600);    if( id->fd<0 ){      return SQLITE_CANTOPEN;    } @@ -496,7 +536,7 @@ int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){  */  int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){  #if OS_UNIX -  id->fd = open(zFilename, O_RDONLY|O_LARGEFILE); +  id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY);    if( id->fd<0 ){      return SQLITE_CANTOPEN;    } @@ -1036,7 +1076,7 @@ int sqliteOsReadLock(OsFile *id){      lock.l_start = lock.l_len = 0L;      s = fcntl(id->fd, F_SETLK, &lock);      if( s!=0 ){ -      rc = (s==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; +      rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;      }else{        rc = SQLITE_OK;        id->pLock->cnt = 1; @@ -1132,7 +1172,7 @@ int sqliteOsWriteLock(OsFile *id){      lock.l_start = lock.l_len = 0L;      s = fcntl(id->fd, F_SETLK, &lock);      if( s!=0 ){ -      rc = (s==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; +      rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;      }else{        rc = SQLITE_OK;        id->pLock->cnt = -1; @@ -1239,7 +1279,7 @@ int sqliteOsUnlock(OsFile *id){      lock.l_start = lock.l_len = 0L;      s = fcntl(id->fd, F_SETLK, &lock);      if( s!=0 ){ -      rc = (s==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY; +      rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;      }else{        rc = SQLITE_OK;        id->pLock->cnt = 0; diff --git a/ext/sqlite/libsqlite/src/os.h b/ext/sqlite/libsqlite/src/os.h index 8491d90dfe..d7674267d7 100644 --- a/ext/sqlite/libsqlite/src/os.h +++ b/ext/sqlite/libsqlite/src/os.h @@ -18,6 +18,11 @@  #define _SQLITE_OS_H_  /* +** Helpful hint:  To get this to compile on HP/UX, add -D_INCLUDE_POSIX_SOURCE +** to the compiler command line. +*/ + +/*  ** These #defines should enable >2GB file support on Posix if the  ** underlying operating system supports it.  If the OS lacks  ** large file support, or if the OS is windows, these should be no-ops. @@ -147,6 +152,7 @@  int sqliteOsDelete(const char*);  int sqliteOsFileExists(const char*); +int sqliteOsFileRename(const char*, const char*);  int sqliteOsOpenReadWrite(const char*, OsFile*, int*);  int sqliteOsOpenExclusive(const char*, OsFile*, int);  int sqliteOsOpenReadOnly(const char*, OsFile*); diff --git a/ext/sqlite/libsqlite/src/pager.c b/ext/sqlite/libsqlite/src/pager.c index 7b32f6e089..e133a3cad0 100644 --- a/ext/sqlite/libsqlite/src/pager.c +++ b/ext/sqlite/libsqlite/src/pager.c @@ -928,6 +928,34 @@ int sqlitepager_pagecount(Pager *pPager){  }  /* +** Forward declaration +*/ +static int syncAllPages(Pager*); + +/* +** Truncate the file to the number of pages specified. +*/ +int sqlitepager_truncate(Pager *pPager, Pgno nPage){ +  int rc; +  if( pPager->dbSize<0 ){ +    sqlitepager_pagecount(pPager); +  } +  if( pPager->errMask!=0 ){ +    rc = pager_errcode(pPager); +    return rc; +  } +  if( nPage>=pPager->dbSize ){ +    return SQLITE_OK; +  } +  syncAllPages(pPager); +  rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)nPage); +  if( rc==SQLITE_OK ){ +    pPager->dbSize = nPage; +  } +  return rc; +} + +/*  ** Shutdown the page cache.  Free all memory and close all files.  **  ** If a transaction was in progress when this routine is called, that @@ -966,6 +994,10 @@ int sqlitepager_close(Pager *pPager){    ** }    */    CLR_PAGER(pPager); +  if( pPager->zFilename!=(char*)&pPager[1] ){ +    sqliteFree(pPager->zFilename); +    sqliteFree(pPager->zJournal); +  }    sqliteFree(pPager);    return SQLITE_OK;  } @@ -1171,6 +1203,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){    */     assert( pPager!=0 );    assert( pgno!=0 ); +  *ppPage = 0;    if( pPager->errMask & ~(PAGER_ERR_FULL) ){      return pager_errcode(pPager);    } @@ -1181,7 +1214,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){    if( pPager->nRef==0 ){      rc = sqliteOsReadLock(&pPager->fd);      if( rc!=SQLITE_OK ){ -      *ppPage = 0;        return rc;      }      pPager->state = SQLITE_READLOCK; @@ -1199,7 +1231,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){             /* This should never happen! */             rc = SQLITE_INTERNAL;           } -         *ppPage = 0;           return rc;         }         pPager->state = SQLITE_WRITELOCK; @@ -1215,7 +1246,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){         if( rc!=SQLITE_OK ){           rc = sqliteOsUnlock(&pPager->fd);           assert( rc==SQLITE_OK ); -         *ppPage = 0;           return SQLITE_BUSY;         }         pPager->journalOpen = 1; @@ -1243,7 +1273,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){        pPg = sqliteMallocRaw( sizeof(*pPg) + SQLITE_PAGE_SIZE                                 + sizeof(u32) + pPager->nExtra );        if( pPg==0 ){ -        *ppPage = 0;          pager_unwritelock(pPager);          pPager->errMask |= PAGER_ERR_MEM;          return SQLITE_NOMEM; @@ -1272,7 +1301,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){          int rc = syncAllPages(pPager);          if( rc!=0 ){            sqlitepager_rollback(pPager); -          *ppPage = 0;            return SQLITE_IOERR;          }          pPg = pPager->pFirst; @@ -1287,7 +1315,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){          rc = pager_write_pagelist( pPg );          if( rc!=SQLITE_OK ){            sqlitepager_rollback(pPager); -          *ppPage = 0;            return SQLITE_IOERR;          }        } @@ -1365,7 +1392,15 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){        assert( pPg->pNextHash->pPrevHash==0 );        pPg->pNextHash->pPrevHash = pPg;      } +    if( pPager->nExtra>0 ){ +      memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); +    }      if( pPager->dbSize<0 ) sqlitepager_pagecount(pPager); +    if( pPager->errMask!=0 ){ +      sqlitepager_unref(PGHDR_TO_DATA(pPg)); +      rc = pager_errcode(pPager); +      return rc; +    }      if( pPager->dbSize<(int)pgno ){        memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);      }else{ @@ -1376,15 +1411,13 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){          off_t fileSize;          if( sqliteOsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK                 || fileSize>=pgno*SQLITE_PAGE_SIZE ){ +          sqlitepager_unref(PGHDR_TO_DATA(pPg));            return rc;          }else{            memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);          }        }      } -    if( pPager->nExtra>0 ){ -      memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); -    }    }else{      /* The requested page is in the page cache. */      pPager->nHit++; @@ -1506,6 +1539,10 @@ static int pager_open_journal(Pager *pPager){    pPager->alwaysRollback = 0;    pPager->nRec = 0;    sqlitepager_pagecount(pPager); +  if( pPager->errMask!=0 ){ +    rc = pager_errcode(pPager); +    return rc; +  }    pPager->origDbSize = pPager->dbSize;    if( journal_format==JOURNAL_FORMAT_3 ){      rc = sqliteOsWrite(&pPager->jfd, aJournalMagic3, sizeof(aJournalMagic3)); @@ -1723,6 +1760,25 @@ int sqlitepager_iswriteable(void *pData){  }  /* +** Replace the content of a single page with the information in the third +** argument. +*/ +int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void *pData){ +  void *pPage; +  int rc; + +  rc = sqlitepager_get(pPager, pgno, &pPage); +  if( rc==SQLITE_OK ){ +    rc = sqlitepager_write(pPage); +    if( rc==SQLITE_OK ){ +      memcpy(pPage, pData, SQLITE_PAGE_SIZE); +    } +    sqlitepager_unref(pPage); +  } +  return rc; +} + +/*  ** A call to this routine tells the pager that it is not necessary to  ** write the information on page "pgno" back to the disk, even though  ** that page might be marked as dirty. @@ -2007,6 +2063,13 @@ int sqlitepager_ckpt_rollback(Pager *pPager){    return rc;  } +/* +** Return the full pathname of the database file. +*/ +const char *sqlitepager_filename(Pager *pPager){ +  return pPager->zFilename; +} +  #ifdef SQLITE_TEST  /*  ** Print a listing of all referenced pages and their ref count. diff --git a/ext/sqlite/libsqlite/src/pager.h b/ext/sqlite/libsqlite/src/pager.h index a2f08d3ac9..42fa3dc378 100644 --- a/ext/sqlite/libsqlite/src/pager.h +++ b/ext/sqlite/libsqlite/src/pager.h @@ -59,7 +59,9 @@ int sqlitepager_unref(void*);  Pgno sqlitepager_pagenumber(void*);  int sqlitepager_write(void*);  int sqlitepager_iswriteable(void*); +int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*);  int sqlitepager_pagecount(Pager*); +int sqlitepager_truncate(Pager*,Pgno);  int sqlitepager_begin(void*);  int sqlitepager_commit(Pager*);  int sqlitepager_rollback(Pager*); @@ -71,6 +73,8 @@ void sqlitepager_dont_rollback(void*);  void sqlitepager_dont_write(Pager*, Pgno);  int *sqlitepager_stats(Pager*);  void sqlitepager_set_safety_level(Pager*,int); +const char *sqlitepager_filename(Pager*); +int sqlitepager_rename(Pager*, const char *zNewName);  #ifdef SQLITE_TEST  void sqlitepager_refdump(Pager*); diff --git a/ext/sqlite/libsqlite/src/parse.c b/ext/sqlite/libsqlite/src/parse.c index 60468f79fa..da1a6f0461 100644 --- a/ext/sqlite/libsqlite/src/parse.c +++ b/ext/sqlite/libsqlite/src/parse.c @@ -81,34 +81,34 @@ struct TrigEvent { int a; IdList * b; };  */  /*  */  #define YYCODETYPE unsigned char -#define YYNOCODE 214 +#define YYNOCODE 219  #define YYACTIONTYPE unsigned short int  #define sqliteParserTOKENTYPE Token  typedef union {    sqliteParserTOKENTYPE yy0; -  struct TrigEvent yy72; -  struct {int value; int mask;} yy83; -  int yy136; -  ExprList* yy168; -  Expr * yy176; -  Select* yy207; -  TriggerStep * yy209; -  IdList* yy268; -  Expr* yy272; -  SrcList* yy289; -  Token yy324; -  struct LimitVal yy336; -  int yy427; +  Select* yy11; +  int yy52; +  ExprList* yy62; +  IdList* yy92; +  Token yy210; +  struct TrigEvent yy234; +  Expr * yy270; +  struct {int value; int mask;} yy279; +  struct LimitVal yy280; +  Expr* yy334; +  SrcList* yy335; +  TriggerStep * yy347; +  int yy437;  } YYMINORTYPE;  #define YYSTACKDEPTH 100  #define sqliteParserARG_SDECL Parse *pParse;  #define sqliteParserARG_PDECL ,Parse *pParse  #define sqliteParserARG_FETCH Parse *pParse = yypParser->pParse  #define sqliteParserARG_STORE yypParser->pParse = pParse -#define YYNSTATE 531 -#define YYNRULE 280 -#define YYERRORSYMBOL 150 -#define YYERRSYMDT yy427 +#define YYNSTATE 555 +#define YYNRULE 287 +#define YYERRORSYMBOL 155 +#define YYERRSYMDT yy437  #define YYFALLBACK 1  #define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)  #define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1) @@ -140,2967 +140,3043 @@ struct yyActionEntry {  typedef struct yyActionEntry yyActionEntry;  static const yyActionEntry yyActionTable[] = {  /* State 0 */ -  {  44,   0, 529}, /*  1:                EXPLAIN shift  529 */ -  { 151,   0,   3}, /*  2:                explain shift  3 */ -  { 104,   1, 528}, /*  3:                   SEMI shift  528 */ -  { 165,   0, 812}, /*  4:                  input accept */ -  { 136,   0,   1}, /*  5:                cmdlist shift  1 */ -  { 149,   0, 530}, /*  6:                   ecmd shift  530 */ +  { 156,   0,   3}, /*  1:                explain shift  3 */ +  { 139,   0,   1}, /*  2:                cmdlist shift  1 */ +  { 170,   0, 843}, /*  3:                  input accept */ +  {  47,   0, 553}, /*  4:                EXPLAIN shift  553 */ +  { 154,   0, 554}, /*  5:                   ecmd shift  554 */ +  { 107,   4, 552}, /*  6:                   SEMI shift  552 */  /* State 1 */ -  {   0,   0, 531}, /*  1:                      $ reduce 0 */ -  { 151,   0,   3}, /*  2:                explain shift  3 */ -  { 104,   4, 528}, /*  3:                   SEMI shift  528 */ -  {  44,   0, 529}, /*  4:                EXPLAIN shift  529 */ -  { 149,   3,   2}, /*  5:                   ecmd shift  2 */ +  {   0,   0, 555}, /*  1:                      $ reduce 0 */ +  { 156,   0,   3}, /*  2:                explain shift  3 */ +  { 107,   4, 552}, /*  3:                   SEMI shift  552 */ +  {  47,   0, 553}, /*  4:                EXPLAIN shift  553 */ +  { 154,   0,   2}, /*  5:                   ecmd shift  2 */  /* State 3 */ -  { 120,   3, 483}, /*  1:                 UPDATE shift  483 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  {  40,   0,  25}, /*  3:                    END shift  25 */ -  { 123,   6, 509}, /*  4:                 VACUUM shift  509 */ -  { 144,   0,  29}, /*  5:           create_table shift  29 */ -  { 103,   7,  73}, /*  6:                 SELECT shift  73 */ -  {  63,  11, 498}, /*  7:                 INSERT shift  498 */ -  {  27,   0, 501}, /*  8:                   COPY shift  501 */ -  { 168,  12, 489}, /*  9:             insert_cmd shift  489 */ -  {   9,   0,   7}, /* 10:                  BEGIN shift  7 */ -  {  23,   0,  23}, /* 11:                 COMMIT shift  23 */ -  {  28,   0, 382}, /* 12:                 CREATE shift  382 */ -  { 192,  14, 478}, /* 13:                 select shift  478 */ -  {  92,  15, 511}, /* 14:                 PRAGMA shift  511 */ -  {  32,   0, 479}, /* 15:                 DELETE shift  479 */ -  { 135,   0,   6}, /* 16:                    cmd shift  6 */ -  {  97,  19, 500}, /* 17:                REPLACE shift  500 */ -  { 137,  17,   4}, /* 18:                   cmdx shift  4 */ -  {  37,   0, 469}, /* 19:                   DROP shift  469 */ -  {  99,   0,  27}, /* 20:               ROLLBACK shift  27 */ +  {  66,   0, 512}, /*  1:                 INSERT shift  512 */ +  {  28,   0, 515}, /*  2:                   COPY shift  515 */ +  {  24,   0,  23}, /*  3:                 COMMIT shift  23 */ +  {  29,   0, 388}, /*  4:                 CREATE shift  388 */ +  {   8,   0, 543}, /*  5:                 ATTACH shift  543 */ +  {  34,   0, 490}, /*  6:                 DELETE shift  490 */ +  { 138,   2,   6}, /*  7:                    cmd shift  6 */ +  {  95,   4, 526}, /*  8:                 PRAGMA shift  526 */ +  { 140,   5,   4}, /*  9:                   cmdx shift  4 */ +  { 185,   0,  69}, /* 10:              oneselect shift  69 */ +  {  10,   0,   7}, /* 11:                  BEGIN shift  7 */ +  {  37,   0, 549}, /* 12:                 DETACH shift  549 */ +  { 100,   6, 514}, /* 13:                REPLACE shift  514 */ +  { 123,   0, 495}, /* 14:                 UPDATE shift  495 */ +  { 102,   0,  27}, /* 15:               ROLLBACK shift  27 */ +  { 147,  12,  29}, /* 16:           create_table shift  29 */ +  { 126,   0, 524}, /* 17:                 VACUUM shift  524 */ +  {  40,   0, 478}, /* 18:                   DROP shift  478 */ +  { 106,  18,  73}, /* 19:                 SELECT shift  73 */ +  { 173,   0, 502}, /* 20:             insert_cmd shift  502 */ +  { 196,   0, 489}, /* 21:                 select shift  489 */ +  {  43,   0,  25}, /* 22:                    END shift  25 */  /* State 4 */ -  { 104,   0,   5}, /*  1:                   SEMI shift  5 */ +  { 107,   0,   5}, /*  1:                   SEMI shift  5 */  /* State 6 */ -  { 104,   0, 536}, /*  1:                   SEMI reduce 5 */ +  { 107,   0, 560}, /*  1:                   SEMI reduce 5 */  /* State 7 */ -  { 202,   2,   8}, /*  1:              trans_opt shift  8 */ -  { 114,   0,  18}, /*  2:            TRANSACTION shift  18 */ +  { 206,   0,   8}, /*  1:              trans_opt shift  8 */ +  { 117,   0,  18}, /*  2:            TRANSACTION shift  18 */  /* State 8 */ -  { 180,   2,   9}, /*  1:                 onconf shift  9 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ -  { 104,   0, 619}, /*  3:                   SEMI reduce 88 */ +  {  90,   0,  10}, /*  1:                     ON shift  10 */ +  { 184,   0,   9}, /*  2:                 onconf shift  9 */ +  { 107,   0, 643}, /*  3:                   SEMI reduce 88 */  /* State 9 */ -  { 104,   0, 539}, /*  1:                   SEMI reduce 8 */ +  { 107,   0, 563}, /*  1:                   SEMI reduce 8 */  /* State 10 */ -  {  25,   0,  11}, /*  1:               CONFLICT shift  11 */ +  {  26,   0,  11}, /*  1:               CONFLICT shift  11 */  /* State 11 */ -  {   1,   0,  14}, /*  1:                  ABORT shift  14 */ -  {  97,   1,  17}, /*  2:                REPLACE shift  17 */ -  {  99,   5,  13}, /*  3:               ROLLBACK shift  13 */ -  { 189,   3,  12}, /*  4:            resolvetype shift  12 */ -  {  57,   6,  16}, /*  5:                 IGNORE shift  16 */ -  {  45,   0,  15}, /*  6:                   FAIL shift  15 */ +  { 102,   3,  13}, /*  1:               ROLLBACK shift  13 */ +  { 193,   4,  12}, /*  2:            resolvetype shift  12 */ +  {  60,   6,  16}, /*  3:                 IGNORE shift  16 */ +  {   1,   0,  14}, /*  4:                  ABORT shift  14 */ +  { 100,   0,  17}, /*  5:                REPLACE shift  17 */ +  {  48,   0,  15}, /*  6:                   FAIL shift  15 */  /* State 18 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0,  19}, /*  2:                     nm shift  19 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1,  19}, /*  2:                     nm shift  19 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 23 */ -  { 114,   0,  18}, /*  1:            TRANSACTION shift  18 */ -  { 202,   0,  24}, /*  2:              trans_opt shift  24 */ -  { 104,   0, 540}, /*  3:                   SEMI reduce 9 */ +  { 117,   0,  18}, /*  1:            TRANSACTION shift  18 */ +  { 107,   0, 564}, /*  2:                   SEMI reduce 9 */ +  { 206,   2,  24}, /*  3:              trans_opt shift  24 */  /* State 24 */ -  { 104,   0, 543}, /*  1:                   SEMI reduce 12 */ +  { 107,   0, 567}, /*  1:                   SEMI reduce 12 */  /* State 25 */ -  { 114,   0,  18}, /*  1:            TRANSACTION shift  18 */ -  { 202,   0,  26}, /*  2:              trans_opt shift  26 */ -  { 104,   0, 540}, /*  3:                   SEMI reduce 9 */ +  { 117,   0,  18}, /*  1:            TRANSACTION shift  18 */ +  { 107,   0, 564}, /*  2:                   SEMI reduce 9 */ +  { 206,   2,  26}, /*  3:              trans_opt shift  26 */  /* State 26 */ -  { 104,   0, 544}, /*  1:                   SEMI reduce 13 */ +  { 107,   0, 568}, /*  1:                   SEMI reduce 13 */  /* State 27 */ -  { 114,   0,  18}, /*  1:            TRANSACTION shift  18 */ -  { 202,   0,  28}, /*  2:              trans_opt shift  28 */ -  { 104,   0, 540}, /*  3:                   SEMI reduce 9 */ +  { 117,   0,  18}, /*  1:            TRANSACTION shift  18 */ +  { 107,   0, 564}, /*  2:                   SEMI reduce 9 */ +  { 206,   2,  28}, /*  3:              trans_opt shift  28 */  /* State 28 */ -  { 104,   0, 545}, /*  1:                   SEMI reduce 14 */ +  { 107,   0, 569}, /*  1:                   SEMI reduce 14 */  /* State 29 */ -  {   6,   0, 380}, /*  1:                     AS shift  380 */ -  { 145,   3,  30}, /*  2:      create_table_args shift  30 */ -  {  76,   0,  31}, /*  3:                     LP shift  31 */ +  {   6,   0, 386}, /*  1:                     AS shift  386 */ +  { 148,   3,  30}, /*  2:      create_table_args shift  30 */ +  {  79,   0,  31}, /*  3:                     LP shift  31 */  /* State 30 */ -  { 104,   0, 546}, /*  1:                   SEMI reduce 15 */ +  { 107,   0, 570}, /*  1:                   SEMI reduce 15 */  /* State 31 */ -  { 140,   4,  37}, /*  1:               columnid shift  37 */ -  { 141,   5,  32}, /*  2:             columnlist shift  32 */ -  { 177,   0, 345}, /*  3:                     nm shift  345 */ -  {  56,   0,  20}, /*  4:                     ID shift  20 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 110,   0,  21}, /*  6:                 STRING shift  21 */ -  { 139,   0, 379}, /*  7:                 column shift  379 */ +  {  59,   0,  20}, /*  1:                     ID shift  20 */ +  { 113,   0,  21}, /*  2:                 STRING shift  21 */ +  { 142,   0, 385}, /*  3:                 column shift  385 */ +  { 143,   1,  37}, /*  4:               columnid shift  37 */ +  { 144,   6,  32}, /*  5:             columnlist shift  32 */ +  {  74,   0,  22}, /*  6:                JOIN_KW shift  22 */ +  { 181,   0, 351}, /*  7:                     nm shift  351 */  /* State 32 */ -  {  21,   0,  35}, /*  1:                  COMMA shift  35 */ -  { 101,   0, 607}, /*  2:                     RP reduce 76 */ -  { 143,   2,  33}, /*  3:           conslist_opt shift  33 */ +  { 104,   0, 631}, /*  1:                     RP reduce 76 */ +  {  22,   0,  35}, /*  2:                  COMMA shift  35 */ +  { 146,   1,  33}, /*  3:           conslist_opt shift  33 */  /* State 33 */ -  { 101,   0,  34}, /*  1:                     RP shift  34 */ +  { 104,   0,  34}, /*  1:                     RP shift  34 */  /* State 34 */ -  { 104,   0, 550}, /*  1:                   SEMI reduce 19 */ +  { 107,   0, 574}, /*  1:                   SEMI reduce 19 */  /* State 35 */ -  {  26,   0, 349}, /*  1:             CONSTRAINT shift  349 */ -  {  93,   0, 351}, /*  2:                PRIMARY shift  351 */ -  { 119,   2, 357}, /*  3:                 UNIQUE shift  357 */ -  {  17,   0, 362}, /*  4:                  CHECK shift  362 */ -  {  56,   4,  20}, /*  5:                     ID shift  20 */ -  { 200,   0, 378}, /*  6:                  tcons shift  378 */ -  { 110,   8,  21}, /*  7:                 STRING shift  21 */ -  {  71,   0,  22}, /*  8:                JOIN_KW shift  22 */ -  { 177,   0, 345}, /*  9:                     nm shift  345 */ -  { 139,  12,  36}, /* 10:                 column shift  36 */ -  { 140,   0,  37}, /* 11:               columnid shift  37 */ -  {  48,   0, 365}, /* 12:                FOREIGN shift  365 */ -  { 142,   0, 346}, /* 13:               conslist shift  346 */ +  { 143,   0,  37}, /*  1:               columnid shift  37 */ +  {  27,   0, 355}, /*  2:             CONSTRAINT shift  355 */ +  { 145,   0, 352}, /*  3:               conslist shift  352 */ +  {  96,   5, 357}, /*  4:                PRIMARY shift  357 */ +  {  18,   0, 368}, /*  5:                  CHECK shift  368 */ +  { 122,   4, 363}, /*  6:                 UNIQUE shift  363 */ +  { 113,   9,  21}, /*  7:                 STRING shift  21 */ +  {  59,   0,  20}, /*  8:                     ID shift  20 */ +  {  74,   0,  22}, /*  9:                JOIN_KW shift  22 */ +  { 204,   7, 384}, /* 10:                  tcons shift  384 */ +  { 142,  12,  36}, /* 11:                 column shift  36 */ +  {  51,   0, 371}, /* 12:                FOREIGN shift  371 */ +  { 181,  11, 351}, /* 13:                     nm shift  351 */  /* State 37 */ -  { 160,   5, 344}, /*  1:                    ids shift  344 */ -  {  56,   0, 248}, /*  2:                     ID shift  248 */ -  { 207,   0,  38}, /*  3:                   type shift  38 */ -  { 208,   0, 331}, /*  4:               typename shift  331 */ -  { 110,   0, 249}, /*  5:                 STRING shift  249 */ +  { 165,   0, 350}, /*  1:                    ids shift  350 */ +  { 113,   0, 252}, /*  2:                 STRING shift  252 */ +  { 212,   0,  38}, /*  3:                   type shift  38 */ +  { 213,   2, 337}, /*  4:               typename shift  337 */ +  {  59,   0, 251}, /*  5:                     ID shift  251 */  /* State 38 */ -  { 130,   0,  39}, /*  1:               carglist shift  39 */ +  { 133,   0,  39}, /*  1:               carglist shift  39 */  /* State 39 */ -  {  26,   0,  41}, /*  1:             CONSTRAINT shift  41 */ -  {  93,   0,  54}, /*  2:                PRIMARY shift  54 */ -  { 119,   2,  60}, /*  3:                 UNIQUE shift  60 */ -  { 146,   6, 313}, /*  4:        defer_subclause shift  313 */ -  { 134,   8, 318}, /*  5:                  ccons shift  318 */ -  {  29,   0, 319}, /*  6:                DEFAULT shift  319 */ -  {  84,   9,  44}, /*  7:                   NULL shift  44 */ -  {  95,  10, 291}, /*  8:             REFERENCES shift  291 */ -  {  19,   0, 314}, /*  9:                COLLATE shift  314 */ -  {  82,  11,  46}, /* 10:                    NOT shift  46 */ -  {  30,  12, 316}, /* 11:             DEFERRABLE shift  316 */ -  {  17,   0,  62}, /* 12:                  CHECK shift  62 */ -  { 129,   0,  40}, /* 13:                   carg shift  40 */ +  {  96,   4,  54}, /*  1:                PRIMARY shift  54 */ +  {  27,   0,  41}, /*  2:             CONSTRAINT shift  41 */ +  { 132,   0,  40}, /*  3:                   carg shift  40 */ +  {  31,   5, 325}, /*  4:                DEFAULT shift  325 */ +  {  18,   0,  62}, /*  5:                  CHECK shift  62 */ +  { 122,   1,  60}, /*  6:                 UNIQUE shift  60 */ +  {  32,   0, 322}, /*  7:             DEFERRABLE shift  322 */ +  { 137,  11, 324}, /*  8:                  ccons shift  324 */ +  { 151,   0, 319}, /*  9:        defer_subclause shift  319 */ +  {  87,   0,  44}, /* 10:                   NULL shift  44 */ +  {  98,  12, 297}, /* 11:             REFERENCES shift  297 */ +  {  85,  13,  46}, /* 12:                    NOT shift  46 */ +  {  20,   0, 320}, /* 13:                COLLATE shift  320 */  /* State 41 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0,  42}, /*  2:                     nm shift  42 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1,  42}, /*  2:                     nm shift  42 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 42 */ -  {  30,   0, 316}, /*  1:             DEFERRABLE shift  316 */ -  {  84,   0,  44}, /*  2:                   NULL shift  44 */ -  {  82,   0,  46}, /*  3:                    NOT shift  46 */ -  {  93,   0,  54}, /*  4:                PRIMARY shift  54 */ -  { 134,   2,  43}, /*  5:                  ccons shift  43 */ -  {  95,   0, 291}, /*  6:             REFERENCES shift  291 */ -  { 146,   0, 313}, /*  7:        defer_subclause shift  313 */ -  {  17,   0,  62}, /*  8:                  CHECK shift  62 */ -  {  19,   0, 314}, /*  9:                COLLATE shift  314 */ -  { 119,   9,  60}, /* 10:                 UNIQUE shift  60 */ +  {  20,   0, 320}, /*  1:                COLLATE shift  320 */ +  { 151,   0, 319}, /*  2:        defer_subclause shift  319 */ +  { 122,   4,  60}, /*  3:                 UNIQUE shift  60 */ +  {  32,   0, 322}, /*  4:             DEFERRABLE shift  322 */ +  {  87,   0,  44}, /*  5:                   NULL shift  44 */ +  {  85,   0,  46}, /*  6:                    NOT shift  46 */ +  {  96,   0,  54}, /*  7:                PRIMARY shift  54 */ +  { 137,   5,  43}, /*  8:                  ccons shift  43 */ +  {  98,  10, 297}, /*  9:             REFERENCES shift  297 */ +  {  18,   0,  62}, /* 10:                  CHECK shift  62 */  /* State 44 */ -  { 180,   0,  45}, /*  1:                 onconf shift  45 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ +  { 184,   2,  45}, /*  1:                 onconf shift  45 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 46 */ -  {  84,   2,  47}, /*  1:                   NULL shift  47 */ -  {  30,   0,  49}, /*  2:             DEFERRABLE shift  49 */ +  {  32,   0,  49}, /*  1:             DEFERRABLE shift  49 */ +  {  87,   0,  47}, /*  2:                   NULL shift  47 */  /* State 47 */ -  { 180,   0,  48}, /*  1:                 onconf shift  48 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ +  { 184,   2,  48}, /*  1:                 onconf shift  48 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 49 */ -  { 164,   2,  50}, /*  1: init_deferred_pred_opt shift  50 */ -  {  62,   0,  51}, /*  2:              INITIALLY shift  51 */ +  {  65,   0,  51}, /*  1:              INITIALLY shift  51 */ +  { 169,   1,  50}, /*  2: init_deferred_pred_opt shift  50 */  /* State 51 */ -  {  31,   0,  52}, /*  1:               DEFERRED shift  52 */ -  {  59,   1,  53}, /*  2:              IMMEDIATE shift  53 */ +  {  62,   0,  53}, /*  1:              IMMEDIATE shift  53 */ +  {  33,   0,  52}, /*  2:               DEFERRED shift  52 */  /* State 54 */ -  {  72,   0,  55}, /*  1:                    KEY shift  55 */ +  {  75,   0,  55}, /*  1:                    KEY shift  55 */  /* State 55 */ -  { 198,   0,  56}, /*  1:              sortorder shift  56 */ -  {  34,   3,  59}, /*  2:                   DESC shift  59 */ +  {  36,   0,  59}, /*  1:                   DESC shift  59 */ +  { 202,   3,  56}, /*  2:              sortorder shift  56 */    {   7,   0,  58}, /*  3:                    ASC shift  58 */  /* State 56 */ -  { 180,   0,  57}, /*  1:                 onconf shift  57 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ +  { 184,   2,  57}, /*  1:                 onconf shift  57 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 60 */ -  { 180,   0,  61}, /*  1:                 onconf shift  61 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ +  { 184,   2,  61}, /*  1:                 onconf shift  61 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 62 */ -  {  76,   0,  63}, /*  1:                     LP shift  63 */ +  {  79,   0,  63}, /*  1:                     LP shift  63 */  /* State 63 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 288}, /*  3:                   expr shift  288 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 294}, /*  8:                   expr shift  294 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 64 */ -  {  76,   2,  65}, /*  1:                     LP shift  65 */ -  {  36,   0, 559}, /*  2:                    DOT reduce 28 */ +  {  39,   0, 583}, /*  1:                    DOT reduce 28 */ +  {  79,   1,  65}, /*  2:                     LP shift  65 */  /* State 65 */ -  { 108,   0, 286}, /*  1:                   STAR shift  286 */ -  {  91,   0, 174}, /*  2:                   PLUS shift  174 */ -  { 110,   4,  66}, /*  3:                 STRING shift  66 */ -  {  56,   0,  64}, /*  4:                     ID shift  64 */ -  {  94,   6, 186}, /*  5:                  RAISE shift  186 */ -  {  76,   0,  68}, /*  6:                     LP shift  68 */ -  {  80,   0, 172}, /*  7:                  MINUS shift  172 */ -  {  82,  14, 168}, /*  8:                    NOT shift  168 */ -  { 152,   7, 165}, /*  9:                   expr shift  165 */ -  { 153,   0, 212}, /* 10:               expritem shift  212 */ -  { 154,   8, 284}, /* 11:               exprlist shift  284 */ -  {  65,   0, 166}, /* 12:                INTEGER shift  166 */ -  {  84,  15, 101}, /* 13:                   NULL shift  101 */ -  {  46,   0, 167}, /* 14:                  FLOAT shift  167 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -  { 177,   0, 102}, /* 16:                     nm shift  102 */ -  {  16,   0, 176}, /* 17:                   CASE shift  176 */ -  {  71,   0,  67}, /* 18:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /*  1:                     ID shift  64 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  74,   0,  67}, /*  3:                JOIN_KW shift  67 */ +  { 111,   0, 292}, /*  4:                   STAR shift  292 */ +  {  94,   0, 176}, /*  5:                   PLUS shift  176 */ +  { 113,   1,  66}, /*  6:                 STRING shift  66 */ +  {  79,   0,  68}, /*  7:                     LP shift  68 */ +  {  97,   7, 188}, /*  8:                  RAISE shift  188 */ +  {  85,  10, 170}, /*  9:                    NOT shift  170 */ +  {  49,  11, 169}, /* 10:                  FLOAT shift  169 */ +  {  13,   0, 172}, /* 11:                 BITNOT shift  172 */ +  {  83,   0, 174}, /* 12:                  MINUS shift  174 */ +  {  68,   0, 168}, /* 13:                INTEGER shift  168 */ +  { 157,   9, 167}, /* 14:                   expr shift  167 */ +  { 158,  13, 214}, /* 15:               expritem shift  214 */ +  { 159,  17, 290}, /* 16:               exprlist shift  290 */ +  {  87,   0, 101}, /* 17:                   NULL shift  101 */ +  {  17,   0, 178}, /* 18:                   CASE shift  178 */  /* State 66 */ -  {  36,   0, 560}, /*  1:                    DOT reduce 29 */ +  {  39,   0, 584}, /*  1:                    DOT reduce 29 */  /* State 67 */ -  {  36,   0, 561}, /*  1:                    DOT reduce 30 */ +  {  39,   0, 585}, /*  1:                    DOT reduce 30 */  /* State 68 */ -  {  91,   0, 174}, /*  1:                   PLUS shift  174 */ -  { 181,   1,  69}, /*  2:              oneselect shift  69 */ -  { 110,   4,  66}, /*  3:                 STRING shift  66 */ -  {  56,   0,  64}, /*  4:                     ID shift  64 */ -  {  94,   6, 186}, /*  5:                  RAISE shift  186 */ -  {  76,   0,  68}, /*  6:                     LP shift  68 */ -  {  80,   0, 172}, /*  7:                  MINUS shift  172 */ -  {  46,   0, 167}, /*  8:                  FLOAT shift  167 */ -  { 152,   7, 282}, /*  9:                   expr shift  282 */ -  {  84,  15, 101}, /* 10:                   NULL shift  101 */ -  {  82,   8, 168}, /* 11:                    NOT shift  168 */ -  {  65,   0, 166}, /* 12:                INTEGER shift  166 */ -  { 192,  10,  70}, /* 13:                 select shift  70 */ -  { 103,   0,  73}, /* 14:                 SELECT shift  73 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -  { 177,   0, 102}, /* 16:                     nm shift  102 */ -  {  16,   0, 176}, /* 17:                   CASE shift  176 */ -  {  71,   0,  67}, /* 18:                JOIN_KW shift  67 */ +  { 113,   4,  66}, /*  1:                 STRING shift  66 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  74,   0,  67}, /*  3:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /*  4:                     ID shift  64 */ +  {  94,   0, 176}, /*  5:                   PLUS shift  176 */ +  { 185,   1,  69}, /*  6:              oneselect shift  69 */ +  {  79,   0,  68}, /*  7:                     LP shift  68 */ +  {  97,   7, 188}, /*  8:                  RAISE shift  188 */ +  {  85,  10, 170}, /*  9:                    NOT shift  170 */ +  {  49,  11, 169}, /* 10:                  FLOAT shift  169 */ +  {  13,   0, 172}, /* 11:                 BITNOT shift  172 */ +  {  83,   0, 174}, /* 12:                  MINUS shift  174 */ +  { 106,   0,  73}, /* 13:                 SELECT shift  73 */ +  { 157,   9, 288}, /* 14:                   expr shift  288 */ +  {  68,   0, 168}, /* 15:                INTEGER shift  168 */ +  {  87,   0, 101}, /* 16:                   NULL shift  101 */ +  { 196,  13,  70}, /* 17:                 select shift  70 */ +  {  17,   0, 178}, /* 18:                   CASE shift  178 */  /* State 70 */ -  { 101,   3, 281}, /*  1:                     RP shift  281 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  66,   0, 162}, /*  3:              INTERSECT shift  162 */ -  { 118,   5, 160}, /*  4:                  UNION shift  160 */ -  {  43,   0, 163}, /*  5:                 EXCEPT shift  163 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   3, 162}, /*  2:                  UNION shift  162 */ +  {  46,   0, 165}, /*  3:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  4:              INTERSECT shift  164 */ +  { 104,   4, 287}, /*  5:                     RP shift  287 */  /* State 71 */ -  { 103,   0,  73}, /*  1:                 SELECT shift  73 */ -  { 181,   1,  72}, /*  2:              oneselect shift  72 */ +  { 106,   0,  73}, /*  1:                 SELECT shift  73 */ +  { 185,   0,  72}, /*  2:              oneselect shift  72 */  /* State 73 */ -  {   4,   0, 280}, /*  1:                    ALL shift  280 */ -  { 148,   1,  74}, /*  2:               distinct shift  74 */ -  {  35,   0, 279}, /*  3:               DISTINCT shift  279 */ +  { 153,   0,  74}, /*  1:               distinct shift  74 */ +  {   4,   0, 286}, /*  2:                    ALL shift  286 */ +  {  38,   0, 285}, /*  3:               DISTINCT shift  285 */  /* State 74 */ -  { 190,   0, 272}, /*  1:                   sclp shift  272 */ -  { 191,   0,  75}, /*  2:             selcollist shift  75 */ +  { 194,   0, 278}, /*  1:                   sclp shift  278 */ +  { 195,   0,  75}, /*  2:             selcollist shift  75 */  /* State 75 */ -  { 156,   3,  76}, /*  1:                   from shift  76 */ -  {  49,   0, 235}, /*  2:                   FROM shift  235 */ -  {  21,   0, 234}, /*  3:                  COMMA shift  234 */ +  {  22,   0, 236}, /*  1:                  COMMA shift  236 */ +  {  52,   1, 237}, /*  2:                   FROM shift  237 */ +  { 161,   0,  76}, /*  3:                   from shift  76 */  /* State 76 */ -  { 212,   0,  77}, /*  1:              where_opt shift  77 */ -  { 127,   0, 232}, /*  2:                  WHERE shift  232 */ +  { 130,   0, 234}, /*  1:                  WHERE shift  234 */ +  { 217,   0,  77}, /*  2:              where_opt shift  77 */  /* State 77 */ -  {  53,   0, 229}, /*  1:                  GROUP shift  229 */ -  { 157,   1,  78}, /*  2:            groupby_opt shift  78 */ +  { 162,   2,  78}, /*  1:            groupby_opt shift  78 */ +  {  56,   0, 231}, /*  2:                  GROUP shift  231 */  /* State 78 */ -  { 158,   0,  79}, /*  1:             having_opt shift  79 */ -  {  55,   0, 227}, /*  2:                 HAVING shift  227 */ +  {  58,   0, 229}, /*  1:                 HAVING shift  229 */ +  { 163,   0,  79}, /*  2:             having_opt shift  79 */  /* State 79 */ -  {  90,   0,  88}, /*  1:                  ORDER shift  88 */ -  { 183,   0,  80}, /*  2:            orderby_opt shift  80 */ +  {  93,   0,  88}, /*  1:                  ORDER shift  88 */ +  { 187,   1,  80}, /*  2:            orderby_opt shift  80 */  /* State 80 */ -  {  75,   0,  82}, /*  1:                  LIMIT shift  82 */ -  { 173,   1,  81}, /*  2:              limit_opt shift  81 */ +  { 178,   2,  81}, /*  1:              limit_opt shift  81 */ +  {  78,   0,  82}, /*  2:                  LIMIT shift  82 */  /* State 82 */ -  {  65,   0,  83}, /*  1:                INTEGER shift  83 */ +  {  68,   0,  83}, /*  1:                INTEGER shift  83 */  /* State 83 */ -  { 174,   2,  84}, /*  1:              limit_sep shift  84 */ -  {  21,   0,  87}, /*  2:                  COMMA shift  87 */ -  {  86,   0,  86}, /*  3:                 OFFSET shift  86 */ +  {  22,   0,  86}, /*  1:                  COMMA shift  86 */ +  {  89,   0,  84}, /*  2:                 OFFSET shift  84 */  /* State 84 */ -  {  65,   0,  85}, /*  1:                INTEGER shift  85 */ +  {  68,   0,  85}, /*  1:                INTEGER shift  85 */  /* State 86 */ -  {  65,   0, 682}, /*  1:                INTEGER reduce 151 */ -/* State 87 */ -  {  65,   0, 683}, /*  1:                INTEGER reduce 152 */ +  {  68,   0,  87}, /*  1:                INTEGER shift  87 */  /* State 88 */ -  {  14,   0,  89}, /*  1:                     BY shift  89 */ +  {  15,   0,  89}, /*  1:                     BY shift  89 */  /* State 89 */ -  {  76,   0,  68}, /*  1:                     LP shift  68 */ -  {  94,   0, 186}, /*  2:                  RAISE shift  186 */ -  {  46,   5, 167}, /*  3:                  FLOAT shift  167 */ -  {  71,   0,  67}, /*  4:                JOIN_KW shift  67 */ -  {  12,   0, 170}, /*  5:                 BITNOT shift  170 */ -  {  56,   0,  64}, /*  6:                     ID shift  64 */ -  {  91,   0, 174}, /*  7:                   PLUS shift  174 */ -  { 177,   0, 102}, /*  8:                     nm shift  102 */ -  { 110,   1,  66}, /*  9:                 STRING shift  66 */ -  { 196,   2, 224}, /* 10:               sortitem shift  224 */ -  { 197,   0,  90}, /* 11:               sortlist shift  90 */ -  {  65,   0, 166}, /* 12:                INTEGER shift  166 */ -  {  80,   3, 172}, /* 13:                  MINUS shift  172 */ -  {  84,  16, 101}, /* 14:                   NULL shift  101 */ -  {  82,  12, 168}, /* 15:                    NOT shift  168 */ -  {  16,   0, 176}, /* 16:                   CASE shift  176 */ -  { 152,  14,  98}, /* 17:                   expr shift  98 */ +  {  85,   2, 170}, /*  1:                    NOT shift  170 */ +  {  68,   4, 168}, /*  2:                INTEGER shift  168 */ +  {  87,   0, 101}, /*  3:                   NULL shift  101 */ +  {  17,   0, 178}, /*  4:                   CASE shift  178 */ +  { 157,   0,  98}, /*  5:                   expr shift  98 */ +  { 113,   8,  66}, /*  6:                 STRING shift  66 */ +  {  74,   0,  67}, /*  7:                JOIN_KW shift  67 */ +  {  79,   0,  68}, /*  8:                     LP shift  68 */ +  {  59,   0,  64}, /*  9:                     ID shift  64 */ +  {  94,   0, 176}, /* 10:                   PLUS shift  176 */ +  {  13,   0, 172}, /* 11:                 BITNOT shift  172 */ +  { 181,   6, 102}, /* 12:                     nm shift  102 */ +  {  97,   0, 188}, /* 13:                  RAISE shift  188 */ +  { 200,  11, 226}, /* 14:               sortitem shift  226 */ +  { 201,   0,  90}, /* 15:               sortlist shift  90 */ +  {  83,  17, 174}, /* 16:                  MINUS shift  174 */ +  {  49,   0, 169}, /* 17:                  FLOAT shift  169 */  /* State 90 */ -  {  21,   0,  91}, /*  1:                  COMMA shift  91 */ +  {  22,   0,  91}, /*  1:                  COMMA shift  91 */  /* State 91 */ -  {  80,   4, 172}, /*  1:                  MINUS shift  172 */ -  { 177,   6, 102}, /*  2:                     nm shift  102 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  {  16,   0, 176}, /*  4:                   CASE shift  176 */ -  { 196,   7,  92}, /*  5:               sortitem shift  92 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  84,   0, 101}, /*  7:                   NULL shift  101 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,  10,  98}, /*  9:                   expr shift  98 */ -  {  56,   0,  64}, /* 10:                     ID shift  64 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  91,   0, 174}, /* 12:                   PLUS shift  174 */ -  {  76,  11,  68}, /* 13:                     LP shift  68 */ -  {  94,  16, 186}, /* 14:                  RAISE shift  186 */ -  { 110,  14,  66}, /* 15:                 STRING shift  66 */ -  {  46,   0, 167}, /* 16:                  FLOAT shift  167 */ +  {  97,   3, 188}, /*  1:                  RAISE shift  188 */ +  { 113,   1,  66}, /*  2:                 STRING shift  66 */ +  {  49,   7, 169}, /*  3:                  FLOAT shift  169 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  68,   0, 168}, /*  5:                INTEGER shift  168 */ +  { 181,  10, 102}, /*  6:                     nm shift  102 */ +  {  17,   0, 178}, /*  7:                   CASE shift  178 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  { 200,   0,  92}, /*  9:               sortitem shift  92 */ +  {  85,   0, 170}, /* 10:                    NOT shift  170 */ +  {  74,   0,  67}, /* 11:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  13,   0, 172}, /* 13:                 BITNOT shift  172 */ +  { 157,  13,  98}, /* 14:                   expr shift  98 */ +  {  94,   0, 176}, /* 15:                   PLUS shift  176 */ +  {  79,   0,  68}, /* 16:                     LP shift  68 */  /* State 92 */ -  { 138,   0,  93}, /*  1:                collate shift  93 */ -  {  19,   0,  95}, /*  2:                COLLATE shift  95 */ +  {  20,   0,  95}, /*  1:                COLLATE shift  95 */ +  { 141,   0,  93}, /*  2:                collate shift  93 */  /* State 93 */ -  { 198,   0,  94}, /*  1:              sortorder shift  94 */ -  {  34,   3,  59}, /*  2:                   DESC shift  59 */ +  {  36,   0,  59}, /*  1:                   DESC shift  59 */ +  { 202,   3,  94}, /*  2:              sortorder shift  94 */    {   7,   0,  58}, /*  3:                    ASC shift  58 */  /* State 95 */ -  {  56,   0,  96}, /*  1:                     ID shift  96 */ -  { 159,   0,  97}, /*  2:                     id shift  97 */ +  { 164,   0,  97}, /*  1:                     id shift  97 */ +  {  59,   0,  96}, /*  2:                     ID shift  96 */  /* State 98 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 100 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 105}, /*  3:                   expr shift  105 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 107}, /*  8:                   expr shift  107 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 102 */ -  {  36,   0, 103}, /*  1:                    DOT shift  103 */ +  {  39,   0, 103}, /*  1:                    DOT shift  103 */  /* State 103 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 104}, /*  2:                     nm shift  104 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 104}, /*  2:                     nm shift  104 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 104 */ +  {  39,   0, 105}, /*  1:                    DOT shift  105 */  /* State 105 */ -  {  78,   2, 108}, /*  1:                     LT shift  108 */ -  {  52,   0, 134}, /*  2:                   GLOB shift  134 */ -  { 106,   7, 141}, /*  3:                  SLASH shift  141 */ -  {  81,   0, 116}, /*  4:                     NE shift  116 */ -  { 108,   8, 139}, /*  5:                   STAR shift  139 */ -  {  83,   0, 152}, /*  6:                NOTNULL shift  152 */ -  {  80,  10, 137}, /*  7:                  MINUS shift  137 */ -  {  82,   0, 130}, /*  8:                    NOT shift  130 */ -  {  60,   0, 157}, /*  9:                     IN shift  157 */ -  {  54,   0, 110}, /* 10:                     GT shift  110 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  89,  13,  99}, /* 12:      ORACLE_OUTER_JOIN shift  99 */ -  {  11,   0, 120}, /* 13:                 BITAND shift  120 */ -  {  91,  15, 135}, /* 14:                   PLUS shift  135 */ -  {  13,   0, 122}, /* 15:                  BITOR shift  122 */ -  {  68,  20, 148}, /* 16:                     IS shift  148 */ -  { 172,  16, 128}, /* 17:                 likeop shift  128 */ -  {  69,   0, 147}, /* 18:                 ISNULL shift  147 */ -  {  96,   0, 143}, /* 19:                    REM shift  143 */ -  {  42,   0, 118}, /* 20:                     EQ shift  118 */ -  {  24,   0, 145}, /* 21:                 CONCAT shift  145 */ -  {  73,   0, 112}, /* 22:                     LE shift  112 */ -  {  74,   0, 133}, /* 23:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 102,  21, 126}, /* 25:                 RSHIFT shift  126 */ -  {  77,  24, 124}, /* 26:                 LSHIFT shift  124 */ -/* State 106 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 107}, /*  3:                   expr shift  107 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 106}, /*  2:                     nm shift  106 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 107 */ -  { 108,   4, 139}, /*  1:                   STAR shift  139 */ -  {  82,   0, 130}, /*  2:                    NOT shift  130 */ -  {  83,   0, 152}, /*  3:                NOTNULL shift  152 */ -  {  81,   5, 116}, /*  4:                     NE shift  116 */ -  {  54,   0, 110}, /*  5:                     GT shift  110 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  60,   0, 157}, /*  7:                     IN shift  157 */ -  {  91,  10, 135}, /*  8:                   PLUS shift  135 */ -  {  89,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /* 10:                BETWEEN shift  153 */ -  { 172,   8, 128}, /* 11:                 likeop shift  128 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  69,  17, 147}, /* 13:                 ISNULL shift  147 */ -  {  13,   0, 122}, /* 14:                  BITOR shift  122 */ -  {  68,   0, 148}, /* 15:                     IS shift  148 */ -  {  96,  13, 143}, /* 16:                    REM shift  143 */ -  {  42,   0, 118}, /* 17:                     EQ shift  118 */ -  {  51,  19, 114}, /* 18:                     GE shift  114 */ -  {  24,   0, 145}, /* 19:                 CONCAT shift  145 */ -  {  73,   0, 112}, /* 20:                     LE shift  112 */ -  {  74,   0, 133}, /* 21:                   LIKE shift  133 */ -  { 102,   0, 126}, /* 22:                 RSHIFT shift  126 */ -  {  52,   0, 134}, /* 23:                   GLOB shift  134 */ -  {  77,   0, 124}, /* 24:                 LSHIFT shift  124 */ -  {  78,  18, 108}, /* 25:                     LT shift  108 */ -  { 106,  23, 141}, /* 26:                  SLASH shift  141 */ -  {  80,   0, 137}, /* 27:                  MINUS shift  137 */ +  {  54,   0, 116}, /*  1:                     GE shift  116 */ +  { 105,   0, 128}, /*  2:                 RSHIFT shift  128 */ +  {  80,   1, 126}, /*  3:                 LSHIFT shift  126 */ +  {  81,   5, 110}, /*  4:                     LT shift  110 */ +  {  55,   0, 136}, /*  5:                   GLOB shift  136 */ +  { 109,  10, 143}, /*  6:                  SLASH shift  143 */ +  {  84,   0, 118}, /*  7:                     NE shift  118 */ +  { 111,  11, 141}, /*  8:                   STAR shift  141 */ +  {  86,   0, 154}, /*  9:                NOTNULL shift  154 */ +  {  83,  14, 139}, /* 10:                  MINUS shift  139 */ +  {  85,   0, 132}, /* 11:                    NOT shift  132 */ +  {  63,  16, 159}, /* 12:                     IN shift  159 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  57,   0, 112}, /* 14:                     GT shift  112 */ +  {  92,  18,  99}, /* 15:      ORACLE_OUTER_JOIN shift  99 */ +  {  11,   0, 155}, /* 16:                BETWEEN shift  155 */ +  {  94,   0, 137}, /* 17:                   PLUS shift  137 */ +  {  14,   0, 124}, /* 18:                  BITOR shift  124 */ +  {  45,   0, 120}, /* 19:                     EQ shift  120 */ +  {  71,  19, 150}, /* 20:                     IS shift  150 */ +  {  72,   0, 149}, /* 21:                 ISNULL shift  149 */ +  { 177,  23, 130}, /* 22:                 likeop shift  130 */ +  {  99,   0, 145}, /* 23:                    REM shift  145 */ +  {  25,   0, 147}, /* 24:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 25:                     LE shift  114 */ +  {  77,  24, 135}, /* 26:                   LIKE shift  135 */  /* State 108 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 109}, /*  3:                   expr shift  109 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 109}, /*  8:                   expr shift  109 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 109 */ -  { 108,   3, 139}, /*  1:                   STAR shift  139 */ -  {  13,   0, 122}, /*  2:                  BITOR shift  122 */ -  {  96,   4, 143}, /*  3:                    REM shift  143 */ -  {  24,   0, 145}, /*  4:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  5:                 likeop shift  128 */ -  {  89,  10,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  { 102,   0, 126}, /*  7:                 RSHIFT shift  126 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  80,   0, 137}, /*  9:                  MINUS shift  137 */ -  {  77,   0, 124}, /* 10:                 LSHIFT shift  124 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ +  {  81,   7, 110}, /*  1:                     LT shift  110 */ +  { 109,   8, 143}, /*  2:                  SLASH shift  143 */ +  {  83,   0, 139}, /*  3:                  MINUS shift  139 */ +  { 111,   9, 141}, /*  4:                   STAR shift  141 */ +  {  85,   0, 132}, /*  5:                    NOT shift  132 */ +  {  86,  11, 154}, /*  6:                NOTNULL shift  154 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  55,   0, 136}, /*  8:                   GLOB shift  136 */ +  {  84,  17, 118}, /*  9:                     NE shift  118 */ +  {  63,   0, 159}, /* 10:                     IN shift  159 */ +  {   5,   0, 100}, /* 11:                    AND shift  100 */ +  {  92,  20,  99}, /* 12:      ORACLE_OUTER_JOIN shift  99 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  94,   0, 137}, /* 14:                   PLUS shift  137 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  { 177,   0, 130}, /* 16:                 likeop shift  130 */ +  {  57,   0, 112}, /* 17:                     GT shift  112 */ +  {  71,   0, 150}, /* 18:                     IS shift  150 */ +  {  99,  21, 145}, /* 19:                    REM shift  145 */ +  {  11,   0, 155}, /* 20:                BETWEEN shift  155 */ +  {  72,  22, 149}, /* 21:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 22:                     EQ shift  120 */ +  {  76,   0, 114}, /* 23:                     LE shift  114 */ +  {  77,   0, 135}, /* 24:                   LIKE shift  135 */ +  { 105,   0, 128}, /* 25:                 RSHIFT shift  128 */ +  {  25,   0, 147}, /* 26:                 CONCAT shift  147 */ +  {  80,   0, 126}, /* 27:                 LSHIFT shift  126 */  /* State 110 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 111}, /*  3:                   expr shift  111 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 111}, /*  8:                   expr shift  111 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 111 */ -  { 108,   3, 139}, /*  1:                   STAR shift  139 */ -  {  13,   0, 122}, /*  2:                  BITOR shift  122 */ -  {  96,   4, 143}, /*  3:                    REM shift  143 */ -  {  24,   0, 145}, /*  4:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  5:                 likeop shift  128 */ -  {  89,  10,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  { 102,   0, 126}, /*  7:                 RSHIFT shift  126 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  80,   0, 137}, /*  9:                  MINUS shift  137 */ -  {  77,   0, 124}, /* 10:                 LSHIFT shift  124 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ +  {  12,   0, 122}, /*  1:                 BITAND shift  122 */ +  { 109,   5, 143}, /*  2:                  SLASH shift  143 */ +  {  14,   0, 124}, /*  3:                  BITOR shift  124 */ +  { 111,   6, 141}, /*  4:                   STAR shift  141 */ +  {  25,   0, 147}, /*  5:                 CONCAT shift  147 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */ +  {  80,   0, 126}, /*  7:                 LSHIFT shift  126 */ +  { 105,   0, 128}, /*  8:                 RSHIFT shift  128 */ +  {  92,   7,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   8, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  83,   0, 139}, /* 12:                  MINUS shift  139 */  /* State 112 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 113}, /*  3:                   expr shift  113 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 113}, /*  8:                   expr shift  113 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 113 */ -  { 108,   3, 139}, /*  1:                   STAR shift  139 */ -  {  13,   0, 122}, /*  2:                  BITOR shift  122 */ -  {  96,   4, 143}, /*  3:                    REM shift  143 */ -  {  24,   0, 145}, /*  4:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  5:                 likeop shift  128 */ -  {  89,  10,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  { 102,   0, 126}, /*  7:                 RSHIFT shift  126 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  80,   0, 137}, /*  9:                  MINUS shift  137 */ -  {  77,   0, 124}, /* 10:                 LSHIFT shift  124 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ +  {  12,   0, 122}, /*  1:                 BITAND shift  122 */ +  { 109,   5, 143}, /*  2:                  SLASH shift  143 */ +  {  14,   0, 124}, /*  3:                  BITOR shift  124 */ +  { 111,   6, 141}, /*  4:                   STAR shift  141 */ +  {  25,   0, 147}, /*  5:                 CONCAT shift  147 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */ +  {  80,   0, 126}, /*  7:                 LSHIFT shift  126 */ +  { 105,   0, 128}, /*  8:                 RSHIFT shift  128 */ +  {  92,   7,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   8, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  83,   0, 139}, /* 12:                  MINUS shift  139 */  /* State 114 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 115}, /*  3:                   expr shift  115 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 115}, /*  8:                   expr shift  115 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 115 */ -  { 108,   3, 139}, /*  1:                   STAR shift  139 */ -  {  13,   0, 122}, /*  2:                  BITOR shift  122 */ -  {  96,   4, 143}, /*  3:                    REM shift  143 */ -  {  24,   0, 145}, /*  4:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  5:                 likeop shift  128 */ -  {  89,  10,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  { 102,   0, 126}, /*  7:                 RSHIFT shift  126 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  80,   0, 137}, /*  9:                  MINUS shift  137 */ -  {  77,   0, 124}, /* 10:                 LSHIFT shift  124 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ +  {  12,   0, 122}, /*  1:                 BITAND shift  122 */ +  { 109,   5, 143}, /*  2:                  SLASH shift  143 */ +  {  14,   0, 124}, /*  3:                  BITOR shift  124 */ +  { 111,   6, 141}, /*  4:                   STAR shift  141 */ +  {  25,   0, 147}, /*  5:                 CONCAT shift  147 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */ +  {  80,   0, 126}, /*  7:                 LSHIFT shift  126 */ +  { 105,   0, 128}, /*  8:                 RSHIFT shift  128 */ +  {  92,   7,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   8, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  83,   0, 139}, /* 12:                  MINUS shift  139 */  /* State 116 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 117}, /*  3:                   expr shift  117 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 117}, /*  8:                   expr shift  117 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 117 */ -  {  96,   2, 143}, /*  1:                    REM shift  143 */ -  {  80,   0, 137}, /*  2:                  MINUS shift  137 */ -  {  54,   0, 110}, /*  3:                     GT shift  110 */ -  {  51,   0, 114}, /*  4:                     GE shift  114 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {  11,   0, 120}, /*  6:                 BITAND shift  120 */ -  { 102,   3, 126}, /*  7:                 RSHIFT shift  126 */ -  { 108,   0, 139}, /*  8:                   STAR shift  139 */ -  {  24,   0, 145}, /*  9:                 CONCAT shift  145 */ -  {  89,   5,  99}, /* 10:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  91,   6, 135}, /* 12:                   PLUS shift  135 */ -  { 172,   8, 128}, /* 13:                 likeop shift  128 */ -  {  77,  16, 124}, /* 14:                 LSHIFT shift  124 */ -  {  78,   0, 108}, /* 15:                     LT shift  108 */ -  {  13,   0, 122}, /* 16:                  BITOR shift  122 */ +  {  12,   0, 122}, /*  1:                 BITAND shift  122 */ +  { 109,   5, 143}, /*  2:                  SLASH shift  143 */ +  {  14,   0, 124}, /*  3:                  BITOR shift  124 */ +  { 111,   6, 141}, /*  4:                   STAR shift  141 */ +  {  25,   0, 147}, /*  5:                 CONCAT shift  147 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */ +  {  80,   0, 126}, /*  7:                 LSHIFT shift  126 */ +  { 105,   0, 128}, /*  8:                 RSHIFT shift  128 */ +  {  92,   7,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   8, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  83,   0, 139}, /* 12:                  MINUS shift  139 */  /* State 118 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 119}, /*  3:                   expr shift  119 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 119}, /*  8:                   expr shift  119 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 119 */ -  {  96,   2, 143}, /*  1:                    REM shift  143 */ -  {  80,   0, 137}, /*  2:                  MINUS shift  137 */ -  {  54,   0, 110}, /*  3:                     GT shift  110 */ -  {  51,   0, 114}, /*  4:                     GE shift  114 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {  11,   0, 120}, /*  6:                 BITAND shift  120 */ -  { 102,   3, 126}, /*  7:                 RSHIFT shift  126 */ -  { 108,   0, 139}, /*  8:                   STAR shift  139 */ -  {  24,   0, 145}, /*  9:                 CONCAT shift  145 */ -  {  89,   5,  99}, /* 10:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  91,   6, 135}, /* 12:                   PLUS shift  135 */ -  { 172,   8, 128}, /* 13:                 likeop shift  128 */ -  {  77,  16, 124}, /* 14:                 LSHIFT shift  124 */ -  {  78,   0, 108}, /* 15:                     LT shift  108 */ -  {  13,   0, 122}, /* 16:                  BITOR shift  122 */ +  {  80,   0, 126}, /*  1:                 LSHIFT shift  126 */ +  { 177,   3, 130}, /*  2:                 likeop shift  130 */ +  {  81,   0, 110}, /*  3:                     LT shift  110 */ +  {  99,   5, 145}, /*  4:                    REM shift  145 */ +  {  83,   0, 139}, /*  5:                  MINUS shift  139 */ +  {  57,   8, 112}, /*  6:                     GT shift  112 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  25,   0, 147}, /*  8:                 CONCAT shift  147 */ +  {  76,  11, 114}, /*  9:                     LE shift  114 */ +  { 105,   6, 128}, /* 10:                 RSHIFT shift  128 */ +  {  12,   0, 122}, /* 11:                 BITAND shift  122 */ +  {  14,   0, 124}, /* 12:                  BITOR shift  124 */ +  {  92,   9,  99}, /* 13:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /* 14:                  SLASH shift  143 */ +  {  94,  12, 137}, /* 15:                   PLUS shift  137 */ +  { 111,   0, 141}, /* 16:                   STAR shift  141 */  /* State 120 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 121}, /*  3:                   expr shift  121 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 121}, /*  8:                   expr shift  121 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 121 */ -  {  96,   6, 143}, /*  1:                    REM shift  143 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /*  3:                  SLASH shift  141 */ -  {  91,   0, 135}, /*  4:                   PLUS shift  135 */ -  { 172,   7, 128}, /*  5:                 likeop shift  128 */ -  {  80,   8, 137}, /*  6:                  MINUS shift  137 */ -  { 108,   0, 139}, /*  7:                   STAR shift  139 */ -  {  24,   0, 145}, /*  8:                 CONCAT shift  145 */ +  {  80,   0, 126}, /*  1:                 LSHIFT shift  126 */ +  { 177,   3, 130}, /*  2:                 likeop shift  130 */ +  {  81,   0, 110}, /*  3:                     LT shift  110 */ +  {  99,   5, 145}, /*  4:                    REM shift  145 */ +  {  83,   0, 139}, /*  5:                  MINUS shift  139 */ +  {  57,   8, 112}, /*  6:                     GT shift  112 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  25,   0, 147}, /*  8:                 CONCAT shift  147 */ +  {  76,  11, 114}, /*  9:                     LE shift  114 */ +  { 105,   6, 128}, /* 10:                 RSHIFT shift  128 */ +  {  12,   0, 122}, /* 11:                 BITAND shift  122 */ +  {  14,   0, 124}, /* 12:                  BITOR shift  124 */ +  {  92,   9,  99}, /* 13:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /* 14:                  SLASH shift  143 */ +  {  94,  12, 137}, /* 15:                   PLUS shift  137 */ +  { 111,   0, 141}, /* 16:                   STAR shift  141 */  /* State 122 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 123}, /*  3:                   expr shift  123 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 123}, /*  8:                   expr shift  123 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 123 */ -  {  96,   6, 143}, /*  1:                    REM shift  143 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /*  3:                  SLASH shift  141 */ -  {  91,   0, 135}, /*  4:                   PLUS shift  135 */ -  { 172,   7, 128}, /*  5:                 likeop shift  128 */ -  {  80,   8, 137}, /*  6:                  MINUS shift  137 */ -  { 108,   0, 139}, /*  7:                   STAR shift  139 */ -  {  24,   0, 145}, /*  8:                 CONCAT shift  145 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 177,   1, 130}, /*  2:                 likeop shift  130 */ +  {  83,   0, 139}, /*  3:                  MINUS shift  139 */ +  {  99,   3, 145}, /*  4:                    REM shift  145 */ +  {  92,   0,  99}, /*  5:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /*  6:                  SLASH shift  143 */ +  {  94,   0, 137}, /*  7:                   PLUS shift  137 */ +  { 111,   0, 141}, /*  8:                   STAR shift  141 */  /* State 124 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 125}, /*  3:                   expr shift  125 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 125}, /*  8:                   expr shift  125 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 125 */ -  {  96,   6, 143}, /*  1:                    REM shift  143 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /*  3:                  SLASH shift  141 */ -  {  91,   0, 135}, /*  4:                   PLUS shift  135 */ -  { 172,   7, 128}, /*  5:                 likeop shift  128 */ -  {  80,   8, 137}, /*  6:                  MINUS shift  137 */ -  { 108,   0, 139}, /*  7:                   STAR shift  139 */ -  {  24,   0, 145}, /*  8:                 CONCAT shift  145 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 177,   1, 130}, /*  2:                 likeop shift  130 */ +  {  83,   0, 139}, /*  3:                  MINUS shift  139 */ +  {  99,   3, 145}, /*  4:                    REM shift  145 */ +  {  92,   0,  99}, /*  5:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /*  6:                  SLASH shift  143 */ +  {  94,   0, 137}, /*  7:                   PLUS shift  137 */ +  { 111,   0, 141}, /*  8:                   STAR shift  141 */  /* State 126 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 127}, /*  3:                   expr shift  127 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 127}, /*  8:                   expr shift  127 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 127 */ -  {  96,   6, 143}, /*  1:                    REM shift  143 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /*  3:                  SLASH shift  141 */ -  {  91,   0, 135}, /*  4:                   PLUS shift  135 */ -  { 172,   7, 128}, /*  5:                 likeop shift  128 */ -  {  80,   8, 137}, /*  6:                  MINUS shift  137 */ -  { 108,   0, 139}, /*  7:                   STAR shift  139 */ -  {  24,   0, 145}, /*  8:                 CONCAT shift  145 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 177,   1, 130}, /*  2:                 likeop shift  130 */ +  {  83,   0, 139}, /*  3:                  MINUS shift  139 */ +  {  99,   3, 145}, /*  4:                    REM shift  145 */ +  {  92,   0,  99}, /*  5:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /*  6:                  SLASH shift  143 */ +  {  94,   0, 137}, /*  7:                   PLUS shift  137 */ +  { 111,   0, 141}, /*  8:                   STAR shift  141 */  /* State 128 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 129}, /*  3:                   expr shift  129 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 129}, /*  8:                   expr shift  129 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 129 */ -  {  96,   2, 143}, /*  1:                    REM shift  143 */ -  {  80,   0, 137}, /*  2:                  MINUS shift  137 */ -  {  54,   0, 110}, /*  3:                     GT shift  110 */ -  {  51,   0, 114}, /*  4:                     GE shift  114 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {  11,   0, 120}, /*  6:                 BITAND shift  120 */ -  { 102,   3, 126}, /*  7:                 RSHIFT shift  126 */ -  { 108,   0, 139}, /*  8:                   STAR shift  139 */ -  {  24,   0, 145}, /*  9:                 CONCAT shift  145 */ -  {  89,   5,  99}, /* 10:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  91,   6, 135}, /* 12:                   PLUS shift  135 */ -  { 172,   8, 128}, /* 13:                 likeop shift  128 */ -  {  77,  16, 124}, /* 14:                 LSHIFT shift  124 */ -  {  78,   0, 108}, /* 15:                     LT shift  108 */ -  {  13,   0, 122}, /* 16:                  BITOR shift  122 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 177,   1, 130}, /*  2:                 likeop shift  130 */ +  {  83,   0, 139}, /*  3:                  MINUS shift  139 */ +  {  99,   3, 145}, /*  4:                    REM shift  145 */ +  {  92,   0,  99}, /*  5:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /*  6:                  SLASH shift  143 */ +  {  94,   0, 137}, /*  7:                   PLUS shift  137 */ +  { 111,   0, 141}, /*  8:                   STAR shift  141 */  /* State 130 */ -  {  84,   2, 213}, /*  1:                   NULL shift  213 */ -  {  60,   0, 218}, /*  2:                     IN shift  218 */ -  {  74,   0, 133}, /*  3:                   LIKE shift  133 */ -  {  52,   6, 134}, /*  4:                   GLOB shift  134 */ -  { 172,   4, 131}, /*  5:                 likeop shift  131 */ -  {  10,   0, 214}, /*  6:                BETWEEN shift  214 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 131}, /*  8:                   expr shift  131 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 131 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 132}, /*  3:                   expr shift  132 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  80,   0, 126}, /*  1:                 LSHIFT shift  126 */ +  { 177,   3, 130}, /*  2:                 likeop shift  130 */ +  {  81,   0, 110}, /*  3:                     LT shift  110 */ +  {  99,   5, 145}, /*  4:                    REM shift  145 */ +  {  83,   0, 139}, /*  5:                  MINUS shift  139 */ +  {  57,   8, 112}, /*  6:                     GT shift  112 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  25,   0, 147}, /*  8:                 CONCAT shift  147 */ +  {  76,  11, 114}, /*  9:                     LE shift  114 */ +  { 105,   6, 128}, /* 10:                 RSHIFT shift  128 */ +  {  12,   0, 122}, /* 11:                 BITAND shift  122 */ +  {  14,   0, 124}, /* 12:                  BITOR shift  124 */ +  {  92,   9,  99}, /* 13:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /* 14:                  SLASH shift  143 */ +  {  94,  12, 137}, /* 15:                   PLUS shift  137 */ +  { 111,   0, 141}, /* 16:                   STAR shift  141 */  /* State 132 */ -  {  96,   2, 143}, /*  1:                    REM shift  143 */ -  {  80,   0, 137}, /*  2:                  MINUS shift  137 */ -  {  54,   0, 110}, /*  3:                     GT shift  110 */ -  {  51,   0, 114}, /*  4:                     GE shift  114 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {  11,   0, 120}, /*  6:                 BITAND shift  120 */ -  { 102,   3, 126}, /*  7:                 RSHIFT shift  126 */ -  { 108,   0, 139}, /*  8:                   STAR shift  139 */ -  {  24,   0, 145}, /*  9:                 CONCAT shift  145 */ -  {  89,   5,  99}, /* 10:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  91,   6, 135}, /* 12:                   PLUS shift  135 */ -  { 172,   8, 128}, /* 13:                 likeop shift  128 */ -  {  77,  16, 124}, /* 14:                 LSHIFT shift  124 */ -  {  78,   0, 108}, /* 15:                     LT shift  108 */ -  {  13,   0, 122}, /* 16:                  BITOR shift  122 */ -/* State 135 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 136}, /*  3:                   expr shift  136 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 136 */ -  { 108,   2, 139}, /*  1:                   STAR shift  139 */ -  {  96,   3, 143}, /*  2:                    REM shift  143 */ -  {  24,   0, 145}, /*  3:                 CONCAT shift  145 */ -  { 106,   0, 141}, /*  4:                  SLASH shift  141 */ -  { 172,   4, 128}, /*  5:                 likeop shift  128 */ -  {  89,   0,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  87,   3, 215}, /*  1:                   NULL shift  215 */ +  {  55,   0, 136}, /*  2:                   GLOB shift  136 */ +  {  63,   0, 220}, /*  3:                     IN shift  220 */ +  { 177,   1, 133}, /*  4:                 likeop shift  133 */ +  {  11,   0, 216}, /*  5:                BETWEEN shift  216 */ +  {  77,   5, 135}, /*  6:                   LIKE shift  135 */ +/* State 133 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 134}, /*  8:                   expr shift  134 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */ +/* State 134 */ +  {  80,   0, 126}, /*  1:                 LSHIFT shift  126 */ +  { 177,   3, 130}, /*  2:                 likeop shift  130 */ +  {  81,   0, 110}, /*  3:                     LT shift  110 */ +  {  99,   5, 145}, /*  4:                    REM shift  145 */ +  {  83,   0, 139}, /*  5:                  MINUS shift  139 */ +  {  57,   8, 112}, /*  6:                     GT shift  112 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  25,   0, 147}, /*  8:                 CONCAT shift  147 */ +  {  76,  11, 114}, /*  9:                     LE shift  114 */ +  { 105,   6, 128}, /* 10:                 RSHIFT shift  128 */ +  {  12,   0, 122}, /* 11:                 BITAND shift  122 */ +  {  14,   0, 124}, /* 12:                  BITOR shift  124 */ +  {  92,   9,  99}, /* 13:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /* 14:                  SLASH shift  143 */ +  {  94,  12, 137}, /* 15:                   PLUS shift  137 */ +  { 111,   0, 141}, /* 16:                   STAR shift  141 */  /* State 137 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 138}, /*  3:                   expr shift  138 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 138}, /*  8:                   expr shift  138 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 138 */ -  { 108,   2, 139}, /*  1:                   STAR shift  139 */ -  {  96,   3, 143}, /*  2:                    REM shift  143 */ -  {  24,   0, 145}, /*  3:                 CONCAT shift  145 */ -  { 106,   0, 141}, /*  4:                  SLASH shift  141 */ -  { 172,   4, 128}, /*  5:                 likeop shift  128 */ -  {  89,   0,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 109,   1, 143}, /*  2:                  SLASH shift  143 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   5, 130}, /*  4:                 likeop shift  130 */ +  { 111,   6, 141}, /*  5:                   STAR shift  141 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */  /* State 139 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 140}, /*  3:                   expr shift  140 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 140}, /*  8:                   expr shift  140 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 140 */ -  {  24,   0, 145}, /*  1:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  2:                 likeop shift  128 */ -  {  89,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  {  25,   0, 147}, /*  1:                 CONCAT shift  147 */ +  { 109,   1, 143}, /*  2:                  SLASH shift  143 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   5, 130}, /*  4:                 likeop shift  130 */ +  { 111,   6, 141}, /*  5:                   STAR shift  141 */ +  {  99,   0, 145}, /*  6:                    REM shift  145 */  /* State 141 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 142}, /*  3:                   expr shift  142 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 142}, /*  8:                   expr shift  142 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 142 */ -  {  24,   0, 145}, /*  1:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  2:                 likeop shift  128 */ -  {  89,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  1:                 likeop shift  130 */ +  {  25,   0, 147}, /*  2:                 CONCAT shift  147 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */  /* State 143 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 144}, /*  3:                   expr shift  144 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 144}, /*  8:                   expr shift  144 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 144 */ -  {  24,   0, 145}, /*  1:                 CONCAT shift  145 */ -  { 172,   0, 128}, /*  2:                 likeop shift  128 */ -  {  89,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  1:                 likeop shift  130 */ +  {  25,   0, 147}, /*  2:                 CONCAT shift  147 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */  /* State 145 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 146}, /*  3:                   expr shift  146 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 146}, /*  8:                   expr shift  146 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 146 */ -  { 172,   0, 128}, /*  1:                 likeop shift  128 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  1:                 likeop shift  130 */ +  {  25,   0, 147}, /*  2:                 CONCAT shift  147 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +/* State 147 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 148}, /*  8:                   expr shift  148 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 148 */ -  {  84,   2, 149}, /*  1:                   NULL shift  149 */ -  {  82,   0, 150}, /*  2:                    NOT shift  150 */ +  {  92,   0,  99}, /*  1:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  2:                 likeop shift  130 */  /* State 150 */ -  {  84,   0, 151}, /*  1:                   NULL shift  151 */ -/* State 153 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 154}, /*  3:                   expr shift  154 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 154 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 155}, /*  3:                    AND shift  155 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  85,   0, 152}, /*  1:                    NOT shift  152 */ +  {  87,   1, 151}, /*  2:                   NULL shift  151 */ +/* State 152 */ +  {  87,   0, 153}, /*  1:                   NULL shift  153 */  /* State 155 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 156}, /*  3:                   expr shift  156 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 156}, /*  8:                   expr shift  156 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 156 */ -  {  96,   2, 143}, /*  1:                    REM shift  143 */ -  {  80,   0, 137}, /*  2:                  MINUS shift  137 */ -  {  54,   0, 110}, /*  3:                     GT shift  110 */ -  {  51,   0, 114}, /*  4:                     GE shift  114 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {  11,   0, 120}, /*  6:                 BITAND shift  120 */ -  { 102,   3, 126}, /*  7:                 RSHIFT shift  126 */ -  { 108,   0, 139}, /*  8:                   STAR shift  139 */ -  {  24,   0, 145}, /*  9:                 CONCAT shift  145 */ -  {  89,   5,  99}, /* 10:      ORACLE_OUTER_JOIN shift  99 */ -  { 106,   0, 141}, /* 11:                  SLASH shift  141 */ -  {  91,   6, 135}, /* 12:                   PLUS shift  135 */ -  { 172,   8, 128}, /* 13:                 likeop shift  128 */ -  {  77,  16, 124}, /* 14:                 LSHIFT shift  124 */ -  {  78,   0, 108}, /* 15:                     LT shift  108 */ -  {  13,   0, 122}, /* 16:                  BITOR shift  122 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 157}, /*  6:                    AND shift  157 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 157 */ -  {  76,   0, 158}, /*  1:                     LP shift  158 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 158}, /*  8:                   expr shift  158 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 158 */ -  {  80,   0, 172}, /*  1:                  MINUS shift  172 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  { 103,   0,  73}, /*  4:                 SELECT shift  73 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  46,   0, 167}, /*  7:                  FLOAT shift  167 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,  10, 165}, /*  9:                   expr shift  165 */ -  {  12,   0, 170}, /* 10:                 BITNOT shift  170 */ -  { 110,   0,  66}, /* 11:                 STRING shift  66 */ -  {  91,   8, 174}, /* 12:                   PLUS shift  174 */ -  { 192,   9, 159}, /* 13:                 select shift  159 */ -  { 153,   0, 212}, /* 14:               expritem shift  212 */ -  { 154,  16, 208}, /* 15:               exprlist shift  208 */ -  {  94,   0, 186}, /* 16:                  RAISE shift  186 */ -  {  76,  19,  68}, /* 17:                     LP shift  68 */ -  { 177,   0, 102}, /* 18:                     nm shift  102 */ -  {  56,  20,  64}, /* 19:                     ID shift  64 */ -  {  16,   0, 176}, /* 20:                   CASE shift  176 */ +  {  80,   0, 126}, /*  1:                 LSHIFT shift  126 */ +  { 177,   3, 130}, /*  2:                 likeop shift  130 */ +  {  81,   0, 110}, /*  3:                     LT shift  110 */ +  {  99,   5, 145}, /*  4:                    REM shift  145 */ +  {  83,   0, 139}, /*  5:                  MINUS shift  139 */ +  {  57,   8, 112}, /*  6:                     GT shift  112 */ +  {  54,   0, 116}, /*  7:                     GE shift  116 */ +  {  25,   0, 147}, /*  8:                 CONCAT shift  147 */ +  {  76,  11, 114}, /*  9:                     LE shift  114 */ +  { 105,   6, 128}, /* 10:                 RSHIFT shift  128 */ +  {  12,   0, 122}, /* 11:                 BITAND shift  122 */ +  {  14,   0, 124}, /* 12:                  BITOR shift  124 */ +  {  92,   9,  99}, /* 13:      ORACLE_OUTER_JOIN shift  99 */ +  { 109,   0, 143}, /* 14:                  SLASH shift  143 */ +  {  94,  12, 137}, /* 15:                   PLUS shift  137 */ +  { 111,   0, 141}, /* 16:                   STAR shift  141 */  /* State 159 */ -  { 101,   3, 164}, /*  1:                     RP shift  164 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  66,   0, 162}, /*  3:              INTERSECT shift  162 */ -  { 118,   5, 160}, /*  4:                  UNION shift  160 */ -  {  43,   0, 163}, /*  5:                 EXCEPT shift  163 */ +  {  79,   0, 160}, /*  1:                     LP shift  160 */  /* State 160 */ -  {   4,   0, 161}, /*  1:                    ALL shift  161 */ -  { 103,   0, 634}, /*  2:                 SELECT reduce 103 */ +  {  85,   0, 170}, /*  1:                    NOT shift  170 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  13,   0, 172}, /*  3:                 BITNOT shift  172 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  74,   0,  67}, /*  5:                JOIN_KW shift  67 */ +  { 185,   1,  69}, /*  6:              oneselect shift  69 */ +  { 106,   0,  73}, /*  7:                 SELECT shift  73 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  68,   0, 168}, /*  9:                INTEGER shift  168 */ +  {  49,   0, 169}, /* 10:                  FLOAT shift  169 */ +  {  97,  12, 188}, /* 11:                  RAISE shift  188 */ +  {  17,   0, 178}, /* 12:                   CASE shift  178 */ +  {  79,  16,  68}, /* 13:                     LP shift  68 */ +  { 113,   3,  66}, /* 14:                 STRING shift  66 */ +  {  94,   5, 176}, /* 15:                   PLUS shift  176 */ +  {  59,   0,  64}, /* 16:                     ID shift  64 */ +  { 196,   0, 161}, /* 17:                 select shift  161 */ +  { 157,  11, 167}, /* 18:                   expr shift  167 */ +  { 158,   0, 214}, /* 19:               expritem shift  214 */ +  { 159,  13, 210}, /* 20:               exprlist shift  210 */  /* State 161 */ -  { 103,   0, 635}, /*  1:                 SELECT reduce 104 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   3, 162}, /*  2:                  UNION shift  162 */ +  {  46,   0, 165}, /*  3:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  4:              INTERSECT shift  164 */ +  { 104,   4, 166}, /*  5:                     RP shift  166 */  /* State 162 */ -  { 103,   0, 636}, /*  1:                 SELECT reduce 105 */ +  { 106,   2, 658}, /*  1:                 SELECT reduce 103 */ +  {   4,   0, 163}, /*  2:                    ALL shift  163 */  /* State 163 */ -  { 103,   0, 637}, /*  1:                 SELECT reduce 106 */ +  { 106,   0, 659}, /*  1:                 SELECT reduce 104 */ +/* State 164 */ +  { 106,   0, 660}, /*  1:                 SELECT reduce 105 */  /* State 165 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ -/* State 168 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 169}, /*  3:                   expr shift  169 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 169 */ -  {  78,   2, 108}, /*  1:                     LT shift  108 */ -  {  52,   0, 134}, /*  2:                   GLOB shift  134 */ -  { 106,   7, 141}, /*  3:                  SLASH shift  141 */ -  {  81,   0, 116}, /*  4:                     NE shift  116 */ -  { 108,   8, 139}, /*  5:                   STAR shift  139 */ -  {  83,   0, 152}, /*  6:                NOTNULL shift  152 */ -  {  80,  10, 137}, /*  7:                  MINUS shift  137 */ -  {  82,   0, 130}, /*  8:                    NOT shift  130 */ -  {  60,   0, 157}, /*  9:                     IN shift  157 */ -  {  54,   0, 110}, /* 10:                     GT shift  110 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  89,  13,  99}, /* 12:      ORACLE_OUTER_JOIN shift  99 */ -  {  11,   0, 120}, /* 13:                 BITAND shift  120 */ -  {  91,  15, 135}, /* 14:                   PLUS shift  135 */ -  {  13,   0, 122}, /* 15:                  BITOR shift  122 */ -  {  68,  20, 148}, /* 16:                     IS shift  148 */ -  { 172,  16, 128}, /* 17:                 likeop shift  128 */ -  {  69,   0, 147}, /* 18:                 ISNULL shift  147 */ -  {  96,   0, 143}, /* 19:                    REM shift  143 */ -  {  42,   0, 118}, /* 20:                     EQ shift  118 */ -  {  24,   0, 145}, /* 21:                 CONCAT shift  145 */ -  {  73,   0, 112}, /* 22:                     LE shift  112 */ -  {  74,   0, 133}, /* 23:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 102,  21, 126}, /* 25:                 RSHIFT shift  126 */ -  {  77,  24, 124}, /* 26:                 LSHIFT shift  124 */ +  { 106,   0, 661}, /*  1:                 SELECT reduce 106 */ +/* State 167 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 170 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 171}, /*  3:                   expr shift  171 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 171}, /*  8:                   expr shift  171 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 171 */ -  { 172,   0, 128}, /*  1:                 likeop shift  128 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ +  {  54,   0, 116}, /*  1:                     GE shift  116 */ +  { 105,   0, 128}, /*  2:                 RSHIFT shift  128 */ +  {  80,   1, 126}, /*  3:                 LSHIFT shift  126 */ +  {  81,   5, 110}, /*  4:                     LT shift  110 */ +  {  55,   0, 136}, /*  5:                   GLOB shift  136 */ +  { 109,  10, 143}, /*  6:                  SLASH shift  143 */ +  {  84,   0, 118}, /*  7:                     NE shift  118 */ +  { 111,  11, 141}, /*  8:                   STAR shift  141 */ +  {  86,   0, 154}, /*  9:                NOTNULL shift  154 */ +  {  83,  14, 139}, /* 10:                  MINUS shift  139 */ +  {  85,   0, 132}, /* 11:                    NOT shift  132 */ +  {  63,  16, 159}, /* 12:                     IN shift  159 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  57,   0, 112}, /* 14:                     GT shift  112 */ +  {  92,  18,  99}, /* 15:      ORACLE_OUTER_JOIN shift  99 */ +  {  11,   0, 155}, /* 16:                BETWEEN shift  155 */ +  {  94,   0, 137}, /* 17:                   PLUS shift  137 */ +  {  14,   0, 124}, /* 18:                  BITOR shift  124 */ +  {  45,   0, 120}, /* 19:                     EQ shift  120 */ +  {  71,  19, 150}, /* 20:                     IS shift  150 */ +  {  72,   0, 149}, /* 21:                 ISNULL shift  149 */ +  { 177,  23, 130}, /* 22:                 likeop shift  130 */ +  {  99,   0, 145}, /* 23:                    REM shift  145 */ +  {  25,   0, 147}, /* 24:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 25:                     LE shift  114 */ +  {  77,  24, 135}, /* 26:                   LIKE shift  135 */  /* State 172 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 173}, /*  3:                   expr shift  173 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 173}, /*  8:                   expr shift  173 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 173 */ -  { 172,   0, 128}, /*  1:                 likeop shift  128 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ +  {  92,   0,  99}, /*  1:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  2:                 likeop shift  130 */  /* State 174 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 175}, /*  3:                   expr shift  175 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 175}, /*  8:                   expr shift  175 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 175 */ -  { 172,   0, 128}, /*  1:                 likeop shift  128 */ -  {  89,   0,  99}, /*  2:      ORACLE_OUTER_JOIN shift  99 */ +  {  92,   0,  99}, /*  1:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  2:                 likeop shift  130 */  /* State 176 */ -  { 126,   0, 755}, /*  1:                   WHEN reduce 224 */ -  {  76,   0,  68}, /*  2:                     LP shift  68 */ -  {  46,   5, 167}, /*  3:                  FLOAT shift  167 */ -  {  71,   0,  67}, /*  4:                JOIN_KW shift  67 */ -  {  12,   0, 170}, /*  5:                 BITNOT shift  170 */ -  {  56,   0,  64}, /*  6:                     ID shift  64 */ -  {  91,   0, 174}, /*  7:                   PLUS shift  174 */ -  { 177,   1, 102}, /*  8:                     nm shift  102 */ -  { 110,   2,  66}, /*  9:                 STRING shift  66 */ -  {  94,   0, 186}, /* 10:                  RAISE shift  186 */ -  {  82,  12, 168}, /* 11:                    NOT shift  168 */ -  {  65,   0, 166}, /* 12:                INTEGER shift  166 */ -  {  80,   3, 172}, /* 13:                  MINUS shift  172 */ -  {  84,  16, 101}, /* 14:                   NULL shift  101 */ -  { 133,  11, 178}, /* 15:           case_operand shift  178 */ -  {  16,   0, 176}, /* 16:                   CASE shift  176 */ -  { 152,  14, 177}, /* 17:                   expr shift  177 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 177}, /*  8:                   expr shift  177 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 177 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  68,   7, 148}, /*  4:                     IS shift  148 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  10,   0, 153}, /*  7:                BETWEEN shift  153 */ -  {  11,   0, 120}, /*  8:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  9:                  BITOR shift  122 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  { 126,   4, 754}, /* 11:                   WHEN reduce 223 */ -  {  69,   8, 147}, /* 12:                 ISNULL shift  147 */ -  {  73,   0, 112}, /* 13:                     LE shift  112 */ -  {  42,   9, 118}, /* 14:                     EQ shift  118 */ -  {  77,   0, 124}, /* 15:                 LSHIFT shift  124 */ -  { 102,  13, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 18:                     GE shift  114 */ -  {  52,   0, 134}, /* 19:                   GLOB shift  134 */ -  { 106,  15, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  18, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  19, 116}, /* 24:                     NE shift  116 */ -  {  82,  27, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ +  {  92,   0,  99}, /*  1:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /*  2:                 likeop shift  130 */  /* State 178 */ -  { 132,   2, 179}, /*  1:          case_exprlist shift  179 */ -  { 126,   0, 204}, /*  2:                   WHEN shift  204 */ +  { 136,   2, 180}, /*  1:           case_operand shift  180 */ +  {  85,   4, 170}, /*  2:                    NOT shift  170 */ +  {  87,   0, 101}, /*  3:                   NULL shift  101 */ +  {  68,   6, 168}, /*  4:                INTEGER shift  168 */ +  { 157,   0, 179}, /*  5:                   expr shift  179 */ +  {  17,   0, 178}, /*  6:                   CASE shift  178 */ +  {  74,   0,  67}, /*  7:                JOIN_KW shift  67 */ +  { 113,  15,  66}, /*  8:                 STRING shift  66 */ +  {  59,   0,  64}, /*  9:                     ID shift  64 */ +  {  94,   0, 176}, /* 10:                   PLUS shift  176 */ +  { 129,   0, 781}, /* 11:                   WHEN reduce 226 */ +  { 181,   8, 102}, /* 12:                     nm shift  102 */ +  {  97,   0, 188}, /* 13:                  RAISE shift  188 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  79,   0,  68}, /* 15:                     LP shift  68 */ +  {  83,  17, 174}, /* 16:                  MINUS shift  174 */ +  {  49,   0, 169}, /* 17:                  FLOAT shift  169 */  /* State 179 */ -  {  40,   0, 753}, /*  1:                    END reduce 222 */ -  {  39,   0, 202}, /*  2:                   ELSE shift  202 */ -  { 126,   0, 182}, /*  3:                   WHEN shift  182 */ -  { 131,   2, 180}, /*  4:              case_else shift  180 */ +  {  63,   2, 159}, /*  1:                     IN shift  159 */ +  {   5,   0, 100}, /*  2:                    AND shift  100 */ +  {  12,   0, 122}, /*  3:                 BITAND shift  122 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   1,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  14,   0, 124}, /*  9:                  BITOR shift  124 */ +  {  76,   0, 114}, /* 10:                     LE shift  114 */ +  {  80,   0, 126}, /* 11:                 LSHIFT shift  126 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   3, 145}, /* 13:                    REM shift  145 */ +  { 129,   7, 780}, /* 14:                   WHEN reduce 225 */ +  {  72,   9, 149}, /* 15:                 ISNULL shift  149 */ +  {  54,  18, 116}, /* 16:                     GE shift  116 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  {  25,   0, 147}, /* 18:                 CONCAT shift  147 */ +  { 105,  10, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  11, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  16, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */  /* State 180 */ -  {  40,   0, 181}, /*  1:                    END shift  181 */ +  { 129,   0, 206}, /*  1:                   WHEN shift  206 */ +  { 135,   1, 181}, /*  2:          case_exprlist shift  181 */ +/* State 181 */ +  {  42,   0, 204}, /*  1:                   ELSE shift  204 */ +  { 129,   0, 184}, /*  2:                   WHEN shift  184 */ +  { 134,   1, 182}, /*  3:              case_else shift  182 */ +  {  43,   0, 779}, /*  4:                    END reduce 224 */  /* State 182 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 183}, /*  3:                   expr shift  183 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 183 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /*  4:                BETWEEN shift  153 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  11,   0, 120}, /*  7:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  8:                  BITOR shift  122 */ -  {  73,   0, 112}, /*  9:                     LE shift  112 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  {  68,   4, 148}, /* 11:                     IS shift  148 */ -  {  69,   7, 147}, /* 12:                 ISNULL shift  147 */ -  {  77,   0, 124}, /* 13:                 LSHIFT shift  124 */ -  {  42,   8, 118}, /* 14:                     EQ shift  118 */ -  {  51,   0, 114}, /* 15:                     GE shift  114 */ -  { 102,   9, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  52,   0, 134}, /* 18:                   GLOB shift  134 */ -  {  24,   0, 145}, /* 19:                 CONCAT shift  145 */ -  { 106,  13, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  15, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  18, 116}, /* 24:                     NE shift  116 */ -  {  82,  19, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  { 113,   0, 184}, /* 27:                   THEN shift  184 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ +  {  43,   0, 183}, /*  1:                    END shift  183 */  /* State 184 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 185}, /*  3:                   expr shift  185 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 185}, /*  8:                   expr shift  185 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 185 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ +  { 116,   0, 186}, /*  1:                   THEN shift  186 */ +  {  63,   3, 159}, /*  2:                     IN shift  159 */    {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   2,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  12,   0, 122}, /*  7:                 BITAND shift  122 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  14,   0, 124}, /*  9:                  BITOR shift  124 */ +  {  76,   0, 114}, /* 10:                     LE shift  114 */ +  {  80,   0, 126}, /* 11:                 LSHIFT shift  126 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   7, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   9, 149}, /* 15:                 ISNULL shift  149 */ +  {  54,  18, 116}, /* 16:                     GE shift  116 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  {  25,   0, 147}, /* 18:                 CONCAT shift  147 */ +  { 105,  10, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  11, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  16, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */  /* State 186 */ -  {  76,   0, 187}, /*  1:                     LP shift  187 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 187}, /*  8:                   expr shift  187 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 187 */ -  {  45,   3, 198}, /*  1:                   FAIL shift  198 */ -  {  57,   1, 188}, /*  2:                 IGNORE shift  188 */ -  {   1,   0, 194}, /*  3:                  ABORT shift  194 */ -  {  99,   0, 190}, /*  4:               ROLLBACK shift  190 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 188 */ -  { 101,   0, 189}, /*  1:                     RP shift  189 */ +  {  79,   0, 189}, /*  1:                     LP shift  189 */ +/* State 189 */ +  {  60,   4, 190}, /*  1:                 IGNORE shift  190 */ +  {   1,   0, 196}, /*  2:                  ABORT shift  196 */ +  { 102,   0, 192}, /*  3:               ROLLBACK shift  192 */ +  {  48,   0, 200}, /*  4:                   FAIL shift  200 */  /* State 190 */ -  {  21,   0, 191}, /*  1:                  COMMA shift  191 */ -/* State 191 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 192}, /*  2:                     nm shift  192 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 104,   0, 191}, /*  1:                     RP shift  191 */  /* State 192 */ -  { 101,   0, 193}, /*  1:                     RP shift  193 */ +  {  22,   0, 193}, /*  1:                  COMMA shift  193 */ +/* State 193 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 194}, /*  2:                     nm shift  194 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 194 */ -  {  21,   0, 195}, /*  1:                  COMMA shift  195 */ -/* State 195 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 196}, /*  2:                     nm shift  196 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 104,   0, 195}, /*  1:                     RP shift  195 */  /* State 196 */ -  { 101,   0, 197}, /*  1:                     RP shift  197 */ +  {  22,   0, 197}, /*  1:                  COMMA shift  197 */ +/* State 197 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 198}, /*  2:                     nm shift  198 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 198 */ -  {  21,   0, 199}, /*  1:                  COMMA shift  199 */ -/* State 199 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 200}, /*  2:                     nm shift  200 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 104,   0, 199}, /*  1:                     RP shift  199 */  /* State 200 */ -  { 101,   0, 201}, /*  1:                     RP shift  201 */ +  {  22,   0, 201}, /*  1:                  COMMA shift  201 */ +/* State 201 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 202}, /*  2:                     nm shift  202 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 202 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 203}, /*  3:                   expr shift  203 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 203 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /*  4:                BETWEEN shift  153 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  40,   8, 752}, /*  7:                    END reduce 221 */ -  {  11,   0, 120}, /*  8:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  9:                  BITOR shift  122 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  {  68,   4, 148}, /* 11:                     IS shift  148 */ -  {  69,   7, 147}, /* 12:                 ISNULL shift  147 */ -  {  73,   0, 112}, /* 13:                     LE shift  112 */ -  {  42,   9, 118}, /* 14:                     EQ shift  118 */ -  {  77,   0, 124}, /* 15:                 LSHIFT shift  124 */ -  { 102,  13, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 18:                     GE shift  114 */ -  {  52,   0, 134}, /* 19:                   GLOB shift  134 */ -  { 106,  15, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  18, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  19, 116}, /* 24:                     NE shift  116 */ -  {  82,  27, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ +  { 104,   0, 203}, /*  1:                     RP shift  203 */  /* State 204 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 205}, /*  3:                   expr shift  205 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 205}, /*  8:                   expr shift  205 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 205 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /*  4:                BETWEEN shift  153 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  11,   0, 120}, /*  7:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  8:                  BITOR shift  122 */ -  {  73,   0, 112}, /*  9:                     LE shift  112 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  {  68,   4, 148}, /* 11:                     IS shift  148 */ -  {  69,   7, 147}, /* 12:                 ISNULL shift  147 */ -  {  77,   0, 124}, /* 13:                 LSHIFT shift  124 */ -  {  42,   8, 118}, /* 14:                     EQ shift  118 */ -  {  51,   0, 114}, /* 15:                     GE shift  114 */ -  { 102,   9, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  52,   0, 134}, /* 18:                   GLOB shift  134 */ -  {  24,   0, 145}, /* 19:                 CONCAT shift  145 */ -  { 106,  13, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  15, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  18, 116}, /* 24:                     NE shift  116 */ -  {  82,  19, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  { 113,   0, 206}, /* 27:                   THEN shift  206 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ +  {  63,   2, 159}, /*  1:                     IN shift  159 */ +  {   5,   0, 100}, /*  2:                    AND shift  100 */ +  {  12,   0, 122}, /*  3:                 BITAND shift  122 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   1,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  43,   9, 778}, /*  7:                    END reduce 223 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  14,   0, 124}, /*  9:                  BITOR shift  124 */ +  {  76,   0, 114}, /* 10:                     LE shift  114 */ +  {  80,   0, 126}, /* 11:                 LSHIFT shift  126 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   3, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   7, 149}, /* 15:                 ISNULL shift  149 */ +  {  54,  18, 116}, /* 16:                     GE shift  116 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  {  25,   0, 147}, /* 18:                 CONCAT shift  147 */ +  { 105,  10, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  11, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  16, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */  /* State 206 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 207}, /*  3:                   expr shift  207 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 207}, /*  8:                   expr shift  207 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 207 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ +  { 116,   0, 208}, /*  1:                   THEN shift  208 */ +  {  63,   3, 159}, /*  2:                     IN shift  159 */    {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   2,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  12,   0, 122}, /*  7:                 BITAND shift  122 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  14,   0, 124}, /*  9:                  BITOR shift  124 */ +  {  76,   0, 114}, /* 10:                     LE shift  114 */ +  {  80,   0, 126}, /* 11:                 LSHIFT shift  126 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   7, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   9, 149}, /* 15:                 ISNULL shift  149 */ +  {  54,  18, 116}, /* 16:                     GE shift  116 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  {  25,   0, 147}, /* 18:                 CONCAT shift  147 */ +  { 105,  10, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  11, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  16, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */  /* State 208 */ -  {  21,   0, 210}, /*  1:                  COMMA shift  210 */ -  { 101,   1, 209}, /*  2:                     RP shift  209 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 209}, /*  8:                   expr shift  209 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */ +/* State 209 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 210 */ -  {  80,   4, 172}, /*  1:                  MINUS shift  172 */ -  { 177,   6, 102}, /*  2:                     nm shift  102 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  {  16,   0, 176}, /*  4:                   CASE shift  176 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  56,   0,  64}, /*  7:                     ID shift  64 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,   7, 165}, /*  9:                   expr shift  165 */ -  { 153,   0, 211}, /* 10:               expritem shift  211 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  91,   0, 174}, /* 12:                   PLUS shift  174 */ -  {  76,  11,  68}, /* 13:                     LP shift  68 */ -  {  94,  16, 186}, /* 14:                  RAISE shift  186 */ -  { 110,  14,  66}, /* 15:                 STRING shift  66 */ -  {  46,   0, 167}, /* 16:                  FLOAT shift  167 */ -/* State 214 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 215}, /*  3:                   expr shift  215 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 215 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 216}, /*  3:                    AND shift  216 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  { 104,   2, 211}, /*  1:                     RP shift  211 */ +  {  22,   0, 212}, /*  2:                  COMMA shift  212 */ +/* State 212 */ +  {  97,   3, 188}, /*  1:                  RAISE shift  188 */ +  { 113,   1,  66}, /*  2:                 STRING shift  66 */ +  {  49,   7, 169}, /*  3:                  FLOAT shift  169 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  68,   0, 168}, /*  5:                INTEGER shift  168 */ +  { 181,   9, 102}, /*  6:                     nm shift  102 */ +  {  17,   0, 178}, /*  7:                   CASE shift  178 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  85,   0, 170}, /*  9:                    NOT shift  170 */ +  {  13,   0, 172}, /* 10:                 BITNOT shift  172 */ +  {  74,   0,  67}, /* 11:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  94,   0, 176}, /* 13:                   PLUS shift  176 */ +  { 157,  10, 167}, /* 14:                   expr shift  167 */ +  { 158,  13, 213}, /* 15:               expritem shift  213 */ +  {  79,   0,  68}, /* 16:                     LP shift  68 */  /* State 216 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 217}, /*  3:                   expr shift  217 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 217}, /*  8:                   expr shift  217 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 217 */ -  {  78,   2, 108}, /*  1:                     LT shift  108 */ -  {  52,   0, 134}, /*  2:                   GLOB shift  134 */ -  { 106,   7, 141}, /*  3:                  SLASH shift  141 */ -  {  81,   0, 116}, /*  4:                     NE shift  116 */ -  { 108,   8, 139}, /*  5:                   STAR shift  139 */ -  {  83,   0, 152}, /*  6:                NOTNULL shift  152 */ -  {  80,  10, 137}, /*  7:                  MINUS shift  137 */ -  {  82,   0, 130}, /*  8:                    NOT shift  130 */ -  {  60,   0, 157}, /*  9:                     IN shift  157 */ -  {  54,   0, 110}, /* 10:                     GT shift  110 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  89,  13,  99}, /* 12:      ORACLE_OUTER_JOIN shift  99 */ -  {  11,   0, 120}, /* 13:                 BITAND shift  120 */ -  {  91,  15, 135}, /* 14:                   PLUS shift  135 */ -  {  13,   0, 122}, /* 15:                  BITOR shift  122 */ -  {  68,  20, 148}, /* 16:                     IS shift  148 */ -  { 172,  16, 128}, /* 17:                 likeop shift  128 */ -  {  69,   0, 147}, /* 18:                 ISNULL shift  147 */ -  {  96,   0, 143}, /* 19:                    REM shift  143 */ -  {  42,   0, 118}, /* 20:                     EQ shift  118 */ -  {  24,   0, 145}, /* 21:                 CONCAT shift  145 */ -  {  73,   0, 112}, /* 22:                     LE shift  112 */ -  {  74,   0, 133}, /* 23:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 102,  21, 126}, /* 25:                 RSHIFT shift  126 */ -  {  77,  24, 124}, /* 26:                 LSHIFT shift  124 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 218}, /*  6:                    AND shift  218 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 218 */ -  {  76,   0, 219}, /*  1:                     LP shift  219 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 219}, /*  8:                   expr shift  219 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 219 */ -  {  80,   0, 172}, /*  1:                  MINUS shift  172 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  { 103,   0,  73}, /*  4:                 SELECT shift  73 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  46,   0, 167}, /*  7:                  FLOAT shift  167 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,  10, 165}, /*  9:                   expr shift  165 */ -  {  12,   0, 170}, /* 10:                 BITNOT shift  170 */ -  { 110,   0,  66}, /* 11:                 STRING shift  66 */ -  {  91,   8, 174}, /* 12:                   PLUS shift  174 */ -  { 192,   9, 220}, /* 13:                 select shift  220 */ -  { 153,   0, 212}, /* 14:               expritem shift  212 */ -  { 154,  16, 222}, /* 15:               exprlist shift  222 */ -  {  94,   0, 186}, /* 16:                  RAISE shift  186 */ -  {  76,  19,  68}, /* 17:                     LP shift  68 */ -  { 177,   0, 102}, /* 18:                     nm shift  102 */ -  {  56,  20,  64}, /* 19:                     ID shift  64 */ -  {  16,   0, 176}, /* 20:                   CASE shift  176 */ +  {  54,   0, 116}, /*  1:                     GE shift  116 */ +  { 105,   0, 128}, /*  2:                 RSHIFT shift  128 */ +  {  80,   1, 126}, /*  3:                 LSHIFT shift  126 */ +  {  81,   5, 110}, /*  4:                     LT shift  110 */ +  {  55,   0, 136}, /*  5:                   GLOB shift  136 */ +  { 109,  10, 143}, /*  6:                  SLASH shift  143 */ +  {  84,   0, 118}, /*  7:                     NE shift  118 */ +  { 111,  11, 141}, /*  8:                   STAR shift  141 */ +  {  86,   0, 154}, /*  9:                NOTNULL shift  154 */ +  {  83,  14, 139}, /* 10:                  MINUS shift  139 */ +  {  85,   0, 132}, /* 11:                    NOT shift  132 */ +  {  63,  16, 159}, /* 12:                     IN shift  159 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  57,   0, 112}, /* 14:                     GT shift  112 */ +  {  92,  18,  99}, /* 15:      ORACLE_OUTER_JOIN shift  99 */ +  {  11,   0, 155}, /* 16:                BETWEEN shift  155 */ +  {  94,   0, 137}, /* 17:                   PLUS shift  137 */ +  {  14,   0, 124}, /* 18:                  BITOR shift  124 */ +  {  45,   0, 120}, /* 19:                     EQ shift  120 */ +  {  71,  19, 150}, /* 20:                     IS shift  150 */ +  {  72,   0, 149}, /* 21:                 ISNULL shift  149 */ +  { 177,  23, 130}, /* 22:                 likeop shift  130 */ +  {  99,   0, 145}, /* 23:                    REM shift  145 */ +  {  25,   0, 147}, /* 24:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 25:                     LE shift  114 */ +  {  77,  24, 135}, /* 26:                   LIKE shift  135 */  /* State 220 */ -  { 101,   3, 221}, /*  1:                     RP shift  221 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  66,   0, 162}, /*  3:              INTERSECT shift  162 */ -  { 118,   5, 160}, /*  4:                  UNION shift  160 */ -  {  43,   0, 163}, /*  5:                 EXCEPT shift  163 */ +  {  79,   0, 221}, /*  1:                     LP shift  221 */ +/* State 221 */ +  {  85,   0, 170}, /*  1:                    NOT shift  170 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  13,   0, 172}, /*  3:                 BITNOT shift  172 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  74,   0,  67}, /*  5:                JOIN_KW shift  67 */ +  { 185,   1,  69}, /*  6:              oneselect shift  69 */ +  { 106,   0,  73}, /*  7:                 SELECT shift  73 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  68,   0, 168}, /*  9:                INTEGER shift  168 */ +  {  49,   0, 169}, /* 10:                  FLOAT shift  169 */ +  {  97,  12, 188}, /* 11:                  RAISE shift  188 */ +  {  17,   0, 178}, /* 12:                   CASE shift  178 */ +  {  79,  16,  68}, /* 13:                     LP shift  68 */ +  { 113,   3,  66}, /* 14:                 STRING shift  66 */ +  {  94,   5, 176}, /* 15:                   PLUS shift  176 */ +  {  59,   0,  64}, /* 16:                     ID shift  64 */ +  { 196,   0, 222}, /* 17:                 select shift  222 */ +  { 157,  11, 167}, /* 18:                   expr shift  167 */ +  { 158,   0, 214}, /* 19:               expritem shift  214 */ +  { 159,  13, 224}, /* 20:               exprlist shift  224 */  /* State 222 */ -  {  21,   0, 210}, /*  1:                  COMMA shift  210 */ -  { 101,   1, 223}, /*  2:                     RP shift  223 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   3, 162}, /*  2:                  UNION shift  162 */ +  {  46,   0, 165}, /*  3:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  4:              INTERSECT shift  164 */ +  { 104,   4, 223}, /*  5:                     RP shift  223 */  /* State 224 */ -  { 138,   0, 225}, /*  1:                collate shift  225 */ -  {  19,   0,  95}, /*  2:                COLLATE shift  95 */ -/* State 225 */ -  { 198,   0, 226}, /*  1:              sortorder shift  226 */ -  {  34,   3,  59}, /*  2:                   DESC shift  59 */ -  {   7,   0,  58}, /*  3:                    ASC shift  58 */ +  { 104,   2, 225}, /*  1:                     RP shift  225 */ +  {  22,   0, 212}, /*  2:                  COMMA shift  212 */ +/* State 226 */ +  {  20,   0,  95}, /*  1:                COLLATE shift  95 */ +  { 141,   0, 227}, /*  2:                collate shift  227 */  /* State 227 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 228}, /*  3:                   expr shift  228 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 228 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  36,   0,  59}, /*  1:                   DESC shift  59 */ +  { 202,   3, 228}, /*  2:              sortorder shift  228 */ +  {   7,   0,  58}, /*  3:                    ASC shift  58 */  /* State 229 */ -  {  14,   0, 230}, /*  1:                     BY shift  230 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 230}, /*  8:                   expr shift  230 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 230 */ -  { 153,   0, 212}, /*  1:               expritem shift  212 */ -  { 154,   0, 231}, /*  2:               exprlist shift  231 */ -  {  76,   0,  68}, /*  3:                     LP shift  68 */ -  {  71,   0,  67}, /*  4:                JOIN_KW shift  67 */ -  {  46,  11, 167}, /*  5:                  FLOAT shift  167 */ -  {  56,   0,  64}, /*  6:                     ID shift  64 */ -  {  91,   0, 174}, /*  7:                   PLUS shift  174 */ -  { 177,   0, 102}, /*  8:                     nm shift  102 */ -  { 110,   3,  66}, /*  9:                 STRING shift  66 */ -  {  94,   0, 186}, /* 10:                  RAISE shift  186 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  65,   0, 166}, /* 12:                INTEGER shift  166 */ -  {  80,   5, 172}, /* 13:                  MINUS shift  172 */ -  {  84,  16, 101}, /* 14:                   NULL shift  101 */ -  {  82,  12, 168}, /* 15:                    NOT shift  168 */ -  {  16,   0, 176}, /* 16:                   CASE shift  176 */ -  { 152,  14, 165}, /* 17:                   expr shift  165 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 231 */ -  {  21,   0, 210}, /*  1:                  COMMA shift  210 */ +  {  15,   0, 232}, /*  1:                     BY shift  232 */  /* State 232 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 233}, /*  3:                   expr shift  233 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  {  85,   2, 170}, /*  1:                    NOT shift  170 */ +  {  68,   4, 168}, /*  2:                INTEGER shift  168 */ +  {  87,   0, 101}, /*  3:                   NULL shift  101 */ +  {  17,   0, 178}, /*  4:                   CASE shift  178 */ +  { 157,   0, 167}, /*  5:                   expr shift  167 */ +  { 158,   0, 214}, /*  6:               expritem shift  214 */ +  { 159,   8, 233}, /*  7:               exprlist shift  233 */ +  {  74,   0,  67}, /*  8:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /*  9:                     ID shift  64 */ +  {  94,   0, 176}, /* 10:                   PLUS shift  176 */ +  { 113,  15,  66}, /* 11:                 STRING shift  66 */ +  { 181,  11, 102}, /* 12:                     nm shift  102 */ +  {  97,   0, 188}, /* 13:                  RAISE shift  188 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  79,   0,  68}, /* 15:                     LP shift  68 */ +  {  83,  17, 174}, /* 16:                  MINUS shift  174 */ +  {  49,   0, 169}, /* 17:                  FLOAT shift  169 */  /* State 233 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  22,   0, 212}, /*  1:                  COMMA shift  212 */ +/* State 234 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 235}, /*  8:                   expr shift  235 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 235 */ -  { 193,   0, 236}, /*  1:             seltablist shift  236 */ -  { 199,   1, 246}, /*  2:             stl_prefix shift  246 */ -/* State 236 */ -  {  70,   0, 239}, /*  1:                   JOIN shift  239 */ -  {  21,   0, 238}, /*  2:                  COMMA shift  238 */ -  { 170,   1, 237}, /*  3:                 joinop shift  237 */ -  {  71,   0, 240}, /*  4:                JOIN_KW shift  240 */ -/* State 240 */ -  { 110,   4,  21}, /*  1:                 STRING shift  21 */ -  {  71,   5,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 242}, /*  3:                     nm shift  242 */ -  {  70,   0, 241}, /*  4:                   JOIN shift  241 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */ +/* State 237 */ +  { 197,   0, 238}, /*  1:             seltablist shift  238 */ +  { 203,   1, 248}, /*  2:             stl_prefix shift  248 */ +/* State 238 */ +  {  22,   0, 240}, /*  1:                  COMMA shift  240 */ +  {  73,   0, 241}, /*  2:                   JOIN shift  241 */ +  {  74,   1, 242}, /*  3:                JOIN_KW shift  242 */ +  { 175,   0, 239}, /*  4:                 joinop shift  239 */  /* State 242 */ -  { 110,   4,  21}, /*  1:                 STRING shift  21 */ -  {  71,   5,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 244}, /*  3:                     nm shift  244 */ -  {  70,   0, 243}, /*  4:                   JOIN shift  243 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ +  {  73,   0, 243}, /*  1:                   JOIN shift  243 */ +  { 181,   0, 244}, /*  2:                     nm shift  244 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   1,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 244 */ -  {  70,   0, 245}, /*  1:                   JOIN shift  245 */ +  {  73,   0, 245}, /*  1:                   JOIN shift  245 */ +  { 181,   0, 246}, /*  2:                     nm shift  246 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   1,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 246 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  {  76,   4, 266}, /*  2:                     LP shift  266 */ -  { 177,   0, 247}, /*  3:                     nm shift  247 */ -  {  71,   5,  22}, /*  4:                JOIN_KW shift  22 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ -/* State 247 */ -  { 160,   3, 252}, /*  1:                    ids shift  252 */ -  {  56,   5, 248}, /*  2:                     ID shift  248 */ -  { 110,   0, 249}, /*  3:                 STRING shift  249 */ -  { 128,   0, 253}, /*  4:                     as shift  253 */ -  {   6,   0, 250}, /*  5:                     AS shift  250 */ +  {  73,   0, 247}, /*  1:                   JOIN shift  247 */ +/* State 248 */ +  {  74,   3,  22}, /*  1:                JOIN_KW shift  22 */ +  { 181,   0, 249}, /*  2:                     nm shift  249 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  79,   1, 272}, /*  5:                     LP shift  272 */ +/* State 249 */ +  { 150,   0, 250}, /*  1:                   dbnm shift  250 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */  /* State 250 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 251}, /*  2:                     nm shift  251 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 165,   0, 255}, /*  1:                    ids shift  255 */ +  { 131,   3, 256}, /*  2:                     as shift  256 */ +  {   6,   0, 253}, /*  3:                     AS shift  253 */ +  { 113,   0, 252}, /*  4:                 STRING shift  252 */ +  {  59,   0, 251}, /*  5:                     ID shift  251 */  /* State 253 */ -  {  87,   0, 264}, /*  1:                     ON shift  264 */ -  { 179,   1, 254}, /*  2:                 on_opt shift  254 */ -/* State 254 */ -  { 210,   2, 255}, /*  1:              using_opt shift  255 */ -  { 122,   0, 256}, /*  2:                  USING shift  256 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 254}, /*  2:                     nm shift  254 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 256 */ -  {  76,   0, 257}, /*  1:                     LP shift  257 */ +  {  90,   0, 268}, /*  1:                     ON shift  268 */ +  { 183,   0, 257}, /*  2:                 on_opt shift  257 */  /* State 257 */ -  { 162,   0, 258}, /*  1:                idxlist shift  258 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ -/* State 258 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 259}, /*  2:                     RP shift  259 */ +  { 125,   0, 259}, /*  1:                  USING shift  259 */ +  { 215,   1, 258}, /*  2:              using_opt shift  258 */ +/* State 259 */ +  {  79,   0, 260}, /*  1:                     LP shift  260 */  /* State 260 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  { 161,   4, 261}, /*  2:                idxitem shift  261 */ -  { 177,   0, 262}, /*  3:                     nm shift  262 */ -  {  71,   5,  22}, /*  4:                JOIN_KW shift  22 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ -/* State 264 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 265}, /*  3:                   expr shift  265 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 261}, /*  6:                idxlist shift  261 */ +/* State 261 */ +  { 104,   2, 262}, /*  1:                     RP shift  262 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */ +/* State 263 */ +  { 166,   0, 264}, /*  1:                idxitem shift  264 */ +  { 181,   1, 265}, /*  2:                     nm shift  265 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 265 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ -/* State 266 */ -  { 192,   0, 267}, /*  1:                 select shift  267 */ -  { 181,   3,  69}, /*  2:              oneselect shift  69 */ -  { 103,   0,  73}, /*  3:                 SELECT shift  73 */ -/* State 267 */ -  { 101,   3, 268}, /*  1:                     RP shift  268 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  66,   0, 162}, /*  3:              INTERSECT shift  162 */ -  { 118,   5, 160}, /*  4:                  UNION shift  160 */ -  {  43,   0, 163}, /*  5:                 EXCEPT shift  163 */ +  {  36,   0,  59}, /*  1:                   DESC shift  59 */ +  { 202,   3, 266}, /*  2:              sortorder shift  266 */ +  {   7,   0,  58}, /*  3:                    ASC shift  58 */  /* State 268 */ -  { 160,   3, 252}, /*  1:                    ids shift  252 */ -  {  56,   5, 248}, /*  2:                     ID shift  248 */ -  { 110,   0, 249}, /*  3:                 STRING shift  249 */ -  { 128,   0, 269}, /*  4:                     as shift  269 */ -  {   6,   0, 250}, /*  5:                     AS shift  250 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 269}, /*  8:                   expr shift  269 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 269 */ -  {  87,   0, 264}, /*  1:                     ON shift  264 */ -  { 179,   1, 270}, /*  2:                 on_opt shift  270 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 270 */ -  { 210,   2, 271}, /*  1:              using_opt shift  271 */ -  { 122,   0, 256}, /*  2:                  USING shift  256 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 271}, /*  2:                     nm shift  271 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 272 */ -  {  80,   4, 172}, /*  1:                  MINUS shift  172 */ -  { 177,   6, 276}, /*  2:                     nm shift  276 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  {  16,   0, 176}, /*  4:                   CASE shift  176 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  56,   0,  64}, /*  7:                     ID shift  64 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,   7, 273}, /*  9:                   expr shift  273 */ -  {  76,  11,  68}, /* 10:                     LP shift  68 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  91,   0, 174}, /* 12:                   PLUS shift  174 */ -  { 108,  10, 275}, /* 13:                   STAR shift  275 */ -  {  94,  16, 186}, /* 14:                  RAISE shift  186 */ -  { 110,  14,  66}, /* 15:                 STRING shift  66 */ -  {  46,   0, 167}, /* 16:                  FLOAT shift  167 */ +  { 106,   0,  73}, /*  1:                 SELECT shift  73 */ +  { 196,   1, 273}, /*  2:                 select shift  273 */ +  { 185,   0,  69}, /*  3:              oneselect shift  69 */  /* State 273 */ -  {  69,   0, 147}, /*  1:                 ISNULL shift  147 */ -  { 106,   5, 141}, /*  2:                  SLASH shift  141 */ -  {  68,   0, 148}, /*  3:                     IS shift  148 */ -  { 102,   1, 126}, /*  4:                 RSHIFT shift  126 */ -  {  73,   0, 112}, /*  5:                     LE shift  112 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {   6,   0, 250}, /*  7:                     AS shift  250 */ -  { 172,   2, 128}, /*  8:                 likeop shift  128 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  { 108,  21, 139}, /* 10:                   STAR shift  139 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  { 110,  27, 249}, /* 12:                 STRING shift  249 */ -  {  78,   0, 108}, /* 13:                     LT shift  108 */ -  {  13,   0, 122}, /* 14:                  BITOR shift  122 */ -  {  80,   0, 137}, /* 15:                  MINUS shift  137 */ -  {  81,   0, 116}, /* 16:                     NE shift  116 */ -  {  82,   0, 130}, /* 17:                    NOT shift  130 */ -  {  83,   0, 152}, /* 18:                NOTNULL shift  152 */ -  {  51,   0, 114}, /* 19:                     GE shift  114 */ -  {  52,   0, 134}, /* 20:                   GLOB shift  134 */ -  {  42,   0, 118}, /* 21:                     EQ shift  118 */ -  {  54,   0, 110}, /* 22:                     GT shift  110 */ -  {  88,   0, 106}, /* 23:                     OR shift  106 */ -  {  89,  32,  99}, /* 24:      ORACLE_OUTER_JOIN shift  99 */ -  {  24,   0, 145}, /* 25:                 CONCAT shift  145 */ -  {  91,   0, 135}, /* 26:                   PLUS shift  135 */ -  {  77,  33, 124}, /* 27:                 LSHIFT shift  124 */ -  {  60,   0, 157}, /* 28:                     IN shift  157 */ -  { 160,   0, 252}, /* 29:                    ids shift  252 */ -  { 128,   0, 274}, /* 30:                     as shift  274 */ -  {  96,   0, 143}, /* 31:                    REM shift  143 */ -  {  56,   0, 248}, /* 32:                     ID shift  248 */ -  {  11,   0, 120}, /* 33:                 BITAND shift  120 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   3, 162}, /*  2:                  UNION shift  162 */ +  {  46,   0, 165}, /*  3:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  4:              INTERSECT shift  164 */ +  { 104,   4, 274}, /*  5:                     RP shift  274 */ +/* State 274 */ +  { 165,   0, 255}, /*  1:                    ids shift  255 */ +  { 131,   3, 275}, /*  2:                     as shift  275 */ +  {   6,   0, 253}, /*  3:                     AS shift  253 */ +  { 113,   0, 252}, /*  4:                 STRING shift  252 */ +  {  59,   0, 251}, /*  5:                     ID shift  251 */ +/* State 275 */ +  {  90,   0, 268}, /*  1:                     ON shift  268 */ +  { 183,   0, 276}, /*  2:                 on_opt shift  276 */  /* State 276 */ -  {  36,   0, 277}, /*  1:                    DOT shift  277 */ -/* State 277 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  {  71,   5,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 104}, /*  3:                     nm shift  104 */ -  { 108,   0, 278}, /*  4:                   STAR shift  278 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ +  { 125,   0, 259}, /*  1:                  USING shift  259 */ +  { 215,   1, 277}, /*  2:              using_opt shift  277 */ +/* State 278 */ +  {  97,   3, 188}, /*  1:                  RAISE shift  188 */ +  { 113,   1,  66}, /*  2:                 STRING shift  66 */ +  {  49,   7, 169}, /*  3:                  FLOAT shift  169 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  68,   0, 168}, /*  5:                INTEGER shift  168 */ +  { 181,   9, 282}, /*  6:                     nm shift  282 */ +  {  17,   0, 178}, /*  7:                   CASE shift  178 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  85,   0, 170}, /*  9:                    NOT shift  170 */ +  {  13,   0, 172}, /* 10:                 BITNOT shift  172 */ +  {  74,   0,  67}, /* 11:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  79,   0,  68}, /* 13:                     LP shift  68 */ +  { 157,  10, 279}, /* 14:                   expr shift  279 */ +  {  94,   0, 176}, /* 15:                   PLUS shift  176 */ +  { 111,  13, 281}, /* 16:                   STAR shift  281 */ +/* State 279 */ +  { 165,   2, 255}, /*  1:                    ids shift  255 */ +  {  99,   0, 145}, /*  2:                    REM shift  145 */ +  {   5,   0, 100}, /*  3:                    AND shift  100 */ +  {  72,   5, 149}, /*  4:                 ISNULL shift  149 */ +  {   6,   0, 253}, /*  5:                     AS shift  253 */ +  {  71,   3, 150}, /*  6:                     IS shift  150 */ +  { 105,   4, 128}, /*  7:                 RSHIFT shift  128 */ +  {  76,   0, 114}, /*  8:                     LE shift  114 */ +  {  11,   0, 155}, /*  9:                BETWEEN shift  155 */ +  { 111,  14, 141}, /* 10:                   STAR shift  141 */ +  { 109,   8, 143}, /* 11:                  SLASH shift  143 */ +  {  77,   9, 135}, /* 12:                   LIKE shift  135 */ +  { 177,  10, 130}, /* 13:                 likeop shift  130 */ +  {  45,  17, 120}, /* 14:                     EQ shift  120 */ +  { 113,  24, 252}, /* 15:                 STRING shift  252 */ +  {  81,   0, 110}, /* 16:                     LT shift  110 */ +  {  12,   0, 122}, /* 17:                 BITAND shift  122 */ +  {  83,   0, 139}, /* 18:                  MINUS shift  139 */ +  {  84,   0, 118}, /* 19:                     NE shift  118 */ +  {  85,   0, 132}, /* 20:                    NOT shift  132 */ +  {  86,   0, 154}, /* 21:                NOTNULL shift  154 */ +  {  54,   0, 116}, /* 22:                     GE shift  116 */ +  {  55,   0, 136}, /* 23:                   GLOB shift  136 */ +  {  80,  28, 126}, /* 24:                 LSHIFT shift  126 */ +  {  57,   0, 112}, /* 25:                     GT shift  112 */ +  {  91,  30, 108}, /* 26:                     OR shift  108 */ +  {  92,  32,  99}, /* 27:      ORACLE_OUTER_JOIN shift  99 */ +  {  14,   0, 124}, /* 28:                  BITOR shift  124 */ +  {  94,   0, 137}, /* 29:                   PLUS shift  137 */ +  {  25,   0, 147}, /* 30:                 CONCAT shift  147 */ +  {  63,   0, 159}, /* 31:                     IN shift  159 */ +  {  59,   0, 251}, /* 32:                     ID shift  251 */ +  { 131,   0, 280}, /* 33:                     as shift  280 */  /* State 282 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /*  4:                BETWEEN shift  153 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  11,   0, 120}, /*  7:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  8:                  BITOR shift  122 */ -  {  73,   0, 112}, /*  9:                     LE shift  112 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  {  68,   4, 148}, /* 11:                     IS shift  148 */ -  {  69,   7, 147}, /* 12:                 ISNULL shift  147 */ -  {  77,   0, 124}, /* 13:                 LSHIFT shift  124 */ -  {  42,   8, 118}, /* 14:                     EQ shift  118 */ -  { 101,   0, 283}, /* 15:                     RP shift  283 */ -  { 102,   9, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 18:                     GE shift  114 */ -  {  52,   0, 134}, /* 19:                   GLOB shift  134 */ -  { 106,  13, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  18, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  19, 116}, /* 24:                     NE shift  116 */ -  {  82,  27, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ -/* State 284 */ -  {  21,   0, 210}, /*  1:                  COMMA shift  210 */ -  { 101,   1, 285}, /*  2:                     RP shift  285 */ -/* State 286 */ -  { 101,   0, 287}, /*  1:                     RP shift  287 */ +  {  39,   0, 283}, /*  1:                    DOT shift  283 */ +/* State 283 */ +  { 111,   0, 284}, /*  1:                   STAR shift  284 */ +  { 181,   1, 104}, /*  2:                     nm shift  104 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 288 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {  10,   0, 153}, /*  4:                BETWEEN shift  153 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  11,   0, 120}, /*  7:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  8:                  BITOR shift  122 */ -  {  73,   0, 112}, /*  9:                     LE shift  112 */ -  {  96,   0, 143}, /* 10:                    REM shift  143 */ -  {  68,   4, 148}, /* 11:                     IS shift  148 */ -  {  69,   7, 147}, /* 12:                 ISNULL shift  147 */ -  {  77,   0, 124}, /* 13:                 LSHIFT shift  124 */ -  {  42,   8, 118}, /* 14:                     EQ shift  118 */ -  { 101,   0, 289}, /* 15:                     RP shift  289 */ -  { 102,   9, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 18:                     GE shift  114 */ -  {  52,   0, 134}, /* 19:                   GLOB shift  134 */ -  { 106,  13, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  18, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  19, 116}, /* 24:                     NE shift  116 */ -  {  82,  27, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ -/* State 289 */ -  { 180,   0, 290}, /*  1:                 onconf shift  290 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ -/* State 291 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 292}, /*  2:                     nm shift  292 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  63,   2, 159}, /*  1:                     IN shift  159 */ +  {   5,   0, 100}, /*  2:                    AND shift  100 */ +  {  12,   0, 122}, /*  3:                 BITAND shift  122 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   1,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  14,   0, 124}, /*  7:                  BITOR shift  124 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  76,   0, 114}, /*  9:                     LE shift  114 */ +  {  80,   0, 126}, /* 10:                 LSHIFT shift  126 */ +  {  54,  16, 116}, /* 11:                     GE shift  116 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   3, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   7, 149}, /* 15:                 ISNULL shift  149 */ +  {  25,   0, 147}, /* 16:                 CONCAT shift  147 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  { 104,   0, 289}, /* 18:                     RP shift  289 */ +  { 105,   9, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  10, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  11, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */ +/* State 290 */ +  { 104,   2, 291}, /*  1:                     RP shift  291 */ +  {  22,   0, 212}, /*  2:                  COMMA shift  212 */  /* State 292 */ -  {  76,   0, 310}, /*  1:                     LP shift  310 */ -  { 163,   0, 293}, /*  2:            idxlist_opt shift  293 */ -/* State 293 */ -  { 188,   0, 294}, /*  1:                refargs shift  294 */ +  { 104,   0, 293}, /*  1:                     RP shift  293 */  /* State 294 */ -  {  87,   0, 298}, /*  1:                     ON shift  298 */ -  { 187,   3, 295}, /*  2:                 refarg shift  295 */ -  {  79,   0, 296}, /*  3:                  MATCH shift  296 */ -/* State 296 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 297}, /*  2:                     nm shift  297 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  63,   2, 159}, /*  1:                     IN shift  159 */ +  {   5,   0, 100}, /*  2:                    AND shift  100 */ +  {  12,   0, 122}, /*  3:                 BITAND shift  122 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   1,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  14,   0, 124}, /*  7:                  BITOR shift  124 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  76,   0, 114}, /*  9:                     LE shift  114 */ +  {  80,   0, 126}, /* 10:                 LSHIFT shift  126 */ +  {  54,  16, 116}, /* 11:                     GE shift  116 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   3, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   7, 149}, /* 15:                 ISNULL shift  149 */ +  {  25,   0, 147}, /* 16:                 CONCAT shift  147 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  { 104,   0, 295}, /* 18:                     RP shift  295 */ +  { 105,   9, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  10, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  11, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */ +/* State 295 */ +  { 184,   2, 296}, /*  1:                 onconf shift  296 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */ +/* State 297 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 298}, /*  2:                     nm shift  298 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 298 */ -  { 120,   2, 306}, /*  1:                 UPDATE shift  306 */ -  {  63,   0, 308}, /*  2:                 INSERT shift  308 */ -  {  32,   0, 299}, /*  3:                 DELETE shift  299 */ +  { 168,   0, 299}, /*  1:            idxlist_opt shift  299 */ +  {  79,   0, 316}, /*  2:                     LP shift  316 */  /* State 299 */ -  {  98,   0, 305}, /*  1:               RESTRICT shift  305 */ -  { 105,   0, 301}, /*  2:                    SET shift  301 */ -  { 186,   1, 300}, /*  3:                 refact shift  300 */ -  {  15,   0, 304}, /*  4:                CASCADE shift  304 */ -/* State 301 */ -  {  84,   0, 302}, /*  1:                   NULL shift  302 */ -  {  29,   0, 303}, /*  2:                DEFAULT shift  303 */ -/* State 306 */ -  {  98,   0, 305}, /*  1:               RESTRICT shift  305 */ -  { 105,   0, 301}, /*  2:                    SET shift  301 */ -  { 186,   1, 307}, /*  3:                 refact shift  307 */ -  {  15,   0, 304}, /*  4:                CASCADE shift  304 */ -/* State 308 */ -  {  98,   0, 305}, /*  1:               RESTRICT shift  305 */ -  { 105,   0, 301}, /*  2:                    SET shift  301 */ -  { 186,   1, 309}, /*  3:                 refact shift  309 */ -  {  15,   0, 304}, /*  4:                CASCADE shift  304 */ -/* State 310 */ -  { 162,   0, 311}, /*  1:                idxlist shift  311 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ -/* State 311 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 312}, /*  2:                     RP shift  312 */ +  { 192,   0, 300}, /*  1:                refargs shift  300 */ +/* State 300 */ +  {  90,   0, 304}, /*  1:                     ON shift  304 */ +  {  82,   0, 302}, /*  2:                  MATCH shift  302 */ +  { 191,   0, 301}, /*  3:                 refarg shift  301 */ +/* State 302 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 303}, /*  2:                     nm shift  303 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 304 */ +  { 123,   3, 312}, /*  1:                 UPDATE shift  312 */ +  {  34,   0, 305}, /*  2:                 DELETE shift  305 */ +  {  66,   0, 314}, /*  3:                 INSERT shift  314 */ +/* State 305 */ +  { 108,   4, 307}, /*  1:                    SET shift  307 */ +  { 101,   0, 311}, /*  2:               RESTRICT shift  311 */ +  { 190,   0, 306}, /*  3:                 refact shift  306 */ +  {  16,   0, 310}, /*  4:                CASCADE shift  310 */ +/* State 307 */ +  {  31,   0, 309}, /*  1:                DEFAULT shift  309 */ +  {  87,   1, 308}, /*  2:                   NULL shift  308 */ +/* State 312 */ +  { 108,   4, 307}, /*  1:                    SET shift  307 */ +  { 101,   0, 311}, /*  2:               RESTRICT shift  311 */ +  { 190,   0, 313}, /*  3:                 refact shift  313 */ +  {  16,   0, 310}, /*  4:                CASCADE shift  310 */  /* State 314 */ -  {  56,   0,  96}, /*  1:                     ID shift  96 */ -  { 159,   0, 315}, /*  2:                     id shift  315 */ +  { 108,   4, 307}, /*  1:                    SET shift  307 */ +  { 101,   0, 311}, /*  2:               RESTRICT shift  311 */ +  { 190,   0, 315}, /*  3:                 refact shift  315 */ +  {  16,   0, 310}, /*  4:                CASCADE shift  310 */  /* State 316 */ -  { 164,   2, 317}, /*  1: init_deferred_pred_opt shift  317 */ -  {  62,   0,  51}, /*  2:              INITIALLY shift  51 */ -/* State 319 */ -  {  91,   2, 323}, /*  1:                   PLUS shift  323 */ -  {  84,   7, 330}, /*  2:                   NULL shift  330 */ -  {  65,   0, 322}, /*  3:                INTEGER shift  322 */ -  {  80,   0, 326}, /*  4:                  MINUS shift  326 */ -  {  46,   0, 329}, /*  5:                  FLOAT shift  329 */ -  { 110,   0, 320}, /*  6:                 STRING shift  320 */ -  {  56,   0, 321}, /*  7:                     ID shift  321 */ -/* State 323 */ -  {  46,   0, 325}, /*  1:                  FLOAT shift  325 */ -  {  65,   0, 324}, /*  2:                INTEGER shift  324 */ -/* State 326 */ -  {  46,   0, 328}, /*  1:                  FLOAT shift  328 */ -  {  65,   0, 327}, /*  2:                INTEGER shift  327 */ -/* State 331 */ -  { 160,   2, 343}, /*  1:                    ids shift  343 */ -  {  76,   4, 332}, /*  2:                     LP shift  332 */ -  { 110,   0, 249}, /*  3:                 STRING shift  249 */ -  {  56,   0, 248}, /*  4:                     ID shift  248 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 317}, /*  6:                idxlist shift  317 */ +/* State 317 */ +  { 104,   2, 318}, /*  1:                     RP shift  318 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */ +/* State 320 */ +  { 164,   0, 321}, /*  1:                     id shift  321 */ +  {  59,   0,  96}, /*  2:                     ID shift  96 */ +/* State 322 */ +  {  65,   0,  51}, /*  1:              INITIALLY shift  51 */ +  { 169,   1, 323}, /*  2: init_deferred_pred_opt shift  323 */ +/* State 325 */ +  {  49,   0, 335}, /*  1:                  FLOAT shift  335 */ +  { 113,   0, 326}, /*  2:                 STRING shift  326 */ +  {  87,   5, 336}, /*  3:                   NULL shift  336 */ +  {  94,   3, 329}, /*  4:                   PLUS shift  329 */ +  {  59,   0, 327}, /*  5:                     ID shift  327 */ +  {  68,   0, 328}, /*  6:                INTEGER shift  328 */ +  {  83,   0, 332}, /*  7:                  MINUS shift  332 */ +/* State 329 */ +  {  68,   0, 330}, /*  1:                INTEGER shift  330 */ +  {  49,   0, 331}, /*  2:                  FLOAT shift  331 */  /* State 332 */ -  {  80,   0, 341}, /*  1:                  MINUS shift  341 */ -  {  65,   0, 338}, /*  2:                INTEGER shift  338 */ -  {  91,   0, 339}, /*  3:                   PLUS shift  339 */ -  { 195,   3, 333}, /*  4:                 signed shift  333 */ -/* State 333 */ -  {  21,   0, 335}, /*  1:                  COMMA shift  335 */ -  { 101,   1, 334}, /*  2:                     RP shift  334 */ -/* State 335 */ -  {  80,   0, 341}, /*  1:                  MINUS shift  341 */ -  {  65,   0, 338}, /*  2:                INTEGER shift  338 */ -  {  91,   0, 339}, /*  3:                   PLUS shift  339 */ -  { 195,   3, 336}, /*  4:                 signed shift  336 */ -/* State 336 */ -  { 101,   0, 337}, /*  1:                     RP shift  337 */ +  {  68,   0, 333}, /*  1:                INTEGER shift  333 */ +  {  49,   0, 334}, /*  2:                  FLOAT shift  334 */ +/* State 337 */ +  { 113,   0, 252}, /*  1:                 STRING shift  252 */ +  { 165,   1, 349}, /*  2:                    ids shift  349 */ +  {  59,   0, 251}, /*  3:                     ID shift  251 */ +  {  79,   3, 338}, /*  4:                     LP shift  338 */ +/* State 338 */ +  {  68,   0, 344}, /*  1:                INTEGER shift  344 */ +  {  83,   0, 347}, /*  2:                  MINUS shift  347 */ +  {  94,   0, 345}, /*  3:                   PLUS shift  345 */ +  { 199,   2, 339}, /*  4:                 signed shift  339 */  /* State 339 */ -  {  65,   0, 340}, /*  1:                INTEGER shift  340 */ +  { 104,   2, 340}, /*  1:                     RP shift  340 */ +  {  22,   0, 341}, /*  2:                  COMMA shift  341 */  /* State 341 */ -  {  65,   0, 342}, /*  1:                INTEGER shift  342 */ -/* State 346 */ -  { 200,   4, 377}, /*  1:                  tcons shift  377 */ -  {  17,   0, 362}, /*  2:                  CHECK shift  362 */ -  {  26,   0, 349}, /*  3:             CONSTRAINT shift  349 */ -  {  48,   0, 365}, /*  4:                FOREIGN shift  365 */ -  {  93,   7, 351}, /*  5:                PRIMARY shift  351 */ -  { 101,   5, 608}, /*  6:                     RP reduce 77 */ -  {  21,   0, 347}, /*  7:                  COMMA shift  347 */ -  { 119,   0, 357}, /*  8:                 UNIQUE shift  357 */ +  {  68,   0, 344}, /*  1:                INTEGER shift  344 */ +  {  83,   0, 347}, /*  2:                  MINUS shift  347 */ +  {  94,   0, 345}, /*  3:                   PLUS shift  345 */ +  { 199,   2, 342}, /*  4:                 signed shift  342 */ +/* State 342 */ +  { 104,   0, 343}, /*  1:                     RP shift  343 */ +/* State 345 */ +  {  68,   0, 346}, /*  1:                INTEGER shift  346 */  /* State 347 */ -  {  48,   0, 365}, /*  1:                FOREIGN shift  365 */ -  {  26,   0, 349}, /*  2:             CONSTRAINT shift  349 */ -  { 200,   2, 348}, /*  3:                  tcons shift  348 */ -  {  93,   0, 351}, /*  4:                PRIMARY shift  351 */ -  {  17,   0, 362}, /*  5:                  CHECK shift  362 */ -  { 119,   5, 357}, /*  6:                 UNIQUE shift  357 */ -/* State 349 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 350}, /*  2:                     nm shift  350 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ -/* State 351 */ -  {  72,   0, 352}, /*  1:                    KEY shift  352 */ +  {  68,   0, 348}, /*  1:                INTEGER shift  348 */  /* State 352 */ -  {  76,   0, 353}, /*  1:                     LP shift  353 */ +  { 104,   2, 632}, /*  1:                     RP reduce 77 */ +  {  96,   0, 357}, /*  2:                PRIMARY shift  357 */ +  { 122,   6, 363}, /*  3:                 UNIQUE shift  363 */ +  {  51,   8, 371}, /*  4:                FOREIGN shift  371 */ +  { 204,   0, 383}, /*  5:                  tcons shift  383 */ +  {  18,   0, 368}, /*  6:                  CHECK shift  368 */ +  {  22,   0, 353}, /*  7:                  COMMA shift  353 */ +  {  27,   0, 355}, /*  8:             CONSTRAINT shift  355 */  /* State 353 */ -  { 162,   0, 354}, /*  1:                idxlist shift  354 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ -/* State 354 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 355}, /*  2:                     RP shift  355 */ +  { 204,   2, 354}, /*  1:                  tcons shift  354 */ +  {  96,   5, 357}, /*  2:                PRIMARY shift  357 */ +  { 122,   0, 363}, /*  3:                 UNIQUE shift  363 */ +  {  51,   6, 371}, /*  4:                FOREIGN shift  371 */ +  {  18,   0, 368}, /*  5:                  CHECK shift  368 */ +  {  27,   0, 355}, /*  6:             CONSTRAINT shift  355 */  /* State 355 */ -  { 180,   0, 356}, /*  1:                 onconf shift  356 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 356}, /*  2:                     nm shift  356 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 357 */ -  {  76,   0, 358}, /*  1:                     LP shift  358 */ +  {  75,   0, 358}, /*  1:                    KEY shift  358 */  /* State 358 */ -  { 162,   0, 359}, /*  1:                idxlist shift  359 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ +  {  79,   0, 359}, /*  1:                     LP shift  359 */  /* State 359 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 360}, /*  2:                     RP shift  360 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 360}, /*  6:                idxlist shift  360 */  /* State 360 */ -  { 180,   0, 361}, /*  1:                 onconf shift  361 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ -/* State 362 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 363}, /*  3:                   expr shift  363 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 104,   2, 361}, /*  1:                     RP shift  361 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */ +/* State 361 */ +  { 184,   2, 362}, /*  1:                 onconf shift  362 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 363 */ -  { 180,   3, 364}, /*  1:                 onconf shift  364 */ -  {  91,   0, 135}, /*  2:                   PLUS shift  135 */ -  {  60,   0, 157}, /*  3:                     IN shift  157 */ -  {  42,   0, 118}, /*  4:                     EQ shift  118 */ -  {  13,   0, 122}, /*  5:                  BITOR shift  122 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  96,   0, 143}, /*  7:                    REM shift  143 */ -  {  78,   0, 108}, /*  8:                     LT shift  108 */ -  {  68,   0, 148}, /*  9:                     IS shift  148 */ -  {  69,   0, 147}, /* 10:                 ISNULL shift  147 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  { 102,   4, 126}, /* 13:                 RSHIFT shift  126 */ -  {  73,   5, 112}, /* 14:                     LE shift  112 */ -  {  74,   0, 133}, /* 15:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 16:                     GE shift  114 */ -  { 106,   0, 141}, /* 17:                  SLASH shift  141 */ -  {  77,   0, 124}, /* 18:                 LSHIFT shift  124 */ -  { 108,   8, 139}, /* 19:                   STAR shift  139 */ -  {  82,  26, 130}, /* 20:                    NOT shift  130 */ -  {  80,   0, 137}, /* 21:                  MINUS shift  137 */ -  {  81,  16, 116}, /* 22:                     NE shift  116 */ -  { 172,  20, 128}, /* 23:                 likeop shift  128 */ -  {  83,   0, 152}, /* 24:                NOTNULL shift  152 */ -  {  54,  27, 110}, /* 25:                     GT shift  110 */ -  {  52,   0, 134}, /* 26:                   GLOB shift  134 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  {  87,   0,  10}, /* 28:                     ON shift  10 */ -  {  88,   0, 106}, /* 29:                     OR shift  106 */ -  {  89,   0,  99}, /* 30:      ORACLE_OUTER_JOIN shift  99 */ +  {  79,   0, 364}, /*  1:                     LP shift  364 */ +/* State 364 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 365}, /*  6:                idxlist shift  365 */  /* State 365 */ -  {  72,   0, 366}, /*  1:                    KEY shift  366 */ +  { 104,   2, 366}, /*  1:                     RP shift  366 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */  /* State 366 */ -  {  76,   0, 367}, /*  1:                     LP shift  367 */ -/* State 367 */ -  { 162,   0, 368}, /*  1:                idxlist shift  368 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ +  { 184,   2, 367}, /*  1:                 onconf shift  367 */ +  {  90,   0,  10}, /*  2:                     ON shift  10 */  /* State 368 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 369}, /*  2:                     RP shift  369 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 369}, /*  8:                   expr shift  369 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 369 */ -  {  95,   0, 370}, /*  1:             REFERENCES shift  370 */ -/* State 370 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 371}, /*  2:                     nm shift  371 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  90,   0,  10}, /*  1:                     ON shift  10 */ +  {  91,   0, 108}, /*  2:                     OR shift  108 */ +  {  92,   0,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ +  {  63,   0, 159}, /*  4:                     IN shift  159 */ +  { 184,   7, 370}, /*  5:                 onconf shift  370 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  94,   0, 137}, /*  7:                   PLUS shift  137 */ +  {  11,   0, 155}, /*  8:                BETWEEN shift  155 */ +  {  12,   0, 122}, /*  9:                 BITAND shift  122 */ +  {  99,   0, 145}, /* 10:                    REM shift  145 */ +  {  45,   0, 120}, /* 11:                     EQ shift  120 */ +  {  71,   8, 150}, /* 12:                     IS shift  150 */ +  {  72,   9, 149}, /* 13:                 ISNULL shift  149 */ +  {  81,   0, 110}, /* 14:                     LT shift  110 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  { 105,  11, 128}, /* 16:                 RSHIFT shift  128 */ +  {  76,   0, 114}, /* 17:                     LE shift  114 */ +  {  77,   0, 135}, /* 18:                   LIKE shift  135 */ +  {  54,   0, 116}, /* 19:                     GE shift  116 */ +  { 109,   0, 143}, /* 20:                  SLASH shift  143 */ +  {  80,   0, 126}, /* 21:                 LSHIFT shift  126 */ +  { 111,  14, 141}, /* 22:                   STAR shift  141 */ +  {  55,  29, 136}, /* 23:                   GLOB shift  136 */ +  {  83,   0, 139}, /* 24:                  MINUS shift  139 */ +  {  84,  19, 118}, /* 25:                     NE shift  118 */ +  {  85,  23, 132}, /* 26:                    NOT shift  132 */ +  {  86,   0, 154}, /* 27:                NOTNULL shift  154 */ +  { 177,  30, 130}, /* 28:                 likeop shift  130 */ +  {  25,   0, 147}, /* 29:                 CONCAT shift  147 */ +  {  57,   0, 112}, /* 30:                     GT shift  112 */  /* State 371 */ -  {  76,   0, 310}, /*  1:                     LP shift  310 */ -  { 163,   0, 372}, /*  2:            idxlist_opt shift  372 */ +  {  75,   0, 372}, /*  1:                    KEY shift  372 */  /* State 372 */ -  { 188,   0, 373}, /*  1:                refargs shift  373 */ +  {  79,   0, 373}, /*  1:                     LP shift  373 */  /* State 373 */ -  { 147,   0, 375}, /*  1:    defer_subclause_opt shift  375 */ -  {  30,   0, 316}, /*  2:             DEFERRABLE shift  316 */ -  {  79,   2, 296}, /*  3:                  MATCH shift  296 */ -  {  87,   0, 298}, /*  4:                     ON shift  298 */ -  {  82,   0, 374}, /*  5:                    NOT shift  374 */ -  { 187,   5, 295}, /*  6:                 refarg shift  295 */ -  { 146,   0, 376}, /*  7:        defer_subclause shift  376 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 374}, /*  6:                idxlist shift  374 */  /* State 374 */ -  {  30,   0,  49}, /*  1:             DEFERRABLE shift  49 */ +  { 104,   2, 375}, /*  1:                     RP shift  375 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */ +/* State 375 */ +  {  98,   0, 376}, /*  1:             REFERENCES shift  376 */ +/* State 376 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 377}, /*  2:                     nm shift  377 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 377 */ +  { 168,   0, 378}, /*  1:            idxlist_opt shift  378 */ +  {  79,   0, 316}, /*  2:                     LP shift  316 */ +/* State 378 */ +  { 192,   0, 379}, /*  1:                refargs shift  379 */ +/* State 379 */ +  {  32,   0, 322}, /*  1:             DEFERRABLE shift  322 */ +  {  85,   0, 380}, /*  2:                    NOT shift  380 */ +  { 191,   0, 301}, /*  3:                 refarg shift  301 */ +  {  82,   0, 302}, /*  4:                  MATCH shift  302 */ +  { 151,   1, 382}, /*  5:        defer_subclause shift  382 */ +  { 152,   4, 381}, /*  6:    defer_subclause_opt shift  381 */ +  {  90,   0, 304}, /*  7:                     ON shift  304 */  /* State 380 */ -  { 192,   0, 381}, /*  1:                 select shift  381 */ -  { 181,   3,  69}, /*  2:              oneselect shift  69 */ -  { 103,   0,  73}, /*  3:                 SELECT shift  73 */ -/* State 381 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 551}, /*  5:                   SEMI reduce 20 */ -/* State 382 */ -  {  61,   0, 762}, /*  1:                  INDEX reduce 231 */ -  { 115,   1, 401}, /*  2:                TRIGGER shift  401 */ -  { 119,   0, 400}, /*  3:                 UNIQUE shift  400 */ -  { 201,   0, 383}, /*  4:                   temp shift  383 */ -  { 112,   0, 390}, /*  5:                   TEMP shift  390 */ -  { 209,   3, 391}, /*  6:             uniqueflag shift  391 */ -/* State 383 */ -  { 111,   0, 384}, /*  1:                  TABLE shift  384 */ -  { 125,   1, 386}, /*  2:                   VIEW shift  386 */ -/* State 384 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 385}, /*  2:                     nm shift  385 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  32,   0,  49}, /*  1:             DEFERRABLE shift  49 */  /* State 386 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 387}, /*  2:                     nm shift  387 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 106,   0,  73}, /*  1:                 SELECT shift  73 */ +  { 196,   1, 387}, /*  2:                 select shift  387 */ +  { 185,   0,  69}, /*  3:              oneselect shift  69 */  /* State 387 */ -  {   6,   0, 388}, /*  1:                     AS shift  388 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 575}, /*  3:                   SEMI reduce 20 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 388 */ -  { 192,   0, 389}, /*  1:                 select shift  389 */ -  { 181,   3,  69}, /*  2:              oneselect shift  69 */ -  { 103,   0,  73}, /*  3:                 SELECT shift  73 */ +  { 115,   0, 434}, /*  1:                   TEMP shift  434 */ +  { 205,   1, 389}, /*  2:                   temp shift  389 */ +  { 209,   0, 435}, /*  3:           trigger_decl shift  435 */  /* State 389 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 629}, /*  5:                   SEMI reduce 98 */ -/* State 391 */ -  {  61,   0, 392}, /*  1:                  INDEX shift  392 */ +  { 114,   0, 390}, /*  1:                  TABLE shift  390 */ +  { 122,   0, 406}, /*  2:                 UNIQUE shift  406 */ +  { 128,   2, 392}, /*  3:                   VIEW shift  392 */ +  { 118,   6, 407}, /*  4:                TRIGGER shift  407 */ +  { 214,   4, 396}, /*  5:             uniqueflag shift  396 */ +  {  64,   0, 788}, /*  6:                  INDEX reduce 233 */ +/* State 390 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 391}, /*  2:                     nm shift  391 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 392 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 393}, /*  2:                     nm shift  393 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 393}, /*  2:                     nm shift  393 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 393 */ -  {  87,   0, 394}, /*  1:                     ON shift  394 */ +  {   6,   0, 394}, /*  1:                     AS shift  394 */  /* State 394 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 395}, /*  2:                     nm shift  395 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 106,   0,  73}, /*  1:                 SELECT shift  73 */ +  { 196,   1, 395}, /*  2:                 select shift  395 */ +  { 185,   0,  69}, /*  3:              oneselect shift  69 */  /* State 395 */ -  {  76,   0, 396}, /*  1:                     LP shift  396 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 653}, /*  3:                   SEMI reduce 98 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 396 */ -  { 162,   0, 397}, /*  1:                idxlist shift  397 */ -  {  56,   0,  20}, /*  2:                     ID shift  20 */ -  { 110,   2,  21}, /*  3:                 STRING shift  21 */ -  { 177,   0, 262}, /*  4:                     nm shift  262 */ -  {  71,   0,  22}, /*  5:                JOIN_KW shift  22 */ -  { 161,   5, 263}, /*  6:                idxitem shift  263 */ +  {  64,   0, 397}, /*  1:                  INDEX shift  397 */  /* State 397 */ -  {  21,   0, 260}, /*  1:                  COMMA shift  260 */ -  { 101,   1, 398}, /*  2:                     RP shift  398 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 398}, /*  2:                     nm shift  398 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 398 */ -  { 180,   2, 399}, /*  1:                 onconf shift  399 */ -  {  87,   0,  10}, /*  2:                     ON shift  10 */ -  { 104,   0, 619}, /*  3:                   SEMI reduce 88 */ +  {  90,   0, 399}, /*  1:                     ON shift  399 */  /* State 399 */ -  { 104,   0, 760}, /*  1:                   SEMI reduce 229 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 400}, /*  2:                     nm shift  400 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 400 */ -  {  61,   0, 761}, /*  1:                  INDEX reduce 230 */ +  { 150,   3, 401}, /*  1:                   dbnm shift  401 */ +  {  79,   0, 680}, /*  2:                     LP reduce 125 */ +  {  39,   0, 270}, /*  3:                    DOT shift  270 */  /* State 401 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 402}, /*  2:                     nm shift  402 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  79,   0, 402}, /*  1:                     LP shift  402 */  /* State 402 */ -  {  64,   2, 467}, /*  1:                INSTEAD shift  467 */ -  {   8,   0, 465}, /*  2:                 BEFORE shift  465 */ -  { 206,   4, 403}, /*  3:           trigger_time shift  403 */ -  {   2,   0, 466}, /*  4:                  AFTER shift  466 */ +  { 113,   4,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 265}, /*  2:                     nm shift  265 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +  { 166,   0, 267}, /*  5:                idxitem shift  267 */ +  { 167,   1, 403}, /*  6:                idxlist shift  403 */  /* State 403 */ -  { 120,   3, 462}, /*  1:                 UPDATE shift  462 */ -  { 205,   0, 404}, /*  2:          trigger_event shift  404 */ -  {  32,   0, 460}, /*  3:                 DELETE shift  460 */ -  {  63,   0, 461}, /*  4:                 INSERT shift  461 */ +  { 104,   2, 404}, /*  1:                     RP shift  404 */ +  {  22,   0, 263}, /*  2:                  COMMA shift  263 */  /* State 404 */ -  {  87,   0, 405}, /*  1:                     ON shift  405 */ +  {  90,   0,  10}, /*  1:                     ON shift  10 */ +  { 184,   0, 405}, /*  2:                 onconf shift  405 */ +  { 107,   0, 643}, /*  3:                   SEMI reduce 88 */  /* State 405 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 406}, /*  2:                     nm shift  406 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 107,   0, 786}, /*  1:                   SEMI reduce 231 */  /* State 406 */ -  {  47,   0, 456}, /*  1:                    FOR shift  456 */ -  { 155,   1, 407}, /*  2:         foreach_clause shift  407 */ +  {  64,   0, 787}, /*  1:                  INDEX reduce 232 */  /* State 407 */ -  { 126,   3, 454}, /*  1:                   WHEN shift  454 */ -  { 211,   0, 408}, /*  2:            when_clause shift  408 */ -  {   9,   0, 797}, /*  3:                  BEGIN reduce 266 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 408}, /*  2:                     nm shift  408 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 408 */ -  {   9,   0, 409}, /*  1:                  BEGIN shift  409 */ +  {  67,   0, 432}, /*  1:                INSTEAD shift  432 */ +  {   9,   0, 430}, /*  2:                 BEFORE shift  430 */ +  {   2,   0, 431}, /*  3:                  AFTER shift  431 */ +  { 211,   1, 409}, /*  4:           trigger_time shift  409 */  /* State 409 */ -  {  63,   0, 431}, /*  1:                 INSERT shift  431 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  { 120,   0, 416}, /*  3:                 UPDATE shift  416 */ -  { 192,   3, 410}, /*  4:                 select shift  410 */ -  { 103,   8,  73}, /*  5:                 SELECT shift  73 */ -  { 203,   9, 413}, /*  6:            trigger_cmd shift  413 */ -  { 204,   0, 411}, /*  7:       trigger_cmd_list shift  411 */ -  {  40,   0, 800}, /*  8:                    END reduce 269 */ -  {  32,   0, 450}, /*  9:                 DELETE shift  450 */ +  {  66,   2, 423}, /*  1:                 INSERT shift  423 */ +  {  34,   0, 422}, /*  2:                 DELETE shift  422 */ +  { 210,   1, 410}, /*  3:          trigger_event shift  410 */ +  { 123,   0, 424}, /*  4:                 UPDATE shift  424 */  /* State 410 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 805}, /*  5:                   SEMI reduce 274 */ +  {  90,   0, 411}, /*  1:                     ON shift  411 */  /* State 411 */ -  {  40,   0, 412}, /*  1:                    END shift  412 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 412}, /*  2:                     nm shift  412 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 412 */ -  { 104,   0, 785}, /*  1:                   SEMI reduce 254 */ +  { 150,   0, 413}, /*  1:                   dbnm shift  413 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */  /* State 413 */ -  { 104,   0, 414}, /*  1:                   SEMI shift  414 */ +  { 160,   2, 414}, /*  1:         foreach_clause shift  414 */ +  {  50,   0, 418}, /*  2:                    FOR shift  418 */  /* State 414 */ -  {  63,   0, 431}, /*  1:                 INSERT shift  431 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  { 120,   0, 416}, /*  3:                 UPDATE shift  416 */ -  { 192,   3, 410}, /*  4:                 select shift  410 */ -  { 103,   8,  73}, /*  5:                 SELECT shift  73 */ -  { 203,   9, 413}, /*  6:            trigger_cmd shift  413 */ -  { 204,   0, 415}, /*  7:       trigger_cmd_list shift  415 */ -  {  40,   0, 800}, /*  8:                    END reduce 269 */ -  {  32,   0, 450}, /*  9:                 DELETE shift  450 */ +  { 216,   3, 415}, /*  1:            when_clause shift  415 */ +  {  10,   0, 824}, /*  2:                  BEGIN reduce 269 */ +  { 129,   0, 416}, /*  3:                   WHEN shift  416 */  /* State 415 */ -  {  40,   0, 799}, /*  1:                    END reduce 268 */ +  {  10,   0, 812}, /*  1:                  BEGIN reduce 257 */  /* State 416 */ -  { 182,   2, 419}, /*  1:                 orconf shift  419 */ -  {  88,   0, 417}, /*  2:                     OR shift  417 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 417}, /*  8:                   expr shift  417 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 417 */ -  {   1,   0,  14}, /*  1:                  ABORT shift  14 */ -  {  97,   1,  17}, /*  2:                REPLACE shift  17 */ -  {  99,   5,  13}, /*  3:               ROLLBACK shift  13 */ -  { 189,   3, 418}, /*  4:            resolvetype shift  418 */ -  {  57,   6,  16}, /*  5:                 IGNORE shift  16 */ -  {  45,   0,  15}, /*  6:                   FAIL shift  15 */ +  {  63,   2, 159}, /*  1:                     IN shift  159 */ +  {   5,   0, 100}, /*  2:                    AND shift  100 */ +  {  12,   0, 122}, /*  3:                 BITAND shift  122 */ +  { 177,   0, 130}, /*  4:                 likeop shift  130 */ +  {  91,   0, 108}, /*  5:                     OR shift  108 */ +  {  92,   1,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ +  {  14,   0, 124}, /*  7:                  BITOR shift  124 */ +  {  94,   0, 137}, /*  8:                   PLUS shift  137 */ +  {  76,   0, 114}, /*  9:                     LE shift  114 */ +  {  80,   0, 126}, /* 10:                 LSHIFT shift  126 */ +  {  10,   0, 825}, /* 11:                  BEGIN reduce 270 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  99,   3, 145}, /* 13:                    REM shift  145 */ +  {  71,   0, 150}, /* 14:                     IS shift  150 */ +  {  72,   7, 149}, /* 15:                 ISNULL shift  149 */ +  {  54,  18, 116}, /* 16:                     GE shift  116 */ +  {  45,   0, 120}, /* 17:                     EQ shift  120 */ +  {  25,   0, 147}, /* 18:                 CONCAT shift  147 */ +  { 105,   9, 128}, /* 19:                 RSHIFT shift  128 */ +  {  77,   0, 135}, /* 20:                   LIKE shift  135 */ +  {  55,   0, 136}, /* 21:                   GLOB shift  136 */ +  {  57,   0, 112}, /* 22:                     GT shift  112 */ +  { 109,  10, 143}, /* 23:                  SLASH shift  143 */ +  {  81,   0, 110}, /* 24:                     LT shift  110 */ +  { 111,   0, 141}, /* 25:                   STAR shift  141 */ +  {  83,  16, 139}, /* 26:                  MINUS shift  139 */ +  {  84,  21, 118}, /* 27:                     NE shift  118 */ +  {  85,   0, 132}, /* 28:                    NOT shift  132 */ +  {  86,  22, 154}, /* 29:                NOTNULL shift  154 */ +/* State 418 */ +  {  41,   0, 419}, /*  1:                   EACH shift  419 */  /* State 419 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 420}, /*  2:                     nm shift  420 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ -/* State 420 */ -  { 105,   0, 421}, /*  1:                    SET shift  421 */ -/* State 421 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  {  71,   4,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 428}, /*  3:                     nm shift  428 */ -  {  56,   0,  20}, /*  4:                     ID shift  20 */ -  { 194,   0, 422}, /*  5:                setlist shift  422 */ +  { 112,   0, 421}, /*  1:              STATEMENT shift  421 */ +  { 103,   0, 420}, /*  2:                    ROW shift  420 */  /* State 422 */ -  { 212,   3, 427}, /*  1:              where_opt shift  427 */ -  {  21,   0, 423}, /*  2:                  COMMA shift  423 */ -  { 104,   0, 685}, /*  3:                   SEMI reduce 154 */ -  { 127,   0, 232}, /*  4:                  WHERE shift  232 */ +  {  90,   0, 817}, /*  1:                     ON reduce 262 */  /* State 423 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 424}, /*  2:                     nm shift  424 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  90,   0, 818}, /*  1:                     ON reduce 263 */  /* State 424 */ -  {  42,   0, 425}, /*  1:                     EQ shift  425 */ +  {  90,   2, 819}, /*  1:                     ON reduce 264 */ +  {  88,   0, 425}, /*  2:                     OF shift  425 */  /* State 425 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 426}, /*  3:                   expr shift  426 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 171,   0, 426}, /*  1:             inscollist shift  426 */ +  { 181,   1, 429}, /*  2:                     nm shift  429 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 426 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  90,   2, 820}, /*  1:                     ON reduce 265 */ +  {  22,   0, 427}, /*  2:                  COMMA shift  427 */  /* State 427 */ -  { 104,   0, 801}, /*  1:                   SEMI reduce 270 */ -/* State 428 */ -  {  42,   0, 429}, /*  1:                     EQ shift  429 */ -/* State 429 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 430}, /*  3:                   expr shift  430 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ -/* State 430 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ -/* State 431 */ -  {  67,   0, 621}, /*  1:                   INTO reduce 90 */ -  {  88,   1, 417}, /*  2:                     OR shift  417 */ -  { 182,   0, 432}, /*  3:                 orconf shift  432 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 428}, /*  2:                     nm shift  428 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 432 */ -  {  67,   0, 433}, /*  1:                   INTO shift  433 */ -/* State 433 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 434}, /*  2:                     nm shift  434 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ -/* State 434 */ -  {  76,   0, 435}, /*  1:                     LP shift  435 */ -  { 167,   0, 441}, /*  2:         inscollist_opt shift  441 */ +  {  88,   0, 433}, /*  1:                     OF shift  433 */  /* State 435 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  { 166,   4, 436}, /*  2:             inscollist shift  436 */ -  { 177,   0, 440}, /*  3:                     nm shift  440 */ -  {  71,   5,  22}, /*  4:                JOIN_KW shift  22 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ +  {  10,   0, 436}, /*  1:                  BEGIN shift  436 */  /* State 436 */ -  {  21,   0, 438}, /*  1:                  COMMA shift  438 */ -  { 101,   1, 437}, /*  2:                     RP shift  437 */ +  { 207,   0, 440}, /*  1:            trigger_cmd shift  440 */ +  { 208,   0, 438}, /*  2:       trigger_cmd_list shift  438 */ +  { 106,   5,  73}, /*  3:                 SELECT shift  73 */ +  {  66,   0, 458}, /*  4:                 INSERT shift  458 */ +  {  43,   9, 827}, /*  5:                    END reduce 272 */ +  { 185,   0,  69}, /*  6:              oneselect shift  69 */ +  { 123,   0, 443}, /*  7:                 UPDATE shift  443 */ +  { 196,   3, 437}, /*  8:                 select shift  437 */ +  {  34,   0, 474}, /*  9:                 DELETE shift  474 */ +/* State 437 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 832}, /*  3:                   SEMI reduce 277 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 438 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 439}, /*  2:                     nm shift  439 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  43,   0, 439}, /*  1:                    END shift  439 */ +/* State 439 */ +  { 107,   0, 811}, /*  1:                   SEMI reduce 256 */ +/* State 440 */ +  { 107,   0, 441}, /*  1:                   SEMI shift  441 */  /* State 441 */ -  { 192,   3, 442}, /*  1:                 select shift  442 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  { 124,   0, 443}, /*  3:                 VALUES shift  443 */ -  { 103,   0,  73}, /*  4:                 SELECT shift  73 */ +  { 207,   0, 440}, /*  1:            trigger_cmd shift  440 */ +  { 208,   0, 442}, /*  2:       trigger_cmd_list shift  442 */ +  { 106,   5,  73}, /*  3:                 SELECT shift  73 */ +  {  66,   0, 458}, /*  4:                 INSERT shift  458 */ +  {  43,   9, 827}, /*  5:                    END reduce 272 */ +  { 185,   0,  69}, /*  6:              oneselect shift  69 */ +  { 123,   0, 443}, /*  7:                 UPDATE shift  443 */ +  { 196,   3, 437}, /*  8:                 select shift  437 */ +  {  34,   0, 474}, /*  9:                 DELETE shift  474 */  /* State 442 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 803}, /*  5:                   SEMI reduce 272 */ +  {  43,   0, 826}, /*  1:                    END reduce 271 */  /* State 443 */ -  {  76,   0, 444}, /*  1:                     LP shift  444 */ +  { 186,   0, 446}, /*  1:                 orconf shift  446 */ +  {  91,   0, 444}, /*  2:                     OR shift  444 */  /* State 444 */ -  {  80,   4, 172}, /*  1:                  MINUS shift  172 */ -  { 177,   6, 102}, /*  2:                     nm shift  102 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  {  16,   0, 176}, /*  4:                   CASE shift  176 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  56,   0,  64}, /*  7:                     ID shift  64 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,   7, 449}, /*  9:                   expr shift  449 */ -  { 169,   0, 445}, /* 10:               itemlist shift  445 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  91,   0, 174}, /* 12:                   PLUS shift  174 */ -  {  76,  11,  68}, /* 13:                     LP shift  68 */ -  {  94,  16, 186}, /* 14:                  RAISE shift  186 */ -  { 110,  14,  66}, /* 15:                 STRING shift  66 */ -  {  46,   0, 167}, /* 16:                  FLOAT shift  167 */ -/* State 445 */ -  {  21,   0, 446}, /*  1:                  COMMA shift  446 */ -  { 101,   1, 448}, /*  2:                     RP shift  448 */ +  { 102,   3,  13}, /*  1:               ROLLBACK shift  13 */ +  { 193,   4, 445}, /*  2:            resolvetype shift  445 */ +  {  60,   6,  16}, /*  3:                 IGNORE shift  16 */ +  {   1,   0,  14}, /*  4:                  ABORT shift  14 */ +  { 100,   0,  17}, /*  5:                REPLACE shift  17 */ +  {  48,   0,  15}, /*  6:                   FAIL shift  15 */  /* State 446 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 447}, /*  3:                   expr shift  447 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 447}, /*  2:                     nm shift  447 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 447 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  { 108,   0, 448}, /*  1:                    SET shift  448 */  /* State 448 */ -  { 104,   0, 802}, /*  1:                   SEMI reduce 271 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 455}, /*  2:                     nm shift  455 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 198,   1, 449}, /*  4:                setlist shift  449 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 449 */ -  {  88,   2, 106}, /*  1:                     OR shift  106 */ -  {  60,   0, 157}, /*  2:                     IN shift  157 */ -  {   5,   0, 100}, /*  3:                    AND shift  100 */ -  {  68,   0, 148}, /*  4:                     IS shift  148 */ -  { 172,   1, 128}, /*  5:                 likeop shift  128 */ -  {  89,   3,  99}, /*  6:      ORACLE_OUTER_JOIN shift  99 */ -  {  13,   0, 122}, /*  7:                  BITOR shift  122 */ -  {  91,   0, 135}, /*  8:                   PLUS shift  135 */ -  {  74,   0, 133}, /*  9:                   LIKE shift  133 */ -  {  78,   0, 108}, /* 10:                     LT shift  108 */ -  {  10,   0, 153}, /* 11:                BETWEEN shift  153 */ -  {  11,   0, 120}, /* 12:                 BITAND shift  120 */ -  {  96,   4, 143}, /* 13:                    REM shift  143 */ -  {  69,   7, 147}, /* 14:                 ISNULL shift  147 */ -  {  42,   0, 118}, /* 15:                     EQ shift  118 */ -  {  80,  17, 137}, /* 16:                  MINUS shift  137 */ -  {  52,  20, 134}, /* 17:                   GLOB shift  134 */ -  {  73,   0, 112}, /* 18:                     LE shift  112 */ -  { 102,   9, 126}, /* 19:                 RSHIFT shift  126 */ -  {  24,   0, 145}, /* 20:                 CONCAT shift  145 */ -  {  54,   0, 110}, /* 21:                     GT shift  110 */ -  {  77,   0, 124}, /* 22:                 LSHIFT shift  124 */ -  { 106,  10, 141}, /* 23:                  SLASH shift  141 */ -  {  51,   0, 114}, /* 24:                     GE shift  114 */ -  { 108,  16, 139}, /* 25:                   STAR shift  139 */ -  {  81,   0, 116}, /* 26:                     NE shift  116 */ -  {  82,  21, 130}, /* 27:                    NOT shift  130 */ -  {  83,   0, 152}, /* 28:                NOTNULL shift  152 */ +  {  22,   0, 450}, /*  1:                  COMMA shift  450 */ +  { 217,   0, 454}, /*  2:              where_opt shift  454 */ +  { 130,   1, 234}, /*  3:                  WHERE shift  234 */ +  { 107,   0, 710}, /*  4:                   SEMI reduce 155 */  /* State 450 */ -  {  49,   0, 451}, /*  1:                   FROM shift  451 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 451}, /*  2:                     nm shift  451 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 451 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 452}, /*  2:                     nm shift  452 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  45,   0, 452}, /*  1:                     EQ shift  452 */  /* State 452 */ -  { 104,   0, 685}, /*  1:                   SEMI reduce 154 */ -  { 127,   0, 232}, /*  2:                  WHERE shift  232 */ -  { 212,   1, 453}, /*  3:              where_opt shift  453 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 453}, /*  8:                   expr shift  453 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 453 */ -  { 104,   0, 804}, /*  1:                   SEMI reduce 273 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 454 */ -  {  76,   4,  68}, /*  1:                     LP shift  68 */ -  {  91,   1, 174}, /*  2:                   PLUS shift  174 */ -  { 152,   0, 455}, /*  3:                   expr shift  455 */ -  {  46,   7, 167}, /*  4:                  FLOAT shift  167 */ -  {  94,   0, 186}, /*  5:                  RAISE shift  186 */ -  { 110,   9,  66}, /*  6:                 STRING shift  66 */ -  {  16,   0, 176}, /*  7:                   CASE shift  176 */ -  {  82,   0, 168}, /*  8:                    NOT shift  168 */ -  {  80,  11, 172}, /*  9:                  MINUS shift  172 */ -  {  84,   0, 101}, /* 10:                   NULL shift  101 */ -  {  65,   0, 166}, /* 11:                INTEGER shift  166 */ -  {  71,  14,  67}, /* 12:                JOIN_KW shift  67 */ -  { 177,  15, 102}, /* 13:                     nm shift  102 */ -  {  56,   0,  64}, /* 14:                     ID shift  64 */ -  {  12,   0, 170}, /* 15:                 BITNOT shift  170 */ +  { 107,   0, 828}, /*  1:                   SEMI reduce 273 */  /* State 455 */ -  {  60,   0, 157}, /*  1:                     IN shift  157 */ -  {  88,   0, 106}, /*  2:                     OR shift  106 */ -  {  89,   1,  99}, /*  3:      ORACLE_OUTER_JOIN shift  99 */ -  {   9,   0, 798}, /*  4:                  BEGIN reduce 267 */ -  {  91,   0, 135}, /*  5:                   PLUS shift  135 */ -  {   5,   0, 100}, /*  6:                    AND shift  100 */ -  {  10,   0, 153}, /*  7:                BETWEEN shift  153 */ -  {  11,   0, 120}, /*  8:                 BITAND shift  120 */ -  {  13,   0, 122}, /*  9:                  BITOR shift  122 */ -  {  96,   4, 143}, /* 10:                    REM shift  143 */ -  {  68,   7, 148}, /* 11:                     IS shift  148 */ -  {  69,   8, 147}, /* 12:                 ISNULL shift  147 */ -  {  73,   0, 112}, /* 13:                     LE shift  112 */ -  {  42,   9, 118}, /* 14:                     EQ shift  118 */ -  {  77,   0, 124}, /* 15:                 LSHIFT shift  124 */ -  { 102,  13, 126}, /* 16:                 RSHIFT shift  126 */ -  {  74,   0, 133}, /* 17:                   LIKE shift  133 */ -  {  51,   0, 114}, /* 18:                     GE shift  114 */ -  {  52,   0, 134}, /* 19:                   GLOB shift  134 */ -  { 106,  15, 141}, /* 20:                  SLASH shift  141 */ -  {  78,   0, 108}, /* 21:                     LT shift  108 */ -  { 108,   0, 139}, /* 22:                   STAR shift  139 */ -  {  80,  18, 137}, /* 23:                  MINUS shift  137 */ -  {  81,  19, 116}, /* 24:                     NE shift  116 */ -  {  82,  27, 130}, /* 25:                    NOT shift  130 */ -  {  83,  29, 152}, /* 26:                NOTNULL shift  152 */ -  {  24,   0, 145}, /* 27:                 CONCAT shift  145 */ -  { 172,   0, 128}, /* 28:                 likeop shift  128 */ -  {  54,   0, 110}, /* 29:                     GT shift  110 */ +  {  45,   0, 456}, /*  1:                     EQ shift  456 */  /* State 456 */ -  {  38,   0, 457}, /*  1:                   EACH shift  457 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 457}, /*  8:                   expr shift  457 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 457 */ -  { 100,   0, 458}, /*  1:                    ROW shift  458 */ -  { 109,   0, 459}, /*  2:              STATEMENT shift  459 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */ +/* State 458 */ +  { 186,   0, 459}, /*  1:                 orconf shift  459 */ +  {  91,   3, 444}, /*  2:                     OR shift  444 */ +  {  70,   0, 645}, /*  3:                   INTO reduce 90 */ +/* State 459 */ +  {  70,   0, 460}, /*  1:                   INTO shift  460 */  /* State 460 */ -  {  87,   0, 790}, /*  1:                     ON reduce 259 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 461}, /*  2:                     nm shift  461 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 461 */ -  {  87,   0, 791}, /*  1:                     ON reduce 260 */ +  { 172,   0, 465}, /*  1:         inscollist_opt shift  465 */ +  {  79,   0, 462}, /*  2:                     LP shift  462 */  /* State 462 */ -  {  85,   0, 463}, /*  1:                     OF shift  463 */ -  {  87,   1, 792}, /*  2:                     ON reduce 261 */ +  { 171,   0, 463}, /*  1:             inscollist shift  463 */ +  { 181,   1, 429}, /*  2:                     nm shift  429 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 463 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  { 166,   4, 464}, /*  2:             inscollist shift  464 */ -  { 177,   0, 440}, /*  3:                     nm shift  440 */ -  {  71,   5,  22}, /*  4:                JOIN_KW shift  22 */ -  {  56,   0,  20}, /*  5:                     ID shift  20 */ -/* State 464 */ -  {  21,   0, 438}, /*  1:                  COMMA shift  438 */ -  {  87,   1, 793}, /*  2:                     ON reduce 262 */ +  { 104,   2, 464}, /*  1:                     RP shift  464 */ +  {  22,   0, 427}, /*  2:                  COMMA shift  427 */ +/* State 465 */ +  { 196,   0, 466}, /*  1:                 select shift  466 */ +  { 185,   0,  69}, /*  2:              oneselect shift  69 */ +  { 106,   0,  73}, /*  3:                 SELECT shift  73 */ +  { 127,   0, 467}, /*  4:                 VALUES shift  467 */ +/* State 466 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 830}, /*  3:                   SEMI reduce 275 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 467 */ -  {  85,   0, 468}, /*  1:                     OF shift  468 */ +  {  79,   0, 468}, /*  1:                     LP shift  468 */ +/* State 468 */ +  {  97,   3, 188}, /*  1:                  RAISE shift  188 */ +  { 113,   1,  66}, /*  2:                 STRING shift  66 */ +  {  49,   7, 169}, /*  3:                  FLOAT shift  169 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  68,   0, 168}, /*  5:                INTEGER shift  168 */ +  { 181,   9, 102}, /*  6:                     nm shift  102 */ +  {  17,   0, 178}, /*  7:                   CASE shift  178 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  85,   0, 170}, /*  9:                    NOT shift  170 */ +  {  13,   0, 172}, /* 10:                 BITNOT shift  172 */ +  {  74,   0,  67}, /* 11:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  94,   0, 176}, /* 13:                   PLUS shift  176 */ +  { 157,  10, 473}, /* 14:                   expr shift  473 */ +  { 174,  13, 469}, /* 15:               itemlist shift  469 */ +  {  79,   0,  68}, /* 16:                     LP shift  68 */  /* State 469 */ -  {  61,   0, 474}, /*  1:                  INDEX shift  474 */ -  { 125,   1, 472}, /*  2:                   VIEW shift  472 */ -  { 111,   0, 470}, /*  3:                  TABLE shift  470 */ -  { 115,   3, 476}, /*  4:                TRIGGER shift  476 */ +  { 104,   2, 472}, /*  1:                     RP shift  472 */ +  {  22,   0, 470}, /*  2:                  COMMA shift  470 */  /* State 470 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 471}, /*  2:                     nm shift  471 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  79,   4,  68}, /*  1:                     LP shift  68 */ +  { 181,   0, 102}, /*  2:                     nm shift  102 */ +  {  17,   0, 178}, /*  3:                   CASE shift  178 */ +  {  49,   0, 169}, /*  4:                  FLOAT shift  169 */ +  {  94,   1, 176}, /*  5:                   PLUS shift  176 */ +  {  97,   0, 188}, /*  6:                  RAISE shift  188 */ +  {  83,  10, 174}, /*  7:                  MINUS shift  174 */ +  { 157,   6, 471}, /*  8:                   expr shift  471 */ +  { 113,   7,  66}, /*  9:                 STRING shift  66 */ +  {  68,   0, 168}, /* 10:                INTEGER shift  168 */ +  {  85,   0, 170}, /* 11:                    NOT shift  170 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  87,   0, 101}, /* 13:                   NULL shift  101 */ +  {  13,   0, 172}, /* 14:                 BITNOT shift  172 */ +  {  74,  12,  67}, /* 15:                JOIN_KW shift  67 */  /* State 471 */ -  { 104,   0, 628}, /*  1:                   SEMI reduce 97 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 472 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 473}, /*  2:                     nm shift  473 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 107,   0, 829}, /*  1:                   SEMI reduce 274 */  /* State 473 */ -  { 104,   0, 630}, /*  1:                   SEMI reduce 99 */ +  {  84,   0, 118}, /*  1:                     NE shift  118 */ +  {  85,   4, 132}, /*  2:                    NOT shift  132 */ +  {  86,   0, 154}, /*  3:                NOTNULL shift  154 */ +  {  57,   0, 112}, /*  4:                     GT shift  112 */ +  {  63,   0, 159}, /*  5:                     IN shift  159 */ +  {   5,   0, 100}, /*  6:                    AND shift  100 */ +  {  71,   0, 150}, /*  7:                     IS shift  150 */ +  {  91,   5, 108}, /*  8:                     OR shift  108 */ +  {  92,   0,  99}, /*  9:      ORACLE_OUTER_JOIN shift  99 */ +  { 177,   0, 130}, /* 10:                 likeop shift  130 */ +  {  94,   0, 137}, /* 11:                   PLUS shift  137 */ +  {  11,   0, 155}, /* 12:                BETWEEN shift  155 */ +  {  12,   0, 122}, /* 13:                 BITAND shift  122 */ +  {  77,   0, 135}, /* 14:                   LIKE shift  135 */ +  {  14,   0, 124}, /* 15:                  BITOR shift  124 */ +  {  99,   7, 145}, /* 16:                    REM shift  145 */ +  {  72,   0, 149}, /* 17:                 ISNULL shift  149 */ +  {  45,   0, 120}, /* 18:                     EQ shift  120 */ +  {  81,  20, 110}, /* 19:                     LT shift  110 */ +  {  25,   0, 147}, /* 20:                 CONCAT shift  147 */ +  {  76,   0, 114}, /* 21:                     LE shift  114 */ +  { 105,  14, 128}, /* 22:                 RSHIFT shift  128 */ +  {  83,  24, 139}, /* 23:                  MINUS shift  139 */ +  {  55,   0, 136}, /* 24:                   GLOB shift  136 */ +  {  80,   0, 126}, /* 25:                 LSHIFT shift  126 */ +  { 109,  19, 143}, /* 26:                  SLASH shift  143 */ +  {  54,   0, 116}, /* 27:                     GE shift  116 */ +  { 111,  23, 141}, /* 28:                   STAR shift  141 */  /* State 474 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 475}, /*  2:                     nm shift  475 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  52,   0, 475}, /*  1:                   FROM shift  475 */  /* State 475 */ -  { 104,   0, 768}, /*  1:                   SEMI reduce 237 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 476}, /*  2:                     nm shift  476 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 476 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 477}, /*  2:                     nm shift  477 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 130,   0, 234}, /*  1:                  WHERE shift  234 */ +  { 217,   1, 477}, /*  2:              where_opt shift  477 */ +  { 107,   0, 710}, /*  3:                   SEMI reduce 155 */  /* State 477 */ -  { 104,   0, 810}, /*  1:                   SEMI reduce 279 */ +  { 107,   0, 831}, /*  1:                   SEMI reduce 276 */  /* State 478 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 631}, /*  5:                   SEMI reduce 100 */ +  { 128,   2, 481}, /*  1:                   VIEW shift  481 */ +  {  64,   0, 483}, /*  2:                  INDEX shift  483 */ +  { 118,   4, 486}, /*  3:                TRIGGER shift  486 */ +  { 114,   0, 479}, /*  4:                  TABLE shift  479 */  /* State 479 */ -  {  49,   0, 480}, /*  1:                   FROM shift  480 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 480}, /*  2:                     nm shift  480 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 480 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 481}, /*  2:                     nm shift  481 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 107,   0, 652}, /*  1:                   SEMI reduce 97 */  /* State 481 */ -  { 104,   0, 685}, /*  1:                   SEMI reduce 154 */ -  { 127,   0, 232}, /*  2:                  WHERE shift  232 */ -  { 212,   1, 482}, /*  3:              where_opt shift  482 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 482}, /*  2:                     nm shift  482 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 482 */ -  { 104,   0, 684}, /*  1:                   SEMI reduce 153 */ +  { 107,   0, 654}, /*  1:                   SEMI reduce 99 */  /* State 483 */ -  { 182,   2, 484}, /*  1:                 orconf shift  484 */ -  {  88,   0, 417}, /*  2:                     OR shift  417 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 484}, /*  2:                     nm shift  484 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 484 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 485}, /*  2:                     nm shift  485 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 150,   2, 485}, /*  1:                   dbnm shift  485 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */ +  { 107,   0, 680}, /*  3:                   SEMI reduce 125 */  /* State 485 */ -  { 105,   0, 486}, /*  1:                    SET shift  486 */ +  { 107,   0, 794}, /*  1:                   SEMI reduce 239 */  /* State 486 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  {  71,   4,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 428}, /*  3:                     nm shift  428 */ -  {  56,   0,  20}, /*  4:                     ID shift  20 */ -  { 194,   0, 487}, /*  5:                setlist shift  487 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 487}, /*  2:                     nm shift  487 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 487 */ -  { 212,   3, 488}, /*  1:              where_opt shift  488 */ -  {  21,   0, 423}, /*  2:                  COMMA shift  423 */ -  { 104,   0, 685}, /*  3:                   SEMI reduce 154 */ -  { 127,   0, 232}, /*  4:                  WHERE shift  232 */ +  { 150,   2, 488}, /*  1:                   dbnm shift  488 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */ +  { 107,   0, 680}, /*  3:                   SEMI reduce 125 */  /* State 488 */ -  { 104,   0, 687}, /*  1:                   SEMI reduce 156 */ +  { 107,   0, 837}, /*  1:                   SEMI reduce 282 */  /* State 489 */ -  {  67,   0, 490}, /*  1:                   INTO shift  490 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 655}, /*  3:                   SEMI reduce 100 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 490 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 491}, /*  2:                     nm shift  491 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  52,   0, 491}, /*  1:                   FROM shift  491 */  /* State 491 */ -  {  76,   0, 435}, /*  1:                     LP shift  435 */ -  { 167,   0, 492}, /*  2:         inscollist_opt shift  492 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 492}, /*  2:                     nm shift  492 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 492 */ -  { 192,   3, 493}, /*  1:                 select shift  493 */ -  { 181,   0,  69}, /*  2:              oneselect shift  69 */ -  { 124,   0, 494}, /*  3:                 VALUES shift  494 */ -  { 103,   0,  73}, /*  4:                 SELECT shift  73 */ +  { 150,   0, 493}, /*  1:                   dbnm shift  493 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */  /* State 493 */ -  {  66,   0, 162}, /*  1:              INTERSECT shift  162 */ -  { 176,   1,  71}, /*  2:         multiselect_op shift  71 */ -  {  43,   0, 163}, /*  3:                 EXCEPT shift  163 */ -  { 118,   3, 160}, /*  4:                  UNION shift  160 */ -  { 104,   0, 691}, /*  5:                   SEMI reduce 160 */ +  { 130,   0, 234}, /*  1:                  WHERE shift  234 */ +  { 217,   1, 494}, /*  2:              where_opt shift  494 */ +  { 107,   0, 710}, /*  3:                   SEMI reduce 155 */  /* State 494 */ -  {  76,   0, 495}, /*  1:                     LP shift  495 */ +  { 107,   0, 709}, /*  1:                   SEMI reduce 154 */  /* State 495 */ -  {  80,   4, 172}, /*  1:                  MINUS shift  172 */ -  { 177,   6, 102}, /*  2:                     nm shift  102 */ -  {  82,   0, 168}, /*  3:                    NOT shift  168 */ -  {  16,   0, 176}, /*  4:                   CASE shift  176 */ -  {  84,   0, 101}, /*  5:                   NULL shift  101 */ -  {  65,   0, 166}, /*  6:                INTEGER shift  166 */ -  {  56,   0,  64}, /*  7:                     ID shift  64 */ -  {  71,   0,  67}, /*  8:                JOIN_KW shift  67 */ -  { 152,   7, 449}, /*  9:                   expr shift  449 */ -  { 169,   0, 496}, /* 10:               itemlist shift  496 */ -  {  12,   0, 170}, /* 11:                 BITNOT shift  170 */ -  {  91,   0, 174}, /* 12:                   PLUS shift  174 */ -  {  76,  11,  68}, /* 13:                     LP shift  68 */ -  {  94,  16, 186}, /* 14:                  RAISE shift  186 */ -  { 110,  14,  66}, /* 15:                 STRING shift  66 */ -  {  46,   0, 167}, /* 16:                  FLOAT shift  167 */ +  { 186,   0, 496}, /*  1:                 orconf shift  496 */ +  {  91,   0, 444}, /*  2:                     OR shift  444 */  /* State 496 */ -  {  21,   0, 446}, /*  1:                  COMMA shift  446 */ -  { 101,   1, 497}, /*  2:                     RP shift  497 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 497}, /*  2:                     nm shift  497 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 497 */ -  { 104,   0, 690}, /*  1:                   SEMI reduce 159 */ +  { 150,   2, 498}, /*  1:                   dbnm shift  498 */ +  { 108,   3, 680}, /*  2:                    SET reduce 125 */ +  {  39,   0, 270}, /*  3:                    DOT shift  270 */  /* State 498 */ -  {  67,   0, 621}, /*  1:                   INTO reduce 90 */ -  {  88,   1, 417}, /*  2:                     OR shift  417 */ -  { 182,   0, 499}, /*  3:                 orconf shift  499 */ +  { 108,   0, 499}, /*  1:                    SET shift  499 */  /* State 499 */ -  {  67,   0, 692}, /*  1:                   INTO reduce 161 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   0, 455}, /*  2:                     nm shift  455 */ +  {  59,   0,  20}, /*  3:                     ID shift  20 */ +  { 198,   1, 500}, /*  4:                setlist shift  500 */ +  {  74,   3,  22}, /*  5:                JOIN_KW shift  22 */  /* State 500 */ -  {  67,   0, 693}, /*  1:                   INTO reduce 162 */ +  {  22,   0, 450}, /*  1:                  COMMA shift  450 */ +  { 217,   0, 501}, /*  2:              where_opt shift  501 */ +  { 130,   1, 234}, /*  3:                  WHERE shift  234 */ +  { 107,   0, 710}, /*  4:                   SEMI reduce 155 */  /* State 501 */ -  { 182,   2, 502}, /*  1:                 orconf shift  502 */ -  {  88,   0, 417}, /*  2:                     OR shift  417 */ +  { 107,   0, 712}, /*  1:                   SEMI reduce 157 */  /* State 502 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 503}, /*  2:                     nm shift  503 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  {  70,   0, 503}, /*  1:                   INTO shift  503 */  /* State 503 */ -  {  49,   0, 504}, /*  1:                   FROM shift  504 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 504}, /*  2:                     nm shift  504 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 504 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 505}, /*  2:                     nm shift  505 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 150,   0, 505}, /*  1:                   dbnm shift  505 */ +  {  39,   0, 270}, /*  2:                    DOT shift  270 */  /* State 505 */ -  { 122,   2, 506}, /*  1:                  USING shift  506 */ -  { 104,   0, 770}, /*  2:                   SEMI reduce 239 */ +  { 172,   0, 506}, /*  1:         inscollist_opt shift  506 */ +  {  79,   0, 462}, /*  2:                     LP shift  462 */  /* State 506 */ -  {  33,   0, 507}, /*  1:             DELIMITERS shift  507 */ +  { 196,   0, 507}, /*  1:                 select shift  507 */ +  { 185,   0,  69}, /*  2:              oneselect shift  69 */ +  { 106,   0,  73}, /*  3:                 SELECT shift  73 */ +  { 127,   0, 508}, /*  4:                 VALUES shift  508 */  /* State 507 */ -  { 110,   0, 508}, /*  1:                 STRING shift  508 */ +  { 180,   0,  71}, /*  1:         multiselect_op shift  71 */ +  { 121,   4, 162}, /*  2:                  UNION shift  162 */ +  { 107,   0, 716}, /*  3:                   SEMI reduce 161 */ +  {  46,   0, 165}, /*  4:                 EXCEPT shift  165 */ +  {  69,   0, 164}, /*  5:              INTERSECT shift  164 */  /* State 508 */ -  { 104,   0, 769}, /*  1:                   SEMI reduce 238 */ +  {  79,   0, 509}, /*  1:                     LP shift  509 */  /* State 509 */ -  { 110,   0,  21}, /*  1:                 STRING shift  21 */ -  {  71,   4,  22}, /*  2:                JOIN_KW shift  22 */ -  { 177,   0, 510}, /*  3:                     nm shift  510 */ -  {  56,   0,  20}, /*  4:                     ID shift  20 */ -  { 104,   0, 771}, /*  5:                   SEMI reduce 240 */ +  {  97,   3, 188}, /*  1:                  RAISE shift  188 */ +  { 113,   1,  66}, /*  2:                 STRING shift  66 */ +  {  49,   7, 169}, /*  3:                  FLOAT shift  169 */ +  {  83,   0, 174}, /*  4:                  MINUS shift  174 */ +  {  68,   0, 168}, /*  5:                INTEGER shift  168 */ +  { 181,   9, 102}, /*  6:                     nm shift  102 */ +  {  17,   0, 178}, /*  7:                   CASE shift  178 */ +  {  87,   0, 101}, /*  8:                   NULL shift  101 */ +  {  85,   0, 170}, /*  9:                    NOT shift  170 */ +  {  13,   0, 172}, /* 10:                 BITNOT shift  172 */ +  {  74,   0,  67}, /* 11:                JOIN_KW shift  67 */ +  {  59,   0,  64}, /* 12:                     ID shift  64 */ +  {  94,   0, 176}, /* 13:                   PLUS shift  176 */ +  { 157,  10, 473}, /* 14:                   expr shift  473 */ +  { 174,  13, 510}, /* 15:               itemlist shift  510 */ +  {  79,   0,  68}, /* 16:                     LP shift  68 */  /* State 510 */ -  { 104,   0, 772}, /*  1:                   SEMI reduce 241 */ +  { 104,   2, 511}, /*  1:                     RP shift  511 */ +  {  22,   0, 470}, /*  2:                  COMMA shift  470 */  /* State 511 */ -  {  56,   0, 248}, /*  1:                     ID shift  248 */ -  { 160,   0, 512}, /*  2:                    ids shift  512 */ -  { 110,   1, 249}, /*  3:                 STRING shift  249 */ +  { 107,   0, 715}, /*  1:                   SEMI reduce 160 */  /* State 512 */ -  {  42,   0, 513}, /*  1:                     EQ shift  513 */ -  {  76,   0, 525}, /*  2:                     LP shift  525 */ -  { 104,   0, 778}, /*  3:                   SEMI reduce 247 */ +  { 186,   0, 513}, /*  1:                 orconf shift  513 */ +  {  91,   3, 444}, /*  2:                     OR shift  444 */ +  {  70,   0, 645}, /*  3:                   INTO reduce 90 */  /* State 513 */ -  { 110,   3,  21}, /*  1:                 STRING shift  21 */ -  {  91,   4, 524}, /*  2:                   PLUS shift  524 */ -  {  80,   0, 522}, /*  3:                  MINUS shift  522 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ -  { 184,   0, 516}, /*  5:               plus_num shift  516 */ -  { 185,   9, 518}, /*  6:               plus_opt shift  518 */ -  {  56,   0,  20}, /*  7:                     ID shift  20 */ -  { 177,  10, 514}, /*  8:                     nm shift  514 */ -  { 175,   0, 517}, /*  9:              minus_num shift  517 */ -  {  87,   0, 515}, /* 10:                     ON shift  515 */ +  {  70,   0, 717}, /*  1:                   INTO reduce 162 */  /* State 514 */ -  { 104,   0, 773}, /*  1:                   SEMI reduce 242 */ +  {  70,   0, 718}, /*  1:                   INTO reduce 163 */  /* State 515 */ -  { 104,   0, 774}, /*  1:                   SEMI reduce 243 */ +  { 186,   0, 516}, /*  1:                 orconf shift  516 */ +  {  91,   0, 444}, /*  2:                     OR shift  444 */  /* State 516 */ -  { 104,   0, 775}, /*  1:                   SEMI reduce 244 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 517}, /*  2:                     nm shift  517 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 517 */ -  { 104,   0, 776}, /*  1:                   SEMI reduce 245 */ +  { 150,   3, 518}, /*  1:                   dbnm shift  518 */ +  {  52,   0, 680}, /*  2:                   FROM reduce 125 */ +  {  39,   0, 270}, /*  3:                    DOT shift  270 */  /* State 518 */ -  {  46,   0, 521}, /*  1:                  FLOAT shift  521 */ -  { 178,   1, 519}, /*  2:                 number shift  519 */ -  {  65,   0, 520}, /*  3:                INTEGER shift  520 */ +  {  52,   0, 519}, /*  1:                   FROM shift  519 */  /* State 519 */ -  { 104,   0, 779}, /*  1:                   SEMI reduce 248 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 520}, /*  2:                     nm shift  520 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */  /* State 520 */ -  { 104,   0, 781}, /*  1:                   SEMI reduce 250 */ +  { 107,   0, 796}, /*  1:                   SEMI reduce 241 */ +  { 125,   1, 521}, /*  2:                  USING shift  521 */  /* State 521 */ -  { 104,   0, 782}, /*  1:                   SEMI reduce 251 */ +  {  35,   0, 522}, /*  1:             DELIMITERS shift  522 */  /* State 522 */ -  {  46,   0, 521}, /*  1:                  FLOAT shift  521 */ -  { 178,   1, 523}, /*  2:                 number shift  523 */ -  {  65,   0, 520}, /*  3:                INTEGER shift  520 */ +  { 113,   0, 523}, /*  1:                 STRING shift  523 */  /* State 523 */ -  { 104,   0, 780}, /*  1:                   SEMI reduce 249 */ +  { 107,   0, 795}, /*  1:                   SEMI reduce 240 */ +/* State 524 */ +  {  59,   0,  20}, /*  1:                     ID shift  20 */ +  { 181,   0, 525}, /*  2:                     nm shift  525 */ +  { 107,   0, 797}, /*  3:                   SEMI reduce 242 */ +  { 113,   0,  21}, /*  4:                 STRING shift  21 */ +  {  74,   1,  22}, /*  5:                JOIN_KW shift  22 */  /* State 525 */ -  {  56,   0,  20}, /*  1:                     ID shift  20 */ -  { 177,   0, 526}, /*  2:                     nm shift  526 */ -  { 110,   0,  21}, /*  3:                 STRING shift  21 */ -  {  71,   0,  22}, /*  4:                JOIN_KW shift  22 */ +  { 107,   0, 798}, /*  1:                   SEMI reduce 243 */  /* State 526 */ -  { 101,   0, 527}, /*  1:                     RP shift  527 */ +  { 165,   0, 527}, /*  1:                    ids shift  527 */ +  {  59,   0, 251}, /*  2:                     ID shift  251 */ +  { 113,   2, 252}, /*  3:                 STRING shift  252 */  /* State 527 */ -  { 104,   0, 777}, /*  1:                   SEMI reduce 246 */ +  {  45,   0, 528}, /*  1:                     EQ shift  528 */ +  {  79,   0, 540}, /*  2:                     LP shift  540 */ +  { 107,   0, 804}, /*  3:                   SEMI reduce 249 */ +/* State 528 */ +  {  90,   0, 530}, /*  1:                     ON shift  530 */ +  { 181,   0, 529}, /*  2:                     nm shift  529 */ +  {  83,   0, 537}, /*  3:                  MINUS shift  537 */ +  { 113,   3,  21}, /*  4:                 STRING shift  21 */ +  {  94,   6, 539}, /*  5:                   PLUS shift  539 */ +  {  74,   0,  22}, /*  6:                JOIN_KW shift  22 */ +  { 179,   8, 532}, /*  7:              minus_num shift  532 */ +  {  59,   0,  20}, /*  8:                     ID shift  20 */ +  { 188,   0, 531}, /*  9:               plus_num shift  531 */ +  { 189,   7, 533}, /* 10:               plus_opt shift  533 */ +/* State 529 */ +  { 107,   0, 799}, /*  1:                   SEMI reduce 244 */ +/* State 530 */ +  { 107,   0, 800}, /*  1:                   SEMI reduce 245 */ +/* State 531 */ +  { 107,   0, 801}, /*  1:                   SEMI reduce 246 */ +/* State 532 */ +  { 107,   0, 802}, /*  1:                   SEMI reduce 247 */ +/* State 533 */ +  {  68,   0, 535}, /*  1:                INTEGER shift  535 */ +  {  49,   0, 536}, /*  2:                  FLOAT shift  536 */ +  { 182,   1, 534}, /*  3:                 number shift  534 */ +/* State 534 */ +  { 107,   0, 805}, /*  1:                   SEMI reduce 250 */ +/* State 535 */ +  { 107,   0, 807}, /*  1:                   SEMI reduce 252 */ +/* State 536 */ +  { 107,   0, 808}, /*  1:                   SEMI reduce 253 */ +/* State 537 */ +  {  68,   0, 535}, /*  1:                INTEGER shift  535 */ +  {  49,   0, 536}, /*  2:                  FLOAT shift  536 */ +  { 182,   1, 538}, /*  3:                 number shift  538 */ +/* State 538 */ +  { 107,   0, 806}, /*  1:                   SEMI reduce 251 */ +/* State 540 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 541}, /*  2:                     nm shift  541 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 541 */ +  { 104,   0, 542}, /*  1:                     RP shift  542 */ +/* State 542 */ +  { 107,   0, 803}, /*  1:                   SEMI reduce 248 */ +/* State 543 */ +  {  30,   0, 548}, /*  1:               DATABASE shift  548 */ +  { 149,   0, 544}, /*  2:        database_kw_opt shift  544 */ +/* State 544 */ +  { 165,   0, 545}, /*  1:                    ids shift  545 */ +  {  59,   0, 251}, /*  2:                     ID shift  251 */ +  { 113,   2, 252}, /*  3:                 STRING shift  252 */ +/* State 545 */ +  {   6,   0, 546}, /*  1:                     AS shift  546 */ +/* State 546 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 547}, /*  2:                     nm shift  547 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 547 */ +  { 107,   0, 838}, /*  1:                   SEMI reduce 283 */ +/* State 549 */ +  {  30,   0, 548}, /*  1:               DATABASE shift  548 */ +  { 149,   0, 550}, /*  2:        database_kw_opt shift  550 */ +/* State 550 */ +  { 113,   0,  21}, /*  1:                 STRING shift  21 */ +  { 181,   1, 551}, /*  2:                     nm shift  551 */ +  {  74,   0,  22}, /*  3:                JOIN_KW shift  22 */ +  {  59,   0,  20}, /*  4:                     ID shift  20 */ +/* State 551 */ +  { 107,   0, 841}, /*  1:                   SEMI reduce 286 */  };  /* The state table contains information needed to look up the correct @@ -3121,537 +3197,561 @@ struct yyStateEntry {  };  typedef struct yyStateEntry yyStateEntry;  static const yyStateEntry yyStateTable[] = { -  { &yyActionTable[0],   6, 538 }, -  { &yyActionTable[6],   5, 538 }, -  { &yyActionTable[11],   0, 533 }, -  { &yyActionTable[11],  20, 811 }, -  { &yyActionTable[31],   1, 811 }, -  { &yyActionTable[32],   0, 534 }, -  { &yyActionTable[32],   1, 811 }, -  { &yyActionTable[33],   2, 540 }, -  { &yyActionTable[35],   3, 811 }, -  { &yyActionTable[38],   1, 811 }, -  { &yyActionTable[39],   1, 811 }, -  { &yyActionTable[40],   6, 811 }, -  { &yyActionTable[46],   0, 620 }, -  { &yyActionTable[46],   0, 623 }, -  { &yyActionTable[46],   0, 624 }, -  { &yyActionTable[46],   0, 625 }, -  { &yyActionTable[46],   0, 626 }, -  { &yyActionTable[46],   0, 627 }, -  { &yyActionTable[46],   4, 541 }, -  { &yyActionTable[50],   0, 542 }, -  { &yyActionTable[50],   0, 559 }, -  { &yyActionTable[50],   0, 560 }, -  { &yyActionTable[50],   0, 561 }, -  { &yyActionTable[50],   3, 811 }, -  { &yyActionTable[53],   1, 811 }, -  { &yyActionTable[54],   3, 811 }, -  { &yyActionTable[57],   1, 811 }, -  { &yyActionTable[58],   3, 811 }, -  { &yyActionTable[61],   1, 811 }, -  { &yyActionTable[62],   3, 811 }, -  { &yyActionTable[65],   1, 811 }, -  { &yyActionTable[66],   7, 811 }, -  { &yyActionTable[73],   3, 811 }, -  { &yyActionTable[76],   1, 811 }, -  { &yyActionTable[77],   1, 811 }, -  { &yyActionTable[78],  13, 811 }, -  { &yyActionTable[91],   0, 552 }, -  { &yyActionTable[91],   5, 562 }, -  { &yyActionTable[96],   1, 572 }, -  { &yyActionTable[97],  13, 554 }, -  { &yyActionTable[110],   0, 571 }, -  { &yyActionTable[110],   4, 811 }, -  { &yyActionTable[114],  10, 811 }, -  { &yyActionTable[124],   0, 573 }, -  { &yyActionTable[124],   2, 619 }, -  { &yyActionTable[126],   0, 584 }, -  { &yyActionTable[126],   2, 811 }, -  { &yyActionTable[128],   2, 619 }, -  { &yyActionTable[130],   0, 585 }, -  { &yyActionTable[130],   2, 604 }, -  { &yyActionTable[132],   0, 602 }, -  { &yyActionTable[132],   2, 811 }, -  { &yyActionTable[134],   0, 605 }, -  { &yyActionTable[134],   0, 606 }, -  { &yyActionTable[134],   1, 811 }, -  { &yyActionTable[135],   3, 672 }, -  { &yyActionTable[138],   2, 619 }, -  { &yyActionTable[140],   0, 586 }, -  { &yyActionTable[140],   0, 670 }, -  { &yyActionTable[140],   0, 671 }, -  { &yyActionTable[140],   2, 619 }, -  { &yyActionTable[142],   0, 587 }, -  { &yyActionTable[142],   1, 811 }, -  { &yyActionTable[143],  15, 811 }, -  { &yyActionTable[158],   2, 702 }, -  { &yyActionTable[160],  18, 759 }, -  { &yyActionTable[178],   1, 708 }, -  { &yyActionTable[179],   1, 703 }, -  { &yyActionTable[180],  18, 811 }, -  { &yyActionTable[198],   0, 632 }, -  { &yyActionTable[198],   5, 811 }, -  { &yyActionTable[203],   2, 811 }, -  { &yyActionTable[205],   0, 633 }, -  { &yyActionTable[205],   3, 641 }, -  { &yyActionTable[208],   2, 643 }, -  { &yyActionTable[210],   3, 650 }, -  { &yyActionTable[213],   2, 685 }, -  { &yyActionTable[215],   2, 675 }, -  { &yyActionTable[217],   2, 677 }, -  { &yyActionTable[219],   2, 665 }, -  { &yyActionTable[221],   2, 679 }, -  { &yyActionTable[223],   0, 638 }, -  { &yyActionTable[223],   1, 811 }, -  { &yyActionTable[224],   3, 680 }, -  { &yyActionTable[227],   1, 811 }, -  { &yyActionTable[228],   0, 681 }, -  { &yyActionTable[228],   1, 811 }, -  { &yyActionTable[229],   1, 811 }, -  { &yyActionTable[230],   1, 811 }, -  { &yyActionTable[231],  17, 811 }, -  { &yyActionTable[248],   1, 666 }, -  { &yyActionTable[249],  16, 811 }, -  { &yyActionTable[265],   2, 673 }, -  { &yyActionTable[267],   3, 672 }, -  { &yyActionTable[270],   0, 667 }, -  { &yyActionTable[270],   2, 811 }, -  { &yyActionTable[272],   0, 556 }, -  { &yyActionTable[272],   0, 674 }, -  { &yyActionTable[272],  28, 669 }, -  { &yyActionTable[300],   0, 705 }, -  { &yyActionTable[300],  15, 811 }, -  { &yyActionTable[315],   0, 701 }, -  { &yyActionTable[315],   1, 811 }, -  { &yyActionTable[316],   4, 811 }, -  { &yyActionTable[320],   0, 704 }, -  { &yyActionTable[320],  26, 711 }, -  { &yyActionTable[346],  15, 811 }, -  { &yyActionTable[361],  27, 712 }, -  { &yyActionTable[388],  15, 811 }, -  { &yyActionTable[403],  12, 713 }, -  { &yyActionTable[415],  15, 811 }, -  { &yyActionTable[430],  12, 714 }, -  { &yyActionTable[442],  15, 811 }, -  { &yyActionTable[457],  12, 715 }, -  { &yyActionTable[469],  15, 811 }, -  { &yyActionTable[484],  12, 716 }, -  { &yyActionTable[496],  15, 811 }, -  { &yyActionTable[511],  16, 717 }, -  { &yyActionTable[527],  15, 811 }, -  { &yyActionTable[542],  16, 718 }, -  { &yyActionTable[558],  15, 811 }, -  { &yyActionTable[573],   8, 719 }, -  { &yyActionTable[581],  15, 811 }, -  { &yyActionTable[596],   8, 720 }, -  { &yyActionTable[604],  15, 811 }, -  { &yyActionTable[619],   8, 721 }, -  { &yyActionTable[627],  15, 811 }, -  { &yyActionTable[642],   8, 722 }, -  { &yyActionTable[650],  15, 811 }, -  { &yyActionTable[665],  16, 723 }, -  { &yyActionTable[681],   6, 811 }, -  { &yyActionTable[687],  15, 811 }, -  { &yyActionTable[702],  16, 724 }, -  { &yyActionTable[718],   0, 725 }, -  { &yyActionTable[718],   0, 726 }, -  { &yyActionTable[718],  15, 811 }, -  { &yyActionTable[733],   6, 727 }, -  { &yyActionTable[739],  15, 811 }, -  { &yyActionTable[754],   6, 728 }, -  { &yyActionTable[760],  15, 811 }, -  { &yyActionTable[775],   3, 729 }, -  { &yyActionTable[778],  15, 811 }, -  { &yyActionTable[793],   3, 730 }, -  { &yyActionTable[796],  15, 811 }, -  { &yyActionTable[811],   3, 731 }, -  { &yyActionTable[814],  15, 811 }, -  { &yyActionTable[829],   2, 732 }, -  { &yyActionTable[831],   0, 733 }, -  { &yyActionTable[831],   2, 811 }, -  { &yyActionTable[833],   0, 734 }, -  { &yyActionTable[833],   1, 811 }, -  { &yyActionTable[834],   0, 737 }, -  { &yyActionTable[834],   0, 735 }, -  { &yyActionTable[834],  15, 811 }, -  { &yyActionTable[849],  28, 811 }, -  { &yyActionTable[877],  15, 811 }, -  { &yyActionTable[892],  16, 743 }, -  { &yyActionTable[908],   1, 811 }, -  { &yyActionTable[909],  20, 759 }, -  { &yyActionTable[929],   5, 811 }, -  { &yyActionTable[934],   2, 811 }, -  { &yyActionTable[936],   1, 811 }, -  { &yyActionTable[937],   1, 811 }, -  { &yyActionTable[938],   1, 811 }, -  { &yyActionTable[939],   0, 746 }, -  { &yyActionTable[939],  28, 758 }, -  { &yyActionTable[967],   0, 706 }, -  { &yyActionTable[967],   0, 707 }, -  { &yyActionTable[967],  15, 811 }, -  { &yyActionTable[982],  26, 738 }, -  { &yyActionTable[1008],  15, 811 }, -  { &yyActionTable[1023],   2, 739 }, -  { &yyActionTable[1025],  15, 811 }, -  { &yyActionTable[1040],   2, 740 }, -  { &yyActionTable[1042],  15, 811 }, -  { &yyActionTable[1057],   2, 741 }, -  { &yyActionTable[1059],  17, 811 }, -  { &yyActionTable[1076],  29, 811 }, -  { &yyActionTable[1105],   2, 811 }, -  { &yyActionTable[1107],   4, 811 }, -  { &yyActionTable[1111],   1, 811 }, -  { &yyActionTable[1112],   0, 749 }, -  { &yyActionTable[1112],  15, 811 }, -  { &yyActionTable[1127],  29, 811 }, -  { &yyActionTable[1156],  15, 811 }, -  { &yyActionTable[1171],  28, 750 }, -  { &yyActionTable[1199],   1, 811 }, -  { &yyActionTable[1200],   4, 811 }, -  { &yyActionTable[1204],   1, 811 }, -  { &yyActionTable[1205],   0, 806 }, -  { &yyActionTable[1205],   1, 811 }, -  { &yyActionTable[1206],   4, 811 }, -  { &yyActionTable[1210],   1, 811 }, -  { &yyActionTable[1211],   0, 807 }, -  { &yyActionTable[1211],   1, 811 }, -  { &yyActionTable[1212],   4, 811 }, -  { &yyActionTable[1216],   1, 811 }, -  { &yyActionTable[1217],   0, 808 }, -  { &yyActionTable[1217],   1, 811 }, -  { &yyActionTable[1218],   4, 811 }, -  { &yyActionTable[1222],   1, 811 }, -  { &yyActionTable[1223],   0, 809 }, -  { &yyActionTable[1223],  15, 811 }, -  { &yyActionTable[1238],  29, 811 }, -  { &yyActionTable[1267],  15, 811 }, -  { &yyActionTable[1282],  29, 811 }, -  { &yyActionTable[1311],  15, 811 }, -  { &yyActionTable[1326],  28, 751 }, -  { &yyActionTable[1354],   2, 811 }, -  { &yyActionTable[1356],   0, 745 }, -  { &yyActionTable[1356],  16, 759 }, -  { &yyActionTable[1372],   0, 756 }, -  { &yyActionTable[1372],   0, 757 }, -  { &yyActionTable[1372],   0, 736 }, -  { &yyActionTable[1372],  15, 811 }, -  { &yyActionTable[1387],  28, 811 }, -  { &yyActionTable[1415],  15, 811 }, -  { &yyActionTable[1430],  26, 744 }, -  { &yyActionTable[1456],   1, 811 }, -  { &yyActionTable[1457],  20, 759 }, -  { &yyActionTable[1477],   5, 811 }, -  { &yyActionTable[1482],   0, 748 }, -  { &yyActionTable[1482],   2, 811 }, -  { &yyActionTable[1484],   0, 747 }, -  { &yyActionTable[1484],   2, 673 }, -  { &yyActionTable[1486],   3, 672 }, -  { &yyActionTable[1489],   0, 668 }, -  { &yyActionTable[1489],  15, 811 }, -  { &yyActionTable[1504],  28, 678 }, -  { &yyActionTable[1532],   1, 811 }, -  { &yyActionTable[1533],  17, 759 }, -  { &yyActionTable[1550],   1, 676 }, -  { &yyActionTable[1551],  15, 811 }, -  { &yyActionTable[1566],  28, 686 }, -  { &yyActionTable[1594],   0, 642 }, -  { &yyActionTable[1594],   2, 653 }, -  { &yyActionTable[1596],   4, 651 }, -  { &yyActionTable[1600],   0, 652 }, -  { &yyActionTable[1600],   0, 656 }, -  { &yyActionTable[1600],   0, 657 }, -  { &yyActionTable[1600],   5, 811 }, -  { &yyActionTable[1605],   0, 658 }, -  { &yyActionTable[1605],   5, 811 }, -  { &yyActionTable[1610],   0, 659 }, -  { &yyActionTable[1610],   1, 811 }, -  { &yyActionTable[1611],   0, 660 }, -  { &yyActionTable[1611],   5, 811 }, -  { &yyActionTable[1616],   5, 649 }, -  { &yyActionTable[1621],   0, 557 }, -  { &yyActionTable[1621],   0, 558 }, -  { &yyActionTable[1621],   4, 811 }, -  { &yyActionTable[1625],   0, 647 }, -  { &yyActionTable[1625],   0, 648 }, -  { &yyActionTable[1625],   2, 662 }, -  { &yyActionTable[1627],   2, 664 }, -  { &yyActionTable[1629],   0, 654 }, -  { &yyActionTable[1629],   1, 811 }, -  { &yyActionTable[1630],   6, 811 }, -  { &yyActionTable[1636],   2, 811 }, -  { &yyActionTable[1638],   0, 663 }, -  { &yyActionTable[1638],   5, 811 }, -  { &yyActionTable[1643],   0, 765 }, -  { &yyActionTable[1643],   0, 767 }, -  { &yyActionTable[1643],   0, 766 }, -  { &yyActionTable[1643],  15, 811 }, -  { &yyActionTable[1658],  28, 661 }, -  { &yyActionTable[1686],   3, 811 }, -  { &yyActionTable[1689],   5, 811 }, -  { &yyActionTable[1694],   5, 649 }, -  { &yyActionTable[1699],   2, 662 }, -  { &yyActionTable[1701],   2, 664 }, -  { &yyActionTable[1703],   0, 655 }, -  { &yyActionTable[1703],  16, 811 }, -  { &yyActionTable[1719],  33, 649 }, -  { &yyActionTable[1752],   0, 644 }, -  { &yyActionTable[1752],   0, 645 }, -  { &yyActionTable[1752],   1, 811 }, -  { &yyActionTable[1753],   5, 811 }, -  { &yyActionTable[1758],   0, 646 }, -  { &yyActionTable[1758],   0, 639 }, -  { &yyActionTable[1758],   0, 640 }, -  { &yyActionTable[1758],   0, 742 }, -  { &yyActionTable[1758],  29, 811 }, -  { &yyActionTable[1787],   0, 700 }, -  { &yyActionTable[1787],   2, 811 }, -  { &yyActionTable[1789],   0, 709 }, -  { &yyActionTable[1789],   1, 811 }, -  { &yyActionTable[1790],   0, 710 }, -  { &yyActionTable[1790],  29, 811 }, -  { &yyActionTable[1819],   2, 619 }, -  { &yyActionTable[1821],   0, 588 }, -  { &yyActionTable[1821],   4, 811 }, -  { &yyActionTable[1825],   2, 763 }, -  { &yyActionTable[1827],   1, 592 }, -  { &yyActionTable[1828],   3, 589 }, -  { &yyActionTable[1831],   0, 593 }, -  { &yyActionTable[1831],   4, 811 }, -  { &yyActionTable[1835],   0, 594 }, -  { &yyActionTable[1835],   3, 811 }, -  { &yyActionTable[1838],   4, 811 }, -  { &yyActionTable[1842],   0, 595 }, -  { &yyActionTable[1842],   2, 811 }, -  { &yyActionTable[1844],   0, 598 }, -  { &yyActionTable[1844],   0, 599 }, -  { &yyActionTable[1844],   0, 600 }, -  { &yyActionTable[1844],   0, 601 }, -  { &yyActionTable[1844],   4, 811 }, -  { &yyActionTable[1848],   0, 596 }, -  { &yyActionTable[1848],   4, 811 }, -  { &yyActionTable[1852],   0, 597 }, -  { &yyActionTable[1852],   6, 811 }, -  { &yyActionTable[1858],   2, 811 }, -  { &yyActionTable[1860],   0, 764 }, -  { &yyActionTable[1860],   0, 590 }, -  { &yyActionTable[1860],   2, 811 }, -  { &yyActionTable[1862],   0, 591 }, -  { &yyActionTable[1862],   2, 604 }, -  { &yyActionTable[1864],   0, 603 }, -  { &yyActionTable[1864],   0, 574 }, -  { &yyActionTable[1864],   7, 811 }, -  { &yyActionTable[1871],   0, 575 }, -  { &yyActionTable[1871],   0, 576 }, -  { &yyActionTable[1871],   0, 577 }, -  { &yyActionTable[1871],   2, 811 }, -  { &yyActionTable[1873],   0, 578 }, -  { &yyActionTable[1873],   0, 581 }, -  { &yyActionTable[1873],   2, 811 }, -  { &yyActionTable[1875],   0, 579 }, -  { &yyActionTable[1875],   0, 582 }, -  { &yyActionTable[1875],   0, 580 }, -  { &yyActionTable[1875],   0, 583 }, -  { &yyActionTable[1875],   4, 563 }, -  { &yyActionTable[1879],   4, 811 }, -  { &yyActionTable[1883],   2, 811 }, -  { &yyActionTable[1885],   0, 564 }, -  { &yyActionTable[1885],   4, 811 }, -  { &yyActionTable[1889],   1, 811 }, -  { &yyActionTable[1890],   0, 565 }, -  { &yyActionTable[1890],   0, 568 }, -  { &yyActionTable[1890],   1, 811 }, -  { &yyActionTable[1891],   0, 569 }, -  { &yyActionTable[1891],   1, 811 }, -  { &yyActionTable[1892],   0, 570 }, -  { &yyActionTable[1892],   0, 567 }, -  { &yyActionTable[1892],   0, 566 }, -  { &yyActionTable[1892],   0, 555 }, -  { &yyActionTable[1892],   8, 811 }, -  { &yyActionTable[1900],   6, 811 }, -  { &yyActionTable[1906],   0, 609 }, -  { &yyActionTable[1906],   4, 811 }, -  { &yyActionTable[1910],   0, 612 }, -  { &yyActionTable[1910],   1, 811 }, -  { &yyActionTable[1911],   1, 811 }, -  { &yyActionTable[1912],   6, 811 }, -  { &yyActionTable[1918],   2, 811 }, -  { &yyActionTable[1920],   2, 619 }, -  { &yyActionTable[1922],   0, 613 }, -  { &yyActionTable[1922],   1, 811 }, -  { &yyActionTable[1923],   6, 811 }, -  { &yyActionTable[1929],   2, 811 }, -  { &yyActionTable[1931],   2, 619 }, -  { &yyActionTable[1933],   0, 614 }, -  { &yyActionTable[1933],  15, 811 }, -  { &yyActionTable[1948],  30, 619 }, -  { &yyActionTable[1978],   0, 615 }, -  { &yyActionTable[1978],   1, 811 }, -  { &yyActionTable[1979],   1, 811 }, -  { &yyActionTable[1980],   6, 811 }, -  { &yyActionTable[1986],   2, 811 }, -  { &yyActionTable[1988],   1, 811 }, -  { &yyActionTable[1989],   4, 811 }, -  { &yyActionTable[1993],   2, 763 }, -  { &yyActionTable[1995],   1, 592 }, -  { &yyActionTable[1996],   7, 617 }, -  { &yyActionTable[2003],   1, 811 }, -  { &yyActionTable[2004],   0, 616 }, -  { &yyActionTable[2004],   0, 618 }, -  { &yyActionTable[2004],   0, 610 }, -  { &yyActionTable[2004],   0, 611 }, -  { &yyActionTable[2004],   0, 553 }, -  { &yyActionTable[2004],   3, 811 }, -  { &yyActionTable[2007],   5, 811 }, -  { &yyActionTable[2012],   6, 549 }, -  { &yyActionTable[2018],   2, 811 }, -  { &yyActionTable[2020],   4, 811 }, -  { &yyActionTable[2024],   0, 547 }, -  { &yyActionTable[2024],   4, 811 }, -  { &yyActionTable[2028],   1, 811 }, -  { &yyActionTable[2029],   3, 811 }, -  { &yyActionTable[2032],   5, 811 }, -  { &yyActionTable[2037],   0, 548 }, -  { &yyActionTable[2037],   1, 811 }, -  { &yyActionTable[2038],   4, 811 }, -  { &yyActionTable[2042],   1, 811 }, -  { &yyActionTable[2043],   4, 811 }, -  { &yyActionTable[2047],   1, 811 }, -  { &yyActionTable[2048],   6, 811 }, -  { &yyActionTable[2054],   2, 811 }, -  { &yyActionTable[2056],   3, 811 }, -  { &yyActionTable[2059],   1, 811 }, -  { &yyActionTable[2060],   1, 811 }, -  { &yyActionTable[2061],   4, 811 }, -  { &yyActionTable[2065],   4, 789 }, -  { &yyActionTable[2069],   4, 811 }, -  { &yyActionTable[2073],   1, 811 }, -  { &yyActionTable[2074],   4, 811 }, -  { &yyActionTable[2078],   2, 794 }, -  { &yyActionTable[2080],   3, 811 }, -  { &yyActionTable[2083],   1, 811 }, -  { &yyActionTable[2084],   9, 811 }, -  { &yyActionTable[2093],   5, 811 }, -  { &yyActionTable[2098],   1, 811 }, -  { &yyActionTable[2099],   1, 811 }, -  { &yyActionTable[2100],   1, 811 }, -  { &yyActionTable[2101],   9, 811 }, -  { &yyActionTable[2110],   1, 811 }, -  { &yyActionTable[2111],   2, 621 }, -  { &yyActionTable[2113],   6, 811 }, -  { &yyActionTable[2119],   0, 622 }, -  { &yyActionTable[2119],   4, 811 }, -  { &yyActionTable[2123],   1, 811 }, -  { &yyActionTable[2124],   5, 811 }, -  { &yyActionTable[2129],   4, 811 }, -  { &yyActionTable[2133],   4, 811 }, -  { &yyActionTable[2137],   1, 811 }, -  { &yyActionTable[2138],  15, 811 }, -  { &yyActionTable[2153],  28, 688 }, -  { &yyActionTable[2181],   1, 811 }, -  { &yyActionTable[2182],   1, 811 }, -  { &yyActionTable[2183],  15, 811 }, -  { &yyActionTable[2198],  28, 689 }, -  { &yyActionTable[2226],   3, 811 }, -  { &yyActionTable[2229],   1, 811 }, -  { &yyActionTable[2230],   4, 811 }, -  { &yyActionTable[2234],   2, 696 }, -  { &yyActionTable[2236],   5, 811 }, -  { &yyActionTable[2241],   2, 811 }, -  { &yyActionTable[2243],   0, 697 }, -  { &yyActionTable[2243],   4, 811 }, -  { &yyActionTable[2247],   0, 698 }, -  { &yyActionTable[2247],   0, 699 }, -  { &yyActionTable[2247],   4, 811 }, -  { &yyActionTable[2251],   5, 811 }, -  { &yyActionTable[2256],   1, 811 }, -  { &yyActionTable[2257],  16, 811 }, -  { &yyActionTable[2273],   2, 811 }, -  { &yyActionTable[2275],  15, 811 }, -  { &yyActionTable[2290],  28, 694 }, -  { &yyActionTable[2318],   1, 811 }, -  { &yyActionTable[2319],  28, 695 }, -  { &yyActionTable[2347],   1, 811 }, -  { &yyActionTable[2348],   4, 811 }, -  { &yyActionTable[2352],   3, 811 }, -  { &yyActionTable[2355],   1, 811 }, -  { &yyActionTable[2356],  15, 811 }, -  { &yyActionTable[2371],  29, 811 }, -  { &yyActionTable[2400],   1, 811 }, -  { &yyActionTable[2401],   2, 811 }, -  { &yyActionTable[2403],   0, 795 }, -  { &yyActionTable[2403],   0, 796 }, -  { &yyActionTable[2403],   1, 811 }, -  { &yyActionTable[2404],   1, 811 }, -  { &yyActionTable[2405],   2, 811 }, -  { &yyActionTable[2407],   5, 811 }, -  { &yyActionTable[2412],   2, 811 }, -  { &yyActionTable[2414],   0, 786 }, -  { &yyActionTable[2414],   0, 787 }, -  { &yyActionTable[2414],   1, 811 }, -  { &yyActionTable[2415],   0, 788 }, -  { &yyActionTable[2415],   4, 811 }, -  { &yyActionTable[2419],   4, 811 }, -  { &yyActionTable[2423],   1, 811 }, -  { &yyActionTable[2424],   4, 811 }, -  { &yyActionTable[2428],   1, 811 }, -  { &yyActionTable[2429],   4, 811 }, -  { &yyActionTable[2433],   1, 811 }, -  { &yyActionTable[2434],   4, 811 }, -  { &yyActionTable[2438],   1, 811 }, -  { &yyActionTable[2439],   5, 811 }, -  { &yyActionTable[2444],   1, 811 }, -  { &yyActionTable[2445],   4, 811 }, -  { &yyActionTable[2449],   3, 811 }, -  { &yyActionTable[2452],   1, 811 }, -  { &yyActionTable[2453],   2, 621 }, -  { &yyActionTable[2455],   4, 811 }, -  { &yyActionTable[2459],   1, 811 }, -  { &yyActionTable[2460],   5, 811 }, -  { &yyActionTable[2465],   4, 811 }, -  { &yyActionTable[2469],   1, 811 }, -  { &yyActionTable[2470],   1, 811 }, -  { &yyActionTable[2471],   4, 811 }, -  { &yyActionTable[2475],   2, 696 }, -  { &yyActionTable[2477],   4, 811 }, -  { &yyActionTable[2481],   5, 811 }, -  { &yyActionTable[2486],   1, 811 }, -  { &yyActionTable[2487],  16, 811 }, -  { &yyActionTable[2503],   2, 811 }, -  { &yyActionTable[2505],   1, 811 }, -  { &yyActionTable[2506],   3, 811 }, -  { &yyActionTable[2509],   1, 811 }, -  { &yyActionTable[2510],   1, 811 }, -  { &yyActionTable[2511],   2, 621 }, -  { &yyActionTable[2513],   4, 811 }, -  { &yyActionTable[2517],   1, 811 }, -  { &yyActionTable[2518],   4, 811 }, -  { &yyActionTable[2522],   2, 811 }, -  { &yyActionTable[2524],   1, 811 }, -  { &yyActionTable[2525],   1, 811 }, -  { &yyActionTable[2526],   1, 811 }, -  { &yyActionTable[2527],   5, 811 }, -  { &yyActionTable[2532],   1, 811 }, -  { &yyActionTable[2533],   3, 811 }, -  { &yyActionTable[2536],   3, 811 }, -  { &yyActionTable[2539],  10, 784 }, -  { &yyActionTable[2549],   1, 811 }, -  { &yyActionTable[2550],   1, 811 }, -  { &yyActionTable[2551],   1, 811 }, -  { &yyActionTable[2552],   1, 811 }, -  { &yyActionTable[2553],   3, 811 }, -  { &yyActionTable[2556],   1, 811 }, -  { &yyActionTable[2557],   1, 811 }, -  { &yyActionTable[2558],   1, 811 }, -  { &yyActionTable[2559],   3, 811 }, -  { &yyActionTable[2562],   1, 811 }, -  { &yyActionTable[2563],   0, 783 }, -  { &yyActionTable[2563],   4, 811 }, -  { &yyActionTable[2567],   1, 811 }, -  { &yyActionTable[2568],   1, 811 }, -  { &yyActionTable[2569],   0, 535 }, -  { &yyActionTable[2569],   0, 537 }, -  { &yyActionTable[2569],   0, 532 }, +  { &yyActionTable[0],   6, 562 }, +  { &yyActionTable[6],   5, 562 }, +  { &yyActionTable[11],   0, 557 }, +  { &yyActionTable[11],  22, 842 }, +  { &yyActionTable[33],   1, 842 }, +  { &yyActionTable[34],   0, 558 }, +  { &yyActionTable[34],   1, 842 }, +  { &yyActionTable[35],   2, 564 }, +  { &yyActionTable[37],   3, 842 }, +  { &yyActionTable[40],   1, 842 }, +  { &yyActionTable[41],   1, 842 }, +  { &yyActionTable[42],   6, 842 }, +  { &yyActionTable[48],   0, 644 }, +  { &yyActionTable[48],   0, 647 }, +  { &yyActionTable[48],   0, 648 }, +  { &yyActionTable[48],   0, 649 }, +  { &yyActionTable[48],   0, 650 }, +  { &yyActionTable[48],   0, 651 }, +  { &yyActionTable[48],   4, 565 }, +  { &yyActionTable[52],   0, 566 }, +  { &yyActionTable[52],   0, 583 }, +  { &yyActionTable[52],   0, 584 }, +  { &yyActionTable[52],   0, 585 }, +  { &yyActionTable[52],   3, 842 }, +  { &yyActionTable[55],   1, 842 }, +  { &yyActionTable[56],   3, 842 }, +  { &yyActionTable[59],   1, 842 }, +  { &yyActionTable[60],   3, 842 }, +  { &yyActionTable[63],   1, 842 }, +  { &yyActionTable[64],   3, 842 }, +  { &yyActionTable[67],   1, 842 }, +  { &yyActionTable[68],   7, 842 }, +  { &yyActionTable[75],   3, 842 }, +  { &yyActionTable[78],   1, 842 }, +  { &yyActionTable[79],   1, 842 }, +  { &yyActionTable[80],  13, 842 }, +  { &yyActionTable[93],   0, 576 }, +  { &yyActionTable[93],   5, 586 }, +  { &yyActionTable[98],   1, 596 }, +  { &yyActionTable[99],  13, 578 }, +  { &yyActionTable[112],   0, 595 }, +  { &yyActionTable[112],   4, 842 }, +  { &yyActionTable[116],  10, 842 }, +  { &yyActionTable[126],   0, 597 }, +  { &yyActionTable[126],   2, 643 }, +  { &yyActionTable[128],   0, 608 }, +  { &yyActionTable[128],   2, 842 }, +  { &yyActionTable[130],   2, 643 }, +  { &yyActionTable[132],   0, 609 }, +  { &yyActionTable[132],   2, 628 }, +  { &yyActionTable[134],   0, 626 }, +  { &yyActionTable[134],   2, 842 }, +  { &yyActionTable[136],   0, 629 }, +  { &yyActionTable[136],   0, 630 }, +  { &yyActionTable[136],   1, 842 }, +  { &yyActionTable[137],   3, 698 }, +  { &yyActionTable[140],   2, 643 }, +  { &yyActionTable[142],   0, 610 }, +  { &yyActionTable[142],   0, 696 }, +  { &yyActionTable[142],   0, 697 }, +  { &yyActionTable[142],   2, 643 }, +  { &yyActionTable[144],   0, 611 }, +  { &yyActionTable[144],   1, 842 }, +  { &yyActionTable[145],  15, 842 }, +  { &yyActionTable[160],   2, 727 }, +  { &yyActionTable[162],  18, 785 }, +  { &yyActionTable[180],   1, 734 }, +  { &yyActionTable[181],   1, 728 }, +  { &yyActionTable[182],  18, 842 }, +  { &yyActionTable[200],   0, 656 }, +  { &yyActionTable[200],   5, 842 }, +  { &yyActionTable[205],   2, 842 }, +  { &yyActionTable[207],   0, 657 }, +  { &yyActionTable[207],   3, 665 }, +  { &yyActionTable[210],   2, 667 }, +  { &yyActionTable[212],   3, 674 }, +  { &yyActionTable[215],   2, 710 }, +  { &yyActionTable[217],   2, 701 }, +  { &yyActionTable[219],   2, 703 }, +  { &yyActionTable[221],   2, 691 }, +  { &yyActionTable[223],   2, 705 }, +  { &yyActionTable[225],   0, 662 }, +  { &yyActionTable[225],   1, 842 }, +  { &yyActionTable[226],   2, 706 }, +  { &yyActionTable[228],   1, 842 }, +  { &yyActionTable[229],   0, 707 }, +  { &yyActionTable[229],   1, 842 }, +  { &yyActionTable[230],   0, 708 }, +  { &yyActionTable[230],   1, 842 }, +  { &yyActionTable[231],  17, 842 }, +  { &yyActionTable[248],   1, 692 }, +  { &yyActionTable[249],  16, 842 }, +  { &yyActionTable[265],   2, 699 }, +  { &yyActionTable[267],   3, 698 }, +  { &yyActionTable[270],   0, 693 }, +  { &yyActionTable[270],   2, 842 }, +  { &yyActionTable[272],   0, 580 }, +  { &yyActionTable[272],   0, 700 }, +  { &yyActionTable[272],  28, 695 }, +  { &yyActionTable[300],   0, 731 }, +  { &yyActionTable[300],  15, 842 }, +  { &yyActionTable[315],   0, 726 }, +  { &yyActionTable[315],   1, 842 }, +  { &yyActionTable[316],   4, 842 }, +  { &yyActionTable[320],   1, 729 }, +  { &yyActionTable[321],   4, 842 }, +  { &yyActionTable[325],   0, 730 }, +  { &yyActionTable[325],  26, 737 }, +  { &yyActionTable[351],  15, 842 }, +  { &yyActionTable[366],  27, 738 }, +  { &yyActionTable[393],  15, 842 }, +  { &yyActionTable[408],  12, 739 }, +  { &yyActionTable[420],  15, 842 }, +  { &yyActionTable[435],  12, 740 }, +  { &yyActionTable[447],  15, 842 }, +  { &yyActionTable[462],  12, 741 }, +  { &yyActionTable[474],  15, 842 }, +  { &yyActionTable[489],  12, 742 }, +  { &yyActionTable[501],  15, 842 }, +  { &yyActionTable[516],  16, 743 }, +  { &yyActionTable[532],  15, 842 }, +  { &yyActionTable[547],  16, 744 }, +  { &yyActionTable[563],  15, 842 }, +  { &yyActionTable[578],   8, 745 }, +  { &yyActionTable[586],  15, 842 }, +  { &yyActionTable[601],   8, 746 }, +  { &yyActionTable[609],  15, 842 }, +  { &yyActionTable[624],   8, 747 }, +  { &yyActionTable[632],  15, 842 }, +  { &yyActionTable[647],   8, 748 }, +  { &yyActionTable[655],  15, 842 }, +  { &yyActionTable[670],  16, 749 }, +  { &yyActionTable[686],   6, 842 }, +  { &yyActionTable[692],  15, 842 }, +  { &yyActionTable[707],  16, 750 }, +  { &yyActionTable[723],   0, 751 }, +  { &yyActionTable[723],   0, 752 }, +  { &yyActionTable[723],  15, 842 }, +  { &yyActionTable[738],   6, 753 }, +  { &yyActionTable[744],  15, 842 }, +  { &yyActionTable[759],   6, 754 }, +  { &yyActionTable[765],  15, 842 }, +  { &yyActionTable[780],   3, 755 }, +  { &yyActionTable[783],  15, 842 }, +  { &yyActionTable[798],   3, 756 }, +  { &yyActionTable[801],  15, 842 }, +  { &yyActionTable[816],   3, 757 }, +  { &yyActionTable[819],  15, 842 }, +  { &yyActionTable[834],   2, 758 }, +  { &yyActionTable[836],   0, 759 }, +  { &yyActionTable[836],   2, 842 }, +  { &yyActionTable[838],   0, 760 }, +  { &yyActionTable[838],   1, 842 }, +  { &yyActionTable[839],   0, 763 }, +  { &yyActionTable[839],   0, 761 }, +  { &yyActionTable[839],  15, 842 }, +  { &yyActionTable[854],  28, 842 }, +  { &yyActionTable[882],  15, 842 }, +  { &yyActionTable[897],  16, 769 }, +  { &yyActionTable[913],   1, 842 }, +  { &yyActionTable[914],  20, 785 }, +  { &yyActionTable[934],   5, 842 }, +  { &yyActionTable[939],   2, 842 }, +  { &yyActionTable[941],   1, 842 }, +  { &yyActionTable[942],   1, 842 }, +  { &yyActionTable[943],   1, 842 }, +  { &yyActionTable[944],   0, 772 }, +  { &yyActionTable[944],  28, 784 }, +  { &yyActionTable[972],   0, 732 }, +  { &yyActionTable[972],   0, 733 }, +  { &yyActionTable[972],  15, 842 }, +  { &yyActionTable[987],  26, 764 }, +  { &yyActionTable[1013],  15, 842 }, +  { &yyActionTable[1028],   2, 765 }, +  { &yyActionTable[1030],  15, 842 }, +  { &yyActionTable[1045],   2, 766 }, +  { &yyActionTable[1047],  15, 842 }, +  { &yyActionTable[1062],   2, 767 }, +  { &yyActionTable[1064],  17, 842 }, +  { &yyActionTable[1081],  29, 842 }, +  { &yyActionTable[1110],   2, 842 }, +  { &yyActionTable[1112],   4, 842 }, +  { &yyActionTable[1116],   1, 842 }, +  { &yyActionTable[1117],   0, 775 }, +  { &yyActionTable[1117],  15, 842 }, +  { &yyActionTable[1132],  29, 842 }, +  { &yyActionTable[1161],  15, 842 }, +  { &yyActionTable[1176],  28, 776 }, +  { &yyActionTable[1204],   1, 842 }, +  { &yyActionTable[1205],   4, 842 }, +  { &yyActionTable[1209],   1, 842 }, +  { &yyActionTable[1210],   0, 833 }, +  { &yyActionTable[1210],   1, 842 }, +  { &yyActionTable[1211],   4, 842 }, +  { &yyActionTable[1215],   1, 842 }, +  { &yyActionTable[1216],   0, 834 }, +  { &yyActionTable[1216],   1, 842 }, +  { &yyActionTable[1217],   4, 842 }, +  { &yyActionTable[1221],   1, 842 }, +  { &yyActionTable[1222],   0, 835 }, +  { &yyActionTable[1222],   1, 842 }, +  { &yyActionTable[1223],   4, 842 }, +  { &yyActionTable[1227],   1, 842 }, +  { &yyActionTable[1228],   0, 836 }, +  { &yyActionTable[1228],  15, 842 }, +  { &yyActionTable[1243],  29, 842 }, +  { &yyActionTable[1272],  15, 842 }, +  { &yyActionTable[1287],  29, 842 }, +  { &yyActionTable[1316],  15, 842 }, +  { &yyActionTable[1331],  28, 777 }, +  { &yyActionTable[1359],   2, 842 }, +  { &yyActionTable[1361],   0, 771 }, +  { &yyActionTable[1361],  16, 785 }, +  { &yyActionTable[1377],   0, 782 }, +  { &yyActionTable[1377],   0, 783 }, +  { &yyActionTable[1377],   0, 762 }, +  { &yyActionTable[1377],  15, 842 }, +  { &yyActionTable[1392],  28, 842 }, +  { &yyActionTable[1420],  15, 842 }, +  { &yyActionTable[1435],  26, 770 }, +  { &yyActionTable[1461],   1, 842 }, +  { &yyActionTable[1462],  20, 785 }, +  { &yyActionTable[1482],   5, 842 }, +  { &yyActionTable[1487],   0, 774 }, +  { &yyActionTable[1487],   2, 842 }, +  { &yyActionTable[1489],   0, 773 }, +  { &yyActionTable[1489],   2, 699 }, +  { &yyActionTable[1491],   3, 698 }, +  { &yyActionTable[1494],   0, 694 }, +  { &yyActionTable[1494],  15, 842 }, +  { &yyActionTable[1509],  28, 704 }, +  { &yyActionTable[1537],   1, 842 }, +  { &yyActionTable[1538],  17, 785 }, +  { &yyActionTable[1555],   1, 702 }, +  { &yyActionTable[1556],  15, 842 }, +  { &yyActionTable[1571],  28, 711 }, +  { &yyActionTable[1599],   0, 666 }, +  { &yyActionTable[1599],   2, 677 }, +  { &yyActionTable[1601],   4, 675 }, +  { &yyActionTable[1605],   0, 676 }, +  { &yyActionTable[1605],   0, 682 }, +  { &yyActionTable[1605],   0, 683 }, +  { &yyActionTable[1605],   5, 842 }, +  { &yyActionTable[1610],   0, 684 }, +  { &yyActionTable[1610],   5, 842 }, +  { &yyActionTable[1615],   0, 685 }, +  { &yyActionTable[1615],   1, 842 }, +  { &yyActionTable[1616],   0, 686 }, +  { &yyActionTable[1616],   5, 842 }, +  { &yyActionTable[1621],   2, 680 }, +  { &yyActionTable[1623],   5, 673 }, +  { &yyActionTable[1628],   0, 581 }, +  { &yyActionTable[1628],   0, 582 }, +  { &yyActionTable[1628],   4, 842 }, +  { &yyActionTable[1632],   0, 671 }, +  { &yyActionTable[1632],   0, 672 }, +  { &yyActionTable[1632],   2, 688 }, +  { &yyActionTable[1634],   2, 690 }, +  { &yyActionTable[1636],   0, 678 }, +  { &yyActionTable[1636],   1, 842 }, +  { &yyActionTable[1637],   6, 842 }, +  { &yyActionTable[1643],   2, 842 }, +  { &yyActionTable[1645],   0, 689 }, +  { &yyActionTable[1645],   5, 842 }, +  { &yyActionTable[1650],   0, 791 }, +  { &yyActionTable[1650],   3, 698 }, +  { &yyActionTable[1653],   0, 793 }, +  { &yyActionTable[1653],   0, 792 }, +  { &yyActionTable[1653],  15, 842 }, +  { &yyActionTable[1668],  28, 687 }, +  { &yyActionTable[1696],   4, 842 }, +  { &yyActionTable[1700],   0, 681 }, +  { &yyActionTable[1700],   3, 842 }, +  { &yyActionTable[1703],   5, 842 }, +  { &yyActionTable[1708],   5, 673 }, +  { &yyActionTable[1713],   2, 688 }, +  { &yyActionTable[1715],   2, 690 }, +  { &yyActionTable[1717],   0, 679 }, +  { &yyActionTable[1717],  16, 842 }, +  { &yyActionTable[1733],  33, 673 }, +  { &yyActionTable[1766],   0, 668 }, +  { &yyActionTable[1766],   0, 669 }, +  { &yyActionTable[1766],   1, 842 }, +  { &yyActionTable[1767],   5, 842 }, +  { &yyActionTable[1772],   0, 670 }, +  { &yyActionTable[1772],   0, 663 }, +  { &yyActionTable[1772],   0, 664 }, +  { &yyActionTable[1772],   0, 768 }, +  { &yyActionTable[1772],  29, 842 }, +  { &yyActionTable[1801],   0, 725 }, +  { &yyActionTable[1801],   2, 842 }, +  { &yyActionTable[1803],   0, 735 }, +  { &yyActionTable[1803],   1, 842 }, +  { &yyActionTable[1804],   0, 736 }, +  { &yyActionTable[1804],  29, 842 }, +  { &yyActionTable[1833],   2, 643 }, +  { &yyActionTable[1835],   0, 612 }, +  { &yyActionTable[1835],   4, 842 }, +  { &yyActionTable[1839],   2, 789 }, +  { &yyActionTable[1841],   1, 616 }, +  { &yyActionTable[1842],   3, 613 }, +  { &yyActionTable[1845],   0, 617 }, +  { &yyActionTable[1845],   4, 842 }, +  { &yyActionTable[1849],   0, 618 }, +  { &yyActionTable[1849],   3, 842 }, +  { &yyActionTable[1852],   4, 842 }, +  { &yyActionTable[1856],   0, 619 }, +  { &yyActionTable[1856],   2, 842 }, +  { &yyActionTable[1858],   0, 622 }, +  { &yyActionTable[1858],   0, 623 }, +  { &yyActionTable[1858],   0, 624 }, +  { &yyActionTable[1858],   0, 625 }, +  { &yyActionTable[1858],   4, 842 }, +  { &yyActionTable[1862],   0, 620 }, +  { &yyActionTable[1862],   4, 842 }, +  { &yyActionTable[1866],   0, 621 }, +  { &yyActionTable[1866],   6, 842 }, +  { &yyActionTable[1872],   2, 842 }, +  { &yyActionTable[1874],   0, 790 }, +  { &yyActionTable[1874],   0, 614 }, +  { &yyActionTable[1874],   2, 842 }, +  { &yyActionTable[1876],   0, 615 }, +  { &yyActionTable[1876],   2, 628 }, +  { &yyActionTable[1878],   0, 627 }, +  { &yyActionTable[1878],   0, 598 }, +  { &yyActionTable[1878],   7, 842 }, +  { &yyActionTable[1885],   0, 599 }, +  { &yyActionTable[1885],   0, 600 }, +  { &yyActionTable[1885],   0, 601 }, +  { &yyActionTable[1885],   2, 842 }, +  { &yyActionTable[1887],   0, 602 }, +  { &yyActionTable[1887],   0, 605 }, +  { &yyActionTable[1887],   2, 842 }, +  { &yyActionTable[1889],   0, 603 }, +  { &yyActionTable[1889],   0, 606 }, +  { &yyActionTable[1889],   0, 604 }, +  { &yyActionTable[1889],   0, 607 }, +  { &yyActionTable[1889],   4, 587 }, +  { &yyActionTable[1893],   4, 842 }, +  { &yyActionTable[1897],   2, 842 }, +  { &yyActionTable[1899],   0, 588 }, +  { &yyActionTable[1899],   4, 842 }, +  { &yyActionTable[1903],   1, 842 }, +  { &yyActionTable[1904],   0, 589 }, +  { &yyActionTable[1904],   0, 592 }, +  { &yyActionTable[1904],   1, 842 }, +  { &yyActionTable[1905],   0, 593 }, +  { &yyActionTable[1905],   1, 842 }, +  { &yyActionTable[1906],   0, 594 }, +  { &yyActionTable[1906],   0, 591 }, +  { &yyActionTable[1906],   0, 590 }, +  { &yyActionTable[1906],   0, 579 }, +  { &yyActionTable[1906],   8, 842 }, +  { &yyActionTable[1914],   6, 842 }, +  { &yyActionTable[1920],   0, 633 }, +  { &yyActionTable[1920],   4, 842 }, +  { &yyActionTable[1924],   0, 636 }, +  { &yyActionTable[1924],   1, 842 }, +  { &yyActionTable[1925],   1, 842 }, +  { &yyActionTable[1926],   6, 842 }, +  { &yyActionTable[1932],   2, 842 }, +  { &yyActionTable[1934],   2, 643 }, +  { &yyActionTable[1936],   0, 637 }, +  { &yyActionTable[1936],   1, 842 }, +  { &yyActionTable[1937],   6, 842 }, +  { &yyActionTable[1943],   2, 842 }, +  { &yyActionTable[1945],   2, 643 }, +  { &yyActionTable[1947],   0, 638 }, +  { &yyActionTable[1947],  15, 842 }, +  { &yyActionTable[1962],  30, 643 }, +  { &yyActionTable[1992],   0, 639 }, +  { &yyActionTable[1992],   1, 842 }, +  { &yyActionTable[1993],   1, 842 }, +  { &yyActionTable[1994],   6, 842 }, +  { &yyActionTable[2000],   2, 842 }, +  { &yyActionTable[2002],   1, 842 }, +  { &yyActionTable[2003],   4, 842 }, +  { &yyActionTable[2007],   2, 789 }, +  { &yyActionTable[2009],   1, 616 }, +  { &yyActionTable[2010],   7, 641 }, +  { &yyActionTable[2017],   1, 842 }, +  { &yyActionTable[2018],   0, 640 }, +  { &yyActionTable[2018],   0, 642 }, +  { &yyActionTable[2018],   0, 634 }, +  { &yyActionTable[2018],   0, 635 }, +  { &yyActionTable[2018],   0, 577 }, +  { &yyActionTable[2018],   3, 842 }, +  { &yyActionTable[2021],   5, 842 }, +  { &yyActionTable[2026],   3, 573 }, +  { &yyActionTable[2029],   6, 842 }, +  { &yyActionTable[2035],   4, 842 }, +  { &yyActionTable[2039],   0, 571 }, +  { &yyActionTable[2039],   4, 842 }, +  { &yyActionTable[2043],   1, 842 }, +  { &yyActionTable[2044],   3, 842 }, +  { &yyActionTable[2047],   5, 842 }, +  { &yyActionTable[2052],   1, 842 }, +  { &yyActionTable[2053],   4, 842 }, +  { &yyActionTable[2057],   1, 842 }, +  { &yyActionTable[2058],   4, 842 }, +  { &yyActionTable[2062],   3, 842 }, +  { &yyActionTable[2065],   1, 842 }, +  { &yyActionTable[2066],   6, 842 }, +  { &yyActionTable[2072],   2, 842 }, +  { &yyActionTable[2074],   3, 842 }, +  { &yyActionTable[2077],   1, 842 }, +  { &yyActionTable[2078],   1, 842 }, +  { &yyActionTable[2079],   4, 842 }, +  { &yyActionTable[2083],   4, 816 }, +  { &yyActionTable[2087],   4, 842 }, +  { &yyActionTable[2091],   1, 842 }, +  { &yyActionTable[2092],   4, 842 }, +  { &yyActionTable[2096],   2, 680 }, +  { &yyActionTable[2098],   2, 821 }, +  { &yyActionTable[2100],   3, 842 }, +  { &yyActionTable[2103],   1, 842 }, +  { &yyActionTable[2104],  15, 842 }, +  { &yyActionTable[2119],  29, 842 }, +  { &yyActionTable[2148],   1, 842 }, +  { &yyActionTable[2149],   2, 842 }, +  { &yyActionTable[2151],   0, 822 }, +  { &yyActionTable[2151],   0, 823 }, +  { &yyActionTable[2151],   1, 842 }, +  { &yyActionTable[2152],   1, 842 }, +  { &yyActionTable[2153],   2, 842 }, +  { &yyActionTable[2155],   5, 842 }, +  { &yyActionTable[2160],   2, 842 }, +  { &yyActionTable[2162],   4, 842 }, +  { &yyActionTable[2166],   0, 723 }, +  { &yyActionTable[2166],   0, 724 }, +  { &yyActionTable[2166],   0, 813 }, +  { &yyActionTable[2166],   0, 814 }, +  { &yyActionTable[2166],   1, 842 }, +  { &yyActionTable[2167],   0, 815 }, +  { &yyActionTable[2167],   0, 572 }, +  { &yyActionTable[2167],   1, 842 }, +  { &yyActionTable[2168],   9, 842 }, +  { &yyActionTable[2177],   5, 842 }, +  { &yyActionTable[2182],   1, 842 }, +  { &yyActionTable[2183],   1, 842 }, +  { &yyActionTable[2184],   1, 842 }, +  { &yyActionTable[2185],   9, 842 }, +  { &yyActionTable[2194],   1, 842 }, +  { &yyActionTable[2195],   2, 645 }, +  { &yyActionTable[2197],   6, 842 }, +  { &yyActionTable[2203],   0, 646 }, +  { &yyActionTable[2203],   4, 842 }, +  { &yyActionTable[2207],   1, 842 }, +  { &yyActionTable[2208],   5, 842 }, +  { &yyActionTable[2213],   4, 842 }, +  { &yyActionTable[2217],   4, 842 }, +  { &yyActionTable[2221],   1, 842 }, +  { &yyActionTable[2222],  15, 842 }, +  { &yyActionTable[2237],  28, 713 }, +  { &yyActionTable[2265],   1, 842 }, +  { &yyActionTable[2266],   1, 842 }, +  { &yyActionTable[2267],  15, 842 }, +  { &yyActionTable[2282],  28, 714 }, +  { &yyActionTable[2310],   3, 842 }, +  { &yyActionTable[2313],   1, 842 }, +  { &yyActionTable[2314],   4, 842 }, +  { &yyActionTable[2318],   2, 721 }, +  { &yyActionTable[2320],   5, 842 }, +  { &yyActionTable[2325],   2, 842 }, +  { &yyActionTable[2327],   0, 722 }, +  { &yyActionTable[2327],   4, 842 }, +  { &yyActionTable[2331],   5, 842 }, +  { &yyActionTable[2336],   1, 842 }, +  { &yyActionTable[2337],  16, 842 }, +  { &yyActionTable[2353],   2, 842 }, +  { &yyActionTable[2355],  15, 842 }, +  { &yyActionTable[2370],  28, 719 }, +  { &yyActionTable[2398],   1, 842 }, +  { &yyActionTable[2399],  28, 720 }, +  { &yyActionTable[2427],   1, 842 }, +  { &yyActionTable[2428],   4, 842 }, +  { &yyActionTable[2432],   3, 842 }, +  { &yyActionTable[2435],   1, 842 }, +  { &yyActionTable[2436],   4, 842 }, +  { &yyActionTable[2440],   4, 842 }, +  { &yyActionTable[2444],   1, 842 }, +  { &yyActionTable[2445],   4, 842 }, +  { &yyActionTable[2449],   1, 842 }, +  { &yyActionTable[2450],   4, 842 }, +  { &yyActionTable[2454],   3, 842 }, +  { &yyActionTable[2457],   1, 842 }, +  { &yyActionTable[2458],   4, 842 }, +  { &yyActionTable[2462],   3, 842 }, +  { &yyActionTable[2465],   1, 842 }, +  { &yyActionTable[2466],   5, 842 }, +  { &yyActionTable[2471],   1, 842 }, +  { &yyActionTable[2472],   4, 842 }, +  { &yyActionTable[2476],   2, 680 }, +  { &yyActionTable[2478],   3, 842 }, +  { &yyActionTable[2481],   1, 842 }, +  { &yyActionTable[2482],   2, 645 }, +  { &yyActionTable[2484],   4, 842 }, +  { &yyActionTable[2488],   3, 842 }, +  { &yyActionTable[2491],   1, 842 }, +  { &yyActionTable[2492],   5, 842 }, +  { &yyActionTable[2497],   4, 842 }, +  { &yyActionTable[2501],   1, 842 }, +  { &yyActionTable[2502],   1, 842 }, +  { &yyActionTable[2503],   4, 842 }, +  { &yyActionTable[2507],   2, 680 }, +  { &yyActionTable[2509],   2, 721 }, +  { &yyActionTable[2511],   4, 842 }, +  { &yyActionTable[2515],   5, 842 }, +  { &yyActionTable[2520],   1, 842 }, +  { &yyActionTable[2521],  16, 842 }, +  { &yyActionTable[2537],   2, 842 }, +  { &yyActionTable[2539],   1, 842 }, +  { &yyActionTable[2540],   3, 842 }, +  { &yyActionTable[2543],   1, 842 }, +  { &yyActionTable[2544],   1, 842 }, +  { &yyActionTable[2545],   2, 645 }, +  { &yyActionTable[2547],   4, 842 }, +  { &yyActionTable[2551],   3, 842 }, +  { &yyActionTable[2554],   1, 842 }, +  { &yyActionTable[2555],   4, 842 }, +  { &yyActionTable[2559],   2, 842 }, +  { &yyActionTable[2561],   1, 842 }, +  { &yyActionTable[2562],   1, 842 }, +  { &yyActionTable[2563],   1, 842 }, +  { &yyActionTable[2564],   5, 842 }, +  { &yyActionTable[2569],   1, 842 }, +  { &yyActionTable[2570],   3, 842 }, +  { &yyActionTable[2573],   3, 842 }, +  { &yyActionTable[2576],  10, 810 }, +  { &yyActionTable[2586],   1, 842 }, +  { &yyActionTable[2587],   1, 842 }, +  { &yyActionTable[2588],   1, 842 }, +  { &yyActionTable[2589],   1, 842 }, +  { &yyActionTable[2590],   3, 842 }, +  { &yyActionTable[2593],   1, 842 }, +  { &yyActionTable[2594],   1, 842 }, +  { &yyActionTable[2595],   1, 842 }, +  { &yyActionTable[2596],   3, 842 }, +  { &yyActionTable[2599],   1, 842 }, +  { &yyActionTable[2600],   0, 809 }, +  { &yyActionTable[2600],   4, 842 }, +  { &yyActionTable[2604],   1, 842 }, +  { &yyActionTable[2605],   1, 842 }, +  { &yyActionTable[2606],   2, 840 }, +  { &yyActionTable[2608],   3, 842 }, +  { &yyActionTable[2611],   1, 842 }, +  { &yyActionTable[2612],   4, 842 }, +  { &yyActionTable[2616],   1, 842 }, +  { &yyActionTable[2617],   0, 839 }, +  { &yyActionTable[2617],   2, 840 }, +  { &yyActionTable[2619],   4, 842 }, +  { &yyActionTable[2623],   1, 842 }, +  { &yyActionTable[2624],   0, 559 }, +  { &yyActionTable[2624],   0, 561 }, +  { &yyActionTable[2624],   0, 556 },  };  /* The next table maps tokens into fallback tokens.  If a construct @@ -3667,53 +3767,56 @@ static const yyStateEntry yyStateTable[] = {  #ifdef YYFALLBACK  static const YYCODETYPE yyFallback[] = {      0,  /*          $ => nothing */ -   56,  /*      ABORT => ID */ -   56,  /*      AFTER => ID */ +   59,  /*      ABORT => ID */ +   59,  /*      AFTER => ID */      0,  /* AGG_FUNCTION => nothing */      0,  /*        ALL => nothing */      0,  /*        AND => nothing */      0,  /*         AS => nothing */ -   56,  /*        ASC => ID */ -   56,  /*     BEFORE => ID */ -   56,  /*      BEGIN => ID */ +   59,  /*        ASC => ID */ +   59,  /*     ATTACH => ID */ +   59,  /*     BEFORE => ID */ +   59,  /*      BEGIN => ID */      0,  /*    BETWEEN => nothing */      0,  /*     BITAND => nothing */      0,  /*     BITNOT => nothing */      0,  /*      BITOR => nothing */      0,  /*         BY => nothing */ -   56,  /*    CASCADE => ID */ +   59,  /*    CASCADE => ID */      0,  /*       CASE => nothing */      0,  /*      CHECK => nothing */ -   56,  /*    CLUSTER => ID */ +   59,  /*    CLUSTER => ID */      0,  /*    COLLATE => nothing */      0,  /*     COLUMN => nothing */      0,  /*      COMMA => nothing */      0,  /*    COMMENT => nothing */      0,  /*     COMMIT => nothing */      0,  /*     CONCAT => nothing */ -   56,  /*   CONFLICT => ID */ +   59,  /*   CONFLICT => ID */      0,  /* CONSTRAINT => nothing */ -   56,  /*       COPY => ID */ +   59,  /*       COPY => ID */      0,  /*     CREATE => nothing */ +   59,  /*   DATABASE => ID */      0,  /*    DEFAULT => nothing */      0,  /* DEFERRABLE => nothing */ -   56,  /*   DEFERRED => ID */ +   59,  /*   DEFERRED => ID */      0,  /*     DELETE => nothing */ -   56,  /* DELIMITERS => ID */ -   56,  /*       DESC => ID */ +   59,  /* DELIMITERS => ID */ +   59,  /*       DESC => ID */ +   59,  /*     DETACH => ID */      0,  /*   DISTINCT => nothing */      0,  /*        DOT => nothing */      0,  /*       DROP => nothing */ -   56,  /*       EACH => ID */ +   59,  /*       EACH => ID */      0,  /*       ELSE => nothing */ -   56,  /*        END => ID */ +   59,  /*        END => ID */      0,  /* END_OF_FILE => nothing */      0,  /*         EQ => nothing */      0,  /*     EXCEPT => nothing */ -   56,  /*    EXPLAIN => ID */ -   56,  /*       FAIL => ID */ +   59,  /*    EXPLAIN => ID */ +   59,  /*       FAIL => ID */      0,  /*      FLOAT => nothing */ -   56,  /*        FOR => ID */ +   59,  /*        FOR => ID */      0,  /*    FOREIGN => nothing */      0,  /*       FROM => nothing */      0,  /*   FUNCTION => nothing */ @@ -3723,14 +3826,14 @@ static const YYCODETYPE yyFallback[] = {      0,  /*         GT => nothing */      0,  /*     HAVING => nothing */      0,  /*         ID => nothing */ -   56,  /*     IGNORE => ID */ +   59,  /*     IGNORE => ID */      0,  /*    ILLEGAL => nothing */ -   56,  /*  IMMEDIATE => ID */ +   59,  /*  IMMEDIATE => ID */      0,  /*         IN => nothing */      0,  /*      INDEX => nothing */ -   56,  /*  INITIALLY => ID */ +   59,  /*  INITIALLY => ID */      0,  /*     INSERT => nothing */ -   56,  /*    INSTEAD => ID */ +   59,  /*    INSTEAD => ID */      0,  /*    INTEGER => nothing */      0,  /*  INTERSECT => nothing */      0,  /*       INTO => nothing */ @@ -3738,35 +3841,35 @@ static const YYCODETYPE yyFallback[] = {      0,  /*     ISNULL => nothing */      0,  /*       JOIN => nothing */      0,  /*    JOIN_KW => nothing */ -   56,  /*        KEY => ID */ +   59,  /*        KEY => ID */      0,  /*         LE => nothing */      0,  /*       LIKE => nothing */      0,  /*      LIMIT => nothing */      0,  /*         LP => nothing */      0,  /*     LSHIFT => nothing */      0,  /*         LT => nothing */ -   56,  /*      MATCH => ID */ +   59,  /*      MATCH => ID */      0,  /*      MINUS => nothing */      0,  /*         NE => nothing */      0,  /*        NOT => nothing */      0,  /*    NOTNULL => nothing */      0,  /*       NULL => nothing */ -   56,  /*         OF => ID */ -   56,  /*     OFFSET => ID */ +   59,  /*         OF => ID */ +   59,  /*     OFFSET => ID */      0,  /*         ON => nothing */      0,  /*         OR => nothing */      0,  /* ORACLE_OUTER_JOIN => nothing */      0,  /*      ORDER => nothing */      0,  /*       PLUS => nothing */ -   56,  /*     PRAGMA => ID */ +   59,  /*     PRAGMA => ID */      0,  /*    PRIMARY => nothing */ -   56,  /*      RAISE => ID */ +   59,  /*      RAISE => ID */      0,  /* REFERENCES => nothing */      0,  /*        REM => nothing */ -   56,  /*    REPLACE => ID */ -   56,  /*   RESTRICT => ID */ +   59,  /*    REPLACE => ID */ +   59,  /*   RESTRICT => ID */      0,  /*   ROLLBACK => nothing */ -   56,  /*        ROW => ID */ +   59,  /*        ROW => ID */      0,  /*         RP => nothing */      0,  /*     RSHIFT => nothing */      0,  /*     SELECT => nothing */ @@ -3775,13 +3878,13 @@ static const YYCODETYPE yyFallback[] = {      0,  /*      SLASH => nothing */      0,  /*      SPACE => nothing */      0,  /*       STAR => nothing */ -   56,  /*  STATEMENT => ID */ +   59,  /*  STATEMENT => ID */      0,  /*     STRING => nothing */      0,  /*      TABLE => nothing */ -   56,  /*       TEMP => ID */ +   59,  /*       TEMP => ID */      0,  /*       THEN => nothing */      0,  /* TRANSACTION => nothing */ -   56,  /*    TRIGGER => ID */ +   59,  /*    TRIGGER => ID */      0,  /*     UMINUS => nothing */      0,  /* UNCLOSED_STRING => nothing */      0,  /*      UNION => nothing */ @@ -3789,9 +3892,9 @@ static const YYCODETYPE yyFallback[] = {      0,  /*     UPDATE => nothing */      0,  /*      UPLUS => nothing */      0,  /*      USING => nothing */ -   56,  /*     VACUUM => ID */ +   59,  /*     VACUUM => ID */      0,  /*     VALUES => nothing */ -   56,  /*       VIEW => ID */ +   59,  /*       VIEW => ID */      0,  /*       WHEN => nothing */      0,  /*      WHERE => nothing */  }; @@ -3867,48 +3970,49 @@ void sqliteParserTrace(FILE *TraceFILE, char *zTracePrompt){  static const char *yyTokenName[] = {     "$",             "ABORT",         "AFTER",         "AGG_FUNCTION",    "ALL",           "AND",           "AS",            "ASC",          -  "BEFORE",        "BEGIN",         "BETWEEN",       "BITAND",       -  "BITNOT",        "BITOR",         "BY",            "CASCADE",      -  "CASE",          "CHECK",         "CLUSTER",       "COLLATE",      -  "COLUMN",        "COMMA",         "COMMENT",       "COMMIT",       -  "CONCAT",        "CONFLICT",      "CONSTRAINT",    "COPY",         -  "CREATE",        "DEFAULT",       "DEFERRABLE",    "DEFERRED",     -  "DELETE",        "DELIMITERS",    "DESC",          "DISTINCT",     -  "DOT",           "DROP",          "EACH",          "ELSE",         -  "END",           "END_OF_FILE",   "EQ",            "EXCEPT",       -  "EXPLAIN",       "FAIL",          "FLOAT",         "FOR",          -  "FOREIGN",       "FROM",          "FUNCTION",      "GE",           -  "GLOB",          "GROUP",         "GT",            "HAVING",       -  "ID",            "IGNORE",        "ILLEGAL",       "IMMEDIATE",    -  "IN",            "INDEX",         "INITIALLY",     "INSERT",       -  "INSTEAD",       "INTEGER",       "INTERSECT",     "INTO",         -  "IS",            "ISNULL",        "JOIN",          "JOIN_KW",      -  "KEY",           "LE",            "LIKE",          "LIMIT",        -  "LP",            "LSHIFT",        "LT",            "MATCH",        -  "MINUS",         "NE",            "NOT",           "NOTNULL",      -  "NULL",          "OF",            "OFFSET",        "ON",           -  "OR",            "ORACLE_OUTER_JOIN",  "ORDER",         "PLUS",         -  "PRAGMA",        "PRIMARY",       "RAISE",         "REFERENCES",   -  "REM",           "REPLACE",       "RESTRICT",      "ROLLBACK",     -  "ROW",           "RP",            "RSHIFT",        "SELECT",       -  "SEMI",          "SET",           "SLASH",         "SPACE",        -  "STAR",          "STATEMENT",     "STRING",        "TABLE",        -  "TEMP",          "THEN",          "TRANSACTION",   "TRIGGER",      -  "UMINUS",        "UNCLOSED_STRING",  "UNION",         "UNIQUE",       -  "UPDATE",        "UPLUS",         "USING",         "VACUUM",       -  "VALUES",        "VIEW",          "WHEN",          "WHERE",        -  "as",            "carg",          "carglist",      "case_else",    -  "case_exprlist",  "case_operand",  "ccons",         "cmd",          -  "cmdlist",       "cmdx",          "collate",       "column",       -  "columnid",      "columnlist",    "conslist",      "conslist_opt", -  "create_table",  "create_table_args",  "defer_subclause",  "defer_subclause_opt", -  "distinct",      "ecmd",          "error",         "explain",      -  "expr",          "expritem",      "exprlist",      "foreach_clause", -  "from",          "groupby_opt",   "having_opt",    "id",           -  "ids",           "idxitem",       "idxlist",       "idxlist_opt",  -  "init_deferred_pred_opt",  "input",         "inscollist",    "inscollist_opt", -  "insert_cmd",    "itemlist",      "joinop",        "joinop2",      -  "likeop",        "limit_opt",     "limit_sep",     "minus_num",    +  "ATTACH",        "BEFORE",        "BEGIN",         "BETWEEN",      +  "BITAND",        "BITNOT",        "BITOR",         "BY",           +  "CASCADE",       "CASE",          "CHECK",         "CLUSTER",      +  "COLLATE",       "COLUMN",        "COMMA",         "COMMENT",      +  "COMMIT",        "CONCAT",        "CONFLICT",      "CONSTRAINT",   +  "COPY",          "CREATE",        "DATABASE",      "DEFAULT",      +  "DEFERRABLE",    "DEFERRED",      "DELETE",        "DELIMITERS",   +  "DESC",          "DETACH",        "DISTINCT",      "DOT",          +  "DROP",          "EACH",          "ELSE",          "END",          +  "END_OF_FILE",   "EQ",            "EXCEPT",        "EXPLAIN",      +  "FAIL",          "FLOAT",         "FOR",           "FOREIGN",      +  "FROM",          "FUNCTION",      "GE",            "GLOB",         +  "GROUP",         "GT",            "HAVING",        "ID",           +  "IGNORE",        "ILLEGAL",       "IMMEDIATE",     "IN",           +  "INDEX",         "INITIALLY",     "INSERT",        "INSTEAD",      +  "INTEGER",       "INTERSECT",     "INTO",          "IS",           +  "ISNULL",        "JOIN",          "JOIN_KW",       "KEY",          +  "LE",            "LIKE",          "LIMIT",         "LP",           +  "LSHIFT",        "LT",            "MATCH",         "MINUS",        +  "NE",            "NOT",           "NOTNULL",       "NULL",         +  "OF",            "OFFSET",        "ON",            "OR",           +  "ORACLE_OUTER_JOIN",  "ORDER",         "PLUS",          "PRAGMA",       +  "PRIMARY",       "RAISE",         "REFERENCES",    "REM",          +  "REPLACE",       "RESTRICT",      "ROLLBACK",      "ROW",          +  "RP",            "RSHIFT",        "SELECT",        "SEMI",         +  "SET",           "SLASH",         "SPACE",         "STAR",         +  "STATEMENT",     "STRING",        "TABLE",         "TEMP",         +  "THEN",          "TRANSACTION",   "TRIGGER",       "UMINUS",       +  "UNCLOSED_STRING",  "UNION",         "UNIQUE",        "UPDATE",       +  "UPLUS",         "USING",         "VACUUM",        "VALUES",       +  "VIEW",          "WHEN",          "WHERE",         "as",           +  "carg",          "carglist",      "case_else",     "case_exprlist", +  "case_operand",  "ccons",         "cmd",           "cmdlist",      +  "cmdx",          "collate",       "column",        "columnid",     +  "columnlist",    "conslist",      "conslist_opt",  "create_table", +  "create_table_args",  "database_kw_opt",  "dbnm",          "defer_subclause", +  "defer_subclause_opt",  "distinct",      "ecmd",          "error",        +  "explain",       "expr",          "expritem",      "exprlist",     +  "foreach_clause",  "from",          "groupby_opt",   "having_opt",   +  "id",            "ids",           "idxitem",       "idxlist",      +  "idxlist_opt",   "init_deferred_pred_opt",  "input",         "inscollist",   +  "inscollist_opt",  "insert_cmd",    "itemlist",      "joinop",       +  "joinop2",       "likeop",        "limit_opt",     "minus_num",       "multiselect_op",  "nm",            "number",        "on_opt",          "onconf",        "oneselect",     "orconf",        "orderby_opt",     "plus_num",      "plus_opt",      "refact",        "refarg",       @@ -3916,9 +4020,9 @@ static const char *yyTokenName[] = {    "select",        "seltablist",    "setlist",       "signed",          "sortitem",      "sortlist",      "sortorder",     "stl_prefix",      "tcons",         "temp",          "trans_opt",     "trigger_cmd",  -  "trigger_cmd_list",  "trigger_event",  "trigger_time",  "type",         -  "typename",      "uniqueflag",    "using_opt",     "when_clause",  -  "where_opt",    +  "trigger_cmd_list",  "trigger_decl",  "trigger_event",  "trigger_time", +  "type",          "typename",      "uniqueflag",    "using_opt",    +  "when_clause",   "where_opt",     };  #endif /* NDEBUG */ @@ -4049,163 +4153,170 @@ static const char *yyRuleName[] = {   /* 120 */ "from ::= FROM seltablist",   /* 121 */ "stl_prefix ::= seltablist joinop",   /* 122 */ "stl_prefix ::=", - /* 123 */ "seltablist ::= stl_prefix nm as on_opt using_opt", + /* 123 */ "seltablist ::= stl_prefix nm dbnm as on_opt using_opt",   /* 124 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", - /* 125 */ "joinop ::= COMMA", - /* 126 */ "joinop ::= JOIN", - /* 127 */ "joinop ::= JOIN_KW JOIN", - /* 128 */ "joinop ::= JOIN_KW nm JOIN", - /* 129 */ "joinop ::= JOIN_KW nm nm JOIN", - /* 130 */ "on_opt ::= ON expr", - /* 131 */ "on_opt ::=", - /* 132 */ "using_opt ::= USING LP idxlist RP", - /* 133 */ "using_opt ::=", - /* 134 */ "orderby_opt ::=", - /* 135 */ "orderby_opt ::= ORDER BY sortlist", - /* 136 */ "sortlist ::= sortlist COMMA sortitem collate sortorder", - /* 137 */ "sortlist ::= sortitem collate sortorder", - /* 138 */ "sortitem ::= expr", - /* 139 */ "sortorder ::= ASC", - /* 140 */ "sortorder ::= DESC", - /* 141 */ "sortorder ::=", - /* 142 */ "collate ::=", - /* 143 */ "collate ::= COLLATE id", - /* 144 */ "groupby_opt ::=", - /* 145 */ "groupby_opt ::= GROUP BY exprlist", - /* 146 */ "having_opt ::=", - /* 147 */ "having_opt ::= HAVING expr", - /* 148 */ "limit_opt ::=", - /* 149 */ "limit_opt ::= LIMIT INTEGER", - /* 150 */ "limit_opt ::= LIMIT INTEGER limit_sep INTEGER", - /* 151 */ "limit_sep ::= OFFSET", - /* 152 */ "limit_sep ::= COMMA", - /* 153 */ "cmd ::= DELETE FROM nm where_opt", - /* 154 */ "where_opt ::=", - /* 155 */ "where_opt ::= WHERE expr", - /* 156 */ "cmd ::= UPDATE orconf nm SET setlist where_opt", - /* 157 */ "setlist ::= setlist COMMA nm EQ expr", - /* 158 */ "setlist ::= nm EQ expr", - /* 159 */ "cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP", - /* 160 */ "cmd ::= insert_cmd INTO nm inscollist_opt select", - /* 161 */ "insert_cmd ::= INSERT orconf", - /* 162 */ "insert_cmd ::= REPLACE", - /* 163 */ "itemlist ::= itemlist COMMA expr", - /* 164 */ "itemlist ::= expr", - /* 165 */ "inscollist_opt ::=", - /* 166 */ "inscollist_opt ::= LP inscollist RP", - /* 167 */ "inscollist ::= inscollist COMMA nm", - /* 168 */ "inscollist ::= nm", - /* 169 */ "expr ::= LP expr RP", - /* 170 */ "expr ::= NULL", - /* 171 */ "expr ::= ID", - /* 172 */ "expr ::= JOIN_KW", - /* 173 */ "expr ::= nm DOT nm", - /* 174 */ "expr ::= expr ORACLE_OUTER_JOIN", - /* 175 */ "expr ::= INTEGER", - /* 176 */ "expr ::= FLOAT", - /* 177 */ "expr ::= STRING", - /* 178 */ "expr ::= ID LP exprlist RP", - /* 179 */ "expr ::= ID LP STAR RP", - /* 180 */ "expr ::= expr AND expr", - /* 181 */ "expr ::= expr OR expr", - /* 182 */ "expr ::= expr LT expr", - /* 183 */ "expr ::= expr GT expr", - /* 184 */ "expr ::= expr LE expr", - /* 185 */ "expr ::= expr GE expr", - /* 186 */ "expr ::= expr NE expr", - /* 187 */ "expr ::= expr EQ expr", - /* 188 */ "expr ::= expr BITAND expr", - /* 189 */ "expr ::= expr BITOR expr", - /* 190 */ "expr ::= expr LSHIFT expr", - /* 191 */ "expr ::= expr RSHIFT expr", - /* 192 */ "expr ::= expr likeop expr", - /* 193 */ "expr ::= expr NOT likeop expr", - /* 194 */ "likeop ::= LIKE", - /* 195 */ "likeop ::= GLOB", - /* 196 */ "expr ::= expr PLUS expr", - /* 197 */ "expr ::= expr MINUS expr", - /* 198 */ "expr ::= expr STAR expr", - /* 199 */ "expr ::= expr SLASH expr", - /* 200 */ "expr ::= expr REM expr", - /* 201 */ "expr ::= expr CONCAT expr", - /* 202 */ "expr ::= expr ISNULL", - /* 203 */ "expr ::= expr IS NULL", - /* 204 */ "expr ::= expr NOTNULL", - /* 205 */ "expr ::= expr NOT NULL", - /* 206 */ "expr ::= expr IS NOT NULL", - /* 207 */ "expr ::= NOT expr", - /* 208 */ "expr ::= BITNOT expr", - /* 209 */ "expr ::= MINUS expr", - /* 210 */ "expr ::= PLUS expr", - /* 211 */ "expr ::= LP select RP", - /* 212 */ "expr ::= expr BETWEEN expr AND expr", - /* 213 */ "expr ::= expr NOT BETWEEN expr AND expr", - /* 214 */ "expr ::= expr IN LP exprlist RP", - /* 215 */ "expr ::= expr IN LP select RP", - /* 216 */ "expr ::= expr NOT IN LP exprlist RP", - /* 217 */ "expr ::= expr NOT IN LP select RP", - /* 218 */ "expr ::= CASE case_operand case_exprlist case_else END", - /* 219 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", - /* 220 */ "case_exprlist ::= WHEN expr THEN expr", - /* 221 */ "case_else ::= ELSE expr", - /* 222 */ "case_else ::=", - /* 223 */ "case_operand ::= expr", - /* 224 */ "case_operand ::=", - /* 225 */ "exprlist ::= exprlist COMMA expritem", - /* 226 */ "exprlist ::= expritem", - /* 227 */ "expritem ::= expr", - /* 228 */ "expritem ::=", - /* 229 */ "cmd ::= CREATE uniqueflag INDEX nm ON nm LP idxlist RP onconf", - /* 230 */ "uniqueflag ::= UNIQUE", - /* 231 */ "uniqueflag ::=", - /* 232 */ "idxlist_opt ::=", - /* 233 */ "idxlist_opt ::= LP idxlist RP", - /* 234 */ "idxlist ::= idxlist COMMA idxitem", - /* 235 */ "idxlist ::= idxitem", - /* 236 */ "idxitem ::= nm", - /* 237 */ "cmd ::= DROP INDEX nm", - /* 238 */ "cmd ::= COPY orconf nm FROM nm USING DELIMITERS STRING", - /* 239 */ "cmd ::= COPY orconf nm FROM nm", - /* 240 */ "cmd ::= VACUUM", - /* 241 */ "cmd ::= VACUUM nm", - /* 242 */ "cmd ::= PRAGMA ids EQ nm", - /* 243 */ "cmd ::= PRAGMA ids EQ ON", - /* 244 */ "cmd ::= PRAGMA ids EQ plus_num", - /* 245 */ "cmd ::= PRAGMA ids EQ minus_num", - /* 246 */ "cmd ::= PRAGMA ids LP nm RP", - /* 247 */ "cmd ::= PRAGMA ids", - /* 248 */ "plus_num ::= plus_opt number", - /* 249 */ "minus_num ::= MINUS number", - /* 250 */ "number ::= INTEGER", - /* 251 */ "number ::= FLOAT", - /* 252 */ "plus_opt ::= PLUS", - /* 253 */ "plus_opt ::=", - /* 254 */ "cmd ::= CREATE TRIGGER nm trigger_time trigger_event ON nm foreach_clause when_clause BEGIN trigger_cmd_list END", - /* 255 */ "trigger_time ::= BEFORE", - /* 256 */ "trigger_time ::= AFTER", - /* 257 */ "trigger_time ::= INSTEAD OF", - /* 258 */ "trigger_time ::=", - /* 259 */ "trigger_event ::= DELETE", - /* 260 */ "trigger_event ::= INSERT", - /* 261 */ "trigger_event ::= UPDATE", - /* 262 */ "trigger_event ::= UPDATE OF inscollist", - /* 263 */ "foreach_clause ::=", - /* 264 */ "foreach_clause ::= FOR EACH ROW", - /* 265 */ "foreach_clause ::= FOR EACH STATEMENT", - /* 266 */ "when_clause ::=", - /* 267 */ "when_clause ::= WHEN expr", - /* 268 */ "trigger_cmd_list ::= trigger_cmd SEMI trigger_cmd_list", - /* 269 */ "trigger_cmd_list ::=", - /* 270 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", - /* 271 */ "trigger_cmd ::= INSERT orconf INTO nm inscollist_opt VALUES LP itemlist RP", - /* 272 */ "trigger_cmd ::= INSERT orconf INTO nm inscollist_opt select", - /* 273 */ "trigger_cmd ::= DELETE FROM nm where_opt", - /* 274 */ "trigger_cmd ::= select", - /* 275 */ "expr ::= RAISE LP IGNORE RP", - /* 276 */ "expr ::= RAISE LP ROLLBACK COMMA nm RP", - /* 277 */ "expr ::= RAISE LP ABORT COMMA nm RP", - /* 278 */ "expr ::= RAISE LP FAIL COMMA nm RP", - /* 279 */ "cmd ::= DROP TRIGGER nm", + /* 125 */ "dbnm ::=", + /* 126 */ "dbnm ::= DOT nm", + /* 127 */ "joinop ::= COMMA", + /* 128 */ "joinop ::= JOIN", + /* 129 */ "joinop ::= JOIN_KW JOIN", + /* 130 */ "joinop ::= JOIN_KW nm JOIN", + /* 131 */ "joinop ::= JOIN_KW nm nm JOIN", + /* 132 */ "on_opt ::= ON expr", + /* 133 */ "on_opt ::=", + /* 134 */ "using_opt ::= USING LP idxlist RP", + /* 135 */ "using_opt ::=", + /* 136 */ "orderby_opt ::=", + /* 137 */ "orderby_opt ::= ORDER BY sortlist", + /* 138 */ "sortlist ::= sortlist COMMA sortitem collate sortorder", + /* 139 */ "sortlist ::= sortitem collate sortorder", + /* 140 */ "sortitem ::= expr", + /* 141 */ "sortorder ::= ASC", + /* 142 */ "sortorder ::= DESC", + /* 143 */ "sortorder ::=", + /* 144 */ "collate ::=", + /* 145 */ "collate ::= COLLATE id", + /* 146 */ "groupby_opt ::=", + /* 147 */ "groupby_opt ::= GROUP BY exprlist", + /* 148 */ "having_opt ::=", + /* 149 */ "having_opt ::= HAVING expr", + /* 150 */ "limit_opt ::=", + /* 151 */ "limit_opt ::= LIMIT INTEGER", + /* 152 */ "limit_opt ::= LIMIT INTEGER OFFSET INTEGER", + /* 153 */ "limit_opt ::= LIMIT INTEGER COMMA INTEGER", + /* 154 */ "cmd ::= DELETE FROM nm dbnm where_opt", + /* 155 */ "where_opt ::=", + /* 156 */ "where_opt ::= WHERE expr", + /* 157 */ "cmd ::= UPDATE orconf nm dbnm SET setlist where_opt", + /* 158 */ "setlist ::= setlist COMMA nm EQ expr", + /* 159 */ "setlist ::= nm EQ expr", + /* 160 */ "cmd ::= insert_cmd INTO nm dbnm inscollist_opt VALUES LP itemlist RP", + /* 161 */ "cmd ::= insert_cmd INTO nm dbnm inscollist_opt select", + /* 162 */ "insert_cmd ::= INSERT orconf", + /* 163 */ "insert_cmd ::= REPLACE", + /* 164 */ "itemlist ::= itemlist COMMA expr", + /* 165 */ "itemlist ::= expr", + /* 166 */ "inscollist_opt ::=", + /* 167 */ "inscollist_opt ::= LP inscollist RP", + /* 168 */ "inscollist ::= inscollist COMMA nm", + /* 169 */ "inscollist ::= nm", + /* 170 */ "expr ::= LP expr RP", + /* 171 */ "expr ::= NULL", + /* 172 */ "expr ::= ID", + /* 173 */ "expr ::= JOIN_KW", + /* 174 */ "expr ::= nm DOT nm", + /* 175 */ "expr ::= nm DOT nm DOT nm", + /* 176 */ "expr ::= expr ORACLE_OUTER_JOIN", + /* 177 */ "expr ::= INTEGER", + /* 178 */ "expr ::= FLOAT", + /* 179 */ "expr ::= STRING", + /* 180 */ "expr ::= ID LP exprlist RP", + /* 181 */ "expr ::= ID LP STAR RP", + /* 182 */ "expr ::= expr AND expr", + /* 183 */ "expr ::= expr OR expr", + /* 184 */ "expr ::= expr LT expr", + /* 185 */ "expr ::= expr GT expr", + /* 186 */ "expr ::= expr LE expr", + /* 187 */ "expr ::= expr GE expr", + /* 188 */ "expr ::= expr NE expr", + /* 189 */ "expr ::= expr EQ expr", + /* 190 */ "expr ::= expr BITAND expr", + /* 191 */ "expr ::= expr BITOR expr", + /* 192 */ "expr ::= expr LSHIFT expr", + /* 193 */ "expr ::= expr RSHIFT expr", + /* 194 */ "expr ::= expr likeop expr", + /* 195 */ "expr ::= expr NOT likeop expr", + /* 196 */ "likeop ::= LIKE", + /* 197 */ "likeop ::= GLOB", + /* 198 */ "expr ::= expr PLUS expr", + /* 199 */ "expr ::= expr MINUS expr", + /* 200 */ "expr ::= expr STAR expr", + /* 201 */ "expr ::= expr SLASH expr", + /* 202 */ "expr ::= expr REM expr", + /* 203 */ "expr ::= expr CONCAT expr", + /* 204 */ "expr ::= expr ISNULL", + /* 205 */ "expr ::= expr IS NULL", + /* 206 */ "expr ::= expr NOTNULL", + /* 207 */ "expr ::= expr NOT NULL", + /* 208 */ "expr ::= expr IS NOT NULL", + /* 209 */ "expr ::= NOT expr", + /* 210 */ "expr ::= BITNOT expr", + /* 211 */ "expr ::= MINUS expr", + /* 212 */ "expr ::= PLUS expr", + /* 213 */ "expr ::= LP select RP", + /* 214 */ "expr ::= expr BETWEEN expr AND expr", + /* 215 */ "expr ::= expr NOT BETWEEN expr AND expr", + /* 216 */ "expr ::= expr IN LP exprlist RP", + /* 217 */ "expr ::= expr IN LP select RP", + /* 218 */ "expr ::= expr NOT IN LP exprlist RP", + /* 219 */ "expr ::= expr NOT IN LP select RP", + /* 220 */ "expr ::= CASE case_operand case_exprlist case_else END", + /* 221 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", + /* 222 */ "case_exprlist ::= WHEN expr THEN expr", + /* 223 */ "case_else ::= ELSE expr", + /* 224 */ "case_else ::=", + /* 225 */ "case_operand ::= expr", + /* 226 */ "case_operand ::=", + /* 227 */ "exprlist ::= exprlist COMMA expritem", + /* 228 */ "exprlist ::= expritem", + /* 229 */ "expritem ::= expr", + /* 230 */ "expritem ::=", + /* 231 */ "cmd ::= CREATE temp uniqueflag INDEX nm ON nm dbnm LP idxlist RP onconf", + /* 232 */ "uniqueflag ::= UNIQUE", + /* 233 */ "uniqueflag ::=", + /* 234 */ "idxlist_opt ::=", + /* 235 */ "idxlist_opt ::= LP idxlist RP", + /* 236 */ "idxlist ::= idxlist COMMA idxitem", + /* 237 */ "idxlist ::= idxitem", + /* 238 */ "idxitem ::= nm sortorder", + /* 239 */ "cmd ::= DROP INDEX nm dbnm", + /* 240 */ "cmd ::= COPY orconf nm dbnm FROM nm USING DELIMITERS STRING", + /* 241 */ "cmd ::= COPY orconf nm dbnm FROM nm", + /* 242 */ "cmd ::= VACUUM", + /* 243 */ "cmd ::= VACUUM nm", + /* 244 */ "cmd ::= PRAGMA ids EQ nm", + /* 245 */ "cmd ::= PRAGMA ids EQ ON", + /* 246 */ "cmd ::= PRAGMA ids EQ plus_num", + /* 247 */ "cmd ::= PRAGMA ids EQ minus_num", + /* 248 */ "cmd ::= PRAGMA ids LP nm RP", + /* 249 */ "cmd ::= PRAGMA ids", + /* 250 */ "plus_num ::= plus_opt number", + /* 251 */ "minus_num ::= MINUS number", + /* 252 */ "number ::= INTEGER", + /* 253 */ "number ::= FLOAT", + /* 254 */ "plus_opt ::= PLUS", + /* 255 */ "plus_opt ::=", + /* 256 */ "cmd ::= CREATE trigger_decl BEGIN trigger_cmd_list END", + /* 257 */ "trigger_decl ::= temp TRIGGER nm trigger_time trigger_event ON nm dbnm foreach_clause when_clause", + /* 258 */ "trigger_time ::= BEFORE", + /* 259 */ "trigger_time ::= AFTER", + /* 260 */ "trigger_time ::= INSTEAD OF", + /* 261 */ "trigger_time ::=", + /* 262 */ "trigger_event ::= DELETE", + /* 263 */ "trigger_event ::= INSERT", + /* 264 */ "trigger_event ::= UPDATE", + /* 265 */ "trigger_event ::= UPDATE OF inscollist", + /* 266 */ "foreach_clause ::=", + /* 267 */ "foreach_clause ::= FOR EACH ROW", + /* 268 */ "foreach_clause ::= FOR EACH STATEMENT", + /* 269 */ "when_clause ::=", + /* 270 */ "when_clause ::= WHEN expr", + /* 271 */ "trigger_cmd_list ::= trigger_cmd SEMI trigger_cmd_list", + /* 272 */ "trigger_cmd_list ::=", + /* 273 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", + /* 274 */ "trigger_cmd ::= INSERT orconf INTO nm inscollist_opt VALUES LP itemlist RP", + /* 275 */ "trigger_cmd ::= INSERT orconf INTO nm inscollist_opt select", + /* 276 */ "trigger_cmd ::= DELETE FROM nm where_opt", + /* 277 */ "trigger_cmd ::= select", + /* 278 */ "expr ::= RAISE LP IGNORE RP", + /* 279 */ "expr ::= RAISE LP ROLLBACK COMMA nm RP", + /* 280 */ "expr ::= RAISE LP ABORT COMMA nm RP", + /* 281 */ "expr ::= RAISE LP FAIL COMMA nm RP", + /* 282 */ "cmd ::= DROP TRIGGER nm dbnm", + /* 283 */ "cmd ::= ATTACH database_kw_opt ids AS nm", + /* 284 */ "database_kw_opt ::= DATABASE", + /* 285 */ "database_kw_opt ::=", + /* 286 */ "cmd ::= DETACH database_kw_opt nm",  };  #endif /* NDEBUG */ @@ -4263,135 +4374,145 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){      ** which appear on the RHS of the rule, but which are not used      ** inside the C code.      */ -    case 132: -#line 660 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4269 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 135: +#line 673 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4380 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 152: -#line 514 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4274 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 157: +#line 520 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4385 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 153: -#line 679 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4279 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 158: +#line 692 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4390 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 154: -#line 677 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4284 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 159: +#line 690 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4395 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 156: +    case 161:  #line 341 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteSrcListDelete((yypminor->yy289));} -#line 4289 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -      break; -    case 157: -#line 431 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4294 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -      break; -    case 158: -#line 436 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4299 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteSrcListDelete((yypminor->yy335));} +#line 4400 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      case 162: -#line 701 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy268));} -#line 4304 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 435 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4405 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      case 163: -#line 703 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy268));} -#line 4309 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -      break; -    case 166: -#line 492 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy268));} -#line 4314 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 440 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4410 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      case 167: -#line 490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy268));} -#line 4319 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 715 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy92));} +#line 4415 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 169: -#line 484 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4324 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 168: +#line 717 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy92));} +#line 4420 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 179: -#line 392 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4329 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 171: +#line 498 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy92));} +#line 4425 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 181: -#line 276 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteSelectDelete((yypminor->yy207));} -#line 4334 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 172: +#line 496 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy92));} +#line 4430 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      break; +    case 174: +#line 490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4435 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      case 183: -#line 403 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4339 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 396 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4440 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      break; +    case 185: +#line 276 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteSelectDelete((yypminor->yy11));} +#line 4445 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 190: +    case 187: +#line 407 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4450 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      break; +    case 194:  #line 312 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4344 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteExprListDelete((yypminor->yy62));} +#line 4455 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 191: +    case 195:  #line 310 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4349 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteExprListDelete((yypminor->yy62));} +#line 4460 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 192: +    case 196:  #line 274 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteSelectDelete((yypminor->yy207));} -#line 4354 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteSelectDelete((yypminor->yy11));} +#line 4465 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 193: +    case 197:  #line 337 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteSrcListDelete((yypminor->yy289));} -#line 4359 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteSrcListDelete((yypminor->yy335));} +#line 4470 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 194: -#line 460 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4364 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 198: +#line 465 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4475 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 196: -#line 407 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4369 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 200: +#line 411 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4480 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 197: -#line 405 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprListDelete((yypminor->yy168));} -#line 4374 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 201: +#line 409 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprListDelete((yypminor->yy62));} +#line 4485 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 199: +    case 203:  #line 339 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteSrcListDelete((yypminor->yy289));} -#line 4379 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteSrcListDelete((yypminor->yy335));} +#line 4490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      break; +    case 207: +#line 807 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteDeleteTriggerStep((yypminor->yy347));} +#line 4495 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 205: -#line 762 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy72).b);} -#line 4384 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 208: +#line 799 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteDeleteTriggerStep((yypminor->yy347));} +#line 4500 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      case 210: -#line 397 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteIdListDelete((yypminor->yy268));} -#line 4389 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 783 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy234).b);} +#line 4505 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break; -    case 212: -#line 454 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteExprDelete((yypminor->yy272));} -#line 4394 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +    case 215: +#line 401 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteIdListDelete((yypminor->yy92));} +#line 4510 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      break; +    case 217: +#line 459 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteExprDelete((yypminor->yy334));} +#line 4515 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"        break;      default:  break;   /* If no destructor action specified: do nothing */    } @@ -4537,286 +4658,293 @@ static 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[] = { -  { 165, 1 }, -  { 136, 1 }, -  { 136, 2 }, -  { 149, 3 }, -  { 149, 1 }, -  { 137, 1 }, -  { 151, 1 }, -  { 151, 0 }, -  { 135, 3 }, -  { 202, 0 }, -  { 202, 1 }, -  { 202, 2 }, -  { 135, 2 }, -  { 135, 2 }, -  { 135, 2 }, -  { 135, 2 }, -  { 144, 4 }, -  { 201, 1 }, -  { 201, 0 }, -  { 145, 4 }, -  { 145, 2 }, -  { 141, 3 }, -  { 141, 1 }, -  { 139, 3 }, +  { 170, 1 }, +  { 139, 1 }, +  { 139, 2 }, +  { 154, 3 }, +  { 154, 1 },    { 140, 1 }, -  { 159, 1 }, -  { 160, 1 }, -  { 160, 1 }, -  { 177, 1 }, -  { 177, 1 }, -  { 177, 1 }, -  { 207, 0 }, -  { 207, 1 }, -  { 207, 4 }, -  { 207, 6 }, -  { 208, 1 }, -  { 208, 2 }, -  { 195, 1 }, -  { 195, 2 }, -  { 195, 2 }, -  { 130, 2 }, -  { 130, 0 }, -  { 129, 3 }, -  { 129, 1 }, -  { 129, 2 }, -  { 129, 2 }, -  { 129, 2 }, -  { 129, 3 }, -  { 129, 3 }, -  { 129, 2 }, -  { 129, 3 }, -  { 129, 3 }, -  { 129, 2 }, -  { 134, 2 }, -  { 134, 3 }, -  { 134, 4 }, -  { 134, 2 }, -  { 134, 5 }, -  { 134, 4 }, -  { 134, 1 }, -  { 134, 2 }, -  { 188, 0 }, -  { 188, 2 }, -  { 187, 2 }, -  { 187, 3 }, -  { 187, 3 }, -  { 187, 3 }, -  { 186, 2 }, -  { 186, 2 }, -  { 186, 1 }, -  { 186, 1 }, -  { 146, 3 }, -  { 146, 2 }, -  { 164, 0 }, -  { 164, 2 }, -  { 164, 2 }, -  { 143, 0 }, -  { 143, 2 }, -  { 142, 3 }, -  { 142, 2 }, -  { 142, 1 }, -  { 200, 2 }, -  { 200, 6 }, -  { 200, 5 }, -  { 200, 3 }, -  { 200, 10 }, -  { 147, 0 }, -  { 147, 1 }, -  { 180, 0 }, -  { 180, 3 }, -  { 182, 0 }, -  { 182, 2 }, -  { 189, 1 }, -  { 189, 1 }, -  { 189, 1 }, -  { 189, 1 }, -  { 189, 1 }, -  { 135, 3 }, -  { 135, 6 }, -  { 135, 3 }, -  { 135, 1 }, -  { 192, 1 }, -  { 192, 3 }, -  { 176, 1 }, -  { 176, 2 }, -  { 176, 1 }, -  { 176, 1 }, -  { 181, 9 }, -  { 148, 1 }, -  { 148, 1 }, -  { 148, 0 }, -  { 190, 2 }, -  { 190, 0 }, -  { 191, 3 }, -  { 191, 2 }, -  { 191, 4 }, -  { 128, 2 }, -  { 128, 1 }, -  { 128, 0 }, +  { 156, 1 },    { 156, 0 }, -  { 156, 2 }, -  { 199, 2 }, -  { 199, 0 }, -  { 193, 5 }, -  { 193, 7 }, -  { 170, 1 }, -  { 170, 1 }, -  { 170, 2 }, -  { 170, 3 }, -  { 170, 4 }, -  { 179, 2 }, -  { 179, 0 }, -  { 210, 4 }, -  { 210, 0 }, -  { 183, 0 }, -  { 183, 3 }, -  { 197, 5 }, -  { 197, 3 }, -  { 196, 1 }, -  { 198, 1 }, -  { 198, 1 }, -  { 198, 0 }, -  { 138, 0 }, +  { 138, 3 }, +  { 206, 0 }, +  { 206, 1 }, +  { 206, 2 },    { 138, 2 }, -  { 157, 0 }, -  { 157, 3 }, -  { 158, 0 }, -  { 158, 2 }, -  { 173, 0 }, -  { 173, 2 }, -  { 173, 4 }, -  { 174, 1 }, -  { 174, 1 }, -  { 135, 4 }, +  { 138, 2 }, +  { 138, 2 }, +  { 138, 2 }, +  { 147, 4 }, +  { 205, 1 }, +  { 205, 0 }, +  { 148, 4 }, +  { 148, 2 }, +  { 144, 3 }, +  { 144, 1 }, +  { 142, 3 }, +  { 143, 1 }, +  { 164, 1 }, +  { 165, 1 }, +  { 165, 1 }, +  { 181, 1 }, +  { 181, 1 }, +  { 181, 1 },    { 212, 0 }, -  { 212, 2 }, -  { 135, 6 }, -  { 194, 5 }, -  { 194, 3 }, -  { 135, 8 }, -  { 135, 5 }, -  { 168, 2 }, -  { 168, 1 }, -  { 169, 3 }, -  { 169, 1 }, -  { 167, 0 }, -  { 167, 3 }, -  { 166, 3 }, -  { 166, 1 }, -  { 152, 3 }, -  { 152, 1 }, -  { 152, 1 }, -  { 152, 1 }, -  { 152, 3 }, -  { 152, 2 }, -  { 152, 1 }, -  { 152, 1 }, -  { 152, 1 }, -  { 152, 4 }, -  { 152, 4 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 4 }, -  { 172, 1 }, -  { 172, 1 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 3 }, -  { 152, 2 }, -  { 152, 3 }, -  { 152, 2 }, -  { 152, 3 }, -  { 152, 4 }, -  { 152, 2 }, -  { 152, 2 }, -  { 152, 2 }, -  { 152, 2 }, -  { 152, 3 }, -  { 152, 5 }, -  { 152, 6 }, -  { 152, 5 }, -  { 152, 5 }, -  { 152, 6 }, -  { 152, 6 }, -  { 152, 5 }, -  { 132, 5 }, -  { 132, 4 }, -  { 131, 2 }, -  { 131, 0 }, -  { 133, 1 }, +  { 212, 1 }, +  { 212, 4 }, +  { 212, 6 }, +  { 213, 1 }, +  { 213, 2 }, +  { 199, 1 }, +  { 199, 2 }, +  { 199, 2 }, +  { 133, 2 },    { 133, 0 }, -  { 154, 3 }, -  { 154, 1 }, +  { 132, 3 }, +  { 132, 1 }, +  { 132, 2 }, +  { 132, 2 }, +  { 132, 2 }, +  { 132, 3 }, +  { 132, 3 }, +  { 132, 2 }, +  { 132, 3 }, +  { 132, 3 }, +  { 132, 2 }, +  { 137, 2 }, +  { 137, 3 }, +  { 137, 4 }, +  { 137, 2 }, +  { 137, 5 }, +  { 137, 4 }, +  { 137, 1 }, +  { 137, 2 }, +  { 192, 0 }, +  { 192, 2 }, +  { 191, 2 }, +  { 191, 3 }, +  { 191, 3 }, +  { 191, 3 }, +  { 190, 2 }, +  { 190, 2 }, +  { 190, 1 }, +  { 190, 1 }, +  { 151, 3 }, +  { 151, 2 }, +  { 169, 0 }, +  { 169, 2 }, +  { 169, 2 }, +  { 146, 0 }, +  { 146, 2 }, +  { 145, 3 }, +  { 145, 2 }, +  { 145, 1 }, +  { 204, 2 }, +  { 204, 6 }, +  { 204, 5 }, +  { 204, 3 }, +  { 204, 10 }, +  { 152, 0 }, +  { 152, 1 }, +  { 184, 0 }, +  { 184, 3 }, +  { 186, 0 }, +  { 186, 2 }, +  { 193, 1 }, +  { 193, 1 }, +  { 193, 1 }, +  { 193, 1 }, +  { 193, 1 }, +  { 138, 3 }, +  { 138, 6 }, +  { 138, 3 }, +  { 138, 1 }, +  { 196, 1 }, +  { 196, 3 }, +  { 180, 1 }, +  { 180, 2 }, +  { 180, 1 }, +  { 180, 1 }, +  { 185, 9 }, +  { 153, 1 },    { 153, 1 },    { 153, 0 }, -  { 135, 10 }, -  { 209, 1 }, -  { 209, 0 }, -  { 163, 0 }, -  { 163, 3 }, +  { 194, 2 }, +  { 194, 0 }, +  { 195, 3 }, +  { 195, 2 }, +  { 195, 4 }, +  { 131, 2 }, +  { 131, 1 }, +  { 131, 0 }, +  { 161, 0 }, +  { 161, 2 }, +  { 203, 2 }, +  { 203, 0 }, +  { 197, 6 }, +  { 197, 7 }, +  { 150, 0 }, +  { 150, 2 }, +  { 175, 1 }, +  { 175, 1 }, +  { 175, 2 }, +  { 175, 3 }, +  { 175, 4 }, +  { 183, 2 }, +  { 183, 0 }, +  { 215, 4 }, +  { 215, 0 }, +  { 187, 0 }, +  { 187, 3 }, +  { 201, 5 }, +  { 201, 3 }, +  { 200, 1 }, +  { 202, 1 }, +  { 202, 1 }, +  { 202, 0 }, +  { 141, 0 }, +  { 141, 2 }, +  { 162, 0 },    { 162, 3 }, -  { 162, 1 }, -  { 161, 1 }, -  { 135, 3 }, -  { 135, 8 }, +  { 163, 0 }, +  { 163, 2 }, +  { 178, 0 }, +  { 178, 2 }, +  { 178, 4 }, +  { 178, 4 }, +  { 138, 5 }, +  { 217, 0 }, +  { 217, 2 }, +  { 138, 7 }, +  { 198, 5 }, +  { 198, 3 }, +  { 138, 9 }, +  { 138, 6 }, +  { 173, 2 }, +  { 173, 1 }, +  { 174, 3 }, +  { 174, 1 }, +  { 172, 0 }, +  { 172, 3 }, +  { 171, 3 }, +  { 171, 1 }, +  { 157, 3 }, +  { 157, 1 }, +  { 157, 1 }, +  { 157, 1 }, +  { 157, 3 }, +  { 157, 5 }, +  { 157, 2 }, +  { 157, 1 }, +  { 157, 1 }, +  { 157, 1 }, +  { 157, 4 }, +  { 157, 4 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 4 }, +  { 177, 1 }, +  { 177, 1 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 3 }, +  { 157, 2 }, +  { 157, 3 }, +  { 157, 2 }, +  { 157, 3 }, +  { 157, 4 }, +  { 157, 2 }, +  { 157, 2 }, +  { 157, 2 }, +  { 157, 2 }, +  { 157, 3 }, +  { 157, 5 }, +  { 157, 6 }, +  { 157, 5 }, +  { 157, 5 }, +  { 157, 6 }, +  { 157, 6 }, +  { 157, 5 },    { 135, 5 }, -  { 135, 1 }, -  { 135, 2 }, -  { 135, 4 }, -  { 135, 4 },    { 135, 4 }, -  { 135, 4 }, -  { 135, 5 }, -  { 135, 2 }, -  { 184, 2 }, -  { 175, 2 }, -  { 178, 1 }, -  { 178, 1 }, -  { 185, 1 }, -  { 185, 0 }, -  { 135, 12 }, -  { 206, 1 }, -  { 206, 1 }, -  { 206, 2 }, -  { 206, 0 }, -  { 205, 1 }, -  { 205, 1 }, -  { 205, 1 }, -  { 205, 3 }, -  { 155, 0 }, -  { 155, 3 }, -  { 155, 3 }, -  { 211, 0 }, +  { 134, 2 }, +  { 134, 0 }, +  { 136, 1 }, +  { 136, 0 }, +  { 159, 3 }, +  { 159, 1 }, +  { 158, 1 }, +  { 158, 0 }, +  { 138, 12 }, +  { 214, 1 }, +  { 214, 0 }, +  { 168, 0 }, +  { 168, 3 }, +  { 167, 3 }, +  { 167, 1 }, +  { 166, 2 }, +  { 138, 4 }, +  { 138, 9 }, +  { 138, 6 }, +  { 138, 1 }, +  { 138, 2 }, +  { 138, 4 }, +  { 138, 4 }, +  { 138, 4 }, +  { 138, 4 }, +  { 138, 5 }, +  { 138, 2 }, +  { 188, 2 }, +  { 179, 2 }, +  { 182, 1 }, +  { 182, 1 }, +  { 189, 1 }, +  { 189, 0 }, +  { 138, 5 }, +  { 209, 10 }, +  { 211, 1 }, +  { 211, 1 },    { 211, 2 }, -  { 204, 3 }, -  { 204, 0 }, -  { 203, 6 }, -  { 203, 9 }, -  { 203, 6 }, -  { 203, 4 }, -  { 203, 1 }, -  { 152, 4 }, -  { 152, 6 }, -  { 152, 6 }, -  { 152, 6 }, -  { 135, 3 }, +  { 211, 0 }, +  { 210, 1 }, +  { 210, 1 }, +  { 210, 1 }, +  { 210, 3 }, +  { 160, 0 }, +  { 160, 3 }, +  { 160, 3 }, +  { 216, 0 }, +  { 216, 2 }, +  { 208, 3 }, +  { 208, 0 }, +  { 207, 6 }, +  { 207, 9 }, +  { 207, 6 }, +  { 207, 4 }, +  { 207, 1 }, +  { 157, 4 }, +  { 157, 6 }, +  { 157, 6 }, +  { 157, 6 }, +  { 138, 4 }, +  { 138, 5 }, +  { 149, 1 }, +  { 149, 0 }, +  { 138, 3 },  };  static void yy_accept(yyParser*);  /* Forward Declaration */ @@ -4874,24 +5002,24 @@ static void yy_reduce(        case 5:  #line 77 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { sqliteExec(pParse); } -#line 4877 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5005 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for cmd */          break;        case 6:  #line 78 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { sqliteBeginParse(pParse, 1); } -#line 4883 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5011 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for EXPLAIN */          break;        case 7:  #line 79 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { sqliteBeginParse(pParse, 0); } -#line 4889 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5017 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 8:  #line 84 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteBeginTransaction(pParse,yymsp[0].minor.yy136);} -#line 4894 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteBeginTransaction(pParse,yymsp[0].minor.yy52);} +#line 5022 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for BEGIN */          /* No destructor defined for trans_opt */          break; @@ -4907,21 +5035,21 @@ static void yy_reduce(        case 12:  #line 88 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteCommitTransaction(pParse);} -#line 4910 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5038 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COMMIT */          /* No destructor defined for trans_opt */          break;        case 13:  #line 89 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteCommitTransaction(pParse);} -#line 4917 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5045 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for END */          /* No destructor defined for trans_opt */          break;        case 14:  #line 90 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteRollbackTransaction(pParse);} -#line 4924 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5052 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ROLLBACK */          /* No destructor defined for trans_opt */          break; @@ -4932,28 +5060,28 @@ static void yy_reduce(        case 16:  #line 95 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -   sqliteStartTable(pParse,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy324,yymsp[-2].minor.yy136,0); +   sqliteStartTable(pParse,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy210,yymsp[-2].minor.yy52,0);  } -#line 4937 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5065 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for TABLE */          break;        case 17:  #line 99 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = pParse->isTemp || !pParse->initFlag;} -#line 4943 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 1;} +#line 5071 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for TEMP */          break;        case 18:  #line 100 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = pParse->isTemp;} -#line 4949 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5077 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 19:  #line 101 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {    sqliteEndTable(pParse,&yymsp[0].minor.yy0,0);  } -#line 4956 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5084 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for columnlist */          /* No destructor defined for conslist_opt */ @@ -4961,10 +5089,10 @@ static void yy_reduce(        case 20:  #line 104 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  sqliteEndTable(pParse,0,yymsp[0].minor.yy207); -  sqliteSelectDelete(yymsp[0].minor.yy207); +  sqliteEndTable(pParse,0,yymsp[0].minor.yy11); +  sqliteSelectDelete(yymsp[0].minor.yy11);  } -#line 4967 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5095 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for AS */          break;        case 21: @@ -4982,57 +5110,57 @@ static void yy_reduce(          break;        case 24:  #line 116 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddColumn(pParse,&yymsp[0].minor.yy324);} -#line 4986 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddColumn(pParse,&yymsp[0].minor.yy210);} +#line 5114 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 25:  #line 122 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 4991 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5119 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 26:  #line 138 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 4996 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5124 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 27:  #line 139 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 5001 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5129 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 28:  #line 144 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 5006 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5134 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 29:  #line 145 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 5011 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5139 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 30:  #line 146 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 5016 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 5144 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 31:          break;        case 32:  #line 149 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddColumnType(pParse,&yymsp[0].minor.yy324,&yymsp[0].minor.yy324);} -#line 5023 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddColumnType(pParse,&yymsp[0].minor.yy210,&yymsp[0].minor.yy210);} +#line 5151 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 33:  #line 150 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddColumnType(pParse,&yymsp[-3].minor.yy324,&yymsp[0].minor.yy0);} -#line 5028 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddColumnType(pParse,&yymsp[-3].minor.yy210,&yymsp[0].minor.yy0);} +#line 5156 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for signed */          break;        case 34:  #line 152 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddColumnType(pParse,&yymsp[-5].minor.yy324,&yymsp[0].minor.yy0);} -#line 5035 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddColumnType(pParse,&yymsp[-5].minor.yy210,&yymsp[0].minor.yy0);} +#line 5163 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for signed */          /* No destructor defined for COMMA */ @@ -5040,13 +5168,13 @@ static void yy_reduce(          break;        case 35:  #line 154 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy324;} -#line 5044 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[0].minor.yy210;} +#line 5172 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 36:  #line 155 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[-1].minor.yy324;} -#line 5049 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy210 = yymsp[-1].minor.yy210;} +#line 5177 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ids */          break;        case 37: @@ -5077,52 +5205,52 @@ static void yy_reduce(        case 44:  #line 163 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5080 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5208 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          break;        case 45:  #line 164 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5086 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5214 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          break;        case 46:  #line 165 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5092 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5220 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          break;        case 47:  #line 166 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5098 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5226 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          /* No destructor defined for PLUS */          break;        case 48:  #line 167 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,1);} -#line 5105 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5233 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          /* No destructor defined for MINUS */          break;        case 49:  #line 168 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5112 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5240 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          break;        case 50:  #line 169 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,0);} -#line 5118 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5246 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          /* No destructor defined for PLUS */          break;        case 51:  #line 170 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteAddDefaultValue(pParse,&yymsp[0].minor.yy0,1);} -#line 5125 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5253 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFAULT */          /* No destructor defined for MINUS */          break; @@ -5136,144 +5264,144 @@ static void yy_reduce(          break;        case 54:  #line 177 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddNotNull(pParse, yymsp[0].minor.yy136);} -#line 5140 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddNotNull(pParse, yymsp[0].minor.yy52);} +#line 5268 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          /* No destructor defined for NULL */          break;        case 55:  #line 178 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddPrimaryKey(pParse,0,yymsp[0].minor.yy136);} -#line 5147 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddPrimaryKey(pParse,0,yymsp[0].minor.yy52);} +#line 5275 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRIMARY */          /* No destructor defined for KEY */          /* No destructor defined for sortorder */          break;        case 56:  #line 179 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteCreateIndex(pParse,0,0,0,yymsp[0].minor.yy136,0,0);} -#line 5155 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteCreateIndex(pParse,0,0,0,yymsp[0].minor.yy52,0,0,0);} +#line 5283 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UNIQUE */          break;        case 57:          /* No destructor defined for CHECK */          /* No destructor defined for LP */ -  yy_destructor(152,&yymsp[-2].minor); +  yy_destructor(157,&yymsp[-2].minor);          /* No destructor defined for RP */          /* No destructor defined for onconf */          break;        case 58:  #line 182 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteCreateForeignKey(pParse,0,&yymsp[-2].minor.yy324,yymsp[-1].minor.yy268,yymsp[0].minor.yy136);} -#line 5168 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteCreateForeignKey(pParse,0,&yymsp[-2].minor.yy210,yymsp[-1].minor.yy92,yymsp[0].minor.yy52);} +#line 5296 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for REFERENCES */          break;        case 59:  #line 183 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteDeferForeignKey(pParse,yymsp[0].minor.yy136);} -#line 5174 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteDeferForeignKey(pParse,yymsp[0].minor.yy52);} +#line 5302 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 60:  #line 184 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -   sqliteAddCollateType(pParse, sqliteCollateType(yymsp[0].minor.yy324.z, yymsp[0].minor.yy324.n)); +   sqliteAddCollateType(pParse, sqliteCollateType(yymsp[0].minor.yy210.z, yymsp[0].minor.yy210.n));  } -#line 5181 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5309 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COLLATE */          break;        case 61:  #line 194 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Restrict * 0x010101; } -#line 5187 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Restrict * 0x010101; } +#line 5315 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 62:  #line 195 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = (yymsp[-1].minor.yy136 & yymsp[0].minor.yy83.mask) | yymsp[0].minor.yy83.value; } -#line 5192 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = (yymsp[-1].minor.yy52 & yymsp[0].minor.yy279.mask) | yymsp[0].minor.yy279.value; } +#line 5320 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 63:  #line 197 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy83.value = 0;     yygotominor.yy83.mask = 0x000000; } -#line 5197 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy279.value = 0;     yygotominor.yy279.mask = 0x000000; } +#line 5325 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for MATCH */          /* No destructor defined for nm */          break;        case 64:  #line 198 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy83.value = yymsp[0].minor.yy136;     yygotominor.yy83.mask = 0x0000ff; } -#line 5204 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy279.value = yymsp[0].minor.yy52;     yygotominor.yy279.mask = 0x0000ff; } +#line 5332 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ON */          /* No destructor defined for DELETE */          break;        case 65:  #line 199 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy83.value = yymsp[0].minor.yy136<<8;  yygotominor.yy83.mask = 0x00ff00; } -#line 5211 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy279.value = yymsp[0].minor.yy52<<8;  yygotominor.yy279.mask = 0x00ff00; } +#line 5339 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ON */          /* No destructor defined for UPDATE */          break;        case 66:  #line 200 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy83.value = yymsp[0].minor.yy136<<16; yygotominor.yy83.mask = 0xff0000; } -#line 5218 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy279.value = yymsp[0].minor.yy52<<16; yygotominor.yy279.mask = 0xff0000; } +#line 5346 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ON */          /* No destructor defined for INSERT */          break;        case 67:  #line 202 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_SetNull; } -#line 5225 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_SetNull; } +#line 5353 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for SET */          /* No destructor defined for NULL */          break;        case 68:  #line 203 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_SetDflt; } -#line 5232 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_SetDflt; } +#line 5360 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for SET */          /* No destructor defined for DEFAULT */          break;        case 69:  #line 204 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Cascade; } -#line 5239 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Cascade; } +#line 5367 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for CASCADE */          break;        case 70:  #line 205 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Restrict; } -#line 5245 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Restrict; } +#line 5373 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for RESTRICT */          break;        case 71:  #line 207 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = yymsp[0].minor.yy136;} -#line 5251 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = yymsp[0].minor.yy52;} +#line 5379 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          /* No destructor defined for DEFERRABLE */          break;        case 72:  #line 208 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = yymsp[0].minor.yy136;} -#line 5258 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = yymsp[0].minor.yy52;} +#line 5386 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DEFERRABLE */          break;        case 73:  #line 210 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 0;} -#line 5264 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5392 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 74:  #line 211 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 1;} -#line 5269 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 1;} +#line 5397 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INITIALLY */          /* No destructor defined for DEFERRED */          break;        case 75:  #line 212 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 0;} -#line 5276 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5404 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INITIALLY */          /* No destructor defined for IMMEDIATE */          break; @@ -5301,8 +5429,8 @@ static void yy_reduce(          break;        case 82:  #line 224 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteAddPrimaryKey(pParse,yymsp[-2].minor.yy268,yymsp[0].minor.yy136);} -#line 5305 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteAddPrimaryKey(pParse,yymsp[-2].minor.yy92,yymsp[0].minor.yy52);} +#line 5433 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRIMARY */          /* No destructor defined for KEY */          /* No destructor defined for LP */ @@ -5310,24 +5438,24 @@ static void yy_reduce(          break;        case 83:  #line 226 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteCreateIndex(pParse,0,0,yymsp[-2].minor.yy268,yymsp[0].minor.yy136,0,0);} -#line 5314 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteCreateIndex(pParse,0,0,yymsp[-2].minor.yy92,yymsp[0].minor.yy52,0,0,0);} +#line 5442 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UNIQUE */          /* No destructor defined for LP */          /* No destructor defined for RP */          break;        case 84:          /* No destructor defined for CHECK */ -  yy_destructor(152,&yymsp[-1].minor); +  yy_destructor(157,&yymsp[-1].minor);          /* No destructor defined for onconf */          break;        case 85:  #line 229 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -    sqliteCreateForeignKey(pParse, yymsp[-6].minor.yy268, &yymsp[-3].minor.yy324, yymsp[-2].minor.yy268, yymsp[-1].minor.yy136); -    sqliteDeferForeignKey(pParse, yymsp[0].minor.yy136); +    sqliteCreateForeignKey(pParse, yymsp[-6].minor.yy92, &yymsp[-3].minor.yy210, yymsp[-2].minor.yy92, yymsp[-1].minor.yy52); +    sqliteDeferForeignKey(pParse, yymsp[0].minor.yy52);  } -#line 5330 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5458 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for FOREIGN */          /* No destructor defined for KEY */          /* No destructor defined for LP */ @@ -5336,1339 +5464,1405 @@ static void yy_reduce(          break;        case 86:  #line 234 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 0;} -#line 5340 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5468 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 87:  #line 235 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = yymsp[0].minor.yy136;} -#line 5345 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = yymsp[0].minor.yy52;} +#line 5473 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 88:  #line 243 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Default; } -#line 5350 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Default; } +#line 5478 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 89:  #line 244 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = yymsp[0].minor.yy136; } -#line 5355 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = yymsp[0].minor.yy52; } +#line 5483 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ON */          /* No destructor defined for CONFLICT */          break;        case 90:  #line 245 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Default; } -#line 5362 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Default; } +#line 5490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 91:  #line 246 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = yymsp[0].minor.yy136; } -#line 5367 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = yymsp[0].minor.yy52; } +#line 5495 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for OR */          break;        case 92:  #line 247 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Rollback; } -#line 5373 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Rollback; } +#line 5501 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ROLLBACK */          break;        case 93:  #line 248 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Abort; } -#line 5379 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Abort; } +#line 5507 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ABORT */          break;        case 94:  #line 249 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Fail; } -#line 5385 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Fail; } +#line 5513 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for FAIL */          break;        case 95:  #line 250 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Ignore; } -#line 5391 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Ignore; } +#line 5519 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for IGNORE */          break;        case 96:  #line 251 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Replace; } -#line 5397 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy52 = OE_Replace; } +#line 5525 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for REPLACE */          break;        case 97:  #line 255 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteDropTable(pParse,&yymsp[0].minor.yy324,0);} -#line 5403 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{sqliteDropTable(pParse,&yymsp[0].minor.yy210,0);} +#line 5531 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DROP */          /* No destructor defined for TABLE */          break;        case 98:  #line 259 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  sqliteCreateView(pParse, &yymsp[-5].minor.yy0, &yymsp[-2].minor.yy324, yymsp[0].minor.yy207, yymsp[-4].minor.yy136); +  sqliteCreateView(pParse, &yymsp[-5].minor.yy0, &yymsp[-2].minor.yy210, yymsp[0].minor.yy11, yymsp[-4].minor.yy52);  } -#line 5412 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5540 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for VIEW */          /* No destructor defined for AS */          break;        case 99:  #line 262 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  sqliteDropTable(pParse, &yymsp[0].minor.yy324, 1); +  sqliteDropTable(pParse, &yymsp[0].minor.yy210, 1);  } -#line 5421 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5549 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DROP */          /* No destructor defined for VIEW */          break;        case 100:  #line 268 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  sqliteSelect(pParse, yymsp[0].minor.yy207, SRT_Callback, 0, 0, 0, 0); -  sqliteSelectDelete(yymsp[0].minor.yy207); +  sqliteSelect(pParse, yymsp[0].minor.yy11, SRT_Callback, 0, 0, 0, 0); +  sqliteSelectDelete(yymsp[0].minor.yy11);  } -#line 5431 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5559 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 101:  #line 278 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy207 = yymsp[0].minor.yy207;} -#line 5436 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy11 = yymsp[0].minor.yy11;} +#line 5564 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 102:  #line 279 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  if( yymsp[0].minor.yy207 ){ -    yymsp[0].minor.yy207->op = yymsp[-1].minor.yy136; -    yymsp[0].minor.yy207->pPrior = yymsp[-2].minor.yy207; +  if( yymsp[0].minor.yy11 ){ +    yymsp[0].minor.yy11->op = yymsp[-1].minor.yy52; +    yymsp[0].minor.yy11->pPrior = yymsp[-2].minor.yy11;    } -  yygotominor.yy207 = yymsp[0].minor.yy207; +  yygotominor.yy11 = yymsp[0].minor.yy11;  } -#line 5447 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5575 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 103:  #line 287 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_UNION;} -#line 5452 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = TK_UNION;} +#line 5580 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UNION */          break;        case 104:  #line 288 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_ALL;} -#line 5458 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = TK_ALL;} +#line 5586 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UNION */          /* No destructor defined for ALL */          break;        case 105:  #line 289 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_INTERSECT;} -#line 5465 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = TK_INTERSECT;} +#line 5593 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INTERSECT */          break;        case 106:  #line 290 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_EXCEPT;} -#line 5471 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = TK_EXCEPT;} +#line 5599 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for EXCEPT */          break;        case 107:  #line 292 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy207 = sqliteSelectNew(yymsp[-6].minor.yy168,yymsp[-5].minor.yy289,yymsp[-4].minor.yy272,yymsp[-3].minor.yy168,yymsp[-2].minor.yy272,yymsp[-1].minor.yy168,yymsp[-7].minor.yy136,yymsp[0].minor.yy336.limit,yymsp[0].minor.yy336.offset); +  yygotominor.yy11 = sqliteSelectNew(yymsp[-6].minor.yy62,yymsp[-5].minor.yy335,yymsp[-4].minor.yy334,yymsp[-3].minor.yy62,yymsp[-2].minor.yy334,yymsp[-1].minor.yy62,yymsp[-7].minor.yy52,yymsp[0].minor.yy280.limit,yymsp[0].minor.yy280.offset);  } -#line 5479 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5607 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for SELECT */          break;        case 108:  #line 300 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 1;} -#line 5485 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 1;} +#line 5613 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DISTINCT */          break;        case 109:  #line 301 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 0;} -#line 5491 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5619 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ALL */          break;        case 110:  #line 302 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = 0;} -#line 5497 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy52 = 0;} +#line 5625 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 111:  #line 313 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = yymsp[-1].minor.yy168;} -#line 5502 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy62 = yymsp[-1].minor.yy62;} +#line 5630 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COMMA */          break;        case 112:  #line 314 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = 0;} -#line 5508 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy62 = 0;} +#line 5636 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 113:  #line 315 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -   yygotominor.yy168 = sqliteExprListAppend(yymsp[-2].minor.yy168,yymsp[-1].minor.yy272,yymsp[0].minor.yy324.n?&yymsp[0].minor.yy324:0); +   yygotominor.yy62 = sqliteExprListAppend(yymsp[-2].minor.yy62,yymsp[-1].minor.yy334,yymsp[0].minor.yy210.n?&yymsp[0].minor.yy210:0);  } -#line 5515 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5643 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 114:  #line 318 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy168 = sqliteExprListAppend(yymsp[-1].minor.yy168, sqliteExpr(TK_ALL, 0, 0, 0), 0); +  yygotominor.yy62 = sqliteExprListAppend(yymsp[-1].minor.yy62, sqliteExpr(TK_ALL, 0, 0, 0), 0);  } -#line 5522 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5650 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for STAR */          break;        case 115:  #line 321 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {    Expr *pRight = sqliteExpr(TK_ALL, 0, 0, 0); -  Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy324); -  yygotominor.yy168 = sqliteExprListAppend(yymsp[-3].minor.yy168, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0); +  Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy210); +  yygotominor.yy62 = sqliteExprListAppend(yymsp[-3].minor.yy62, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0);  } -#line 5532 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5660 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DOT */          /* No destructor defined for STAR */          break;        case 116:  #line 331 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy324 = yymsp[0].minor.yy324; } -#line 5539 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy210 = yymsp[0].minor.yy210; } +#line 5667 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for AS */          break;        case 117:  #line 332 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy324 = yymsp[0].minor.yy324; } -#line 5545 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy210 = yymsp[0].minor.yy210; } +#line 5673 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 118:  #line 333 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy324.n = 0; } -#line 5550 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{ yygotominor.yy210.n = 0; } +#line 5678 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 119:  #line 345 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy289 = sqliteMalloc(sizeof(*yygotominor.yy289));} -#line 5555 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy335 = sqliteMalloc(sizeof(*yygotominor.yy335));} +#line 5683 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 120:  #line 346 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy289 = yymsp[0].minor.yy289;} -#line 5560 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy335 = yymsp[0].minor.yy335;} +#line 5688 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for FROM */          break;        case 121:  #line 351 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -   yygotominor.yy289 = yymsp[-1].minor.yy289; -   if( yygotominor.yy289 && yygotominor.yy289->nSrc>0 ) yygotominor.yy289->a[yygotominor.yy289->nSrc-1].jointype = yymsp[0].minor.yy136; +   yygotominor.yy335 = yymsp[-1].minor.yy335; +   if( yygotominor.yy335 && yygotominor.yy335->nSrc>0 ) yygotominor.yy335->a[yygotominor.yy335->nSrc-1].jointype = yymsp[0].minor.yy52;  } -#line 5569 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5697 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 122:  #line 355 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy289 = 0;} -#line 5574 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy335 = 0;} +#line 5702 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 123:  #line 356 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy289 = sqliteSrcListAppend(yymsp[-4].minor.yy289,&yymsp[-3].minor.yy324); -  if( yymsp[-2].minor.yy324.n ) sqliteSrcListAddAlias(yygotominor.yy289,&yymsp[-2].minor.yy324); -  if( yymsp[-1].minor.yy272 ){ -    if( yygotominor.yy289 && yygotominor.yy289->nSrc>1 ){ yygotominor.yy289->a[yygotominor.yy289->nSrc-2].pOn = yymsp[-1].minor.yy272; } -    else { sqliteExprDelete(yymsp[-1].minor.yy272); } +  yygotominor.yy335 = sqliteSrcListAppend(yymsp[-5].minor.yy335,&yymsp[-4].minor.yy210,&yymsp[-3].minor.yy210); +  if( yymsp[-2].minor.yy210.n ) sqliteSrcListAddAlias(yygotominor.yy335,&yymsp[-2].minor.yy210); +  if( yymsp[-1].minor.yy334 ){ +    if( yygotominor.yy335 && yygotominor.yy335->nSrc>1 ){ yygotominor.yy335->a[yygotominor.yy335->nSrc-2].pOn = yymsp[-1].minor.yy334; } +    else { sqliteExprDelete(yymsp[-1].minor.yy334); }    } -  if( yymsp[0].minor.yy268 ){ -    if( yygotominor.yy289 && yygotominor.yy289->nSrc>1 ){ yygotominor.yy289->a[yygotominor.yy289->nSrc-2].pUsing = yymsp[0].minor.yy268; } -    else { sqliteIdListDelete(yymsp[0].minor.yy268); } +  if( yymsp[0].minor.yy92 ){ +    if( yygotominor.yy335 && yygotominor.yy335->nSrc>1 ){ yygotominor.yy335->a[yygotominor.yy335->nSrc-2].pUsing = yymsp[0].minor.yy92; } +    else { sqliteIdListDelete(yymsp[0].minor.yy92); }    }  } -#line 5590 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5718 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 124:  #line 368 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy289 = sqliteSrcListAppend(yymsp[-6].minor.yy289,0); -  yygotominor.yy289->a[yygotominor.yy289->nSrc-1].pSelect = yymsp[-4].minor.yy207; -  if( yymsp[-2].minor.yy324.n ) sqliteSrcListAddAlias(yygotominor.yy289,&yymsp[-2].minor.yy324); -  if( yymsp[-1].minor.yy272 ){ -    if( yygotominor.yy289 && yygotominor.yy289->nSrc>1 ){ yygotominor.yy289->a[yygotominor.yy289->nSrc-2].pOn = yymsp[-1].minor.yy272; } -    else { sqliteExprDelete(yymsp[-1].minor.yy272); } +  yygotominor.yy335 = sqliteSrcListAppend(yymsp[-6].minor.yy335,0,0); +  yygotominor.yy335->a[yygotominor.yy335->nSrc-1].pSelect = yymsp[-4].minor.yy11; +  if( yymsp[-2].minor.yy210.n ) sqliteSrcListAddAlias(yygotominor.yy335,&yymsp[-2].minor.yy210); +  if( yymsp[-1].minor.yy334 ){ +    if( yygotominor.yy335 && yygotominor.yy335->nSrc>1 ){ yygotominor.yy335->a[yygotominor.yy335->nSrc-2].pOn = yymsp[-1].minor.yy334; } +    else { sqliteExprDelete(yymsp[-1].minor.yy334); }    } -  if( yymsp[0].minor.yy268 ){ -    if( yygotominor.yy289 && yygotominor.yy289->nSrc>1 ){ yygotominor.yy289->a[yygotominor.yy289->nSrc-2].pUsing = yymsp[0].minor.yy268; } -    else { sqliteIdListDelete(yymsp[0].minor.yy268); } +  if( yymsp[0].minor.yy92 ){ +    if( yygotominor.yy335 && yygotominor.yy335->nSrc>1 ){ yygotominor.yy335->a[yygotominor.yy335->nSrc-2].pUsing = yymsp[0].minor.yy92; } +    else { sqliteIdListDelete(yymsp[0].minor.yy92); }    }  } -#line 5607 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5735 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for RP */          break;        case 125: -#line 384 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = JT_INNER; } -#line 5614 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ +#line 383 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210.z=0; yygotominor.yy210.n=0;} +#line 5742 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 126: -#line 385 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = JT_INNER; } -#line 5620 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for JOIN */ +#line 384 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[0].minor.yy210;} +#line 5747 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DOT */          break;        case 127: -#line 386 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = sqliteJoinType(pParse,&yymsp[-1].minor.yy0,0,0); } -#line 5626 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for JOIN */ +#line 388 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = JT_INNER; } +#line 5753 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          break;        case 128: -#line 387 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = sqliteJoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy324,0); } -#line 5632 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 389 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = JT_INNER; } +#line 5759 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for JOIN */          break;        case 129: -#line 389 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = sqliteJoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy324,&yymsp[-1].minor.yy324); } -#line 5638 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 390 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = sqliteJoinType(pParse,&yymsp[-1].minor.yy0,0,0); } +#line 5765 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for JOIN */          break;        case 130: -#line 393 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 5644 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for ON */ +#line 391 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = sqliteJoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy210,0); } +#line 5771 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for JOIN */          break;        case 131: -#line 394 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 5650 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 393 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = sqliteJoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy210,&yymsp[-1].minor.yy210); } +#line 5777 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for JOIN */          break;        case 132: +#line 397 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 5783 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for ON */ +        break; +      case 133:  #line 398 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = yymsp[-1].minor.yy268;} -#line 5655 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy334 = 0;} +#line 5789 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 134: +#line 402 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = yymsp[-1].minor.yy92;} +#line 5794 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for USING */          /* No destructor defined for LP */          /* No destructor defined for RP */          break; -      case 133: -#line 399 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = 0;} -#line 5663 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 135: +#line 403 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = 0;} +#line 5802 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 134: -#line 409 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = 0;} -#line 5668 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 136: +#line 413 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = 0;} +#line 5807 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 135: -#line 410 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = yymsp[0].minor.yy168;} -#line 5673 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 137: +#line 414 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = yymsp[0].minor.yy62;} +#line 5812 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for ORDER */          /* No destructor defined for BY */          break; -      case 136: -#line 411 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 138: +#line 415 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy168 = sqliteExprListAppend(yymsp[-4].minor.yy168,yymsp[-2].minor.yy272,0); -  if( yygotominor.yy168 ) yygotominor.yy168->a[yygotominor.yy168->nExpr-1].sortOrder = yymsp[-1].minor.yy136+yymsp[0].minor.yy136; +  yygotominor.yy62 = sqliteExprListAppend(yymsp[-4].minor.yy62,yymsp[-2].minor.yy334,0); +  if( yygotominor.yy62 ) yygotominor.yy62->a[yygotominor.yy62->nExpr-1].sortOrder = yymsp[-1].minor.yy52+yymsp[0].minor.yy52;  } -#line 5683 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 5822 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COMMA */          break; -      case 137: -#line 415 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 139: +#line 419 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy168 = sqliteExprListAppend(0,yymsp[-2].minor.yy272,0); -  if( yygotominor.yy168 ) yygotominor.yy168->a[0].sortOrder = yymsp[-1].minor.yy136+yymsp[0].minor.yy136; +  yygotominor.yy62 = sqliteExprListAppend(0,yymsp[-2].minor.yy334,0); +  if( yygotominor.yy62 ) yygotominor.yy62->a[0].sortOrder = yymsp[-1].minor.yy52+yymsp[0].minor.yy52;  } -#line 5692 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        break; -      case 138: -#line 419 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 5697 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        break; -      case 139: -#line 424 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = SQLITE_SO_ASC;} -#line 5702 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for ASC */ +#line 5831 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 140: -#line 425 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = SQLITE_SO_DESC;} -#line 5708 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for DESC */ +#line 423 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 5836 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 141: -#line 426 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = SQLITE_SO_ASC;} -#line 5714 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 428 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = SQLITE_SO_ASC;} +#line 5841 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for ASC */          break;        case 142: -#line 427 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = SQLITE_SO_UNK;} -#line 5719 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 429 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = SQLITE_SO_DESC;} +#line 5847 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DESC */          break;        case 143: -#line 428 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = sqliteCollateType(yymsp[0].minor.yy324.z, yymsp[0].minor.yy324.n);} -#line 5724 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COLLATE */ +#line 430 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = SQLITE_SO_ASC;} +#line 5853 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 144: -#line 432 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = 0;} -#line 5730 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 431 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = SQLITE_SO_UNK;} +#line 5858 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 145: -#line 433 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = yymsp[0].minor.yy168;} -#line 5735 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for GROUP */ -        /* No destructor defined for BY */ +#line 432 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = sqliteCollateType(yymsp[0].minor.yy210.z, yymsp[0].minor.yy210.n);} +#line 5863 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COLLATE */          break;        case 146: -#line 437 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 5742 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 436 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = 0;} +#line 5869 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 147: -#line 438 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 5747 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for HAVING */ +#line 437 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = yymsp[0].minor.yy62;} +#line 5874 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for GROUP */ +        /* No destructor defined for BY */          break;        case 148:  #line 441 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy336.limit = -1; yygotominor.yy336.offset = 0;} -#line 5753 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy334 = 0;} +#line 5881 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 149:  #line 442 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy336.limit = atoi(yymsp[0].minor.yy0.z); yygotominor.yy336.offset = 0;} -#line 5758 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for LIMIT */ +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 5886 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for HAVING */          break;        case 150: -#line 444 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy336.limit = atoi(yymsp[-2].minor.yy0.z); yygotominor.yy336.offset = atoi(yymsp[0].minor.yy0.z);} -#line 5764 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for LIMIT */ -        /* No destructor defined for limit_sep */ +#line 445 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy280.limit = -1; yygotominor.yy280.offset = 0;} +#line 5892 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 151: -        /* No destructor defined for OFFSET */ +#line 446 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy280.limit = atoi(yymsp[0].minor.yy0.z); yygotominor.yy280.offset = 0;} +#line 5897 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for LIMIT */          break;        case 152: -        /* No destructor defined for COMMA */ +#line 448 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy280.limit = atoi(yymsp[-2].minor.yy0.z); yygotominor.yy280.offset = atoi(yymsp[0].minor.yy0.z);} +#line 5903 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for LIMIT */ +        /* No destructor defined for OFFSET */          break;        case 153: -#line 451 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteDeleteFrom(pParse, &yymsp[-1].minor.yy324, yymsp[0].minor.yy272);} -#line 5777 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for DELETE */ -        /* No destructor defined for FROM */ +#line 450 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy280.limit = atoi(yymsp[0].minor.yy0.z); yygotominor.yy280.offset = atoi(yymsp[-2].minor.yy0.z);} +#line 5910 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for LIMIT */ +        /* No destructor defined for COMMA */          break;        case 154: -#line 456 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 5784 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 454 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +   sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&yymsp[-2].minor.yy210,&yymsp[-1].minor.yy210), yymsp[0].minor.yy334); +} +#line 5919 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DELETE */ +        /* No destructor defined for FROM */          break;        case 155: -#line 457 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 5789 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for WHERE */ +#line 461 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = 0;} +#line 5926 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 156: -#line 465 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteUpdate(pParse,&yymsp[-3].minor.yy324,yymsp[-1].minor.yy168,yymsp[0].minor.yy272,yymsp[-4].minor.yy136);} -#line 5795 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for UPDATE */ -        /* No destructor defined for SET */ +#line 462 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 5931 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for WHERE */          break;        case 157: -#line 468 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(yymsp[-4].minor.yy168,yymsp[0].minor.yy272,&yymsp[-2].minor.yy324);} -#line 5802 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ -        /* No destructor defined for EQ */ +#line 470 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteUpdate(pParse,sqliteSrcListAppend(0,&yymsp[-4].minor.yy210,&yymsp[-3].minor.yy210),yymsp[-1].minor.yy62,yymsp[0].minor.yy334,yymsp[-5].minor.yy52);} +#line 5937 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for UPDATE */ +        /* No destructor defined for SET */          break;        case 158: -#line 469 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(0,yymsp[0].minor.yy272,&yymsp[-2].minor.yy324);} -#line 5809 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 473 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = sqliteExprListAppend(yymsp[-4].minor.yy62,yymsp[0].minor.yy334,&yymsp[-2].minor.yy210);} +#line 5944 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          /* No destructor defined for EQ */          break;        case 159:  #line 474 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteInsert(pParse, &yymsp[-5].minor.yy324, yymsp[-1].minor.yy168, 0, yymsp[-4].minor.yy268, yymsp[-7].minor.yy136);} -#line 5815 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +{yygotominor.yy62 = sqliteExprListAppend(0,yymsp[0].minor.yy334,&yymsp[-2].minor.yy210);} +#line 5951 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for EQ */ +        break; +      case 160: +#line 480 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteInsert(pParse, sqliteSrcListAppend(0,&yymsp[-6].minor.yy210,&yymsp[-5].minor.yy210), yymsp[-1].minor.yy62, 0, yymsp[-4].minor.yy92, yymsp[-8].minor.yy52);} +#line 5957 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INTO */          /* No destructor defined for VALUES */          /* No destructor defined for LP */          /* No destructor defined for RP */          break; -      case 160: -#line 476 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteInsert(pParse, &yymsp[-2].minor.yy324, 0, yymsp[0].minor.yy207, yymsp[-1].minor.yy268, yymsp[-4].minor.yy136);} -#line 5824 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for INTO */ -        break;        case 161: -#line 479 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = yymsp[0].minor.yy136;} -#line 5830 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for INSERT */ +#line 482 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteInsert(pParse, sqliteSrcListAppend(0,&yymsp[-3].minor.yy210,&yymsp[-2].minor.yy210), 0, yymsp[0].minor.yy11, yymsp[-1].minor.yy92, yymsp[-5].minor.yy52);} +#line 5966 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for INTO */          break;        case 162: -#line 480 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = OE_Replace;} -#line 5836 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for REPLACE */ +#line 485 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = yymsp[0].minor.yy52;} +#line 5972 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for INSERT */          break;        case 163:  #line 486 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(yymsp[-2].minor.yy168,yymsp[0].minor.yy272,0);} -#line 5842 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ +{yygotominor.yy52 = OE_Replace;} +#line 5978 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for REPLACE */          break;        case 164: -#line 487 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(0,yymsp[0].minor.yy272,0);} -#line 5848 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 492 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = sqliteExprListAppend(yymsp[-2].minor.yy62,yymsp[0].minor.yy334,0);} +#line 5984 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          break;        case 165: -#line 494 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = 0;} -#line 5853 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 493 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = sqliteExprListAppend(0,yymsp[0].minor.yy334,0);} +#line 5990 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 166: -#line 495 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = yymsp[-1].minor.yy268;} -#line 5858 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for LP */ -        /* No destructor defined for RP */ +#line 500 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = 0;} +#line 5995 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 167: -#line 496 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = sqliteIdListAppend(yymsp[-2].minor.yy268,&yymsp[0].minor.yy324);} -#line 5865 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ +#line 501 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = yymsp[-1].minor.yy92;} +#line 6000 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for LP */ +        /* No destructor defined for RP */          break;        case 168: -#line 497 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = sqliteIdListAppend(0,&yymsp[0].minor.yy324);} -#line 5871 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 502 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = sqliteIdListAppend(yymsp[-2].minor.yy92,&yymsp[0].minor.yy210);} +#line 6007 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          break;        case 169: -#line 516 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[-1].minor.yy272; sqliteExprSpan(yygotominor.yy272,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } -#line 5876 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 503 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = sqliteIdListAppend(0,&yymsp[0].minor.yy210);} +#line 6013 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 170: -#line 517 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_NULL, 0, 0, &yymsp[0].minor.yy0);} -#line 5881 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 522 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[-1].minor.yy334; sqliteExprSpan(yygotominor.yy334,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } +#line 6018 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 171: -#line 518 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} -#line 5886 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 523 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_NULL, 0, 0, &yymsp[0].minor.yy0);} +#line 6023 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 172: -#line 519 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} -#line 5891 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 524 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} +#line 6028 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 173: -#line 520 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ -  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy324); -  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy324); -  yygotominor.yy272 = sqliteExpr(TK_DOT, temp1, temp2, 0); -} -#line 5900 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for DOT */ +#line 525 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} +#line 6033 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 174:  #line 526 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[-1].minor.yy272; ExprSetProperty(yygotominor.yy272,EP_Oracle8Join);} -#line 5906 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for ORACLE_OUTER_JOIN */ +{ +  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy210); +  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy210); +  yygotominor.yy334 = sqliteExpr(TK_DOT, temp1, temp2, 0); +} +#line 6042 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DOT */          break;        case 175: -#line 527 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_INTEGER, 0, 0, &yymsp[0].minor.yy0);} -#line 5912 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 531 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &yymsp[-4].minor.yy210); +  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &yymsp[-2].minor.yy210); +  Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &yymsp[0].minor.yy210); +  Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0); +  yygotominor.yy334 = sqliteExpr(TK_DOT, temp1, temp4, 0); +} +#line 6054 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DOT */ +        /* No destructor defined for DOT */          break;        case 176: -#line 528 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_FLOAT, 0, 0, &yymsp[0].minor.yy0);} -#line 5917 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 539 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[-1].minor.yy334; ExprSetProperty(yygotominor.yy334,EP_Oracle8Join);} +#line 6061 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for ORACLE_OUTER_JOIN */          break;        case 177: -#line 529 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_STRING, 0, 0, &yymsp[0].minor.yy0);} -#line 5922 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 540 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_INTEGER, 0, 0, &yymsp[0].minor.yy0);} +#line 6067 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 178: -#line 530 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +#line 541 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_FLOAT, 0, 0, &yymsp[0].minor.yy0);} +#line 6072 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 179: +#line 542 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_STRING, 0, 0, &yymsp[0].minor.yy0);} +#line 6077 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 180: +#line 543 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExprFunction(yymsp[-1].minor.yy168, &yymsp[-3].minor.yy0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExprFunction(yymsp[-1].minor.yy62, &yymsp[-3].minor.yy0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);  } -#line 5930 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6085 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          break; -      case 179: -#line 534 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 181: +#line 547 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExprFunction(0, &yymsp[-3].minor.yy0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExprFunction(0, &yymsp[-3].minor.yy0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);  } -#line 5939 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6094 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for STAR */          break; -      case 180: -#line 538 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_AND, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5946 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 182: +#line 551 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_AND, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6101 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for AND */          break; -      case 181: -#line 539 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_OR, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5952 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 183: +#line 552 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_OR, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6107 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for OR */          break; -      case 182: -#line 540 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_LT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5958 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 184: +#line 553 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_LT, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6113 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LT */          break; -      case 183: -#line 541 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_GT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5964 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 185: +#line 554 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_GT, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6119 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for GT */          break; -      case 184: -#line 542 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_LE, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5970 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 186: +#line 555 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_LE, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6125 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LE */          break; -      case 185: -#line 543 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_GE, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5976 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 187: +#line 556 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_GE, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6131 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for GE */          break; -      case 186: -#line 544 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_NE, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5982 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 188: +#line 557 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_NE, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6137 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NE */          break; -      case 187: -#line 545 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_EQ, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5988 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 189: +#line 558 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_EQ, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6143 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for EQ */          break; -      case 188: -#line 546 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_BITAND, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 5994 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 190: +#line 559 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_BITAND, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6149 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for BITAND */          break; -      case 189: -#line 547 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_BITOR, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6000 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 191: +#line 560 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_BITOR, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6155 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for BITOR */          break; -      case 190: -#line 548 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_LSHIFT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6006 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 192: +#line 561 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_LSHIFT, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6161 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LSHIFT */          break; -      case 191: -#line 549 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_RSHIFT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6012 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 193: +#line 562 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_RSHIFT, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6167 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for RSHIFT */          break; -      case 192: -#line 550 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 194: +#line 563 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy272, 0); -  pList = sqliteExprListAppend(pList, yymsp[-2].minor.yy272, 0); -  yygotominor.yy272 = sqliteExprFunction(pList, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->op = yymsp[-1].minor.yy136; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-2].minor.yy272->span, &yymsp[0].minor.yy272->span); +  ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy334, 0); +  pList = sqliteExprListAppend(pList, yymsp[-2].minor.yy334, 0); +  yygotominor.yy334 = sqliteExprFunction(pList, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->op = yymsp[-1].minor.yy52; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-2].minor.yy334->span, &yymsp[0].minor.yy334->span);  } -#line 6024 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6179 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 193: -#line 557 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 195: +#line 570 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy272, 0); -  pList = sqliteExprListAppend(pList, yymsp[-3].minor.yy272, 0); -  yygotominor.yy272 = sqliteExprFunction(pList, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->op = yymsp[-1].minor.yy136; -  yygotominor.yy272 = sqliteExpr(TK_NOT, yygotominor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-3].minor.yy272->span,&yymsp[0].minor.yy272->span); +  ExprList *pList = sqliteExprListAppend(0, yymsp[0].minor.yy334, 0); +  pList = sqliteExprListAppend(pList, yymsp[-3].minor.yy334, 0); +  yygotominor.yy334 = sqliteExprFunction(pList, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->op = yymsp[-1].minor.yy52; +  yygotominor.yy334 = sqliteExpr(TK_NOT, yygotominor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-3].minor.yy334->span,&yymsp[0].minor.yy334->span);  } -#line 6036 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6191 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          break; -      case 194: -#line 566 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_LIKE;} -#line 6042 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 196: +#line 579 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = TK_LIKE;} +#line 6197 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LIKE */          break; -      case 195: -#line 567 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy136 = TK_GLOB;} -#line 6048 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 197: +#line 580 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy52 = TK_GLOB;} +#line 6203 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for GLOB */          break; -      case 196: -#line 568 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_PLUS, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6054 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 198: +#line 581 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_PLUS, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6209 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PLUS */          break; -      case 197: -#line 569 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_MINUS, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6060 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 199: +#line 582 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_MINUS, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6215 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for MINUS */          break; -      case 198: -#line 570 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_STAR, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6066 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 200: +#line 583 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_STAR, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6221 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for STAR */          break; -      case 199: -#line 571 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_SLASH, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6072 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 201: +#line 584 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_SLASH, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6227 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for SLASH */          break; -      case 200: -#line 572 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_REM, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6078 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 202: +#line 585 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_REM, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6233 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for REM */          break; -      case 201: -#line 573 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = sqliteExpr(TK_CONCAT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, 0);} -#line 6084 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 203: +#line 586 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = sqliteExpr(TK_CONCAT, yymsp[-2].minor.yy334, yymsp[0].minor.yy334, 0);} +#line 6239 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for CONCAT */          break; -      case 202: -#line 574 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 204: +#line 587 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_ISNULL, yymsp[-1].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_ISNULL, yymsp[-1].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6093 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6248 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 203: -#line 578 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 205: +#line 591 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_ISNULL, yymsp[-2].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-2].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_ISNULL, yymsp[-2].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-2].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6101 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6256 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for IS */          break; -      case 204: -#line 582 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 206: +#line 595 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_NOTNULL, yymsp[-1].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_NOTNULL, yymsp[-1].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6110 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6265 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 205: -#line 586 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 207: +#line 599 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_NOTNULL, yymsp[-2].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-2].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_NOTNULL, yymsp[-2].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-2].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6118 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6273 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          break; -      case 206: -#line 590 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 208: +#line 603 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_NOTNULL, yymsp[-3].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-3].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_NOTNULL, yymsp[-3].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-3].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6127 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6282 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for IS */          /* No destructor defined for NOT */          break; -      case 207: -#line 594 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 209: +#line 607 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_NOT, yymsp[0].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy272->span); +  yygotominor.yy334 = sqliteExpr(TK_NOT, yymsp[0].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy334->span);  } -#line 6137 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6292 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 208: -#line 598 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 210: +#line 611 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_BITNOT, yymsp[0].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy272->span); +  yygotominor.yy334 = sqliteExpr(TK_BITNOT, yymsp[0].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy334->span);  } -#line 6145 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6300 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 209: -#line 602 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 211: +#line 615 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_UMINUS, yymsp[0].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy272->span); +  yygotominor.yy334 = sqliteExpr(TK_UMINUS, yymsp[0].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy334->span);  } -#line 6153 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6308 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 210: -#line 606 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 212: +#line 619 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_UPLUS, yymsp[0].minor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy272->span); +  yygotominor.yy334 = sqliteExpr(TK_UPLUS, yymsp[0].minor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy334->span);  } -#line 6161 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6316 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 211: -#line 610 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 213: +#line 623 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_SELECT, 0, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pSelect = yymsp[-1].minor.yy207; -  sqliteExprSpan(yygotominor.yy272,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_SELECT, 0, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pSelect = yymsp[-1].minor.yy11; +  sqliteExprSpan(yygotominor.yy334,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);  } -#line 6170 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6325 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 212: -#line 615 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 214: +#line 628 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy272, 0); -  pList = sqliteExprListAppend(pList, yymsp[0].minor.yy272, 0); -  yygotominor.yy272 = sqliteExpr(TK_BETWEEN, yymsp[-4].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pList = pList; -  sqliteExprSpan(yygotominor.yy272,&yymsp[-4].minor.yy272->span,&yymsp[0].minor.yy272->span); +  ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy334, 0); +  pList = sqliteExprListAppend(pList, yymsp[0].minor.yy334, 0); +  yygotominor.yy334 = sqliteExpr(TK_BETWEEN, yymsp[-4].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pList = pList; +  sqliteExprSpan(yygotominor.yy334,&yymsp[-4].minor.yy334->span,&yymsp[0].minor.yy334->span);  } -#line 6181 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6336 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for BETWEEN */          /* No destructor defined for AND */          break; -      case 213: -#line 622 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 215: +#line 635 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy272, 0); -  pList = sqliteExprListAppend(pList, yymsp[0].minor.yy272, 0); -  yygotominor.yy272 = sqliteExpr(TK_BETWEEN, yymsp[-5].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pList = pList; -  yygotominor.yy272 = sqliteExpr(TK_NOT, yygotominor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-5].minor.yy272->span,&yymsp[0].minor.yy272->span); +  ExprList *pList = sqliteExprListAppend(0, yymsp[-2].minor.yy334, 0); +  pList = sqliteExprListAppend(pList, yymsp[0].minor.yy334, 0); +  yygotominor.yy334 = sqliteExpr(TK_BETWEEN, yymsp[-5].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pList = pList; +  yygotominor.yy334 = sqliteExpr(TK_NOT, yygotominor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-5].minor.yy334->span,&yymsp[0].minor.yy334->span);  } -#line 6195 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6350 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          /* No destructor defined for BETWEEN */          /* No destructor defined for AND */          break; -      case 214: -#line 630 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 216: +#line 643 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_IN, yymsp[-4].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pList = yymsp[-1].minor.yy168; -  sqliteExprSpan(yygotominor.yy272,&yymsp[-4].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_IN, yymsp[-4].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pList = yymsp[-1].minor.yy62; +  sqliteExprSpan(yygotominor.yy334,&yymsp[-4].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6207 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6362 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for IN */          /* No destructor defined for LP */          break; -      case 215: -#line 635 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 217: +#line 648 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_IN, yymsp[-4].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pSelect = yymsp[-1].minor.yy207; -  sqliteExprSpan(yygotominor.yy272,&yymsp[-4].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_IN, yymsp[-4].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pSelect = yymsp[-1].minor.yy11; +  sqliteExprSpan(yygotominor.yy334,&yymsp[-4].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6218 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6373 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for IN */          /* No destructor defined for LP */          break; -      case 216: -#line 640 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 218: +#line 653 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_IN, yymsp[-5].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pList = yymsp[-1].minor.yy168; -  yygotominor.yy272 = sqliteExpr(TK_NOT, yygotominor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-5].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_IN, yymsp[-5].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pList = yymsp[-1].minor.yy62; +  yygotominor.yy334 = sqliteExpr(TK_NOT, yygotominor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-5].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6230 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6385 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          /* No destructor defined for IN */          /* No destructor defined for LP */          break; -      case 217: -#line 646 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 219: +#line 659 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_IN, yymsp[-5].minor.yy272, 0, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pSelect = yymsp[-1].minor.yy207; -  yygotominor.yy272 = sqliteExpr(TK_NOT, yygotominor.yy272, 0, 0); -  sqliteExprSpan(yygotominor.yy272,&yymsp[-5].minor.yy272->span,&yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_IN, yymsp[-5].minor.yy334, 0, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pSelect = yymsp[-1].minor.yy11; +  yygotominor.yy334 = sqliteExpr(TK_NOT, yygotominor.yy334, 0, 0); +  sqliteExprSpan(yygotominor.yy334,&yymsp[-5].minor.yy334->span,&yymsp[0].minor.yy0);  } -#line 6243 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6398 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for NOT */          /* No destructor defined for IN */          /* No destructor defined for LP */          break; -      case 218: -#line 654 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 220: +#line 667 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_CASE, yymsp[-3].minor.yy272, yymsp[-1].minor.yy272, 0); -  if( yygotominor.yy272 ) yygotominor.yy272->pList = yymsp[-2].minor.yy168; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_CASE, yymsp[-3].minor.yy334, yymsp[-1].minor.yy334, 0); +  if( yygotominor.yy334 ) yygotominor.yy334->pList = yymsp[-2].minor.yy62; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);  } -#line 6255 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6410 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 219: -#line 661 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 221: +#line 674 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy168 = sqliteExprListAppend(yymsp[-4].minor.yy168, yymsp[-2].minor.yy272, 0); -  yygotominor.yy168 = sqliteExprListAppend(yygotominor.yy168, yymsp[0].minor.yy272, 0); +  yygotominor.yy62 = sqliteExprListAppend(yymsp[-4].minor.yy62, yymsp[-2].minor.yy334, 0); +  yygotominor.yy62 = sqliteExprListAppend(yygotominor.yy62, yymsp[0].minor.yy334, 0);  } -#line 6263 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6418 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for WHEN */          /* No destructor defined for THEN */          break; -      case 220: -#line 665 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 222: +#line 678 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy168 = sqliteExprListAppend(0, yymsp[-2].minor.yy272, 0); -  yygotominor.yy168 = sqliteExprListAppend(yygotominor.yy168, yymsp[0].minor.yy272, 0); +  yygotominor.yy62 = sqliteExprListAppend(0, yymsp[-2].minor.yy334, 0); +  yygotominor.yy62 = sqliteExprListAppend(yygotominor.yy62, yymsp[0].minor.yy334, 0);  } -#line 6273 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6428 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for WHEN */          /* No destructor defined for THEN */          break; -      case 221: -#line 670 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 6280 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for ELSE */ -        break; -      case 222: -#line 671 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 6286 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        break;        case 223: -#line 673 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 6291 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 683 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 6435 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for ELSE */          break;        case 224: -#line 674 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 6296 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 684 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = 0;} +#line 6441 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 225: -#line 682 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(yymsp[-2].minor.yy168,yymsp[0].minor.yy272,0);} -#line 6301 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ +#line 686 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 6446 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 226: -#line 683 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy168 = sqliteExprListAppend(0,yymsp[0].minor.yy272,0);} -#line 6307 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 687 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = 0;} +#line 6451 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 227: -#line 684 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = yymsp[0].minor.yy272;} -#line 6312 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 695 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = sqliteExprListAppend(yymsp[-2].minor.yy62,yymsp[0].minor.yy334,0);} +#line 6456 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          break;        case 228: -#line 685 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy272 = 0;} -#line 6317 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 696 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy62 = sqliteExprListAppend(0,yymsp[0].minor.yy334,0);} +#line 6462 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 229: -#line 690 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +#line 697 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = yymsp[0].minor.yy334;} +#line 6467 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 230: +#line 698 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy334 = 0;} +#line 6472 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 231: +#line 703 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  if( yymsp[-8].minor.yy136!=OE_None ) yymsp[-8].minor.yy136 = yymsp[0].minor.yy136; -  if( yymsp[-8].minor.yy136==OE_Default) yymsp[-8].minor.yy136 = OE_Abort; -  sqliteCreateIndex(pParse, &yymsp[-6].minor.yy324, &yymsp[-4].minor.yy324, yymsp[-2].minor.yy268, yymsp[-8].minor.yy136, &yymsp[-9].minor.yy0, &yymsp[-1].minor.yy0); +  SrcList *pSrc = sqliteSrcListAppend(0, &yymsp[-5].minor.yy210, &yymsp[-4].minor.yy210); +  if( yymsp[-9].minor.yy52!=OE_None ) yymsp[-9].minor.yy52 = yymsp[0].minor.yy52; +  if( yymsp[-9].minor.yy52==OE_Default) yymsp[-9].minor.yy52 = OE_Abort; +  sqliteCreateIndex(pParse, &yymsp[-7].minor.yy210, pSrc, yymsp[-2].minor.yy92, yymsp[-9].minor.yy52, yymsp[-10].minor.yy52, &yymsp[-11].minor.yy0, &yymsp[-1].minor.yy0);  } -#line 6326 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6482 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INDEX */          /* No destructor defined for ON */          /* No destructor defined for LP */          break; -      case 230: -#line 697 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_Abort; } -#line 6334 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for UNIQUE */ -        break; -      case 231: -#line 698 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = OE_None; } -#line 6340 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        break;        case 232: -#line 706 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = 0;} -#line 6345 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 711 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = OE_Abort; } +#line 6490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for UNIQUE */          break;        case 233: -#line 707 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = yymsp[-1].minor.yy268;} -#line 6350 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for LP */ -        /* No destructor defined for RP */ +#line 712 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = OE_None; } +#line 6496 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 234: -#line 708 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = sqliteIdListAppend(yymsp[-2].minor.yy268,&yymsp[0].minor.yy324);} -#line 6357 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for COMMA */ +#line 720 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = 0;} +#line 6501 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 235: -#line 709 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy268 = sqliteIdListAppend(0,&yymsp[0].minor.yy324);} -#line 6363 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 721 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = yymsp[-1].minor.yy92;} +#line 6506 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for LP */ +        /* No destructor defined for RP */          break;        case 236: -#line 710 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy324;} -#line 6368 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 722 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = sqliteIdListAppend(yymsp[-2].minor.yy92,&yymsp[0].minor.yy210);} +#line 6513 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for COMMA */          break;        case 237: -#line 715 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteDropIndex(pParse, &yymsp[0].minor.yy324);} -#line 6373 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 723 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy92 = sqliteIdListAppend(0,&yymsp[0].minor.yy210);} +#line 6519 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        break; +      case 238: +#line 724 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[-1].minor.yy210;} +#line 6524 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for sortorder */ +        break; +      case 239: +#line 729 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +  sqliteDropIndex(pParse, sqliteSrcListAppend(0,&yymsp[-1].minor.yy210,&yymsp[0].minor.yy210)); +} +#line 6532 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DROP */          /* No destructor defined for INDEX */          break; -      case 238: -#line 721 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteCopy(pParse,&yymsp[-5].minor.yy324,&yymsp[-3].minor.yy324,&yymsp[0].minor.yy0,yymsp[-6].minor.yy136);} -#line 6380 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 240: +#line 737 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteCopy(pParse,sqliteSrcListAppend(0,&yymsp[-6].minor.yy210,&yymsp[-5].minor.yy210),&yymsp[-3].minor.yy210,&yymsp[0].minor.yy0,yymsp[-7].minor.yy52);} +#line 6539 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COPY */          /* No destructor defined for FROM */          /* No destructor defined for USING */          /* No destructor defined for DELIMITERS */          break; -      case 239: -#line 723 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteCopy(pParse,&yymsp[-2].minor.yy324,&yymsp[0].minor.yy324,0,yymsp[-3].minor.yy136);} -#line 6389 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 241: +#line 739 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteCopy(pParse,sqliteSrcListAppend(0,&yymsp[-3].minor.yy210,&yymsp[-2].minor.yy210),&yymsp[0].minor.yy210,0,yymsp[-4].minor.yy52);} +#line 6548 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for COPY */          /* No destructor defined for FROM */          break; -      case 240: -#line 727 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 242: +#line 743 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {sqliteVacuum(pParse,0);} -#line 6396 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for VACUUM */ -        break; -      case 241: -#line 728 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqliteVacuum(pParse,&yymsp[0].minor.yy324);} -#line 6402 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6555 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for VACUUM */          break; -      case 242: -#line 732 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy324,&yymsp[0].minor.yy324,0);} -#line 6408 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for PRAGMA */ -        /* No destructor defined for EQ */ -        break;        case 243: -#line 733 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy324,&yymsp[0].minor.yy0,0);} -#line 6415 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for PRAGMA */ -        /* No destructor defined for EQ */ +#line 744 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqliteVacuum(pParse,&yymsp[0].minor.yy210);} +#line 6561 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for VACUUM */          break;        case 244: -#line 734 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy324,&yymsp[0].minor.yy324,0);} -#line 6422 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 748 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[-2].minor.yy210,&yymsp[0].minor.yy210,0);} +#line 6567 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRAGMA */          /* No destructor defined for EQ */          break;        case 245: -#line 735 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[-2].minor.yy324,&yymsp[0].minor.yy324,1);} -#line 6429 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 749 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[-2].minor.yy210,&yymsp[0].minor.yy0,0);} +#line 6574 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRAGMA */          /* No destructor defined for EQ */          break;        case 246: -#line 736 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[-3].minor.yy324,&yymsp[-1].minor.yy324,0);} -#line 6436 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 750 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[-2].minor.yy210,&yymsp[0].minor.yy210,0);} +#line 6581 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRAGMA */ -        /* No destructor defined for LP */ -        /* No destructor defined for RP */ +        /* No destructor defined for EQ */          break;        case 247: -#line 737 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{sqlitePragma(pParse,&yymsp[0].minor.yy324,&yymsp[0].minor.yy324,0);} -#line 6444 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 751 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[-2].minor.yy210,&yymsp[0].minor.yy210,1);} +#line 6588 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for PRAGMA */ +        /* No destructor defined for EQ */          break;        case 248: -#line 738 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy324;} -#line 6450 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for plus_opt */ +#line 752 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[-3].minor.yy210,&yymsp[-1].minor.yy210,0);} +#line 6595 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for PRAGMA */ +        /* No destructor defined for LP */ +        /* No destructor defined for RP */          break;        case 249: -#line 739 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy324;} -#line 6456 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" -        /* No destructor defined for MINUS */ +#line 753 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{sqlitePragma(pParse,&yymsp[0].minor.yy210,&yymsp[0].minor.yy210,0);} +#line 6603 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for PRAGMA */          break;        case 250: -#line 740 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 6462 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 754 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[0].minor.yy210;} +#line 6609 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for plus_opt */          break;        case 251: -#line 741 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy324 = yymsp[0].minor.yy0;} -#line 6467 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 755 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[0].minor.yy210;} +#line 6615 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for MINUS */          break;        case 252: -        /* No destructor defined for PLUS */ +#line 756 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 6621 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 253: +#line 757 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy210 = yymsp[0].minor.yy0;} +#line 6626 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break;        case 254: -#line 748 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +        /* No destructor defined for PLUS */ +        break; +      case 255: +        break; +      case 256: +#line 763 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  {    Token all; -  all.z = yymsp[-11].minor.yy0.z; -  all.n = (yymsp[0].minor.yy0.z - yymsp[-11].minor.yy0.z) + yymsp[0].minor.yy0.n; -  sqliteCreateTrigger(pParse, &yymsp[-9].minor.yy324, yymsp[-8].minor.yy136, yymsp[-7].minor.yy72.a, yymsp[-7].minor.yy72.b, &yymsp[-5].minor.yy324, yymsp[-4].minor.yy136, yymsp[-3].minor.yy176, yymsp[-1].minor.yy209, &all); +  all.z = yymsp[-4].minor.yy0.z; +  all.n = (yymsp[0].minor.yy0.z - yymsp[-4].minor.yy0.z) + yymsp[0].minor.yy0.n; +  sqliteFinishTrigger(pParse, yymsp[-1].minor.yy347, &all);  } -#line 6482 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6641 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for trigger_decl */ +        /* No destructor defined for BEGIN */ +        break; +      case 257: +#line 771 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +  SrcList *pTab = sqliteSrcListAppend(0, &yymsp[-3].minor.yy210, &yymsp[-2].minor.yy210); +  sqliteBeginTrigger(pParse, &yymsp[-7].minor.yy210, yymsp[-6].minor.yy52, yymsp[-5].minor.yy234.a, yymsp[-5].minor.yy234.b, pTab, yymsp[-1].minor.yy52, yymsp[0].minor.yy270, yymsp[-9].minor.yy52); +} +#line 6651 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for TRIGGER */          /* No destructor defined for ON */ -        /* No destructor defined for BEGIN */          break; -      case 255: -#line 756 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_BEFORE; } -#line 6490 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 258: +#line 777 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_BEFORE; } +#line 6658 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for BEFORE */          break; -      case 256: -#line 757 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_AFTER;  } -#line 6496 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 259: +#line 778 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_AFTER;  } +#line 6664 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for AFTER */          break; -      case 257: -#line 758 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_INSTEAD;} -#line 6502 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 260: +#line 779 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_INSTEAD;} +#line 6670 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INSTEAD */          /* No destructor defined for OF */          break; -      case 258: -#line 759 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_BEFORE; } -#line 6509 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 261: +#line 780 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_BEFORE; } +#line 6677 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 259: -#line 763 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy72.a = TK_DELETE; yygotominor.yy72.b = 0; } -#line 6514 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 262: +#line 784 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy234.a = TK_DELETE; yygotominor.yy234.b = 0; } +#line 6682 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DELETE */          break; -      case 260: -#line 764 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy72.a = TK_INSERT; yygotominor.yy72.b = 0; } -#line 6520 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 263: +#line 785 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy234.a = TK_INSERT; yygotominor.yy234.b = 0; } +#line 6688 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INSERT */          break; -      case 261: -#line 765 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy72.a = TK_UPDATE; yygotominor.yy72.b = 0;} -#line 6526 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 264: +#line 786 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy234.a = TK_UPDATE; yygotominor.yy234.b = 0;} +#line 6694 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UPDATE */          break; -      case 262: -#line 766 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy72.a = TK_UPDATE; yygotominor.yy72.b = yymsp[0].minor.yy268; } -#line 6532 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 265: +#line 787 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy234.a = TK_UPDATE; yygotominor.yy234.b = yymsp[0].minor.yy92; } +#line 6700 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UPDATE */          /* No destructor defined for OF */          break; -      case 263: -#line 769 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_ROW; } -#line 6539 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 266: +#line 790 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_ROW; } +#line 6707 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 264: -#line 770 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_ROW; } -#line 6544 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 267: +#line 791 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_ROW; } +#line 6712 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for FOR */          /* No destructor defined for EACH */          /* No destructor defined for ROW */          break; -      case 265: -#line 771 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy136 = TK_STATEMENT; } -#line 6552 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 268: +#line 792 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy52 = TK_STATEMENT; } +#line 6720 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for FOR */          /* No destructor defined for EACH */          /* No destructor defined for STATEMENT */          break; -      case 266: -#line 774 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy176 = 0; } -#line 6560 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 269: +#line 795 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy270 = 0; } +#line 6728 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 267: -#line 775 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy176 = yymsp[0].minor.yy272; } -#line 6565 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 270: +#line 796 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy270 = yymsp[0].minor.yy334; } +#line 6733 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for WHEN */          break; -      case 268: -#line 778 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 271: +#line 800 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yymsp[-2].minor.yy209->pNext = yymsp[0].minor.yy209 ; yygotominor.yy209 = yymsp[-2].minor.yy209; } -#line 6572 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +  yymsp[-2].minor.yy347->pNext = yymsp[0].minor.yy347; +  yygotominor.yy347 = yymsp[-2].minor.yy347; +} +#line 6742 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for SEMI */          break; -      case 269: -#line 780 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy209 = 0; } -#line 6578 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 272: +#line 804 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy347 = 0; } +#line 6748 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 270: -#line 785 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{ yygotominor.yy209 = sqliteTriggerUpdateStep(&yymsp[-3].minor.yy324, yymsp[-1].minor.yy168, yymsp[0].minor.yy272, yymsp[-4].minor.yy136); } -#line 6583 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 273: +#line 810 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ yygotominor.yy347 = sqliteTriggerUpdateStep(&yymsp[-3].minor.yy210, yymsp[-1].minor.yy62, yymsp[0].minor.yy334, yymsp[-4].minor.yy52); } +#line 6753 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for UPDATE */          /* No destructor defined for SET */          break; -      case 271: -#line 790 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy209 = sqliteTriggerInsertStep(&yymsp[-5].minor.yy324, yymsp[-4].minor.yy268, yymsp[-1].minor.yy168, 0, yymsp[-7].minor.yy136);} -#line 6590 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 274: +#line 815 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy347 = sqliteTriggerInsertStep(&yymsp[-5].minor.yy210, yymsp[-4].minor.yy92, yymsp[-1].minor.yy62, 0, yymsp[-7].minor.yy52);} +#line 6760 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INSERT */          /* No destructor defined for INTO */          /* No destructor defined for VALUES */          /* No destructor defined for LP */          /* No destructor defined for RP */          break; -      case 272: -#line 793 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy209 = sqliteTriggerInsertStep(&yymsp[-2].minor.yy324, yymsp[-1].minor.yy268, 0, yymsp[0].minor.yy207, yymsp[-4].minor.yy136);} -#line 6600 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 275: +#line 818 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy347 = sqliteTriggerInsertStep(&yymsp[-2].minor.yy210, yymsp[-1].minor.yy92, 0, yymsp[0].minor.yy11, yymsp[-4].minor.yy52);} +#line 6770 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for INSERT */          /* No destructor defined for INTO */          break; -      case 273: -#line 797 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy209 = sqliteTriggerDeleteStep(&yymsp[-1].minor.yy324, yymsp[0].minor.yy272);} -#line 6607 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 276: +#line 822 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy347 = sqliteTriggerDeleteStep(&yymsp[-1].minor.yy210, yymsp[0].minor.yy334);} +#line 6777 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DELETE */          /* No destructor defined for FROM */          break; -      case 274: -#line 800 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" -{yygotominor.yy209 = sqliteTriggerSelectStep(yymsp[0].minor.yy207); } -#line 6614 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +      case 277: +#line 825 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{yygotominor.yy347 = sqliteTriggerSelectStep(yymsp[0].minor.yy11); } +#line 6784 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          break; -      case 275: -#line 803 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 278: +#line 828 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_RAISE, 0, 0, 0);  -  yygotominor.yy272->iColumn = OE_Ignore; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_RAISE, 0, 0, 0);  +  yygotominor.yy334->iColumn = OE_Ignore; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);  } -#line 6623 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6793 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for IGNORE */          break; -      case 276: -#line 808 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 279: +#line 833 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy324);  -  yygotominor.yy272->iColumn = OE_Rollback; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy210);  +  yygotominor.yy334->iColumn = OE_Rollback; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);  } -#line 6634 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6804 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for ROLLBACK */          /* No destructor defined for COMMA */          break; -      case 277: -#line 813 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 280: +#line 838 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy324);  -  yygotominor.yy272->iColumn = OE_Abort; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy210);  +  yygotominor.yy334->iColumn = OE_Abort; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);  } -#line 6646 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6816 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for ABORT */          /* No destructor defined for COMMA */          break; -      case 278: -#line 818 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 281: +#line 843 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -  yygotominor.yy272 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy324);  -  yygotominor.yy272->iColumn = OE_Fail; -  sqliteExprSpan(yygotominor.yy272, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); +  yygotominor.yy334 = sqliteExpr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy210);  +  yygotominor.yy334->iColumn = OE_Fail; +  sqliteExprSpan(yygotominor.yy334, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);  } -#line 6658 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6828 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for LP */          /* No destructor defined for FAIL */          /* No destructor defined for COMMA */          break; -      case 279: -#line 825 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +      case 282: +#line 850 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y"  { -    sqliteDropTrigger(pParse,&yymsp[0].minor.yy324,0); +  sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&yymsp[-1].minor.yy210,&yymsp[0].minor.yy210),0);  } -#line 6668 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6838 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"          /* No destructor defined for DROP */          /* No destructor defined for TRIGGER */          break; +      case 283: +#line 855 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +  sqliteAttach(pParse, &yymsp[-2].minor.yy210, &yymsp[0].minor.yy210); +} +#line 6847 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for ATTACH */ +        /* No destructor defined for database_kw_opt */ +        /* No destructor defined for AS */ +        break; +      case 284: +        /* No destructor defined for DATABASE */ +        break; +      case 285: +        break; +      case 286: +#line 863 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.y" +{ +  sqliteDetach(pParse, &yymsp[0].minor.yy210); +} +#line 6862 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +        /* No destructor defined for DETACH */ +        /* No destructor defined for database_kw_opt */ +        break;    };    yygoto = yyRuleInfo[yyruleno].lhs;    yysize = yyRuleInfo[yyruleno].nrhs; @@ -6722,7 +6916,7 @@ static void yy_syntax_error(    }    pParse->nErr++; -#line 6725 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c" +#line 6919 "/home/wez/src/php/pear/PECL/sqlite/libsqlite/src/parse.c"    sqliteParserARG_STORE; /* Suppress warning about unused %extra_argument variable */  } diff --git a/ext/sqlite/libsqlite/src/parse.h b/ext/sqlite/libsqlite/src/parse.h index 16dd234c6d..aba9766596 100644 --- a/ext/sqlite/libsqlite/src/parse.h +++ b/ext/sqlite/libsqlite/src/parse.h @@ -5,123 +5,126 @@  #define TK_AND                             5  #define TK_AS                              6  #define TK_ASC                             7 -#define TK_BEFORE                          8 -#define TK_BEGIN                           9 -#define TK_BETWEEN                        10 -#define TK_BITAND                         11 -#define TK_BITNOT                         12 -#define TK_BITOR                          13 -#define TK_BY                             14 -#define TK_CASCADE                        15 -#define TK_CASE                           16 -#define TK_CHECK                          17 -#define TK_CLUSTER                        18 -#define TK_COLLATE                        19 -#define TK_COLUMN                         20 -#define TK_COMMA                          21 -#define TK_COMMENT                        22 -#define TK_COMMIT                         23 -#define TK_CONCAT                         24 -#define TK_CONFLICT                       25 -#define TK_CONSTRAINT                     26 -#define TK_COPY                           27 -#define TK_CREATE                         28 -#define TK_DEFAULT                        29 -#define TK_DEFERRABLE                     30 -#define TK_DEFERRED                       31 -#define TK_DELETE                         32 -#define TK_DELIMITERS                     33 -#define TK_DESC                           34 -#define TK_DISTINCT                       35 -#define TK_DOT                            36 -#define TK_DROP                           37 -#define TK_EACH                           38 -#define TK_ELSE                           39 -#define TK_END                            40 -#define TK_END_OF_FILE                    41 -#define TK_EQ                             42 -#define TK_EXCEPT                         43 -#define TK_EXPLAIN                        44 -#define TK_FAIL                           45 -#define TK_FLOAT                          46 -#define TK_FOR                            47 -#define TK_FOREIGN                        48 -#define TK_FROM                           49 -#define TK_FUNCTION                       50 -#define TK_GE                             51 -#define TK_GLOB                           52 -#define TK_GROUP                          53 -#define TK_GT                             54 -#define TK_HAVING                         55 -#define TK_ID                             56 -#define TK_IGNORE                         57 -#define TK_ILLEGAL                        58 -#define TK_IMMEDIATE                      59 -#define TK_IN                             60 -#define TK_INDEX                          61 -#define TK_INITIALLY                      62 -#define TK_INSERT                         63 -#define TK_INSTEAD                        64 -#define TK_INTEGER                        65 -#define TK_INTERSECT                      66 -#define TK_INTO                           67 -#define TK_IS                             68 -#define TK_ISNULL                         69 -#define TK_JOIN                           70 -#define TK_JOIN_KW                        71 -#define TK_KEY                            72 -#define TK_LE                             73 -#define TK_LIKE                           74 -#define TK_LIMIT                          75 -#define TK_LP                             76 -#define TK_LSHIFT                         77 -#define TK_LT                             78 -#define TK_MATCH                          79 -#define TK_MINUS                          80 -#define TK_NE                             81 -#define TK_NOT                            82 -#define TK_NOTNULL                        83 -#define TK_NULL                           84 -#define TK_OF                             85 -#define TK_OFFSET                         86 -#define TK_ON                             87 -#define TK_OR                             88 -#define TK_ORACLE_OUTER_JOIN              89 -#define TK_ORDER                          90 -#define TK_PLUS                           91 -#define TK_PRAGMA                         92 -#define TK_PRIMARY                        93 -#define TK_RAISE                          94 -#define TK_REFERENCES                     95 -#define TK_REM                            96 -#define TK_REPLACE                        97 -#define TK_RESTRICT                       98 -#define TK_ROLLBACK                       99 -#define TK_ROW                            100 -#define TK_RP                             101 -#define TK_RSHIFT                         102 -#define TK_SELECT                         103 -#define TK_SEMI                           104 -#define TK_SET                            105 -#define TK_SLASH                          106 -#define TK_SPACE                          107 -#define TK_STAR                           108 -#define TK_STATEMENT                      109 -#define TK_STRING                         110 -#define TK_TABLE                          111 -#define TK_TEMP                           112 -#define TK_THEN                           113 -#define TK_TRANSACTION                    114 -#define TK_TRIGGER                        115 -#define TK_UMINUS                         116 -#define TK_UNCLOSED_STRING                117 -#define TK_UNION                          118 -#define TK_UNIQUE                         119 -#define TK_UPDATE                         120 -#define TK_UPLUS                          121 -#define TK_USING                          122 -#define TK_VACUUM                         123 -#define TK_VALUES                         124 -#define TK_VIEW                           125 -#define TK_WHEN                           126 -#define TK_WHERE                          127 +#define TK_ATTACH                          8 +#define TK_BEFORE                          9 +#define TK_BEGIN                          10 +#define TK_BETWEEN                        11 +#define TK_BITAND                         12 +#define TK_BITNOT                         13 +#define TK_BITOR                          14 +#define TK_BY                             15 +#define TK_CASCADE                        16 +#define TK_CASE                           17 +#define TK_CHECK                          18 +#define TK_CLUSTER                        19 +#define TK_COLLATE                        20 +#define TK_COLUMN                         21 +#define TK_COMMA                          22 +#define TK_COMMENT                        23 +#define TK_COMMIT                         24 +#define TK_CONCAT                         25 +#define TK_CONFLICT                       26 +#define TK_CONSTRAINT                     27 +#define TK_COPY                           28 +#define TK_CREATE                         29 +#define TK_DATABASE                       30 +#define TK_DEFAULT                        31 +#define TK_DEFERRABLE                     32 +#define TK_DEFERRED                       33 +#define TK_DELETE                         34 +#define TK_DELIMITERS                     35 +#define TK_DESC                           36 +#define TK_DETACH                         37 +#define TK_DISTINCT                       38 +#define TK_DOT                            39 +#define TK_DROP                           40 +#define TK_EACH                           41 +#define TK_ELSE                           42 +#define TK_END                            43 +#define TK_END_OF_FILE                    44 +#define TK_EQ                             45 +#define TK_EXCEPT                         46 +#define TK_EXPLAIN                        47 +#define TK_FAIL                           48 +#define TK_FLOAT                          49 +#define TK_FOR                            50 +#define TK_FOREIGN                        51 +#define TK_FROM                           52 +#define TK_FUNCTION                       53 +#define TK_GE                             54 +#define TK_GLOB                           55 +#define TK_GROUP                          56 +#define TK_GT                             57 +#define TK_HAVING                         58 +#define TK_ID                             59 +#define TK_IGNORE                         60 +#define TK_ILLEGAL                        61 +#define TK_IMMEDIATE                      62 +#define TK_IN                             63 +#define TK_INDEX                          64 +#define TK_INITIALLY                      65 +#define TK_INSERT                         66 +#define TK_INSTEAD                        67 +#define TK_INTEGER                        68 +#define TK_INTERSECT                      69 +#define TK_INTO                           70 +#define TK_IS                             71 +#define TK_ISNULL                         72 +#define TK_JOIN                           73 +#define TK_JOIN_KW                        74 +#define TK_KEY                            75 +#define TK_LE                             76 +#define TK_LIKE                           77 +#define TK_LIMIT                          78 +#define TK_LP                             79 +#define TK_LSHIFT                         80 +#define TK_LT                             81 +#define TK_MATCH                          82 +#define TK_MINUS                          83 +#define TK_NE                             84 +#define TK_NOT                            85 +#define TK_NOTNULL                        86 +#define TK_NULL                           87 +#define TK_OF                             88 +#define TK_OFFSET                         89 +#define TK_ON                             90 +#define TK_OR                             91 +#define TK_ORACLE_OUTER_JOIN              92 +#define TK_ORDER                          93 +#define TK_PLUS                           94 +#define TK_PRAGMA                         95 +#define TK_PRIMARY                        96 +#define TK_RAISE                          97 +#define TK_REFERENCES                     98 +#define TK_REM                            99 +#define TK_REPLACE                        100 +#define TK_RESTRICT                       101 +#define TK_ROLLBACK                       102 +#define TK_ROW                            103 +#define TK_RP                             104 +#define TK_RSHIFT                         105 +#define TK_SELECT                         106 +#define TK_SEMI                           107 +#define TK_SET                            108 +#define TK_SLASH                          109 +#define TK_SPACE                          110 +#define TK_STAR                           111 +#define TK_STATEMENT                      112 +#define TK_STRING                         113 +#define TK_TABLE                          114 +#define TK_TEMP                           115 +#define TK_THEN                           116 +#define TK_TRANSACTION                    117 +#define TK_TRIGGER                        118 +#define TK_UMINUS                         119 +#define TK_UNCLOSED_STRING                120 +#define TK_UNION                          121 +#define TK_UNIQUE                         122 +#define TK_UPDATE                         123 +#define TK_UPLUS                          124 +#define TK_USING                          125 +#define TK_VACUUM                         126 +#define TK_VALUES                         127 +#define TK_VIEW                           128 +#define TK_WHEN                           129 +#define TK_WHERE                          130 diff --git a/ext/sqlite/libsqlite/src/parse.y b/ext/sqlite/libsqlite/src/parse.y index 598dc37309..f319cc3922 100644 --- a/ext/sqlite/libsqlite/src/parse.y +++ b/ext/sqlite/libsqlite/src/parse.y @@ -96,8 +96,8 @@ create_table ::= CREATE(X) temp(T) TABLE nm(Y). {     sqliteStartTable(pParse,&X,&Y,T,0);  }  %type temp {int} -temp(A) ::= TEMP.  {A = pParse->isTemp || !pParse->initFlag;} -temp(A) ::= .      {A = pParse->isTemp;} +temp(A) ::= TEMP.  {A = 1;} +temp(A) ::= .      {A = 0;}  create_table_args ::= LP columnlist conslist_opt RP(X). {    sqliteEndTable(pParse,&X,0);  } @@ -126,8 +126,8 @@ id(A) ::= ID(X).         {A = X;}  // This obviates the need for the "id" nonterminal.  //  %fallback ID  -  ABORT AFTER ASC BEFORE BEGIN CASCADE CLUSTER CONFLICT -  COPY DEFERRED DELIMITERS DESC EACH END EXPLAIN FAIL FOR +  ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT +  COPY DATABASE DEFERRED DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR    IGNORE IMMEDIATE INITIALLY INSTEAD MATCH KEY    OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW STATEMENT    TEMP TRIGGER VACUUM VIEW. @@ -176,7 +176,7 @@ carg ::= DEFAULT NULL.  ccons ::= NULL onconf.  ccons ::= NOT NULL onconf(R).               {sqliteAddNotNull(pParse, R);}  ccons ::= PRIMARY KEY sortorder onconf(R).  {sqliteAddPrimaryKey(pParse,0,R);} -ccons ::= UNIQUE onconf(R).            {sqliteCreateIndex(pParse,0,0,0,R,0,0);} +ccons ::= UNIQUE onconf(R).           {sqliteCreateIndex(pParse,0,0,0,R,0,0,0);}  ccons ::= CHECK LP expr RP onconf.  ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R).                                  {sqliteCreateForeignKey(pParse,0,&T,TA,R);} @@ -223,7 +223,7 @@ tcons ::= CONSTRAINT nm.  tcons ::= PRIMARY KEY LP idxlist(X) RP onconf(R).                                               {sqliteAddPrimaryKey(pParse,X,R);}  tcons ::= UNIQUE LP idxlist(X) RP onconf(R). -                                       {sqliteCreateIndex(pParse,0,0,X,R,0,0);} +                                     {sqliteCreateIndex(pParse,0,0,X,R,0,0,0);}  tcons ::= CHECK expr onconf.  tcons ::= FOREIGN KEY LP idxlist(FA) RP            REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). { @@ -353,8 +353,8 @@ stl_prefix(A) ::= seltablist(X) joinop(Y).    {     if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y;  }  stl_prefix(A) ::= .                           {A = 0;} -seltablist(A) ::= stl_prefix(X) nm(Y) as(Z) on_opt(N) using_opt(U). { -  A = sqliteSrcListAppend(X,&Y); +seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) on_opt(N) using_opt(U). { +  A = sqliteSrcListAppend(X,&Y,&D);    if( Z.n ) sqliteSrcListAddAlias(A,&Z);    if( N ){      if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; } @@ -366,7 +366,7 @@ seltablist(A) ::= stl_prefix(X) nm(Y) as(Z) on_opt(N) using_opt(U). {    }  }  seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). { -  A = sqliteSrcListAppend(X,0); +  A = sqliteSrcListAppend(X,0,0);    A->a[A->nSrc-1].pSelect = S;    if( Z.n ) sqliteSrcListAddAlias(A,&Z);    if( N ){ @@ -379,6 +379,10 @@ seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). {    }  } +%type dbnm {Token} +dbnm(A) ::= .          {A.z=0; A.n=0;} +dbnm(A) ::= DOT nm(X). {A = X;} +  %type joinop {int}  %type joinop2 {int}  joinop(X) ::= COMMA.                   { X = JT_INNER; } @@ -440,15 +444,16 @@ having_opt(A) ::= HAVING expr(X).  {A = X;}  %type limit_opt {struct LimitVal}  limit_opt(A) ::= .                  {A.limit = -1; A.offset = 0;}  limit_opt(A) ::= LIMIT INTEGER(X).  {A.limit = atoi(X.z); A.offset = 0;} -limit_opt(A) ::= LIMIT INTEGER(X) limit_sep INTEGER(Y).  +limit_opt(A) ::= LIMIT INTEGER(X) OFFSET INTEGER(Y).                                       {A.limit = atoi(X.z); A.offset = atoi(Y.z);} -limit_sep ::= OFFSET. -limit_sep ::= COMMA. +limit_opt(A) ::= LIMIT INTEGER(X) COMMA INTEGER(Y).  +                                    {A.limit = atoi(Y.z); A.offset = atoi(X.z);}  /////////////////////////// The DELETE statement /////////////////////////////  // -cmd ::= DELETE FROM nm(X) where_opt(Y). -    {sqliteDeleteFrom(pParse, &X, Y);} +cmd ::= DELETE FROM nm(X) dbnm(D) where_opt(Y). { +   sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&X,&D), Y); +}  %type where_opt {Expr*}  %destructor where_opt {sqliteExprDelete($$);} @@ -461,8 +466,8 @@ where_opt(A) ::= WHERE expr(X).       {A = X;}  ////////////////////////// The UPDATE command ////////////////////////////////  // -cmd ::= UPDATE orconf(R) nm(X) SET setlist(Y) where_opt(Z). -    {sqliteUpdate(pParse,&X,Y,Z,R);} +cmd ::= UPDATE orconf(R) nm(X) dbnm(D) SET setlist(Y) where_opt(Z). +    {sqliteUpdate(pParse,sqliteSrcListAppend(0,&X,&D),Y,Z,R);}  setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y).      {A = sqliteExprListAppend(Z,Y,&X);} @@ -470,10 +475,11 @@ setlist(A) ::= nm(X) EQ expr(Y).   {A = sqliteExprListAppend(0,Y,&X);}  ////////////////////////// The INSERT command /////////////////////////////////  // -cmd ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) VALUES LP itemlist(Y) RP. -               {sqliteInsert(pParse, &X, Y, 0, F, R);} -cmd ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) select(S). -               {sqliteInsert(pParse, &X, 0, S, F, R);} +cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F)  +        VALUES LP itemlist(Y) RP. +            {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), Y, 0, F, R);} +cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) select(S). +            {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);}  %type insert_cmd {int}  insert_cmd(A) ::= INSERT orconf(R).   {A = R;} @@ -522,6 +528,13 @@ expr(A) ::= nm(X) DOT nm(Y). {    Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);    A = sqliteExpr(TK_DOT, temp1, temp2, 0);  } +expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). { +  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X); +  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y); +  Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &Z); +  Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0); +  A = sqliteExpr(TK_DOT, temp1, temp4, 0); +}  expr(A) ::= expr(B) ORACLE_OUTER_JOIN.                                {A = B; ExprSetProperty(A,EP_Oracle8Join);}  expr(A) ::= INTEGER(X).      {A = sqliteExpr(TK_INTEGER, 0, 0, &X);} @@ -686,11 +699,12 @@ expritem(A) ::= .                       {A = 0;}  ///////////////////////////// The CREATE INDEX command ///////////////////////  // -cmd ::= CREATE(S) uniqueflag(U) INDEX nm(X) -        ON nm(Y) LP idxlist(Z) RP(E) onconf(R). { +cmd ::= CREATE(S) temp(T) uniqueflag(U) INDEX nm(X) +        ON nm(Y) dbnm(D) LP idxlist(Z) RP(E) onconf(R). { +  SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);    if( U!=OE_None ) U = R;    if( U==OE_Default) U = OE_Abort; -  sqliteCreateIndex(pParse, &X, &Y, Z, U, &S, &E); +  sqliteCreateIndex(pParse, &X, pSrc, Z, U, T, &S, &E);  }  %type uniqueflag {int} @@ -707,20 +721,22 @@ idxlist_opt(A) ::= .                         {A = 0;}  idxlist_opt(A) ::= LP idxlist(X) RP.         {A = X;}  idxlist(A) ::= idxlist(X) COMMA idxitem(Y).  {A = sqliteIdListAppend(X,&Y);}  idxlist(A) ::= idxitem(Y).                   {A = sqliteIdListAppend(0,&Y);} -idxitem(A) ::= nm(X).                        {A = X;} +idxitem(A) ::= nm(X) sortorder.              {A = X;}  ///////////////////////////// The DROP INDEX command /////////////////////////  // -cmd ::= DROP INDEX nm(X).      {sqliteDropIndex(pParse, &X);} +cmd ::= DROP INDEX nm(X) dbnm(Y).   { +  sqliteDropIndex(pParse, sqliteSrcListAppend(0,&X,&Y)); +}  ///////////////////////////// The COPY command ///////////////////////////////  // -cmd ::= COPY orconf(R) nm(X) FROM nm(Y) USING DELIMITERS STRING(Z). -    {sqliteCopy(pParse,&X,&Y,&Z,R);} -cmd ::= COPY orconf(R) nm(X) FROM nm(Y). -    {sqliteCopy(pParse,&X,&Y,0,R);} +cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y) USING DELIMITERS STRING(Z). +    {sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,&Z,R);} +cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y). +    {sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,0,R);}  ///////////////////////////// The VACUUM command /////////////////////////////  // @@ -743,13 +759,18 @@ plus_opt ::= PLUS.  plus_opt ::= .  //////////////////////////// The CREATE TRIGGER command ///////////////////// -cmd ::= CREATE(A) TRIGGER nm(B) trigger_time(C) trigger_event(D) ON nm(E)  -                  foreach_clause(F) when_clause(G) -                  BEGIN trigger_cmd_list(S) END(Z). { + +cmd ::= CREATE(A) trigger_decl BEGIN trigger_cmd_list(S) END(Z). {    Token all;    all.z = A.z;    all.n = (Z.z - A.z) + Z.n; -  sqliteCreateTrigger(pParse, &B, C, D.a, D.b, &E, F, G, S, &all); +  sqliteFinishTrigger(pParse, S, &all); +} + +trigger_decl ::= temp(T) TRIGGER nm(B) trigger_time(C) trigger_event(D) +                 ON nm(E) dbnm(DB) foreach_clause(F) when_clause(G). { +  SrcList *pTab = sqliteSrcListAppend(0, &E, &DB); +  sqliteBeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);  }  %type trigger_time  {int} @@ -775,11 +796,15 @@ when_clause(A) ::= .             { A = 0; }  when_clause(A) ::= WHEN expr(X). { A = X; }  %type trigger_cmd_list {TriggerStep *} +%destructor trigger_cmd_list {sqliteDeleteTriggerStep($$);}  trigger_cmd_list(A) ::= trigger_cmd(X) SEMI trigger_cmd_list(Y). { -  X->pNext = Y ; A = X; } +  X->pNext = Y; +  A = X; +}  trigger_cmd_list(A) ::= . { A = 0; }  %type trigger_cmd {TriggerStep *} +%destructor trigger_cmd {sqliteDeleteTriggerStep($$);}  // UPDATE   trigger_cmd(A) ::= UPDATE orconf(R) nm(X) SET setlist(Y) where_opt(Z).                   { A = sqliteTriggerUpdateStep(&X, Y, Z, R); } @@ -822,6 +847,19 @@ expr(A) ::= RAISE(X) LP FAIL COMMA nm(Z) RP(Y).  {  }  ////////////////////////  DROP TRIGGER statement ////////////////////////////// -cmd ::= DROP TRIGGER nm(X). { -    sqliteDropTrigger(pParse,&X,0); +cmd ::= DROP TRIGGER nm(X) dbnm(D). { +  sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&X,&D),0); +} + +//////////////////////// ATTACH DATABASE file AS name ///////////////////////// +cmd ::= ATTACH database_kw_opt ids(F) AS nm(D). { +  sqliteAttach(pParse, &F, &D); +} + +database_kw_opt ::= DATABASE. +database_kw_opt ::= . + +//////////////////////// DETACH DATABASE name ///////////////////////////////// +cmd ::= DETACH database_kw_opt nm(D). { +  sqliteDetach(pParse, &D);  } diff --git a/ext/sqlite/libsqlite/src/pragma.c b/ext/sqlite/libsqlite/src/pragma.c new file mode 100644 index 0000000000..13f2bf71c4 --- /dev/null +++ b/ext/sqlite/libsqlite/src/pragma.c @@ -0,0 +1,535 @@ +/* +** 2003 April 6 +** +** 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. +** +************************************************************************* +** This file contains code used to implement the PRAGMA command. +** +** $Id$ +*/ +#include "sqliteInt.h" +#include <ctype.h> + +/* +** Interpret the given string as a boolean value. +*/ +static int getBoolean(char *z){ +  static char *azTrue[] = { "yes", "on", "true" }; +  int i; +  if( z[0]==0 ) return 0; +  if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){ +    return atoi(z); +  } +  for(i=0; i<sizeof(azTrue)/sizeof(azTrue[0]); i++){ +    if( sqliteStrICmp(z,azTrue[i])==0 ) return 1; +  } +  return 0; +} + +/* +** Interpret the given string as a safety level.  Return 0 for OFF, +** 1 for ON or NORMAL and 2 for FULL. +** +** Note that the values returned are one less that the values that +** should be passed into sqliteBtreeSetSafetyLevel().  The is done +** to support legacy SQL code.  The safety level used to be boolean +** and older scripts may have used numbers 0 for OFF and 1 for ON. +*/ +static int getSafetyLevel(char *z){ +  static const struct { +    const char *zWord; +    int val; +  } aKey[] = { +    { "no",    0 }, +    { "off",   0 }, +    { "false", 0 }, +    { "yes",   1 }, +    { "on",    1 }, +    { "true",  1 }, +    { "full",  2 }, +  }; +  int i; +  if( z[0]==0 ) return 1; +  if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){ +    return atoi(z); +  } +  for(i=0; i<sizeof(aKey)/sizeof(aKey[0]); i++){ +    if( sqliteStrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val; +  } +  return 1; +} + +/* +** Interpret the given string as a temp db location. Return 1 for file +** backed temporary databases, 2 for the Red-Black tree in memory database +** and 0 to use the compile-time default. +*/ +static int getTempStore(char *z){ +  if( z[0]>='0' || z[0]<='2' ){ +    return z[0] - '0'; +  }else if( sqliteStrICmp(z, "file")==0 ){ +    return 1; +  }else if( sqliteStrICmp(z, "memory")==0 ){ +    return 2; +  }else{ +    return 0; +  } +} + +/* +** Process a pragma statement.   +** +** Pragmas are of this form: +** +**      PRAGMA id = value +** +** The identifier might also be a string.  The value is a string, and +** identifier, or a number.  If minusFlag is true, then the value is +** a number that was preceded by a minus sign. +*/ +void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ +  char *zLeft = 0; +  char *zRight = 0; +  sqlite *db = pParse->db; +  Vdbe *v = sqliteGetVdbe(pParse); +  if( v==0 ) return; + +  zLeft = sqliteStrNDup(pLeft->z, pLeft->n); +  sqliteDequote(zLeft); +  if( minusFlag ){ +    zRight = 0; +    sqliteSetNString(&zRight, "-", 1, pRight->z, pRight->n, 0); +  }else{ +    zRight = sqliteStrNDup(pRight->z, pRight->n); +    sqliteDequote(zRight); +  } +  if( sqliteAuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, 0) ){ +    sqliteFree(zLeft); +    sqliteFree(zRight); +    return; +  } +  +  /* +  **  PRAGMA default_cache_size +  **  PRAGMA default_cache_size=N +  ** +  ** The first form reports the current persistent setting for the +  ** page cache size.  The value returned is the maximum number of +  ** pages in the page cache.  The second form sets both the current +  ** page cache size value and the persistent page cache size value +  ** stored in the database file. +  ** +  ** The default cache size is stored in meta-value 2 of page 1 of the +  ** database file.  The cache size is actually the absolute value of +  ** this memory location.  The sign of meta-value 2 determines the +  ** synchronous setting.  A negative value means synchronous is off +  ** and a positive value means synchronous is on. +  */ +  if( sqliteStrICmp(zLeft,"default_cache_size")==0 ){ +    static VdbeOp getCacheSize[] = { +      { OP_ReadCookie,  0, 2,        0}, +      { OP_AbsValue,    0, 0,        0}, +      { OP_Dup,         0, 0,        0}, +      { OP_Integer,     0, 0,        0}, +      { OP_Ne,          0, 6,        0}, +      { OP_Integer,     MAX_PAGES,0, 0}, +      { OP_ColumnName,  0, 0,        "cache_size"}, +      { OP_Callback,    1, 0,        0}, +    }; +    if( pRight->z==pLeft->z ){ +      sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); +    }else{ +      int addr; +      int size = atoi(zRight); +      if( size<0 ) size = -size; +      sqliteBeginWriteOperation(pParse, 0, 0); +      sqliteVdbeAddOp(v, OP_Integer, size, 0); +      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); +      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); +      sqliteVdbeAddOp(v, OP_Ge, 0, addr+3); +      sqliteVdbeAddOp(v, OP_Negative, 0, 0); +      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); +      sqliteEndWriteOperation(pParse); +      db->cache_size = db->cache_size<0 ? -size : size; +      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); +    } +  }else + +  /* +  **  PRAGMA cache_size +  **  PRAGMA cache_size=N +  ** +  ** The first form reports the current local setting for the +  ** page cache size.  The local setting can be different from +  ** the persistent cache size value that is stored in the database +  ** file itself.  The value returned is the maximum number of +  ** pages in the page cache.  The second form sets the local +  ** page cache size value.  It does not change the persistent +  ** cache size stored on the disk so the cache size will revert +  ** to its default value when the database is closed and reopened. +  ** N should be a positive integer. +  */ +  if( sqliteStrICmp(zLeft,"cache_size")==0 ){ +    static VdbeOp getCacheSize[] = { +      { OP_ColumnName,  0, 0,        "cache_size"}, +      { OP_Callback,    1, 0,        0}, +    }; +    if( pRight->z==pLeft->z ){ +      int size = db->cache_size;; +      if( size<0 ) size = -size; +      sqliteVdbeAddOp(v, OP_Integer, size, 0); +      sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); +    }else{ +      int size = atoi(zRight); +      if( size<0 ) size = -size; +      if( db->cache_size<0 ) size = -size; +      db->cache_size = size; +      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); +    } +  }else + +  /* +  **  PRAGMA default_synchronous +  **  PRAGMA default_synchronous=ON|OFF|NORMAL|FULL +  ** +  ** The first form returns the persistent value of the "synchronous" setting +  ** that is stored in the database.  This is the synchronous setting that +  ** is used whenever the database is opened unless overridden by a separate +  ** "synchronous" pragma.  The second form changes the persistent and the +  ** local synchronous setting to the value given. +  ** +  ** If synchronous is OFF, SQLite does not attempt any fsync() systems calls +  ** to make sure data is committed to disk.  Write operations are very fast, +  ** but a power failure can leave the database in an inconsistent state. +  ** If synchronous is ON or NORMAL, SQLite will do an fsync() system call to +  ** make sure data is being written to disk.  The risk of corruption due to +  ** a power loss in this mode is negligible but non-zero.  If synchronous +  ** is FULL, extra fsync()s occur to reduce the risk of corruption to near +  ** zero, but with a write performance penalty.  The default mode is NORMAL. +  */ +  if( sqliteStrICmp(zLeft,"default_synchronous")==0 ){ +    static VdbeOp getSync[] = { +      { OP_ColumnName,  0, 0,        "synchronous"}, +      { OP_ReadCookie,  0, 3,        0}, +      { OP_Dup,         0, 0,        0}, +      { OP_If,          0, 0,        0},  /* 3 */ +      { OP_ReadCookie,  0, 2,        0}, +      { OP_Integer,     0, 0,        0}, +      { OP_Lt,          0, 5,        0}, +      { OP_AddImm,      1, 0,        0}, +      { OP_Callback,    1, 0,        0}, +      { OP_Halt,        0, 0,        0}, +      { OP_AddImm,     -1, 0,        0},  /* 10 */ +      { OP_Callback,    1, 0,        0} +    }; +    if( pRight->z==pLeft->z ){ +      int addr = sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); +      sqliteVdbeChangeP2(v, addr+3, addr+10); +    }else{ +      int addr; +      int size = db->cache_size; +      if( size<0 ) size = -size; +      sqliteBeginWriteOperation(pParse, 0, 0); +      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2); +      sqliteVdbeAddOp(v, OP_Dup, 0, 0); +      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0); +      sqliteVdbeAddOp(v, OP_Ne, 0, addr+3); +      sqliteVdbeAddOp(v, OP_AddImm, MAX_PAGES, 0); +      sqliteVdbeAddOp(v, OP_AbsValue, 0, 0); +      db->safety_level = getSafetyLevel(zRight)+1; +      if( db->safety_level==1 ){ +        sqliteVdbeAddOp(v, OP_Negative, 0, 0); +        size = -size; +      } +      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2); +      sqliteVdbeAddOp(v, OP_Integer, db->safety_level, 0); +      sqliteVdbeAddOp(v, OP_SetCookie, 0, 3); +      sqliteEndWriteOperation(pParse); +      db->cache_size = size; +      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); +      sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level); +    } +  }else + +  /* +  **   PRAGMA synchronous +  **   PRAGMA synchronous=OFF|ON|NORMAL|FULL +  ** +  ** Return or set the local value of the synchronous flag.  Changing +  ** the local value does not make changes to the disk file and the +  ** default value will be restored the next time the database is +  ** opened. +  */ +  if( sqliteStrICmp(zLeft,"synchronous")==0 ){ +    static VdbeOp getSync[] = { +      { OP_ColumnName,  0, 0,        "synchronous"}, +      { OP_Callback,    1, 0,        0}, +    }; +    if( pRight->z==pLeft->z ){ +      sqliteVdbeAddOp(v, OP_Integer, db->safety_level-1, 0); +      sqliteVdbeAddOpList(v, ArraySize(getSync), getSync); +    }else{ +      int size = db->cache_size; +      if( size<0 ) size = -size; +      db->safety_level = getSafetyLevel(zRight)+1; +      if( db->safety_level==1 ) size = -size; +      db->cache_size = size; +      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size); +      sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level); +    } +  }else + +  if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){ +    if( getBoolean(zRight) ){ +      always_code_trigger_setup = 1; +    }else{ +      always_code_trigger_setup = 0; +    } +  }else + +  if( sqliteStrICmp(zLeft, "vdbe_trace")==0 ){ +    if( getBoolean(zRight) ){ +      db->flags |= SQLITE_VdbeTrace; +    }else{ +      db->flags &= ~SQLITE_VdbeTrace; +    } +  }else + +  if( sqliteStrICmp(zLeft, "full_column_names")==0 ){ +    if( getBoolean(zRight) ){ +      db->flags |= SQLITE_FullColNames; +    }else{ +      db->flags &= ~SQLITE_FullColNames; +    } +  }else + +  if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){ +    if( getBoolean(zRight) ){ +      db->flags |= SQLITE_ReportTypes; +    }else{ +      db->flags &= ~SQLITE_ReportTypes; +    } +  }else + +  if( sqliteStrICmp(zLeft, "count_changes")==0 ){ +    if( getBoolean(zRight) ){ +      db->flags |= SQLITE_CountRows; +    }else{ +      db->flags &= ~SQLITE_CountRows; +    } +  }else + +  if( sqliteStrICmp(zLeft, "empty_result_callbacks")==0 ){ +    if( getBoolean(zRight) ){ +      db->flags |= SQLITE_NullCallback; +    }else{ +      db->flags &= ~SQLITE_NullCallback; +    } +  }else + +  if( sqliteStrICmp(zLeft, "table_info")==0 ){ +    Table *pTab; +    pTab = sqliteFindTable(db, zRight, 0); +    if( pTab ){ +      static VdbeOp tableInfoPreface[] = { +        { OP_ColumnName,  0, 0,       "cid"}, +        { OP_ColumnName,  1, 0,       "name"}, +        { OP_ColumnName,  2, 0,       "type"}, +        { OP_ColumnName,  3, 0,       "notnull"}, +        { OP_ColumnName,  4, 0,       "dflt_value"}, +      }; +      int i; +      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); +      sqliteViewGetColumnNames(pParse, pTab); +      for(i=0; i<pTab->nCol; i++){ +        sqliteVdbeAddOp(v, OP_Integer, i, 0); +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zName, P3_STATIC); +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        sqliteVdbeChangeP3(v, -1,  +           pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", P3_STATIC); +        sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0); +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC); +        sqliteVdbeAddOp(v, OP_Callback, 5, 0); +      } +    } +  }else + +  if( sqliteStrICmp(zLeft, "index_info")==0 ){ +    Index *pIdx; +    Table *pTab; +    pIdx = sqliteFindIndex(db, zRight, 0); +    if( pIdx ){ +      static VdbeOp tableInfoPreface[] = { +        { OP_ColumnName,  0, 0,       "seqno"}, +        { OP_ColumnName,  1, 0,       "cid"}, +        { OP_ColumnName,  2, 0,       "name"}, +      }; +      int i; +      pTab = pIdx->pTable; +      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface); +      for(i=0; i<pIdx->nColumn; i++){ +        int cnum = pIdx->aiColumn[i]; +        sqliteVdbeAddOp(v, OP_Integer, i, 0); +        sqliteVdbeAddOp(v, OP_Integer, cnum, 0); +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        assert( pTab->nCol>cnum ); +        sqliteVdbeChangeP3(v, -1, pTab->aCol[cnum].zName, P3_STATIC); +        sqliteVdbeAddOp(v, OP_Callback, 3, 0); +      } +    } +  }else + +  if( sqliteStrICmp(zLeft, "index_list")==0 ){ +    Index *pIdx; +    Table *pTab; +    pTab = sqliteFindTable(db, zRight, 0); +    if( pTab ){ +      v = sqliteGetVdbe(pParse); +      pIdx = pTab->pIndex; +    } +    if( pTab && pIdx ){ +      int i = 0;  +      static VdbeOp indexListPreface[] = { +        { OP_ColumnName,  0, 0,       "seq"}, +        { OP_ColumnName,  1, 0,       "name"}, +        { OP_ColumnName,  2, 0,       "unique"}, +      }; + +      sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); +      while(pIdx){ +        sqliteVdbeAddOp(v, OP_Integer, i, 0); +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC); +        sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0); +        sqliteVdbeAddOp(v, OP_Callback, 3, 0); +        ++i; +        pIdx = pIdx->pNext; +      } +    } +  }else + +  if( sqliteStrICmp(zLeft, "database_list")==0 ){ +    int i; +    static VdbeOp indexListPreface[] = { +      { OP_ColumnName,  0, 0,       "seq"}, +      { OP_ColumnName,  1, 0,       "name"}, +    }; + +    sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface); +    for(i=0; i<db->nDb; i++){ +      if( db->aDb[i].pBt==0 ) continue; +      assert( db->aDb[i].zName!=0 ); +      sqliteVdbeAddOp(v, OP_Integer, i, 0); +      sqliteVdbeAddOp(v, OP_String, 0, 0); +      sqliteVdbeChangeP3(v, -1, db->aDb[i].zName, P3_STATIC); +      sqliteVdbeAddOp(v, OP_Callback, 2, 0); +    } +  }else +  /* +  **   PRAGMA temp_store +  **   PRAGMA temp_store = "default"|"memory"|"file" +  ** +  ** Return or set the local value of the temp_store flag.  Changing +  ** the local value does not make changes to the disk file and the default +  ** value will be restored the next time the database is opened. +  ** +  ** Note that it is possible for the library compile-time options to +  ** override this setting +  */ +  if( sqliteStrICmp(zLeft, "temp_store")==0 ){ +    static VdbeOp getTmpDbLoc[] = { +      { OP_ColumnName,  0, 0,        "temp_store"}, +      { OP_Callback,    1, 0,        0}, +    }; +    if( pRight->z==pLeft->z ){ +      sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0); +      sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc); +    }else{ +      if (&db->aDb[1].pBt != 0) { +	sqliteErrorMsg(pParse, "The temporary database already exists - " +          "its location cannot now be changed"); +      } else { +	db->temp_store = getTempStore(zRight); +      } +    } +  }else + +  /* +  **   PRAGMA default_temp_store +  **   PRAGMA default_temp_store = "default"|"memory"|"file" +  ** +  ** Return or set the value of the persistent temp_store flag (as +  ** well as the value currently in force). +  ** +  ** Note that it is possible for the library compile-time options to +  ** override this setting +  */ +  if( sqliteStrICmp(zLeft, "default_temp_store")==0 ){ +    static VdbeOp getTmpDbLoc[] = { +      { OP_ColumnName,  0, 0,        "temp_store"}, +      { OP_ReadCookie,  0, 5,        0}, +      { OP_Callback,    1, 0,        0}}; +    if( pRight->z==pLeft->z ){ +      sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc); +    }else{ +      if (&db->aDb[1].pBt != 0) { +	sqliteErrorMsg(pParse, "The temporary database already exists - " +            "its location cannot now be changed"); +      } else { +	sqliteBeginWriteOperation(pParse, 0, 0); +	db->temp_store = getTempStore(zRight); +	sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0); +	sqliteVdbeAddOp(v, OP_SetCookie, 0, 5); +	sqliteEndWriteOperation(pParse); +      } +    } +  }else + +#ifndef NDEBUG +  if( sqliteStrICmp(zLeft, "parser_trace")==0 ){ +    extern void sqliteParserTrace(FILE*, char *); +    if( getBoolean(zRight) ){ +      sqliteParserTrace(stdout, "parser: "); +    }else{ +      sqliteParserTrace(0, 0); +    } +  }else +#endif + +  if( sqliteStrICmp(zLeft, "integrity_check")==0 ){ +    static VdbeOp checkDb[] = { +      { OP_SetInsert,   0, 0,        "2"}, +      { OP_Integer,     0, 0,        0},    +      { OP_OpenRead,    0, 2,        0}, +      { OP_Rewind,      0, 7,        0}, +      { OP_Column,      0, 3,        0},    /* 4 */ +      { OP_SetInsert,   0, 0,        0}, +      { OP_Next,        0, 4,        0}, +      { OP_IntegrityCk, 0, 0,        0},    /* 7 */ +      { OP_ColumnName,  0, 0,        "integrity_check"}, +      { OP_Callback,    1, 0,        0}, +      { OP_SetInsert,   1, 0,        "2"}, +      { OP_Integer,     1, 0,        0}, +      { OP_OpenRead,    1, 2,        0}, +      { OP_Rewind,      1, 17,       0}, +      { OP_Column,      1, 3,        0},    /* 14 */ +      { OP_SetInsert,   1, 0,        0}, +      { OP_Next,        1, 14,       0}, +      { OP_IntegrityCk, 1, 1,        0},    /* 17 */ +      { OP_Callback,    1, 0,        0}, +    }; +    sqliteVdbeAddOpList(v, ArraySize(checkDb), checkDb); +  }else + +  {} +  sqliteFree(zLeft); +  sqliteFree(zRight); +} diff --git a/ext/sqlite/libsqlite/src/printf.c b/ext/sqlite/libsqlite/src/printf.c index 387ea1c2da..8587f80d28 100644 --- a/ext/sqlite/libsqlite/src/printf.c +++ b/ext/sqlite/libsqlite/src/printf.c @@ -687,7 +687,6 @@ static void mout(void *arg, char *zNewText, int nNewChar){  char *sqliteMPrintf(const char *zFormat, ...){    va_list ap;    struct sgMprintf sMprintf; -  char *zNew;    char zBuf[200];    sMprintf.nChar = 0; diff --git a/ext/sqlite/libsqlite/src/select.c b/ext/sqlite/libsqlite/src/select.c index 03eb861c9e..9bed641be7 100644 --- a/ext/sqlite/libsqlite/src/select.c +++ b/ext/sqlite/libsqlite/src/select.c @@ -120,9 +120,8 @@ int sqliteJoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){      pParse->nErr++;      jointype = JT_INNER;    }else if( jointype & JT_RIGHT ){ -    sqliteSetString(&pParse->zErrMsg,  -      "RIGHT and FULL OUTER JOINs are not currently supported", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse,  +      "RIGHT and FULL OUTER JOINs are not currently supported");      jointype = JT_INNER;    }    return jointype; @@ -218,9 +217,8 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){      if( pTerm->jointype & JT_NATURAL ){        Table *pTab;        if( pTerm->pOn || pTerm->pUsing ){ -        sqliteSetString(&pParse->zErrMsg, "a NATURAL join may not have " +        sqliteErrorMsg(pParse, "a NATURAL join may not have "             "an ON or USING clause", 0); -        pParse->nErr++;          return 1;        }        pTab = pTerm->pTab; @@ -234,9 +232,8 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){      /* Disallow both ON and USING clauses in the same join      */      if( pTerm->pOn && pTerm->pUsing ){ -      sqliteSetString(&pParse->zErrMsg, "cannot have both ON and USING " -        "clauses in the same join", 0); -      pParse->nErr++; +      sqliteErrorMsg(pParse, "cannot have both ON and USING " +        "clauses in the same join");        return 1;      } @@ -268,9 +265,8 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){        for(j=0; j<pList->nId; j++){          if( columnIndex(pTerm->pTab, pList->a[j].zName)<0 ||              columnIndex(pOther->pTab, pList->a[j].zName)<0 ){ -          sqliteSetString(&pParse->zErrMsg, "cannot join using column ", -            pList->a[j].zName, " - column not present in both tables", 0); -          pParse->nErr++; +          sqliteErrorMsg(pParse, "cannot join using column %s - column " +            "not present in both tables", pList->a[j].zName);            return 1;          }          addWhereTerm(pList->a[j].zName, pTerm->pTab, pOther->pTab, &p->pWhere); @@ -300,13 +296,15 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){  ** will work correctly for both SQLite and Oracle8.  */  static int sqliteOracle8JoinFixup( -  int base,         /* VDBE cursor number for first table in pSrc */    SrcList *pSrc,    /* List of tables being joined */    Expr *pWhere      /* The WHERE clause of the SELECT statement */  ){    int rc = 0;    if( ExprHasProperty(pWhere, EP_Oracle8Join) && pWhere->op==TK_COLUMN ){ -    int idx = pWhere->iTable - base; +    int idx; +    for(idx=0; idx<pSrc->nSrc; idx++){ +      if( pSrc->a[idx].iCursor==pWhere->iTable ) break; +    }      assert( idx>=0 && idx<pSrc->nSrc );      if( idx>0 ){        pSrc->a[idx-1].jointype &= ~JT_INNER; @@ -315,16 +313,16 @@ static int sqliteOracle8JoinFixup(      }    }    if( pWhere->pRight ){ -    rc = sqliteOracle8JoinFixup(base, pSrc, pWhere->pRight); +    rc = sqliteOracle8JoinFixup(pSrc, pWhere->pRight);    }    if( pWhere->pLeft ){ -    rc |= sqliteOracle8JoinFixup(base, pSrc, pWhere->pLeft); +    rc |= sqliteOracle8JoinFixup(pSrc, pWhere->pLeft);    }    if( pWhere->pList ){      int i;      ExprList *pList = pWhere->pList;      for(i=0; i<pList->nExpr && rc==0; i++){ -      rc |= sqliteOracle8JoinFixup(base, pSrc, pList->a[i].pExpr); +      rc |= sqliteOracle8JoinFixup(pSrc, pList->a[i].pExpr);      }    }    if( rc==1 && (pWhere->op==TK_AND || pWhere->op==TK_EQ) ){ @@ -691,12 +689,11 @@ static void generateSortTail(  */  static void generateColumnTypes(    Parse *pParse,      /* Parser context */ -  int base,           /* VDBE cursor corresponding to first entry in pTabList */    SrcList *pTabList,  /* List of tables */    ExprList *pEList    /* Expressions defining the result set */  ){    Vdbe *v = pParse->pVdbe; -  int i; +  int i, j;    if( pParse->useCallback && (pParse->db->flags & SQLITE_ReportTypes)==0 ){      return;    } @@ -705,8 +702,11 @@ static void generateColumnTypes(      char *zType = 0;      if( p==0 ) continue;      if( p->op==TK_COLUMN && pTabList ){ -      Table *pTab = pTabList->a[p->iTable - base].pTab; +      Table *pTab;        int iCol = p->iColumn; +      for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=p->iTable; j++){} +      assert( j<pTabList->nSrc ); +      pTab = pTabList->a[j].pTab;        if( iCol<0 ) iCol = pTab->iPKey;        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );        if( iCol<0 ){ @@ -733,12 +733,11 @@ static void generateColumnTypes(  */  static void generateColumnNames(    Parse *pParse,      /* Parser context */ -  int base,           /* VDBE cursor corresponding to first entry in pTabList */    SrcList *pTabList,  /* List of tables */    ExprList *pEList    /* Expressions defining the result set */  ){    Vdbe *v = pParse->pVdbe; -  int i; +  int i, j;    if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return;    pParse->colNamesSet = 1;    for(i=0; i<pEList->nExpr; i++){ @@ -755,9 +754,12 @@ static void generateColumnNames(      }      showFullNames = (pParse->db->flags & SQLITE_FullColNames)!=0;      if( p->op==TK_COLUMN && pTabList ){ -      Table *pTab = pTabList->a[p->iTable - base].pTab; +      Table *pTab;        char *zCol;        int iCol = p->iColumn; +      for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=p->iTable; j++){} +      assert( j<pTabList->nSrc ); +      pTab = pTabList->a[j].pTab;        if( iCol<0 ) iCol = pTab->iPKey;        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );        if( iCol<0 ){ @@ -775,7 +777,7 @@ static void generateColumnNames(          char *zName = 0;          char *zTab; -        zTab = pTabList->a[p->iTable - base].zAlias; +        zTab = pTabList->a[j].zAlias;          if( showFullNames || zTab==0 ) zTab = pTab->zName;          sqliteSetString(&zName, zTab, ".", zCol, 0);          sqliteVdbeAddOp(v, OP_ColumnName, i, 0); @@ -863,7 +865,12 @@ Table *sqliteResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){  ** For the given SELECT statement, do three things.  **  **    (1)  Fill in the pTabList->a[].pTab fields in the SrcList that  -**         defines the set of tables that should be scanned.  +**         defines the set of tables that should be scanned.  For views, +**         fill pTabList->a[].pSelect with a copy of the SELECT statement +**         that implements the view.  A copy is made of the view's SELECT +**         statement so that we can freely modify or delete that statement +**         without worrying about messing up the presistent representation +**         of the view.  **  **    (2)  Add terms to the WHERE clause to accomodate the NATURAL keyword  **         on joins and the ON and USING clause of joins. @@ -908,23 +915,31 @@ static int fillInColumnList(Parse *pParse, Select *p){        if( pTab==0 ){          return 1;        } +      /* The isTransient flag indicates that the Table structure has been +      ** dynamically allocated and may be freed at any time.  In other words, +      ** pTab is not pointing to a persistent table structure that defines +      ** part of the schema. */        pTab->isTransient = 1;      }else{        /* An ordinary table or view name in the FROM clause */        pTabList->a[i].pTab = pTab =  -        sqliteFindTable(pParse->db, pTabList->a[i].zName); +        sqliteLocateTable(pParse,pTabList->a[i].zName,pTabList->a[i].zDatabase);        if( pTab==0 ){ -        sqliteSetString(&pParse->zErrMsg, "no such table: ",  -           pTabList->a[i].zName, 0); -        pParse->nErr++;          return 1;        }        if( pTab->pSelect ){ +        /* We reach here if the named table is a really a view */          if( sqliteViewGetColumnNames(pParse, pTab) ){            return 1;          } -        sqliteSelectDelete(pTabList->a[i].pSelect); -        pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect); +        /* If pTabList->a[i].pSelect!=0 it means we are dealing with a +        ** view within a view.  The SELECT structure has already been +        ** copied by the outer view so we can skip the copy step here +        ** in the inner view. +        */ +        if( pTabList->a[i].pSelect==0 ){ +          pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect); +        }        }      }    } @@ -1032,10 +1047,9 @@ static int fillInColumnList(Parse *pParse, Select *p){          }          if( !tableSeen ){            if( pName ){ -            sqliteSetNString(&pParse->zErrMsg, "no such table: ", -1,  -              pName->z, pName->n, 0); +            sqliteErrorMsg(pParse, "no such table: %T", pName);            }else{ -            sqliteSetString(&pParse->zErrMsg, "no tables specified", 0); +            sqliteErrorMsg(pParse, "no tables specified");            }            rc = 1;          } @@ -1056,6 +1070,9 @@ static int fillInColumnList(Parse *pParse, Select *p){  ** This routine is called on the Select structure that defines a  ** VIEW in order to undo any bindings to tables.  This is necessary  ** because those tables might be DROPed by a subsequent SQL command. +** If the bindings are not removed, then the Select.pSrc->a[].pTab field +** will be left pointing to a deallocated Table structure after the +** DROP and a coredump will occur the next time the VIEW is used.  */  void sqliteSelectUnbind(Select *p){    int i; @@ -1066,10 +1083,6 @@ void sqliteSelectUnbind(Select *p){      if( (pTab = pSrc->a[i].pTab)!=0 ){        if( pTab->isTransient ){          sqliteDeleteTable(0, pTab); -#if 0 -        sqliteSelectDelete(pSrc->a[i].pSelect); -        pSrc->a[i].pSelect = 0; -#endif        }        pSrc->a[i].pTab = 0;        if( pSrc->a[i].pSelect ){ @@ -1129,11 +1142,9 @@ static int matchOrderbyToColumn(      if( pOrderBy->a[i].done ) continue;      if( sqliteExprIsInteger(pE, &iCol) ){        if( iCol<=0 || iCol>pEList->nExpr ){ -        char zBuf[200]; -        sprintf(zBuf,"ORDER BY position %d should be between 1 and %d", -           iCol, pEList->nExpr); -        sqliteSetString(&pParse->zErrMsg, zBuf, 0); -        pParse->nErr++; +        sqliteErrorMsg(pParse, +          "ORDER BY position %d should be between 1 and %d", +          iCol, pEList->nExpr);          nErr++;          break;        } @@ -1163,11 +1174,8 @@ static int matchOrderbyToColumn(        pOrderBy->a[i].done = 1;      }      if( iCol<0 && mustComplete ){ -      char zBuf[30]; -      sprintf(zBuf,"%d",i+1); -      sqliteSetString(&pParse->zErrMsg, "ORDER BY term number ", zBuf,  -        " does not match any result column", 0); -      pParse->nErr++; +      sqliteErrorMsg(pParse, +        "ORDER BY term number %d does not match any result column", i+1);        nErr++;        break;      } @@ -1277,9 +1285,8 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){    if( p==0 || p->pPrior==0 ) return 1;    pPrior = p->pPrior;    if( pPrior->pOrderBy ){ -    sqliteSetString(&pParse->zErrMsg,"ORDER BY clause should come after ", -      selectOpName(p->op), " not before", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse,"ORDER BY clause should come after %s not before", +      selectOpName(p->op));      return 1;    } @@ -1367,8 +1374,8 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){          int iCont, iBreak, iStart;          assert( p->pEList );          if( eDest==SRT_Callback ){ -          generateColumnNames(pParse, p->base, 0, p->pEList); -          generateColumnTypes(pParse, p->base, p->pSrc, p->pEList); +          generateColumnNames(pParse, 0, p->pEList); +          generateColumnTypes(pParse, p->pSrc, p->pEList);          }          iBreak = sqliteVdbeMakeLabel(v);          iCont = sqliteVdbeMakeLabel(v); @@ -1424,8 +1431,8 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){        */        assert( p->pEList );        if( eDest==SRT_Callback ){ -        generateColumnNames(pParse, p->base, 0, p->pEList); -        generateColumnTypes(pParse, p->base, p->pSrc, p->pEList); +        generateColumnNames(pParse, 0, p->pEList); +        generateColumnTypes(pParse, p->pSrc, p->pEList);        }        iBreak = sqliteVdbeMakeLabel(v);        iCont = sqliteVdbeMakeLabel(v); @@ -1450,9 +1457,8 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){    }    assert( p->pEList && pPrior->pEList );    if( p->pEList->nExpr!=pPrior->pEList->nExpr ){ -    sqliteSetString(&pParse->zErrMsg, "SELECTs to the left and right of ", -      selectOpName(p->op), " do not have the same number of result columns", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse, "SELECTs to the left and right of %s" +      " do not have the same number of result columns", selectOpName(p->op));      return 1;    } @@ -1467,36 +1473,10 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){  }  /* -** Recursively scan through an expression tree.  For every reference -** to a column in table number iFrom, change that reference to the -** same column in table number iTo. -*/ -static void changeTablesInList(ExprList*, int, int);  /* Forward Declaration */ -static void changeTables(Expr *pExpr, int iFrom, int iTo){ -  if( pExpr==0 ) return; -  if( pExpr->op==TK_COLUMN && pExpr->iTable==iFrom ){ -    pExpr->iTable = iTo; -  }else{ -    changeTables(pExpr->pLeft, iFrom, iTo); -    changeTables(pExpr->pRight, iFrom, iTo); -    changeTablesInList(pExpr->pList, iFrom, iTo); -  } -} -static void changeTablesInList(ExprList *pList, int iFrom, int iTo){ -  if( pList ){ -    int i; -    for(i=0; i<pList->nExpr; i++){ -      changeTables(pList->a[i].pExpr, iFrom, iTo); -    } -  } -} - -/*  ** Scan through the expression pExpr.  Replace every reference to -** a column in table number iTable with a copy of the corresponding +** a column in table number iTable with a copy of the iColumn-th  ** entry in pEList.  (But leave references to the ROWID column  -** unchanged.)  When making a copy of an expression in pEList, change -** references to columns in table iSub into references to table iTable. +** unchanged.)  **  ** This routine is part of the flattening procedure.  A subquery  ** whose result set is defined by pEList appears as entry in the @@ -1505,8 +1485,8 @@ static void changeTablesInList(ExprList *pList, int iFrom, int iTo){  ** changes to pExpr so that it refers directly to the source table  ** of the subquery rather the result set of the subquery.  */ -static void substExprList(ExprList*,int,ExprList*,int);  /* Forward Decl */ -static void substExpr(Expr *pExpr, int iTable, ExprList *pEList, int iSub){ +static void substExprList(ExprList*,int,ExprList*);  /* Forward Decl */ +static void substExpr(Expr *pExpr, int iTable, ExprList *pEList){    if( pExpr==0 ) return;    if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable && pExpr->iColumn>=0 ){      Expr *pNew; @@ -1527,21 +1507,18 @@ static void substExpr(Expr *pExpr, int iTable, ExprList *pEList, int iSub){      pExpr->iAgg = pNew->iAgg;      sqliteTokenCopy(&pExpr->token, &pNew->token);      sqliteTokenCopy(&pExpr->span, &pNew->span); -    if( iSub!=iTable ){ -      changeTables(pExpr, iSub, iTable); -    }    }else{ -    substExpr(pExpr->pLeft, iTable, pEList, iSub); -    substExpr(pExpr->pRight, iTable, pEList, iSub); -    substExprList(pExpr->pList, iTable, pEList, iSub); +    substExpr(pExpr->pLeft, iTable, pEList); +    substExpr(pExpr->pRight, iTable, pEList); +    substExprList(pExpr->pList, iTable, pEList);    }  }  static void  -substExprList(ExprList *pList, int iTable, ExprList *pEList, int iSub){ +substExprList(ExprList *pList, int iTable, ExprList *pEList){    int i;    if( pList==0 ) return;    for(i=0; i<pList->nExpr; i++){ -    substExpr(pList->a[i].pExpr, iTable, pEList, iSub); +    substExpr(pList->a[i].pExpr, iTable, pEList);    }  } @@ -1578,7 +1555,8 @@ substExprList(ExprList *pList, int iTable, ExprList *pEList, int iSub){  **  **   (2)  The subquery is not an aggregate or the outer query is not a join.  ** -**   (3)  The subquery is not a join. +**   (3)  The subquery is not the right operand of a left outer join, or +**        the subquery is not itself a join.  (Ticket #306)  **  **   (4)  The subquery is not DISTINCT or the outer query is not a join.  ** @@ -1604,7 +1582,7 @@ substExprList(ExprList *pList, int iTable, ExprList *pEList, int iSub){  ** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query  ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.  ** -** If flattening is not attempted, this routine is a no-op and return 0. +** If flattening is not attempted, this routine is a no-op and returns 0.  ** If flattening is attempted this routine returns 1.  **  ** All of the expression analysis must occur on both the outer query and @@ -1621,8 +1599,8 @@ static int flattenSubquery(    SrcList *pSrc;      /* The FROM clause of the outer query */    SrcList *pSubSrc;   /* The FROM clause of the subquery */    ExprList *pList;    /* The result set of the outer query */ +  int iParent;        /* VDBE cursor number of the pSub result set temp table */    int i; -  int iParent, iSub;    Expr *pWhere;    /* Check to see if flattening is permitted.  Return 0 if not. @@ -1636,19 +1614,81 @@ static int flattenSubquery(    if( subqueryIsAgg && pSrc->nSrc>1 ) return 0;    pSubSrc = pSub->pSrc;    assert( pSubSrc ); -  if( pSubSrc->nSrc!=1 ) return 0; +  if( pSubSrc->nSrc==0 ) return 0;    if( (pSub->isDistinct || pSub->nLimit>=0) &&  (pSrc->nSrc>1 || isAgg) ){       return 0;    }    if( (p->isDistinct || p->nLimit>=0) && subqueryIsAgg ) return 0;    if( p->pOrderBy && pSub->pOrderBy ) return 0; +  /* Restriction 3:  If the subquery is a join, make sure the subquery is  +  ** not used as the right operand of an outer join.  Examples of why this +  ** is not allowed: +  ** +  **         t1 LEFT OUTER JOIN (t2 JOIN t3) +  ** +  ** If we flatten the above, we would get +  ** +  **         (t1 LEFT OUTER JOIN t2) JOIN t3 +  ** +  ** which is not at all the same thing. +  */ +  if( pSubSrc->nSrc>1 && iFrom>0 && (pSrc->a[iFrom-1].jointype & JT_OUTER)!=0 ){ +    return 0; +  } +    /* If we reach this point, it means flattening is permitted for the -  ** i-th entry of the FROM clause in the outer query. +  ** iFrom-th entry of the FROM clause in the outer query. +  */ + +  /* Move all of the FROM elements of the subquery into the +  ** the FROM clause of the outer query.  Before doing this, remember +  ** the cursor number for the original outer query FROM element in +  ** iParent.  The iParent cursor will never be used.  Subsequent code +  ** will scan expressions looking for iParent references and replace +  ** those references with expressions that resolve to the subquery FROM +  ** elements we are now copying in. +  */ +  iParent = pSrc->a[iFrom].iCursor; +  { +    int nSubSrc = pSubSrc->nSrc; +    int jointype = pSrc->a[iFrom].jointype; + +    if( pSrc->a[iFrom].pTab && pSrc->a[iFrom].pTab->isTransient ){ +      sqliteDeleteTable(0, pSrc->a[iFrom].pTab); +    } +    sqliteFree(pSrc->a[iFrom].zName); +    sqliteFree(pSrc->a[iFrom].zAlias); +    if( nSubSrc>1 ){ +      int extra = nSubSrc - 1; +      for(i=1; i<nSubSrc; i++){ +        pSrc = sqliteSrcListAppend(pSrc, 0, 0); +      } +      p->pSrc = pSrc; +      for(i=pSrc->nSrc-1; i-extra>=iFrom; i--){ +        pSrc->a[i] = pSrc->a[i-extra]; +      } +    } +    for(i=0; i<nSubSrc; i++){ +      pSrc->a[i+iFrom] = pSubSrc->a[i]; +      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); +    } +    pSrc->a[iFrom+nSubSrc-1].jointype = jointype; +  } + +  /* Now begin substituting subquery result set expressions for  +  ** references to the iParent in the outer query. +  **  +  ** Example: +  ** +  **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; +  **   \                     \_____________ subquery __________/          / +  **    \_____________________ outer query ______________________________/ +  ** +  ** We look at every expression in the outer query and every place we see +  ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".    */ -  iParent = p->base + iFrom; -  iSub = pSub->base; -  substExprList(p->pEList, iParent, pSub->pEList, iSub); +  substExprList(p->pEList, iParent, pSub->pEList);    pList = p->pEList;    for(i=0; i<pList->nExpr; i++){      Expr *pExpr; @@ -1657,22 +1697,18 @@ static int flattenSubquery(      }    }    if( isAgg ){ -    substExprList(p->pGroupBy, iParent, pSub->pEList, iSub); -    substExpr(p->pHaving, iParent, pSub->pEList, iSub); +    substExprList(p->pGroupBy, iParent, pSub->pEList); +    substExpr(p->pHaving, iParent, pSub->pEList);    }    if( pSub->pOrderBy ){      assert( p->pOrderBy==0 );      p->pOrderBy = pSub->pOrderBy;      pSub->pOrderBy = 0; -    changeTablesInList(p->pOrderBy, iSub, iParent);    }else if( p->pOrderBy ){ -    substExprList(p->pOrderBy, iParent, pSub->pEList, iSub); +    substExprList(p->pOrderBy, iParent, pSub->pEList);    }    if( pSub->pWhere ){      pWhere = sqliteExprDup(pSub->pWhere); -    if( iParent!=iSub ){ -      changeTables(pWhere, iSub, iParent); -    }    }else{      pWhere = 0;    } @@ -1680,12 +1716,9 @@ static int flattenSubquery(      assert( p->pHaving==0 );      p->pHaving = p->pWhere;      p->pWhere = pWhere; -    substExpr(p->pHaving, iParent, pSub->pEList, iSub); +    substExpr(p->pHaving, iParent, pSub->pEList);      if( pSub->pHaving ){        Expr *pHaving = sqliteExprDup(pSub->pHaving); -      if( iParent!=iSub ){ -        changeTables(pHaving, iSub, iParent); -      }        if( p->pHaving ){          p->pHaving = sqliteExpr(TK_AND, p->pHaving, pHaving, 0);        }else{ @@ -1694,19 +1727,23 @@ static int flattenSubquery(      }      assert( p->pGroupBy==0 );      p->pGroupBy = sqliteExprListDup(pSub->pGroupBy); -    if( iParent!=iSub ){ -      changeTablesInList(p->pGroupBy, iSub, iParent); -    }    }else if( p->pWhere==0 ){      p->pWhere = pWhere;    }else{ -    substExpr(p->pWhere, iParent, pSub->pEList, iSub); +    substExpr(p->pWhere, iParent, pSub->pEList);      if( pWhere ){        p->pWhere = sqliteExpr(TK_AND, p->pWhere, pWhere, 0);      }    } + +  /* The flattened query is distinct if either the inner or the +  ** outer query is distinct.  +  */    p->isDistinct = p->isDistinct || pSub->isDistinct; +  /* Transfer the limit expression from the subquery to the outer +  ** query. +  */    if( pSub->nLimit>=0 ){      if( p->nLimit<0 ){        p->nLimit = pSub->nLimit; @@ -1716,27 +1753,9 @@ static int flattenSubquery(    }    p->nOffset += pSub->nOffset; -  /* If the subquery contains subqueries of its own, that were not -  ** flattened, then code will have already been generated to put -  ** the results of those sub-subqueries into VDBE cursors relative -  ** to the subquery.  We must translate the cursor number into values -  ** suitable for use by the outer query. +  /* Finially, delete what is left of the subquery and return +  ** success.    */ -  for(i=0; i<pSubSrc->nSrc; i++){ -    Vdbe *v; -    if( pSubSrc->a[i].pSelect==0 ) continue; -    v = sqliteGetVdbe(pParse); -    sqliteVdbeAddOp(v, OP_RenameCursor, pSub->base+i, p->base+i); -  } - -  if( pSrc->a[iFrom].pTab && pSrc->a[iFrom].pTab->isTransient ){ -    sqliteDeleteTable(0, pSrc->a[iFrom].pTab); -  } -  pSrc->a[iFrom].pTab = pSubSrc->a[0].pTab; -  pSubSrc->a[0].pTab = 0; -  assert( pSrc->a[iFrom].pSelect==pSub ); -  pSrc->a[iFrom].pSelect = pSubSrc->a[0].pSelect; -  pSubSrc->a[0].pSelect = 0;    sqliteSelectDelete(pSub);    return 1;  } @@ -1768,7 +1787,6 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){    Index *pIdx;    int base;    Vdbe *v; -  int openOp;    int seekOp;    int cont;    ExprList eList; @@ -1818,8 +1836,8 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){    v = sqliteGetVdbe(pParse);    if( v==0 ) return 0;    if( eDest==SRT_Callback ){ -    generateColumnNames(pParse, p->base, p->pSrc, p->pEList); -    generateColumnTypes(pParse, p->base, p->pSrc, p->pEList); +    generateColumnNames(pParse, p->pSrc, p->pEList); +    generateColumnTypes(pParse, p->pSrc, p->pEList);    }    /* Generating code to find the min or the max.  Basically all we have @@ -1827,18 +1845,17 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){    ** the min() or max() is on the INTEGER PRIMARY KEY, then find the first    ** or last entry in the main table.    */ -  if( !pParse->schemaVerified && (pParse->db->flags & SQLITE_InTrans)==0 ){ -    sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0); -    pParse->schemaVerified = 1; -  } -  openOp = pTab->isTemp ? OP_OpenAux : OP_Open; -  base = p->base; -  sqliteVdbeAddOp(v, openOp, base, pTab->tnum); +  sqliteCodeVerifySchema(pParse, pTab->iDb); +  base = p->pSrc->a[0].iCursor; +  sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +  sqliteVdbeAddOp(v, OP_OpenRead, base, pTab->tnum);    sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); +  cont = sqliteVdbeMakeLabel(v);    if( pIdx==0 ){      sqliteVdbeAddOp(v, seekOp, base, 0);    }else{ -    sqliteVdbeAddOp(v, openOp, base+1, pIdx->tnum); +    sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenRead, base+1, pIdx->tnum);      sqliteVdbeChangeP3(v, -1, pIdx->zName, P3_STATIC);      sqliteVdbeAddOp(v, seekOp, base+1, 0);      sqliteVdbeAddOp(v, OP_IdxRecno, base+1, 0); @@ -1849,7 +1866,6 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){    memset(&eListItem, 0, sizeof(eListItem));    eList.a = &eListItem;    eList.a[0].pExpr = pExpr; -  cont = sqliteVdbeMakeLabel(v);    selectInnerLoop(pParse, p, &eList, 0, 0, 0, -1, eDest, iParm, cont, cont);    sqliteVdbeResolveLabel(v, cont);    sqliteVdbeAddOp(v, OP_Close, base, 0); @@ -1929,11 +1945,10 @@ int sqliteSelect(    Expr *pHaving;         /* The HAVING clause.  May be NULL */    int isDistinct;        /* True if the DISTINCT keyword is present */    int distinct;          /* Table to use for the distinct set */ -  int base;              /* First cursor available for use */    int rc = 1;            /* Value to return from this function */    if( sqlite_malloc_failed || pParse->nErr || p==0 ) return 1; -  if( sqliteAuthCheck(pParse, SQLITE_SELECT, 0, 0) ) return 1; +  if( sqliteAuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;    /* If there is are a sequence of queries, do the earlier ones first.    */ @@ -1950,12 +1965,9 @@ int sqliteSelect(    pHaving = p->pHaving;    isDistinct = p->isDistinct; -  /* Allocate a block of VDBE cursors, one for each table in the FROM clause. -  ** The WHERE processing requires that the cursors for the tables in the -  ** FROM clause be consecutive. +  /* Allocate VDBE cursors for each table in the FROM clause    */ -  base = p->base = pParse->nTab; -  pParse->nTab += pTabList->nSrc; +  sqliteSrcListAssignCursors(pParse, pTabList);    /*     ** Do not even attempt to generate any code if we have already seen @@ -1978,9 +1990,8 @@ int sqliteSelect(    ** only a single column may be output.    */    if( (eDest==SRT_Mem || eDest==SRT_Set) && pEList->nExpr>1 ){ -    sqliteSetString(&pParse->zErrMsg, "only a single result allowed for " -       "a SELECT that is part of an expression", 0); -    pParse->nErr++; +    sqliteErrorMsg(pParse, "only a single result allowed for " +       "a SELECT that is part of an expression");      goto select_end;    } @@ -2002,7 +2013,7 @@ int sqliteSelect(    ** Resolve the column names and do a semantics check on all the expressions.    */    for(i=0; i<pEList->nExpr; i++){ -    if( sqliteExprResolveIds(pParse, base, pTabList, 0, pEList->a[i].pExpr) ){ +    if( sqliteExprResolveIds(pParse, pTabList, 0, pEList->a[i].pExpr) ){        goto select_end;      }      if( sqliteExprCheck(pParse, pEList->a[i].pExpr, 1, &isAgg) ){ @@ -2010,22 +2021,20 @@ int sqliteSelect(      }    }    if( pWhere ){ -    if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pWhere) ){ +    if( sqliteExprResolveIds(pParse, pTabList, pEList, pWhere) ){        goto select_end;      }      if( sqliteExprCheck(pParse, pWhere, 0, 0) ){        goto select_end;      } -    sqliteOracle8JoinFixup(base, pTabList, pWhere); +    sqliteOracle8JoinFixup(pTabList, pWhere);    }    if( pHaving ){      if( pGroupBy==0 ){ -      sqliteSetString(&pParse->zErrMsg, "a GROUP BY clause is required " -         "before HAVING", 0); -      pParse->nErr++; +      sqliteErrorMsg(pParse, "a GROUP BY clause is required before HAVING");        goto select_end;      } -    if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pHaving) ){ +    if( sqliteExprResolveIds(pParse, pTabList, pEList, pHaving) ){        goto select_end;      }      if( sqliteExprCheck(pParse, pHaving, 1, &isAgg) ){ @@ -2040,7 +2049,7 @@ int sqliteSelect(          sqliteExprDelete(pE);          pE = pOrderBy->a[i].pExpr = sqliteExprDup(pEList->a[iCol-1].pExpr);        } -      if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pE) ){ +      if( sqliteExprResolveIds(pParse, pTabList, pEList, pE) ){          goto select_end;        }        if( sqliteExprCheck(pParse, pE, isAgg, 0) ){ @@ -2048,16 +2057,13 @@ int sqliteSelect(        }        if( sqliteExprIsConstant(pE) ){          if( sqliteExprIsInteger(pE, &iCol)==0 ){ -          sqliteSetString(&pParse->zErrMsg,  -               "ORDER BY terms must not be non-integer constants", 0); -          pParse->nErr++; +          sqliteErrorMsg(pParse, +             "ORDER BY terms must not be non-integer constants");            goto select_end;          }else if( iCol<=0 || iCol>pEList->nExpr ){ -          char zBuf[2000]; -          sprintf(zBuf,"ORDER BY column number %d out of range - should be " +          sqliteErrorMsg(pParse,  +             "ORDER BY column number %d out of range - should be "               "between 1 and %d", iCol, pEList->nExpr); -          sqliteSetString(&pParse->zErrMsg, zBuf, 0); -          pParse->nErr++;            goto select_end;          }        } @@ -2071,7 +2077,7 @@ int sqliteSelect(          sqliteExprDelete(pE);          pE = pGroupBy->a[i].pExpr = sqliteExprDup(pEList->a[iCol-1].pExpr);        } -      if( sqliteExprResolveIds(pParse, base, pTabList, pEList, pE) ){ +      if( sqliteExprResolveIds(pParse, pTabList, pEList, pE) ){          goto select_end;        }        if( sqliteExprCheck(pParse, pE, isAgg, 0) ){ @@ -2079,16 +2085,13 @@ int sqliteSelect(        }        if( sqliteExprIsConstant(pE) ){          if( sqliteExprIsInteger(pE, &iCol)==0 ){ -          sqliteSetString(&pParse->zErrMsg,  -               "GROUP BY terms must not be non-integer constants", 0); -          pParse->nErr++; +          sqliteErrorMsg(pParse, +            "GROUP BY terms must not be non-integer constants");            goto select_end;          }else if( iCol<=0 || iCol>pEList->nExpr ){ -          char zBuf[2000]; -          sprintf(zBuf,"GROUP BY column number %d out of range - should be " +          sqliteErrorMsg(pParse, +             "GROUP BY column number %d out of range - should be "               "between 1 and %d", iCol, pEList->nExpr); -          sqliteSetString(&pParse->zErrMsg, zBuf, 0); -          pParse->nErr++;            goto select_end;          }        } @@ -2112,7 +2115,7 @@ int sqliteSelect(    ** step is skipped if the output is going to some other destination.    */    if( eDest==SRT_Callback ){ -    generateColumnNames(pParse, p->base, pTabList, pEList); +    generateColumnNames(pParse, pTabList, pEList);    }    /* Set the limiter @@ -2138,12 +2141,25 @@ int sqliteSelect(    /* Generate code for all sub-queries in the FROM clause    */    for(i=0; i<pTabList->nSrc; i++){ +    const char *zSavedAuthContext; +    int needRestoreContext; +      if( pTabList->a[i].pSelect==0 ) continue; -    sqliteSelect(pParse, pTabList->a[i].pSelect, SRT_TempTable, base+i, -                 p, i, &isAgg); +    if( pTabList->a[i].zName!=0 ){ +      zSavedAuthContext = pParse->zAuthContext; +      pParse->zAuthContext = pTabList->a[i].zName; +      needRestoreContext = 1; +    }else{ +      needRestoreContext = 0; +    } +    sqliteSelect(pParse, pTabList->a[i].pSelect, SRT_TempTable,  +                 pTabList->a[i].iCursor, p, i, &isAgg); +    if( needRestoreContext ){ +      pParse->zAuthContext = zSavedAuthContext; +    }      pTabList = p->pSrc;      pWhere = p->pWhere; -    if( eDest==SRT_Callback ){ +    if( eDest!=SRT_Union && eDest!=SRT_Except && eDest!=SRT_Discard ){        pOrderBy = p->pOrderBy;      }      pGroupBy = p->pGroupBy; @@ -2165,7 +2181,7 @@ int sqliteSelect(    ** than a callback.    */    if( eDest==SRT_Callback ){ -    generateColumnTypes(pParse, p->base, pTabList, pEList); +    generateColumnTypes(pParse, pTabList, pEList);    }    /* If the output is destined for a temporary table, open that table. @@ -2239,7 +2255,7 @@ int sqliteSelect(    /* Begin the database scan    */ -  pWInfo = sqliteWhereBegin(pParse, p->base, pTabList, pWhere, 0,  +  pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 0,                               pGroupBy ? 0 : &pOrderBy);    if( pWInfo==0 ) goto select_end; diff --git a/ext/sqlite/libsqlite/src/sqlite.h.in b/ext/sqlite/libsqlite/src/sqlite.h.in index b567a1a6fb..c3980043f0 100644 --- a/ext/sqlite/libsqlite/src/sqlite.h.in +++ b/ext/sqlite/libsqlite/src/sqlite.h.in @@ -165,6 +165,7 @@ int sqlite_exec(  #define SQLITE_MISUSE      21   /* Library used incorrectly */  #define SQLITE_NOLFS       22   /* Uses OS features not supported on host */  #define SQLITE_AUTH        23   /* Authorization denied */ +#define SQLITE_FORMAT      24   /* Auxiliary database format error */  #define SQLITE_ROW         100  /* sqlite_step() has another row ready */  #define SQLITE_DONE        101  /* sqlite_step() has finished executing */ @@ -512,7 +513,7 @@ int sqlite_aggregate_count(sqlite_func*);  */  int sqlite_set_authorizer(    sqlite*, -  int (*xAuth)(void*,int,const char*,const char*), +  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),    void *pUserData  ); @@ -521,7 +522,11 @@ int sqlite_set_authorizer(  ** be one of the values below.  These values signify what kind of operation  ** is to be authorized.  The 3rd and 4th parameters to the authorization  ** function will be parameters or NULL depending on which of the following -** codes is used as the second parameter. +** codes is used as the second parameter.  The 5th parameter is the name +** of the database ("main", "temp", etc.) if applicable.  The 6th parameter +** is the name of the inner-most trigger or view that is responsible for +** the access attempt or NULL if this access attempt is directly from  +** input SQL code.  **  **                                          Arg-3           Arg-4  */ @@ -675,16 +680,6 @@ int sqlite_step(  */  int sqlite_finalize(sqlite_vm*, char **pzErrMsg); -/* -** Attempt to open the file named in the argument as the auxiliary database -** file.  The auxiliary database file is used to store TEMP tables.  But -** by using this API, it is possible to trick SQLite into opening two -** separate databases and acting on them as if they were one. -** -****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE. ****** -*/ -int sqlite_open_aux_file(sqlite *db, const char *zName, char **pzErrMsg); -  #ifdef __cplusplus  }  /* End of the 'extern "C"' block */  #endif diff --git a/ext/sqlite/libsqlite/src/sqliteInt.h b/ext/sqlite/libsqlite/src/sqliteInt.h index 17fa4787de..6c0713d96b 100644 --- a/ext/sqlite/libsqlite/src/sqliteInt.h +++ b/ext/sqlite/libsqlite/src/sqliteInt.h @@ -58,6 +58,37 @@  #define NULL_DISTINCT_FOR_UNIQUE 1  /* +** The maximum number of attached databases.  This must be at least 2 +** in order to support the main database file (0) and the file used to +** hold temporary tables (1).  And it must be less than 256 because +** an unsigned character is used to stored the database index. +*/ +#define MAX_ATTACHED 10 + +/* +** The next macro is used to determine where TEMP tables and indices +** are stored.  Possible values: +** +**   0    Always use a temporary files +**   1    Use a file unless overridden by "PRAGMA temp_store" +**   2    Use memory unless overridden by "PRAGMA temp_store" +**   3    Always use memory +*/ +#ifndef TEMP_STORE +# define TEMP_STORE 1 +#endif + +/* +** When building SQLite for embedded systems where memory is scarce, +** you can define one or more of the following macros to omit extra +** features of the library and thus keep the size of the library to +** a minimum. +*/ +/* #define SQLITE_OMIT_AUTHORIZATION  1 */ +/* #define SQLITE_OMIT_INMEMORYDB     1 */ +/* #define SQLITE_OMIT_VACUUM         1 */ + +/*  ** Integers of known sizes.  These typedefs might change for architectures  ** where the sizes very.  Preprocessor macros are available so that the  ** types can be conveniently redefined at compile-type.  Like this: @@ -187,6 +218,59 @@ typedef struct Trigger Trigger;  typedef struct TriggerStep TriggerStep;  typedef struct TriggerStack TriggerStack;  typedef struct FKey FKey; +typedef struct Db Db; +typedef struct AuthContext AuthContext; + +/* +** Each database file to be accessed by the system is an instance +** of the following structure.  There are normally two of these structures +** in the sqlite.aDb[] array.  aDb[0] is the main database file and +** aDb[1] is the database file used to hold temporary tables.  Additional +** databases may be attached. +*/ +struct Db { +  char *zName;         /* Name of this database */ +  Btree *pBt;          /* The B*Tree structure for this database file */ +  int schema_cookie;   /* Database schema version number for this file */ +  Hash tblHash;        /* All tables indexed by name */ +  Hash idxHash;        /* All (named) indices indexed by name */ +  Hash trigHash;       /* All triggers indexed by name */ +  Hash aFKey;          /* Foreign keys indexed by to-table */ +  u8 inTrans;          /* True if a transaction is underway for this backend */ +  u16 flags;           /* Flags associated with this database */ +}; + +/* +** These macros can be used to test, set, or clear bits in the  +** Db.flags field. +*/ +#define DbHasProperty(D,I,P)     (((D)->aDb[I].flags&(P))==(P)) +#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].flags&(P))!=0) +#define DbSetProperty(D,I,P)     (D)->aDb[I].flags|=(P) +#define DbClearProperty(D,I,P)   (D)->aDb[I].flags&=~(P) + +/* +** Allowed values for the DB.flags field. +** +** The DB_Locked flag is set when the first OP_Transaction or OP_Checkpoint +** opcode is emitted for a database.  This prevents multiple occurances +** of those opcodes for the same database in the same program.  Similarly, +** the DB_Cookie flag is set when the OP_VerifyCookie opcode is emitted, +** and prevents duplicate OP_VerifyCookies from taking up space and slowing +** down execution. +** +** The DB_SchemaLoaded flag is set after the database schema has been +** read into internal hash tables. +** +** DB_UnresetViews means that one or more views have column names that +** have been filled out.  If the schema changes, these column names might +** changes and so the view will need to be reset. +*/ +#define DB_Locked          0x0001  /* OP_Transaction opcode has been emitted */ +#define DB_Cookie          0x0002  /* OP_VerifyCookie opcode has been emiited */ +#define DB_SchemaLoaded    0x0004  /* The schema has been loaded */ +#define DB_UnresetViews    0x0008  /* Some views have defined column names */ +  /*  ** Each database is an instance of the following structure. @@ -202,25 +286,27 @@ typedef struct FKey FKey;  **     file_format==3    Version 2.6.0. Fix empty-string index bug.  **     file_format==4    Version 2.7.0. Add support for separate numeric and  **                       text datatypes. +** +** The sqlite.temp_store determines where temporary database files +** are stored.  If 1, then a file is created to hold those tables.  If +** 2, then they are held in memory.  0 means use the default value in +** the TEMP_STORE macro.  */  struct sqlite { -  Btree *pBe;                   /* The B*Tree backend */ -  Btree *pBeTemp;               /* Backend for session temporary tables */ +  int nDb;                      /* Number of backends currently in use */ +  Db *aDb;                      /* All backends */ +  Db aDbStatic[2];              /* Static space for the 2 default backends */    int flags;                    /* Miscellanous flags. See below */    u8 file_format;               /* What file format version is this database? */    u8 safety_level;              /* How aggressive at synching data to disk */    u8 want_to_close;             /* Close after all VDBEs are deallocated */ -  int schema_cookie;            /* Magic number that changes with the schema */ -  int next_cookie;              /* Value of schema_cookie after commit */ +  int next_cookie;              /* Next value of aDb[0].schema_cookie */    int cache_size;               /* Number of pages to use in the cache */ +  int temp_store;               /* 1=file, 2=memory, 0=compile-time default */    int nTable;                   /* Number of tables in the database */    void *pBusyArg;               /* 1st Argument to the busy callback */    int (*xBusyCallback)(void *,const char*,int);  /* The busy callback */ -  Hash tblHash;                 /* All tables indexed by name */ -  Hash idxHash;                 /* All (named) indices indexed by name */ -  Hash trigHash;                /* All triggers indexed by name */    Hash aFunc;                   /* All functions that can be in SQL exprs */ -  Hash aFKey;                   /* Foreign keys indexed by to-table */    int lastRowid;                /* ROWID of most recent insert */    int priorNewRowid;            /* Last randomly generated ROWID */    int onError;                  /* Default conflict algorithm */ @@ -232,13 +318,18 @@ struct sqlite {    void *pTraceArg;                       /* Argument to the trace function */  #endif  #ifndef SQLITE_OMIT_AUTHORIZATION -  int (*xAuth)(void*,int,const char*,const char*); /* Access Auth function */ +  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); +                                /* Access authorization function */    void *pAuthArg;               /* 1st argument to the access auth function */  #endif  };  /* -** Possible values for the sqlite.flags. +** Possible values for the sqlite.flags and or Db.flags fields. +** +** On sqlite.flags, the SQLITE_InTrans value means that we have +** executed a BEGIN.  On Db.flags, SQLITE_InTrans means a statement +** transaction is active on that particular database file.  */  #define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */  #define SQLITE_Initialized    0x00000002  /* True after initialization */ @@ -251,10 +342,7 @@ struct sqlite {                                            /*   the count using a callback. */  #define SQLITE_NullCallback   0x00000080  /* Invoke the callback once if the */                                            /*   result set is empty */ -#define SQLITE_ResultDetails  0x00000100  /* Details added to result set */ -#define SQLITE_UnresetViews   0x00000200  /* True if one or more views have */ -                                          /*   defined column names */ -#define SQLITE_ReportTypes    0x00000400  /* Include information on datatypes */ +#define SQLITE_ReportTypes    0x00000200  /* Include information on datatypes */                                            /*   in 4th argument of callback */  /* @@ -314,26 +402,27 @@ struct Column {  ** Each SQL table is represented in memory by an instance of the  ** following structure.  ** -** Expr.zName is the name of the table.  The case of the original +** Table.zName is the name of the table.  The case of the original  ** CREATE TABLE statement is stored, but case is not significant for  ** comparisons.  ** -** Expr.nCol is the number of columns in this table.  Expr.aCol is a +** Table.nCol is the number of columns in this table.  Table.aCol is a  ** pointer to an array of Column structures, one for each column.  ** -** If the table has an INTEGER PRIMARY KEY, then Expr.iPKey is the index of -** the column that is that key.   Otherwise Expr.iPKey is negative.  Note +** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of +** the column that is that key.   Otherwise Table.iPKey is negative.  Note  ** that the datatype of the PRIMARY KEY must be INTEGER for this field to  ** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of  ** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid -** is generated for each row of the table.  Expr.hasPrimKey is true if +** is generated for each row of the table.  Table.hasPrimKey is true if  ** the table has any PRIMARY KEY, INTEGER or otherwise.  ** -** Expr.tnum is the page number for the root BTree page of the table in the -** database file.  If Expr.isTemp is true, then this page occurs in the -** auxiliary database file, not the main database file.  If Expr.isTransient +** Table.tnum is the page number for the root BTree page of the table in the +** database file.  If Table.iDb is the index of the database table backend +** in sqlite.aDb[].  0 is for the main database and 1 is for the file that +** holds temporary tables and indices.  If Table.isTransient  ** is true, then the table is stored in a file that is automatically deleted -** when the VDBE cursor to the table is closed.  In this case Expr.tnum  +** when the VDBE cursor to the table is closed.  In this case Table.tnum   ** refers VDBE cursor number that holds the table open, not to the root  ** page number.  Transient tables are used to hold the results of a  ** sub-query that appears instead of a real table name in the FROM clause  @@ -348,7 +437,7 @@ struct Table {    int tnum;        /* Root BTree node for this table (see note above) */    Select *pSelect; /* NULL for tables.  Points to definition if a view. */    u8 readOnly;     /* True if this table should not be written by the user */ -  u8 isTemp;       /* True if stored in db->pBeTemp instead of db->pBe */ +  u8 iDb;          /* Index into sqlite.aDb[] of the backend for this table */    u8 isTransient;  /* True if automatically deleted when VDBE finishes */    u8 hasPrimKey;   /* True if there exists a primary key */    u8 keyConf;      /* What to do in case of uniqueness conflict on iPKey */ @@ -376,7 +465,7 @@ struct Table {  ** the from-table is created.  The existance of the to-table is not checked  ** until an attempt is made to insert data into the from-table.  ** -** The sqlite.aFKey hash table stores pointers to to this structure +** The sqlite.aFKey hash table stores pointers to this structure  ** given the name of a to-table.  For each to-table, all foreign keys  ** associated with that table are on a linked list using the FKey.pNextTo  ** field. @@ -454,6 +543,13 @@ struct FKey {  ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].  ** The second column to be indexed (c1) has an index of 0 in  ** Ex1.aCol[], hence Ex2.aiColumn[1]==0. +** +** The Index.onError field determines whether or not the indexed columns +** must be unique and what to do if they are not.  When Index.onError=OE_None, +** it means this is not a unique index.  Otherwise it is a unique index +** and the value of Index.onError indicate the which conflict resolution  +** algorithm to employ whenever an attempt is made to insert a non-unique +** element.  */  struct Index {    char *zName;     /* Name of this index */ @@ -461,9 +557,9 @@ struct Index {    int *aiColumn;   /* Which columns are used by this index.  1st is 0 */    Table *pTable;   /* The SQL table being indexed */    int tnum;        /* Page containing root of this index in database file */ -  u8 isUnique;     /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */    u8 onError;      /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */    u8 autoIndex;    /* True if is automatically created (ex: by UNIQUE) */ +  u8 iDb;          /* Index in sqlite.aDb[] of where this index is stored */    Index *pNext;    /* The next index associated with the same table */  }; @@ -514,7 +610,8 @@ struct Token {  struct Expr {    u8 op;                 /* Operation performed by this node */    u8 dataType;           /* Either SQLITE_SO_TEXT or SQLITE_SO_NUM */ -  u16 flags;             /* Various flags.  See below */ +  u8 iDb;                /* Database referenced by this expression */ +  u8 flags;              /* Various flags.  See below */    Expr *pLeft, *pRight;  /* Left and right subnodes */    ExprList *pList;       /* A list of expressions used as function arguments                           ** or in "<expr> IN (<expr-list)" */ @@ -589,18 +686,26 @@ struct IdList {  ** The following structure describes the FROM clause of a SELECT statement.  ** Each table or subquery in the FROM clause is a separate element of  ** the SrcList.a[] array. +** +** With the addition of multiple database support, the following structure +** can also be used to describe a particular table such as the table that +** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL, +** such a table must be a simple name: ID.  But in SQLite, the table can +** now be identified by a database name, a dot, then the table name: ID.ID.  */  struct SrcList {    int nSrc;        /* Number of tables or subqueries in the FROM clause */    struct SrcList_item { +    char *zDatabase;  /* Name of database holding this table */      char *zName;      /* Name of the table */      char *zAlias;     /* The "B" part of a "A AS B" phrase.  zName is the "A" */      Table *pTab;      /* An SQL table corresponding to zName */      Select *pSelect;  /* A SELECT statement used in place of a table name */      int jointype;     /* Type of join between this table and the next */ +    int iCursor;      /* The VDBE cursor number used to access this table */      Expr *pOn;        /* The ON clause of a join */      IdList *pUsing;   /* The USING clause of a join */ -  } *a;            /* One entry for each identifier on the list */ +  } a[1];             /* One entry for each identifier on the list */  };  /* @@ -645,7 +750,6 @@ struct WhereInfo {    SrcList *pTabList;   /* List of tables in the join */    int iContinue;       /* Jump here to continue with next record */    int iBreak;          /* Jump here to break out of the loop */ -  int base;            /* Index of first Open opcode */    int nLevel;          /* Number of nested loop */    int savedNTab;       /* Value of pParse->nTab before WhereBegin() */    int peakNTab;        /* Value of pParse->nTab after WhereBegin() */ @@ -682,7 +786,6 @@ struct Select {    Select *pPrior;        /* Prior select in a compound select statement */    int nLimit, nOffset;   /* LIMIT and OFFSET values.  -1 means not used */    char *zSelect;         /* Complete text of the SELECT command */ -  int base;              /* Index of VDBE cursor for left-most FROM table */  };  /* @@ -731,7 +834,6 @@ struct AggExpr {  */  struct Parse {    sqlite *db;          /* The main database structure */ -  Btree *pBe;          /* The database backend */    int rc;              /* Return code from execution */    sqlite_callback xCallback;  /* The callback function */    void *pArg;          /* First argument to the callback function */ @@ -748,10 +850,9 @@ struct Parse {    u8 nameClash;        /* A permanent table name clashes with temp table name */    u8 useAgg;           /* If true, extract field values from the aggregator                         ** while generating expressions.  Normally false */ -  u8 schemaVerified;   /* True if an OP_VerifySchema has been coded someplace -                       ** other than after an OP_Transaction */ -  u8 isTemp;           /* True if parsing temporary tables */ +  u8 iDb;              /* Index of database whose schema is being parsed */    u8 useCallback;      /* True if callbacks should be used to report results */ +  int useDb;           /* Restrict references to tables in this database */    int newTnum;         /* Table number to use when reparsing CREATE TABLEs */    int nErr;            /* Number of errors seen */    int nTab;            /* Number of previously allocated VDBE cursors */ @@ -759,7 +860,18 @@ struct Parse {    int nSet;            /* Number of sets used so far */    int nAgg;            /* Number of aggregate expressions */    AggExpr *aAgg;       /* An array of aggregate expressions */ -  TriggerStack *trigStack; +  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ +  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */ +  TriggerStack *trigStack;  /* Trigger actions being coded */ +}; + +/* +** An instance of the following structure can be declared on a stack and used +** to save the Parse.zAuthContext value so that it can be restored later. +*/ +struct AuthContext { +  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */ +  Parse *pParse;              /* The Parse structure */  };  /* @@ -776,24 +888,13 @@ struct Parse {   *   * The "step_list" member points to the first element of a linked list   * containing the SQL statements specified as the trigger program. - * - * When a trigger is initially created, the "isCommit" member is set to FALSE. - * When a transaction is rolled back, any Trigger structures with "isCommit" set - * to FALSE are deleted by the logic in sqliteRollbackInternalChanges(). When - * a transaction is commited, the "isCommit" member is set to TRUE for any - * Trigger structures for which it is FALSE. - * - * When a trigger is dropped, using the sqliteDropTrigger() interfaced, it is  - * removed from the trigHash hash table and added to the trigDrop hash table. - * If the transaction is rolled back, the trigger is re-added into the trigHash - * hash table (and hence the database schema). If the transaction is commited, - * then the Trigger structure is deleted permanently.   */  struct Trigger {    char *name;             /* The name of the trigger                        */    char *table;            /* The table or view to which the trigger applies */ -  int op;                 /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */ -  int tr_tm;              /* One of TK_BEFORE, TK_AFTER */ +  u8 iDb;                 /* Database containing this trigger               */ +  u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */ +  u8 tr_tm;               /* One of TK_BEFORE, TK_AFTER */    Expr *pWhen;            /* The WHEN clause of the expresion (may be NULL) */    IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,                               the <column-list> is stored here */ @@ -844,6 +945,7 @@ struct Trigger {  struct TriggerStep {    int op;              /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */    int orconf;          /* OE_Rollback etc. */ +  Trigger *pTrig;      /* The trigger that this step is a part of */    Select *pSelect;     /* Valid for SELECT and sometimes   			  INSERT steps (when pExprList == 0) */ @@ -889,9 +991,8 @@ struct TriggerStack {    int oldIdx;          /* Index of vdbe cursor to "old" temp table */    int orconf;          /* Current orconf policy */    int ignoreJump;      /* where to jump to for a RAISE(IGNORE) */ -  Trigger *pTrigger; - -  TriggerStack *pNext; +  Trigger *pTrigger;   /* The trigger currently being coded */ +  TriggerStack *pNext; /* Next trigger down on the trigger stack */  };  /* @@ -907,6 +1008,7 @@ extern int always_code_trigger_setup;  int sqliteStrICmp(const char *, const char *);  int sqliteStrNICmp(const char *, const char *, int);  int sqliteHashNoCase(const char *, int); +int sqliteIsNumber(const char*);  int sqliteCompare(const char *, const char *);  int sqliteSortCompare(const char *, const char *);  void sqliteRealToSortable(double r, char *); @@ -929,6 +1031,7 @@ void sqliteRealToSortable(double r, char *);  char *sqliteMPrintf(const char *,...);  void sqliteSetString(char **, const char *, ...);  void sqliteSetNString(char **, ...); +void sqliteErrorMsg(Parse*, const char*, ...);  void sqliteDequote(char*);  int sqliteKeywordCode(const char*, int);  int sqliteRunParser(Parse*, const char*, char **); @@ -939,9 +1042,9 @@ Expr *sqliteExprFunction(ExprList*, Token*);  void sqliteExprDelete(Expr*);  ExprList *sqliteExprListAppend(ExprList*,Expr*,Token*);  void sqliteExprListDelete(ExprList*); -void sqlitePragma(Parse*,Token*,Token*,int); -void sqliteResetInternalSchema(sqlite*);  int sqliteInit(sqlite*, char**); +void sqlitePragma(Parse*,Token*,Token*,int); +void sqliteResetInternalSchema(sqlite*, int);  void sqliteBeginParse(Parse*,int);  void sqliteRollbackInternalChanges(sqlite*);  void sqliteCommitInternalChanges(sqlite*); @@ -958,18 +1061,18 @@ void sqliteAddCollateType(Parse*, int);  void sqliteEndTable(Parse*,Token*,Select*);  void sqliteCreateView(Parse*,Token*,Token*,Select*,int);  int sqliteViewGetColumnNames(Parse*,Table*); -void sqliteViewResetAll(sqlite*);  void sqliteDropTable(Parse*, Token*, int);  void sqliteDeleteTable(sqlite*, Table*); -void sqliteInsert(Parse*, Token*, ExprList*, Select*, IdList*, int); +void sqliteInsert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);  IdList *sqliteIdListAppend(IdList*, Token*);  int sqliteIdListIndex(IdList*,const char*); -SrcList *sqliteSrcListAppend(SrcList*, Token*); +SrcList *sqliteSrcListAppend(SrcList*, Token*, Token*);  void sqliteSrcListAddAlias(SrcList*, Token*); +void sqliteSrcListAssignCursors(Parse*, SrcList*);  void sqliteIdListDelete(IdList*);  void sqliteSrcListDelete(SrcList*); -void sqliteCreateIndex(Parse*, Token*, Token*, IdList*, int, Token*, Token*); -void sqliteDropIndex(Parse*, Token*); +void sqliteCreateIndex(Parse*,Token*,SrcList*,IdList*,int,int,Token*,Token*); +void sqliteDropIndex(Parse*, SrcList*);  void sqliteAddKeyType(Vdbe*, ExprList*);  void sqliteAddIdxKeyType(Vdbe*, Index*);  int sqliteSelect(Parse*, Select*, int, int, Select*, int, int*); @@ -977,19 +1080,20 @@ Select *sqliteSelectNew(ExprList*,SrcList*,Expr*,ExprList*,Expr*,ExprList*,                          int,int,int);  void sqliteSelectDelete(Select*);  void sqliteSelectUnbind(Select*); -Table *sqliteTableNameToTable(Parse*, const char*); -SrcList *sqliteTableTokenToSrcList(Parse*, Token*); -void sqliteDeleteFrom(Parse*, Token*, Expr*); -void sqliteUpdate(Parse*, Token*, ExprList*, Expr*, int); -WhereInfo *sqliteWhereBegin(Parse*, int, SrcList*, Expr*, int, ExprList**); +Table *sqliteSrcListLookup(Parse*, SrcList*); +int sqliteIsReadOnly(Parse*, Table*, int); +void sqliteDeleteFrom(Parse*, SrcList*, Expr*); +void sqliteUpdate(Parse*, SrcList*, ExprList*, Expr*, int); +WhereInfo *sqliteWhereBegin(Parse*, SrcList*, Expr*, int, ExprList**);  void sqliteWhereEnd(WhereInfo*);  void sqliteExprCode(Parse*, Expr*);  void sqliteExprIfTrue(Parse*, Expr*, int, int);  void sqliteExprIfFalse(Parse*, Expr*, int, int); -Table *sqliteFindTable(sqlite*,const char*); -Index *sqliteFindIndex(sqlite*,const char*); +Table *sqliteFindTable(sqlite*,const char*, const char*); +Table *sqliteLocateTable(Parse*,const char*, const char*); +Index *sqliteFindIndex(sqlite*,const char*, const char*);  void sqliteUnlinkAndDeleteIndex(sqlite*,Index*); -void sqliteCopy(Parse*, Token*, Token*, Token*, int); +void sqliteCopy(Parse*, SrcList*, Token*, Token*, int);  void sqliteVacuum(Parse*, Token*);  int sqliteGlobCompare(const unsigned char*,const unsigned char*);  int sqliteLikeCompare(const unsigned char*,const unsigned char*); @@ -998,11 +1102,13 @@ int sqliteExprCheck(Parse*, Expr*, int, int*);  int sqliteExprType(Expr*);  int sqliteExprCompare(Expr*, Expr*);  int sqliteFuncId(Token*); -int sqliteExprResolveIds(Parse*, int, SrcList*, ExprList*, Expr*); +int sqliteExprResolveIds(Parse*, SrcList*, ExprList*, Expr*);  int sqliteExprAnalyzeAggregates(Parse*, Expr*);  Vdbe *sqliteGetVdbe(Parse*);  int sqliteRandomByte(void);  int sqliteRandomInteger(void); +void sqliteRollbackAll(sqlite*); +void sqliteCodeVerifySchema(Parse*, int);  void sqliteBeginTransaction(Parse*, int);  void sqliteCommitTransaction(Parse*);  void sqliteRollbackTransaction(Parse*); @@ -1012,7 +1118,7 @@ int sqliteIsRowid(const char*);  void sqliteGenerateRowDelete(sqlite*, Vdbe*, Table*, int, int);  void sqliteGenerateRowIndexDelete(sqlite*, Vdbe*, Table*, int, char*);  void sqliteGenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); -void sqliteCompleteInsertion(Parse*, Table*, int, char*, int, int); +void sqliteCompleteInsertion(Parse*, Table*, int, char*, int, int, int);  void sqliteBeginWriteOperation(Parse*, int, int);  void sqliteEndWriteOperation(Parse*);  Expr *sqliteExprDup(Expr*); @@ -1027,13 +1133,14 @@ int sqliteSafetyOn(sqlite*);  int sqliteSafetyOff(sqlite*);  int sqliteSafetyCheck(sqlite*);  void sqliteChangeCookie(sqlite*, Vdbe*); -void sqliteCreateTrigger(Parse*, Token*, int, int, IdList*, Token*,  -                         int, Expr*, TriggerStep*, Token*); -void sqliteDropTrigger(Parse*, Token*, int); +void sqliteBeginTrigger(Parse*, Token*,int,int,IdList*,SrcList*,int,Expr*,int); +void sqliteFinishTrigger(Parse*, TriggerStep*, Token*); +void sqliteDropTrigger(Parse*, SrcList*, int);  int sqliteTriggersExist(Parse* , Trigger* , int , int , int, ExprList*);  int sqliteCodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int,                            int, int);  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); +void sqliteDeleteTriggerStep(TriggerStep*);  TriggerStep *sqliteTriggerSelectStep(Select*);  TriggerStep *sqliteTriggerInsertStep(Token*, IdList*, ExprList*, Select*, int);  TriggerStep *sqliteTriggerUpdateStep(Token*, ExprList*, Expr*, int); @@ -1043,9 +1150,17 @@ int sqliteJoinType(Parse*, Token*, Token*, Token*);  void sqliteCreateForeignKey(Parse*, IdList*, Token*, IdList*, int);  void sqliteDeferForeignKey(Parse*, int);  #ifndef SQLITE_OMIT_AUTHORIZATION -  void sqliteAuthRead(Parse*,Expr*,SrcList*,int); -  int sqliteAuthCheck(Parse*,int, const char*, const char*); +  void sqliteAuthRead(Parse*,Expr*,SrcList*); +  int sqliteAuthCheck(Parse*,int, const char*, const char*, const char*); +  void sqliteAuthContextPush(Parse*, AuthContext*, const char*); +  void sqliteAuthContextPop(AuthContext*);  #else -# define sqliteAuthRead(a,b,c,d) +# define sqliteAuthRead(a,b,c)  # define sqliteAuthCheck(a,b,c,d)    SQLITE_OK +# define sqliteAuthContextPush(a,b,c) +# define sqliteAuthContextPop(a)  #endif +void sqliteAttach(Parse*, Token*, Token*); +void sqliteDetach(Parse*, Token*); +int sqliteBtreeFactory(const sqlite *db, const char *zFilename, +                       int mode, int nPg, Btree **ppBtree); diff --git a/ext/sqlite/libsqlite/src/table.c b/ext/sqlite/libsqlite/src/table.c index eb3118fcc3..71f0b59a3a 100644 --- a/ext/sqlite/libsqlite/src/table.c +++ b/ext/sqlite/libsqlite/src/table.c @@ -172,10 +172,11 @@ int sqlite_get_table(    if( res.nAlloc>res.nData ){      char **azNew;      azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) ); -    if( res.azResult==0 ){ +    if( azNew==0 ){        sqlite_free_table(&res.azResult[1]);        return SQLITE_NOMEM;      } +    res.nAlloc = res.nData+1;      res.azResult = azNew;    }    *pazResult = &res.azResult[1]; @@ -193,6 +194,7 @@ void sqlite_free_table(    if( azResult ){      int i, n;      azResult--; +    if( azResult==0 ) return;      n = (int)azResult[0];      for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }      free(azResult); diff --git a/ext/sqlite/libsqlite/src/tokenize.c b/ext/sqlite/libsqlite/src/tokenize.c index f24da9e181..f053a75934 100644 --- a/ext/sqlite/libsqlite/src/tokenize.c +++ b/ext/sqlite/libsqlite/src/tokenize.c @@ -44,6 +44,7 @@ static Keyword aKeywordTable[] = {    { "AND",               0, TK_AND,              0 },    { "AS",                0, TK_AS,               0 },    { "ASC",               0, TK_ASC,              0 }, +  { "ATTACH",            0, TK_ATTACH,           0 },    { "BEFORE",            0, TK_BEFORE,           0 },    { "BEGIN",             0, TK_BEGIN,            0 },    { "BETWEEN",           0, TK_BETWEEN,          0 }, @@ -59,12 +60,14 @@ static Keyword aKeywordTable[] = {    { "COPY",              0, TK_COPY,             0 },    { "CREATE",            0, TK_CREATE,           0 },    { "CROSS",             0, TK_JOIN_KW,          0 }, +  { "DATABASE",          0, TK_DATABASE,         0 },    { "DEFAULT",           0, TK_DEFAULT,          0 },    { "DEFERRED",          0, TK_DEFERRED,         0 },    { "DEFERRABLE",        0, TK_DEFERRABLE,       0 },    { "DELETE",            0, TK_DELETE,           0 },    { "DELIMITERS",        0, TK_DELIMITERS,       0 },    { "DESC",              0, TK_DESC,             0 }, +  { "DETACH",            0, TK_DETACH,           0 },    { "DISTINCT",          0, TK_DISTINCT,         0 },    { "DROP",              0, TK_DROP,             0 },    { "END",               0, TK_END,              0 }, @@ -349,18 +352,15 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){        return i;      }      case '.': { -      if( !isdigit(z[1]) ){ -        *tokenType = TK_DOT; -        return 1; -      } -      /* Fall thru into the next case */ +      *tokenType = TK_DOT; +      return 1;      }      case '0': case '1': case '2': case '3': case '4':      case '5': case '6': case '7': case '8': case '9': {        *tokenType = TK_INTEGER;        for(i=1; isdigit(z[i]); i++){} -      if( z[i]=='.' ){ -        i++; +      if( z[i]=='.' && isdigit(z[i+1]) ){ +        i += 2;          while( isdigit(z[i]) ){ i++; }          *tokenType = TK_FLOAT;        } @@ -372,8 +372,6 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){          i += 2;          while( isdigit(z[i]) ){ i++; }          *tokenType = TK_FLOAT; -      }else if( z[0]=='.' ){ -        *tokenType = TK_FLOAT;        }        return i;      } @@ -489,8 +487,198 @@ abort_parse:      sqliteDeleteTable(pParse->db, pParse->pNewTable);      pParse->pNewTable = 0;    } +  if( pParse->pNewTrigger ){ +    sqliteDeleteTrigger(pParse->pNewTrigger); +    pParse->pNewTrigger = 0; +  }    if( nErr>0 && (pParse->rc==SQLITE_OK || pParse->rc==SQLITE_DONE) ){      pParse->rc = SQLITE_ERROR;    }    return nErr;  } + +/* +** Token types used by the sqlite_complete() routine.  See the header +** comments on that procedure for additional information. +*/ +#define tkEXPLAIN 0 +#define tkCREATE  1 +#define tkTEMP    2 +#define tkTRIGGER 3 +#define tkEND     4 +#define tkSEMI    5 +#define tkWS      6 +#define tkOTHER   7 + +/* +** Return TRUE if the given SQL string ends in a semicolon. +** +** Special handling is require for CREATE TRIGGER statements. +** Whenever the CREATE TRIGGER keywords are seen, the statement +** must end with ";END;". +** +** This implementation uses a state machine with 7 states: +** +**   (0) START     At the beginning or end of an SQL statement.  This routine +**                 returns 1 if it ends in the START state and 0 if it ends +**                 in any other state. +** +**   (1) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of  +**                 a statement. +** +**   (2) CREATE    The keyword CREATE has been seen at the beginning of a +**                 statement, possibly preceeded by EXPLAIN and/or followed by +**                 TEMP or TEMPORARY +** +**   (3) NORMAL    We are in the middle of statement which ends with a single +**                 semicolon. +** +**   (4) TRIGGER   We are in the middle of a trigger definition that must be +**                 ended by a semicolon, the keyword END, and another semicolon. +** +**   (5) SEMI      We've seen the first semicolon in the ";END;" that occurs at +**                 the end of a trigger definition. +** +**   (6) END       We've seen the ";END" of the ";END;" that occurs at the end +**                 of a trigger difinition. +** +** Transitions between states above are determined by tokens extracted +** from the input.  The following tokens are significant: +** +**   (0) tkEXPLAIN   The "explain" keyword. +**   (1) tkCREATE    The "create" keyword. +**   (2) tkTEMP      The "temp" or "temporary" keyword. +**   (3) tkTRIGGER   The "trigger" keyword. +**   (4) tkEND       The "end" keyword. +**   (5) tkSEMI      A semicolon. +**   (6) tkWS        Whitespace +**   (7) tkOTHER     Any other SQL token. +** +** Whitespace never causes a state transition and is always ignored. +*/ +int sqlite_complete(const char *zSql){ +  u8 state = 0;   /* Current state, using numbers defined in header comment */ +  u8 token;       /* Value of the next token */ + +  /* The following matrix defines the transition from one state to another +  ** according to what token is seen.  trans[state][token] returns the +  ** next state. +  */ +  static const u8 trans[7][8] = { +                     /* Token:                                                */ +     /* State:       **  EXPLAIN  CREATE  TEMP  TRIGGER  END  SEMI  WS  OTHER */ +     /* 0   START: */ {       1,      2,    3,       3,   3,    0,  0,     3, }, +     /* 1 EXPLAIN: */ {       3,      2,    3,       3,   3,    0,  1,     3, }, +     /* 2  CREATE: */ {       3,      3,    2,       4,   3,    0,  2,     3, }, +     /* 3  NORMAL: */ {       3,      3,    3,       3,   3,    0,  3,     3, }, +     /* 4 TRIGGER: */ {       4,      4,    4,       4,   4,    5,  4,     4, }, +     /* 5    SEMI: */ {       4,      4,    4,       4,   6,    5,  5,     4, }, +     /* 6     END: */ {       4,      4,    4,       4,   4,    0,  6,     4, }, +  }; + +  while( *zSql ){ +    switch( *zSql ){ +      case ';': {  /* A semicolon */ +        token = tkSEMI; +        break; +      } +      case ' ': +      case '\r': +      case '\t': +      case '\n': +      case '\f': {  /* White space is ignored */ +        token = tkWS; +        break; +      } +      case '/': {   /* C-style comments */ +        if( zSql[1]!='*' ){ +          token = tkOTHER; +          break; +        } +        zSql += 2; +        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; } +        if( zSql[0]==0 ) return 0; +        zSql++; +        token = tkWS; +        break; +      } +      case '-': {   /* SQL-style comments from "--" to end of line */ +        if( zSql[1]!='-' ){ +          token = tkOTHER; +          break; +        } +        while( *zSql && *zSql!='\n' ){ zSql++; } +        if( *zSql==0 ) return state==0; +        token = tkWS; +        break; +      } +      case '[': {   /* Microsoft-style identifiers in [...] */ +        zSql++; +        while( *zSql && *zSql!=']' ){ zSql++; } +        if( *zSql==0 ) return 0; +        token = tkOTHER; +        break; +      } +      case '"':     /* single- and double-quoted strings */ +      case '\'': { +        int c = *zSql; +        zSql++; +        while( *zSql && *zSql!=c ){ zSql++; } +        if( *zSql==0 ) return 0; +        token = tkOTHER; +        break; +      } +      default: { +        if( isIdChar[(u8)*zSql] ){ +          /* Keywords and unquoted identifiers */ +          int nId; +          for(nId=1; isIdChar[(u8)zSql[nId]]; nId++){} +          switch( *zSql ){ +            case 'c': case 'C': { +              if( nId==6 && sqliteStrNICmp(zSql, "create", 6)==0 ){ +                token = tkCREATE; +              }else{ +                token = tkOTHER; +              } +              break; +            } +            case 't': case 'T': { +              if( nId==7 && sqliteStrNICmp(zSql, "trigger", 7)==0 ){ +                token = tkTRIGGER; +              }else if( nId==4 && sqliteStrNICmp(zSql, "temp", 4)==0 ){ +                token = tkTEMP; +              }else if( nId==9 && sqliteStrNICmp(zSql, "temporary", 9)==0 ){ +                token = tkTEMP; +              }else{ +                token = tkOTHER; +              } +              break; +            } +            case 'e':  case 'E': { +              if( nId==3 && sqliteStrNICmp(zSql, "end", 3)==0 ){ +                token = tkEND; +              }else if( nId==7 && sqliteStrNICmp(zSql, "explain", 7)==0 ){ +                token = tkEXPLAIN; +              }else{ +                token = tkOTHER; +              } +              break; +            } +            default: { +              token = tkOTHER; +              break; +            } +          } +          zSql += nId-1; +        }else{ +          /* Operators and special symbols */ +          token = tkOTHER; +        } +        break; +      } +    } +    state = trans[state][token]; +    zSql++; +  } +  return state==0; +} diff --git a/ext/sqlite/libsqlite/src/trigger.c b/ext/sqlite/libsqlite/src/trigger.c index 03032fe259..227e471534 100644 --- a/ext/sqlite/libsqlite/src/trigger.c +++ b/ext/sqlite/libsqlite/src/trigger.c @@ -15,7 +15,7 @@  /*  ** Delete a linked list of TriggerStep structures.  */ -static void sqliteDeleteTriggerStep(TriggerStep *pTriggerStep){ +void sqliteDeleteTriggerStep(TriggerStep *pTriggerStep){    while( pTriggerStep ){      TriggerStep * pTmp = pTriggerStep;      pTriggerStep = pTriggerStep->pNext; @@ -31,88 +31,90 @@ static void sqliteDeleteTriggerStep(TriggerStep *pTriggerStep){  }  /* -** This is called by the parser when it sees a CREATE TRIGGER statement. See -** comments surrounding struct Trigger in sqliteInt.h for a description of  -** how triggers are stored. +** This is called by the parser when it sees a CREATE TRIGGER statement +** up to the point of the BEGIN before the trigger actions.  A Trigger +** structure is generated based on the information available and stored +** in pParse->pNewTrigger.  After the trigger actions have been parsed, the +** sqliteFinishTrigger() function is called to complete the trigger +** construction process.  */ -void sqliteCreateTrigger( +void sqliteBeginTrigger(    Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */    Token *pName,       /* The name of the trigger */ -  int tr_tm,          /* One of TK_BEFORE, TK_AFTER , TK_INSTEAD */ +  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */    int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */    IdList *pColumns,   /* column list if this is an UPDATE OF trigger */ -  Token *pTableName,  /* The name of the table/view the trigger applies to */ +  SrcList *pTableName,/* The name of the table/view the trigger applies to */    int foreach,        /* One of TK_ROW or TK_STATEMENT */    Expr *pWhen,        /* WHEN clause */ -  TriggerStep *pStepList, /* The triggered program */ -  Token *pAll             /* Token that describes the complete CREATE TRIGGER */ +  int isTemp          /* True if the TEMPORARY keyword is present */  ){    Trigger *nt;    Table   *tab; -  char *zName = 0;    /* Name of the trigger */ +  char *zName = 0;        /* Name of the trigger */ +  sqlite *db = pParse->db; +  int iDb;                /* When database to store the trigger in */    /* Check that:     ** 1. the trigger name does not already exist. -  ** 2. the table (or view) does exist. +  ** 2. the table (or view) does exist in the same database as the trigger.    ** 3. that we are not trying to create a trigger on the sqlite_master table    ** 4. That we are not trying to create an INSTEAD OF trigger on a table.    ** 5. That we are not trying to create a BEFORE or AFTER trigger on a view.    */ +  if( sqlite_malloc_failed ) goto trigger_cleanup; +  assert( pTableName->nSrc==1 ); +  tab = sqliteSrcListLookup(pParse, pTableName); +  if( !tab ){ +    goto trigger_cleanup; +  } +  iDb = isTemp ? 1 : tab->iDb; +  if( iDb>=2 && !pParse->initFlag ){ +    sqliteErrorMsg(pParse, "triggers may not be added to auxiliary " +       "database %s", db->aDb[tab->iDb].zName); +    goto trigger_cleanup; +  } +    zName = sqliteStrNDup(pName->z, pName->n); -  if( sqliteHashFind(&(pParse->db->trigHash), zName, pName->n + 1) ){ -    sqliteSetNString(&pParse->zErrMsg, "trigger ", -1, -        pName->z, pName->n, " already exists", -1, 0); +  if( sqliteHashFind(&(db->aDb[iDb].trigHash), zName,pName->n+1) ){ +    sqliteErrorMsg(pParse, "trigger %T already exists", pName); +    goto trigger_cleanup; +  } +  if( sqliteStrNICmp(tab->zName, "sqlite_", 7)==0 ){ +    sqliteErrorMsg(pParse, "cannot create trigger on system table");      pParse->nErr++;      goto trigger_cleanup;    } +  if( tab->pSelect && tr_tm != TK_INSTEAD ){ +    sqliteErrorMsg(pParse, "cannot create %s trigger on view: %S",  +        (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0); +    goto trigger_cleanup; +  } +  if( !tab->pSelect && tr_tm == TK_INSTEAD ){ +    sqliteErrorMsg(pParse, "cannot create INSTEAD OF" +        " trigger on table: %S", pTableName, 0); +    goto trigger_cleanup; +  } +#ifndef SQLITE_OMIT_AUTHORIZATION    { -    char *tmp_str = sqliteStrNDup(pTableName->z, pTableName->n); -    if( tmp_str==0 ) goto trigger_cleanup; -    tab = sqliteFindTable(pParse->db, tmp_str); -    sqliteFree(tmp_str); -    if( !tab ){ -      sqliteSetNString(&pParse->zErrMsg, "no such table: ", -1, -          pTableName->z, pTableName->n, 0); -      pParse->nErr++; -      goto trigger_cleanup; -    } -    if( sqliteStrICmp(tab->zName, MASTER_NAME)==0 ){ -      sqliteSetString(&pParse->zErrMsg, "cannot create trigger on system " -         "table: " MASTER_NAME, 0); -      pParse->nErr++; +    int code = SQLITE_CREATE_TRIGGER; +    const char *zDb = db->aDb[tab->iDb].zName; +    const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb; +    if( tab->iDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER; +    if( sqliteAuthCheck(pParse, code, zName, tab->zName, zDbTrig) ){        goto trigger_cleanup;      } -    if( sqliteStrICmp(tab->zName, TEMP_MASTER_NAME)==0 ){ -      sqliteSetString(&pParse->zErrMsg, "cannot create trigger on system " -         "table: " TEMP_MASTER_NAME, 0); -      pParse->nErr++; +    if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(tab->iDb), 0, zDb)){        goto trigger_cleanup;      } -    if( tab->pSelect && tr_tm != TK_INSTEAD ){ -      sqliteSetNString(&pParse->zErrMsg, "cannot create ", -1, -	  (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", -1, " trigger on view: ", -1 -          , pTableName->z, pTableName->n, 0); -      goto trigger_cleanup; -    } -    if( !tab->pSelect && tr_tm == TK_INSTEAD ){ -      sqliteSetNString(&pParse->zErrMsg, "cannot create INSTEAD OF", -1,  -	  " trigger on table: ", -1, pTableName->z, pTableName->n, 0); -      goto trigger_cleanup; -    } -#ifndef SQLITE_OMIT_AUTHORIZATION -    { -      int code = SQLITE_CREATE_TRIGGER; -      if( tab->isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER; -      if( sqliteAuthCheck(pParse, code, zName, tab->zName) ){ -        goto trigger_cleanup; -      } -      if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(tab->isTemp), 0)){ -        goto trigger_cleanup; -      } -    } -#endif    } +#endif +  /* INSTEAD OF triggers can only appear on views and BEGIN triggers +  ** cannot appear on views.  So we might as well translate every +  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code +  ** elsewhere. +  */    if (tr_tm == TK_INSTEAD){      tr_tm = TK_BEFORE;    } @@ -122,16 +124,44 @@ void sqliteCreateTrigger(    if( nt==0 ) goto trigger_cleanup;    nt->name = zName;    zName = 0; -  nt->table = sqliteStrNDup(pTableName->z, pTableName->n); +  nt->table = sqliteStrDup(pTableName->a[0].zName);    if( sqlite_malloc_failed ) goto trigger_cleanup; +  nt->iDb = iDb;    nt->op = op;    nt->tr_tm = tr_tm;    nt->pWhen = sqliteExprDup(pWhen); -  sqliteExprDelete(pWhen);    nt->pColumns = sqliteIdListDup(pColumns); -  sqliteIdListDelete(pColumns);    nt->foreach = foreach; +  assert( pParse->pNewTrigger==0 ); +  pParse->pNewTrigger = nt; + +trigger_cleanup: +  sqliteFree(zName); +  sqliteSrcListDelete(pTableName); +  sqliteIdListDelete(pColumns); +  sqliteExprDelete(pWhen); +} + +/* +** This routine is called after all of the trigger actions have been parsed +** in order to complete the process of building the trigger. +*/ +void sqliteFinishTrigger( +  Parse *pParse,          /* Parser context */ +  TriggerStep *pStepList, /* The triggered program */ +  Token *pAll             /* Token that describes the complete CREATE TRIGGER */ +){ +  Trigger *nt;              /* The trigger whose construction is finishing up */ +  sqlite *db = pParse->db;  /* The database */ + +  if( pParse->nErr || pParse->pNewTrigger==0 ) goto triggerfinish_cleanup; +  nt = pParse->pNewTrigger; +  pParse->pNewTrigger = 0;    nt->step_list = pStepList; +  while( pStepList ){ +    pStepList->pTrig = nt; +    pStepList = pStepList->pNext; +  }    /* if we are not initializing, and this trigger is not on a TEMP table,     ** build the sqlite_master entry @@ -152,41 +182,35 @@ void sqliteCreateTrigger(      /* Make an entry in the sqlite_master table */      v = sqliteGetVdbe(pParse); -    if( v==0 ) goto trigger_cleanup; +    if( v==0 ) goto triggerfinish_cleanup;      sqliteBeginWriteOperation(pParse, 0, 0); -    sqliteOpenMasterTable(v, tab->isTemp); +    sqliteOpenMasterTable(v, nt->iDb==1);      addr = sqliteVdbeAddOpList(v, ArraySize(insertTrig), insertTrig); -    sqliteVdbeChangeP3(v, addr, tab->isTemp ? TEMP_MASTER_NAME : MASTER_NAME, -                       P3_STATIC);      sqliteVdbeChangeP3(v, addr+2, nt->name, 0);       sqliteVdbeChangeP3(v, addr+3, nt->table, 0);       sqliteVdbeChangeP3(v, addr+5, pAll->z, pAll->n); -    if( !tab->isTemp ){ -      sqliteChangeCookie(pParse->db, v); +    if( nt->iDb==0 ){ +      sqliteChangeCookie(db, v);      }      sqliteVdbeAddOp(v, OP_Close, 0, 0);      sqliteEndWriteOperation(pParse);    }    if( !pParse->explain ){ -    /* Stick it in the hash-table */ -    sqliteHashInsert(&(pParse->db->trigHash), nt->name, pName->n + 1, nt); - -    /* Attach it to the table object */ -    nt->pNext = tab->pTrigger; -    tab->pTrigger = nt; -    return; +    Table *pTab; +    sqliteHashInsert(&db->aDb[nt->iDb].trigHash,  +                     nt->name, strlen(nt->name)+1, nt); +    pTab = sqliteLocateTable(pParse, nt->table, 0); +    assert( pTab!=0 ); +    nt->pNext = pTab->pTrigger; +    pTab->pTrigger = nt;    }else{ -    sqliteFree(nt->name); -    sqliteFree(nt->table); -    sqliteFree(nt); +    sqliteDeleteTrigger(nt);    } -trigger_cleanup: - -  sqliteFree(zName); -  sqliteIdListDelete(pColumns); -  sqliteExprDelete(pWhen); +triggerfinish_cleanup: +  sqliteDeleteTrigger(pParse->pNewTrigger); +  pParse->pNewTrigger = 0;    sqliteDeleteTriggerStep(pStepList);  } @@ -323,6 +347,7 @@ TriggerStep *sqliteTriggerDeleteStep(Token *pTableName, Expr *pWhere){  ** Recursively delete a Trigger structure  */  void sqliteDeleteTrigger(Trigger *pTrigger){ +  if( pTrigger==0 ) return;    sqliteDeleteTriggerStep(pTrigger->step_list);    sqliteFree(pTrigger->name);    sqliteFree(pTrigger->table); @@ -342,57 +367,53 @@ void sqliteDeleteTrigger(Trigger *pTrigger){   * table. This is so that the trigger can be restored into the database schema   * if the transaction is rolled back.   */ -void sqliteDropTrigger(Parse *pParse, Token *pName, int nested){ -  char *zName; +void sqliteDropTrigger(Parse *pParse, SrcList *pName, int nested){    Trigger *pTrigger;    Table   *pTable;    Vdbe *v; - -  zName = sqliteStrNDup(pName->z, pName->n); - -  /* ensure that the trigger being dropped exists */ -  pTrigger = sqliteHashFind(&(pParse->db->trigHash), zName, pName->n + 1);  +  int i; +  const char *zDb; +  const char *zName; +  int nName; +  sqlite *db = pParse->db; + +  if( sqlite_malloc_failed ) goto drop_trigger_cleanup; +  assert( pName->nSrc==1 ); +  zDb = pName->a[0].zDatabase; +  zName = pName->a[0].zName; +  nName = strlen(zName); +  for(i=0; i<db->nDb; i++){ +    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */ +    if( zDb && sqliteStrICmp(db->aDb[j].zName, zDb) ) continue; +    pTrigger = sqliteHashFind(&(db->aDb[j].trigHash), zName, nName+1); +    if( pTrigger ) break; +  }    if( !pTrigger ){ -    sqliteSetNString(&pParse->zErrMsg, "no such trigger: ", -1, -        zName, -1, 0); -    sqliteFree(zName); -    return; +    sqliteErrorMsg(pParse, "no such trigger: %S", pName, 0); +    goto drop_trigger_cleanup; +  } +  assert( pTrigger->iDb<db->nDb ); +  if( pTrigger->iDb>=2 ){ +    sqliteErrorMsg(pParse, "triggers may not be removed from " +       "auxiliary database %s", db->aDb[pTrigger->iDb].zName); +    goto drop_trigger_cleanup;    } -  pTable = sqliteFindTable(pParse->db, pTrigger->table); +  pTable = sqliteFindTable(db, pTrigger->table, db->aDb[pTrigger->iDb].zName);    assert(pTable); +  assert( pTable->iDb==pTrigger->iDb || pTrigger->iDb==1 );  #ifndef SQLITE_OMIT_AUTHORIZATION    {      int code = SQLITE_DROP_TRIGGER; -    if( pTable->isTemp ) code = SQLITE_DROP_TEMP_TRIGGER; -    if( sqliteAuthCheck(pParse, code, pTrigger->name, pTable->zName) || -      sqliteAuthCheck(pParse, SQLITE_DELETE, SCHEMA_TABLE(pTable->isTemp),0) ){ -      sqliteFree(zName); -      return; +    const char *zDb = db->aDb[pTrigger->iDb].zName; +    const char *zTab = SCHEMA_TABLE(pTrigger->iDb); +    if( pTrigger->iDb ) code = SQLITE_DROP_TEMP_TRIGGER; +    if( sqliteAuthCheck(pParse, code, pTrigger->name, pTable->zName, zDb) || +      sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){ +      goto drop_trigger_cleanup;      }    }  #endif -  /* -   * If this is not an "explain", then delete the trigger structure. -   */ -  if( !pParse->explain ){ -    if( pTable->pTrigger == pTrigger ){ -      pTable->pTrigger = pTrigger->pNext; -    }else{ -      Trigger *cc = pTable->pTrigger; -      while( cc ){  -        if( cc->pNext == pTrigger ){ -          cc->pNext = cc->pNext->pNext; -          break; -        } -        cc = cc->pNext; -      } -      assert(cc); -    } -    sqliteHashInsert(&(pParse->db->trigHash), zName, pName->n + 1, NULL); -    sqliteDeleteTrigger(pTrigger); -  } -    /* Generate code to destroy the database record of the trigger.    */    if( pTable!=0 && !nested && (v = sqliteGetVdbe(pParse))!=0 ){ @@ -409,17 +430,39 @@ void sqliteDropTrigger(Parse *pParse, Token *pName, int nested){      };      sqliteBeginWriteOperation(pParse, 0, 0); -    sqliteOpenMasterTable(v, pTable->isTemp); +    sqliteOpenMasterTable(v, pTrigger->iDb);      base = sqliteVdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);      sqliteVdbeChangeP3(v, base+1, zName, 0); -    if( !pTable->isTemp ){ -      sqliteChangeCookie(pParse->db, v); +    if( pTrigger->iDb==0 ){ +      sqliteChangeCookie(db, v);      }      sqliteVdbeAddOp(v, OP_Close, 0, 0);      sqliteEndWriteOperation(pParse);    } -  sqliteFree(zName); +  /* +   * If this is not an "explain", then delete the trigger structure. +   */ +  if( !pParse->explain ){ +    if( pTable->pTrigger == pTrigger ){ +      pTable->pTrigger = pTrigger->pNext; +    }else{ +      Trigger *cc = pTable->pTrigger; +      while( cc ){  +        if( cc->pNext == pTrigger ){ +          cc->pNext = cc->pNext->pNext; +          break; +        } +        cc = cc->pNext; +      } +      assert(cc); +    } +    sqliteHashInsert(&(db->aDb[pTrigger->iDb].trigHash), zName, nName+1, 0); +    sqliteDeleteTrigger(pTrigger); +  } + +drop_trigger_cleanup: +  sqliteSrcListDelete(pName);  }  /* @@ -502,8 +545,11 @@ static int codeTriggerProgram(    while( pTriggerStep ){      int saveNTab = pParse->nTab; +    int saveUseDb = pParse->useDb;      orconf = (orconfin == OE_Default)?pTriggerStep->orconf:orconfin;      pParse->trigStack->orconf = orconf; +    pParse->useDb = pTriggerStep->pTrig->iDb; +    if( pParse->useDb==1 ) pParse->useDb = -1;      switch( pTriggerStep->op ){        case TK_SELECT: {  	Select * ss = sqliteSelectDup(pTriggerStep->pSelect);		   @@ -514,24 +560,29 @@ static int codeTriggerProgram(  	break;        }        case TK_UPDATE: { +        SrcList *pSrc; +        pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0);          sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); -        sqliteUpdate(pParse, &pTriggerStep->target,  +        sqliteUpdate(pParse, pSrc,  		sqliteExprListDup(pTriggerStep->pExprList),   		sqliteExprDup(pTriggerStep->pWhere), orconf);          sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);          break;        }        case TK_INSERT: { -        sqliteInsert(pParse, &pTriggerStep->target,  -        sqliteExprListDup(pTriggerStep->pExprList),  -        sqliteSelectDup(pTriggerStep->pSelect),  -        sqliteIdListDup(pTriggerStep->pIdList), orconf); +        SrcList *pSrc; +        pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0); +        sqliteInsert(pParse, pSrc, +          sqliteExprListDup(pTriggerStep->pExprList),  +          sqliteSelectDup(pTriggerStep->pSelect),  +          sqliteIdListDup(pTriggerStep->pIdList), orconf);          break;        }        case TK_DELETE: { +        SrcList *pSrc;          sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); -        sqliteDeleteFrom(pParse, &pTriggerStep->target,  -	    sqliteExprDup(pTriggerStep->pWhere)); +        pSrc = sqliteSrcListAppend(0, &pTriggerStep->target, 0); +        sqliteDeleteFrom(pParse, pSrc, sqliteExprDup(pTriggerStep->pWhere));          sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0);          break;        } @@ -539,6 +590,7 @@ static int codeTriggerProgram(          assert(0);      }       pParse->nTab = saveNTab; +    pParse->useDb = saveUseDb;      pTriggerStep = pTriggerStep->pNext;    } @@ -580,7 +632,7 @@ int sqliteCodeRowTrigger(    TriggerStack * pTriggerStack;    assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE); -  assert(tr_tm == TK_BEFORE || tr_tm == TK_AFTER); +  assert(tr_tm == TK_BEFORE || tr_tm == TK_AFTER );    assert(newIdx != -1 || oldIdx != -1); @@ -609,9 +661,9 @@ int sqliteCodeRowTrigger(        int endTrigger;        SrcList dummyTablist;        Expr * whenExpr; +      AuthContext sContext;        dummyTablist.nSrc = 0; -      dummyTablist.a = 0;        /* Push an entry on to the trigger stack */        pTriggerStack->pTrigger = pTrigger; @@ -621,11 +673,12 @@ int sqliteCodeRowTrigger(        pTriggerStack->pNext = pParse->trigStack;        pTriggerStack->ignoreJump = ignoreJump;        pParse->trigStack = pTriggerStack; +      sqliteAuthContextPush(pParse, &sContext, pTrigger->name);        /* code the WHEN clause */        endTrigger = sqliteVdbeMakeLabel(pParse->pVdbe);        whenExpr = sqliteExprDup(pTrigger->pWhen); -      if( sqliteExprResolveIds(pParse, 0, &dummyTablist, 0, whenExpr) ){ +      if( sqliteExprResolveIds(pParse, &dummyTablist, 0, whenExpr) ){          pParse->trigStack = pParse->trigStack->pNext;          sqliteFree(pTriggerStack);          sqliteExprDelete(whenExpr); @@ -638,6 +691,7 @@ int sqliteCodeRowTrigger(        /* Pop the entry off the trigger stack */        pParse->trigStack = pParse->trigStack->pNext; +      sqliteAuthContextPop(&sContext);        sqliteFree(pTriggerStack);        sqliteVdbeResolveLabel(pParse->pVdbe, endTrigger); @@ -647,147 +701,3 @@ int sqliteCodeRowTrigger(    return 0;  } - -/* - * This function is called to code ON UPDATE and ON DELETE triggers on  - * views.  - * - * This function deletes the data pointed at by the pWhere and pChanges - * arguments before it completes. - */ -void sqliteViewTriggers( -  Parse *pParse,  -  Table *pTab,         /* The view to code triggers on */ -  Expr *pWhere,        /* The WHERE clause of the statement causing triggers*/ -  int orconf,          /* The ON CONFLICT policy specified as part of the -			  statement causing these triggers */ -  ExprList *pChanges   /* If this is an statement causing triggers to fire -			  is an UPDATE, then this list holds the columns -			  to update and the expressions to update them to. -			  See comments for sqliteUpdate(). */ -){ -  int oldIdx = -1; -  int newIdx = -1; -  int *aXRef = 0;    -  Vdbe *v; -  int endOfLoop; -  int startOfLoop; -  Select theSelect; -  Token tblNameToken; - -  assert(pTab->pSelect); - -  tblNameToken.z = pTab->zName; -  tblNameToken.n = strlen(pTab->zName); - -  theSelect.isDistinct = 0; -  theSelect.pEList = sqliteExprListAppend(0, sqliteExpr(TK_ALL, 0, 0, 0), 0); -  theSelect.pSrc   = sqliteSrcListAppend(0, &tblNameToken); -  theSelect.pWhere = pWhere;    pWhere = 0; -  theSelect.pGroupBy = 0; -  theSelect.pHaving = 0; -  theSelect.pOrderBy = 0; -  theSelect.op = TK_SELECT; /* ?? */ -  theSelect.pPrior = 0; -  theSelect.nLimit = -1; -  theSelect.nOffset = -1; -  theSelect.zSelect = 0; -  theSelect.base = 0; - -  v = sqliteGetVdbe(pParse); -  assert(v); -  sqliteBeginWriteOperation(pParse, 1, 0); - -  /* Allocate temp tables */ -  oldIdx = pParse->nTab++; -  sqliteVdbeAddOp(v, OP_OpenTemp, oldIdx, 0); -  if( pChanges ){ -    newIdx = pParse->nTab++; -    sqliteVdbeAddOp(v, OP_OpenTemp, newIdx, 0); -  } - -  /* Snapshot the view */ -  if( sqliteSelect(pParse, &theSelect, SRT_Table, oldIdx, 0, 0, 0) ){ -    goto trigger_cleanup; -  } - -  /* loop thru the view snapshot, executing triggers for each row */ -  endOfLoop = sqliteVdbeMakeLabel(v); -  sqliteVdbeAddOp(v, OP_Rewind, oldIdx, endOfLoop); - -  /* Loop thru the view snapshot, executing triggers for each row */ -  startOfLoop = sqliteVdbeCurrentAddr(v); - -  /* Build the updated row if required */ -  if( pChanges ){ -    int ii; - -    aXRef = sqliteMalloc( sizeof(int) * pTab->nCol ); -    if( aXRef==0 ) goto trigger_cleanup; -    for(ii = 0; ii < pTab->nCol; ii++){ -      aXRef[ii] = -1; -    } - -    for(ii=0; ii<pChanges->nExpr; ii++){ -      int jj; -      if( sqliteExprResolveIds(pParse, oldIdx, theSelect.pSrc , 0,  -            pChanges->a[ii].pExpr) ){ -        goto trigger_cleanup; -      } - -      if( sqliteExprCheck(pParse, pChanges->a[ii].pExpr, 0, 0) ) -        goto trigger_cleanup; - -      for(jj=0; jj<pTab->nCol; jj++){ -        if( sqliteStrICmp(pTab->aCol[jj].zName, pChanges->a[ii].zName)==0 ){ -          aXRef[jj] = ii; -          break; -        } -      } -      if( jj>=pTab->nCol ){ -        sqliteSetString(&pParse->zErrMsg, "no such column: ",  -            pChanges->a[ii].zName, 0); -        pParse->nErr++; -        goto trigger_cleanup; -      } -    } - -    sqliteVdbeAddOp(v, OP_Integer, 13, 0); - -    for(ii = 0; ii<pTab->nCol; ii++){ -      if( aXRef[ii] < 0 ){  -        sqliteVdbeAddOp(v, OP_Column, oldIdx, ii); -      }else{ -        sqliteExprCode(pParse, pChanges->a[aXRef[ii]].pExpr); -      } -    } - -    sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); -    sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); -    sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0); - -    sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE,  -        pTab, newIdx, oldIdx, orconf, endOfLoop); -    sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER,  -        pTab, newIdx, oldIdx, orconf, endOfLoop); -  }else{ -    sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, oldIdx,  -        orconf, endOfLoop); -    sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, oldIdx,  -        orconf, endOfLoop); -  } - -  sqliteVdbeAddOp(v, OP_Next, oldIdx, startOfLoop); - -  sqliteVdbeResolveLabel(v, endOfLoop); -  sqliteEndWriteOperation(pParse); - -trigger_cleanup: -  sqliteFree(aXRef); -  sqliteExprListDelete(pChanges); -  sqliteExprDelete(pWhere); -  sqliteExprListDelete(theSelect.pEList); -  sqliteSrcListDelete(theSelect.pSrc); -  sqliteExprDelete(theSelect.pWhere); -  return; -} diff --git a/ext/sqlite/libsqlite/src/update.c b/ext/sqlite/libsqlite/src/update.c index b5825dd12e..95a49590dc 100644 --- a/ext/sqlite/libsqlite/src/update.c +++ b/ext/sqlite/libsqlite/src/update.c @@ -18,81 +18,76 @@  /*  ** Process an UPDATE statement. +** +**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL; +**          \_______/ \________/     \______/       \________________/ +*            onError   pTabList      pChanges             pWhere  */  void sqliteUpdate(    Parse *pParse,         /* The parser context */ -  Token *pTableName,     /* The table in which we should change things */ +  SrcList *pTabList,     /* The table in which we should change things */    ExprList *pChanges,    /* Things to be changed */    Expr *pWhere,          /* The WHERE clause.  May be null */    int onError            /* How to handle constraint errors */  ){    int i, j;              /* Loop counters */    Table *pTab;           /* The table to be updated */ -  SrcList *pTabList = 0; /* Fake FROM clause containing only pTab */    int addr;              /* VDBE instruction address of the start of the loop */    WhereInfo *pWInfo;     /* Information about the WHERE clause */    Vdbe *v;               /* The virtual database engine */    Index *pIdx;           /* For looping over indices */    int nIdx;              /* Number of indices that need updating */    int nIdxTotal;         /* Total number of indices */ -  int base;              /* Index of first available table cursor */ +  int iCur;              /* VDBE Cursor number of pTab */    sqlite *db;            /* The database structure */    Index **apIdx = 0;     /* An array of indices that need updating too */ -  char *aIdxUsed = 0;    /* aIdxUsed[i] if the i-th index is used */ +  char *aIdxUsed = 0;    /* aIdxUsed[i]==1 if the i-th index is used */    int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the                           ** an expression for the i-th column of the table.                           ** aXRef[i]==-1 if the i-th column is not changed. */ -  int openOp;            /* Opcode used to open tables */    int chngRecno;         /* True if the record number is being changed */    Expr *pRecnoExpr;      /* Expression defining the new record number */    int openAll;           /* True if all indices need to be opened */ +  int isView;            /* Trying to update a view */ +  AuthContext sContext;  /* The authorization context */ -  int row_triggers_exist = 0; +  int before_triggers;         /* True if there are any BEFORE triggers */ +  int after_triggers;          /* True if there are any AFTER triggers */ +  int row_triggers_exist = 0;  /* True if any row triggers exist */    int newIdx      = -1;  /* index of trigger "new" temp table       */    int oldIdx      = -1;  /* index of trigger "old" temp table       */ +  sContext.pParse = 0;    if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup;    db = pParse->db; +  assert( pTabList->nSrc==1 ); -  /* Check for the special case of a VIEW with one or more ON UPDATE triggers  -   * defined  -   */ -  { -    char *zTab = sqliteTableNameFromToken(pTableName); - -    if( zTab != 0 ){ -      pTab = sqliteFindTable(pParse->db, zTab); -      if( pTab ){ -        row_triggers_exist =  -          sqliteTriggersExist(pParse, pTab->pTrigger,  -              TK_UPDATE, TK_BEFORE, TK_ROW, pChanges) || -          sqliteTriggersExist(pParse, pTab->pTrigger,  -              TK_UPDATE, TK_AFTER, TK_ROW, pChanges); -      } -      sqliteFree(zTab); -      if( row_triggers_exist &&  pTab->pSelect ){ -        /* Just fire VIEW triggers */ -        sqliteViewTriggers(pParse, pTab, pWhere, onError, pChanges); -        return; -      } +  /* Locate the table which we want to update.  +  */ +  pTab = sqliteSrcListLookup(pParse, pTabList); +  if( pTab==0 ) goto update_cleanup; +  before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,  +            TK_UPDATE, TK_BEFORE, TK_ROW, pChanges); +  after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger,  +            TK_UPDATE, TK_AFTER, TK_ROW, pChanges); +  row_triggers_exist = before_triggers || after_triggers; +  isView = pTab->pSelect!=0; +  if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){ +    goto update_cleanup; +  } +  if( isView ){ +    if( sqliteViewGetColumnNames(pParse, pTab) ){ +      goto update_cleanup;      }    } - -  /* Locate the table which we want to update.  This table has to be -  ** put in an SrcList structure because some of the subroutines we -  ** will be calling are designed to work with multiple tables and expect -  ** an SrcList* parameter instead of just a Table* parameter. -  */ -  pTabList = sqliteTableTokenToSrcList(pParse, pTableName); -  if( pTabList==0 ) goto update_cleanup; -  pTab = pTabList->a[0].pTab; -  assert( pTab->pSelect==0 );  /* This table is not a VIEW */    aXRef = sqliteMalloc( sizeof(int) * pTab->nCol );    if( aXRef==0 ) goto update_cleanup;    for(i=0; i<pTab->nCol; i++) aXRef[i] = -1; -  /* If there are FOR EACH ROW triggers, allocate temp tables */ +  /* If there are FOR EACH ROW triggers, allocate cursors for the +  ** special OLD and NEW tables +  */    if( row_triggers_exist ){      newIdx = pParse->nTab++;      oldIdx = pParse->nTab++; @@ -103,28 +98,20 @@ void sqliteUpdate(    ** need to occur right after the database cursor.  So go ahead and    ** allocate enough space, just in case.    */ -  base = pParse->nTab++; +  pTabList->a[0].iCursor = iCur = pParse->nTab++;    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){      pParse->nTab++;    } -  /* Resolve the column names in all the expressions in both the -  ** WHERE clause and in the new values.  Also find the column index +  /* Resolve the column names in all the expressions of the +  ** of the UPDATE statement.  Also find the column index    ** for each column to be updated in the pChanges array.  For each    ** column to be updated, make sure we have authorization to change    ** that column.    */ -  if( pWhere ){ -    if( sqliteExprResolveIds(pParse, base, pTabList, 0, pWhere) ){ -      goto update_cleanup; -    } -    if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ -      goto update_cleanup; -    } -  }    chngRecno = 0;    for(i=0; i<pChanges->nExpr; i++){ -    if( sqliteExprResolveIds(pParse, base, pTabList, 0, pChanges->a[i].pExpr) ){ +    if( sqliteExprResolveIds(pParse, pTabList, 0, pChanges->a[i].pExpr) ){        goto update_cleanup;      }      if( sqliteExprCheck(pParse, pChanges->a[i].pExpr, 0, 0) ){ @@ -141,16 +128,14 @@ void sqliteUpdate(        }      }      if( j>=pTab->nCol ){ -      sqliteSetString(&pParse->zErrMsg, "no such column: ",  -         pChanges->a[i].zName, 0); -      pParse->nErr++; +      sqliteErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);        goto update_cleanup;      }  #ifndef SQLITE_OMIT_AUTHORIZATION      {        int rc;        rc = sqliteAuthCheck(pParse, SQLITE_UPDATE, pTab->zName, -                           pTab->aCol[j].zName); +                           pTab->aCol[j].zName, db->aDb[pTab->iDb].zName);        if( rc==SQLITE_DENY ){          goto update_cleanup;        }else if( rc==SQLITE_IGNORE ){ @@ -196,15 +181,43 @@ void sqliteUpdate(      }    } +  /* Resolve the column names in all the expressions in the +  ** WHERE clause. +  */ +  if( pWhere ){ +    if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){ +      goto update_cleanup; +    } +    if( sqliteExprCheck(pParse, pWhere, 0, 0) ){ +      goto update_cleanup; +    } +  } + +  /* Start the view context +  */ +  if( isView ){ +    sqliteAuthContextPush(pParse, &sContext, pTab->zName); +  } +    /* Begin generating code.    */    v = sqliteGetVdbe(pParse);    if( v==0 ) goto update_cleanup; -  sqliteBeginWriteOperation(pParse, 1, !row_triggers_exist && pTab->isTemp); +  sqliteBeginWriteOperation(pParse, 1, pTab->iDb); + +  /* If we are trying to update a view, construct that view into +  ** a temporary table. +  */ +  if( isView ){ +    Select *pView; +    pView = sqliteSelectDup(pTab->pSelect); +    sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0); +    sqliteSelectDelete(pView); +  }    /* Begin the database scan    */ -  pWInfo = sqliteWhereBegin(pParse, base, pTabList, pWhere, 1, 0); +  pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0);    if( pWInfo==0 ) goto update_cleanup;    /* Remember the index of every item to be updated. @@ -222,136 +235,150 @@ void sqliteUpdate(    }    if( row_triggers_exist ){ -    int ii; - -    sqliteVdbeAddOp(v, OP_OpenTemp, oldIdx, 0); -    sqliteVdbeAddOp(v, OP_OpenTemp, newIdx, 0); +    /* Create pseudo-tables for NEW and OLD +    */ +    sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0); +    sqliteVdbeAddOp(v, OP_OpenPseudo, newIdx, 0); +    /* The top of the update loop for when there are triggers. +    */      sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);      addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0);      sqliteVdbeAddOp(v, OP_Dup, 0, 0); +    /* Open a cursor and make it point to the record that is +    ** being updated. +    */      sqliteVdbeAddOp(v, OP_Dup, 0, 0); -    sqliteVdbeAddOp(v, (pTab->isTemp?OP_OpenAux:OP_Open), base, pTab->tnum); -    sqliteVdbeAddOp(v, OP_MoveTo, base, 0); - -    sqliteVdbeAddOp(v, OP_Integer, 13, 0); -    for(ii = 0; ii < pTab->nCol; ii++){ -      if( ii == pTab->iPKey ){ -	sqliteVdbeAddOp(v, OP_Recno, base, 0); -      }else{ -	sqliteVdbeAddOp(v, OP_Column, base, ii); -      } +    if( !isView ){ +      sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);      } -    sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0); +    sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0); + +    /* Generate the OLD table +    */ +    sqliteVdbeAddOp(v, OP_Recno, iCur, 0); +    sqliteVdbeAddOp(v, OP_RowData, iCur, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0); -    sqliteVdbeAddOp(v, OP_Integer, 13, 0); -    for(ii = 0; ii < pTab->nCol; ii++){ -      if( aXRef[ii] < 0 ){ -        if( ii == pTab->iPKey ){ -          sqliteVdbeAddOp(v, OP_Recno, base, 0); -	}else{ -          sqliteVdbeAddOp(v, OP_Column, base, ii); -	} +    /* Generate the NEW table +    */ +    if( chngRecno ){ +      sqliteExprCode(pParse, pRecnoExpr); +    }else{ +      sqliteVdbeAddOp(v, OP_Recno, iCur, 0); +    } +    for(i=0; i<pTab->nCol; i++){ +      if( i==pTab->iPKey ){ +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        continue; +      } +      j = aXRef[i]; +      if( j<0 ){ +        sqliteVdbeAddOp(v, OP_Column, iCur, i);        }else{ -        sqliteExprCode(pParse, pChanges->a[aXRef[ii]].pExpr); +        sqliteExprCode(pParse, pChanges->a[j].pExpr);        }      }      sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0); -    sqliteVdbeAddOp(v, OP_Close, base, 0); - -    sqliteVdbeAddOp(v, OP_Rewind, oldIdx, 0); -    sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0); +    if( !isView ){ +      sqliteVdbeAddOp(v, OP_Close, iCur, 0); +    } +    /* Fire the BEFORE and INSTEAD OF triggers +    */      if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, pTab,             newIdx, oldIdx, onError, addr) ){        goto update_cleanup;      }    } -  /* Rewind the list of records that need to be updated and -  ** open every index that needs updating.  Note that if any -  ** index could potentially invoke a REPLACE conflict resolution  -  ** action, then we need to open all indices because we might need -  ** to be deleting some records. -  */ -  openOp = pTab->isTemp ? OP_OpenWrAux : OP_OpenWrite; -  sqliteVdbeAddOp(v, openOp, base, pTab->tnum); -  if( onError==OE_Replace ){ -    openAll = 1; -  }else{ -    openAll = 0; -    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ -      if( pIdx->onError==OE_Replace ){ -        openAll = 1; -        break; +  if( !isView ){ +    /*  +    ** Open every index that needs updating.  Note that if any +    ** index could potentially invoke a REPLACE conflict resolution  +    ** action, then we need to open all indices because we might need +    ** to be deleting some records. +    */ +    sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenWrite, iCur, pTab->tnum); +    if( onError==OE_Replace ){ +      openAll = 1; +    }else{ +      openAll = 0; +      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ +        if( pIdx->onError==OE_Replace ){ +          openAll = 1; +          break; +        }        }      } -  } -  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ -    if( openAll || aIdxUsed[i] ){ -      sqliteVdbeAddOp(v, openOp, base+i+1, pIdx->tnum); -      assert( pParse->nTab>base+i+1 ); +    for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ +      if( openAll || aIdxUsed[i] ){ +        sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0); +        sqliteVdbeAddOp(v, OP_OpenWrite, iCur+i+1, pIdx->tnum); +        assert( pParse->nTab>iCur+i+1 ); +      }      } -  } -  /* Loop over every record that needs updating.  We have to load -  ** the old data for each record to be updated because some columns -  ** might not change and we will need to copy the old value. -  ** Also, the old data is needed to delete the old index entires. -  ** So make the cursor point at the old record. -  */ -  if( !row_triggers_exist ){ -    sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); -    addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0); -    sqliteVdbeAddOp(v, OP_Dup, 0, 0); -  } -  sqliteVdbeAddOp(v, OP_NotExists, base, addr); - -  /* If the record number will change, push the record number as it -  ** will be after the update. (The old record number is currently -  ** on top of the stack.) -  */ -  if( chngRecno ){ -    sqliteExprCode(pParse, pRecnoExpr); -    sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); -  } +    /* Loop over every record that needs updating.  We have to load +    ** the old data for each record to be updated because some columns +    ** might not change and we will need to copy the old value. +    ** Also, the old data is needed to delete the old index entires. +    ** So make the cursor point at the old record. +    */ +    if( !row_triggers_exist ){ +      sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); +      addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0); +      sqliteVdbeAddOp(v, OP_Dup, 0, 0); +    } +    sqliteVdbeAddOp(v, OP_NotExists, iCur, addr); -  /* Compute new data for this record.   -  */ -  for(i=0; i<pTab->nCol; i++){ -    if( i==pTab->iPKey ){ -      sqliteVdbeAddOp(v, OP_String, 0, 0); -      continue; +    /* If the record number will change, push the record number as it +    ** will be after the update. (The old record number is currently +    ** on top of the stack.) +    */ +    if( chngRecno ){ +      sqliteExprCode(pParse, pRecnoExpr); +      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);      } -    j = aXRef[i]; -    if( j<0 ){ -      sqliteVdbeAddOp(v, OP_Column, base, i); -    }else{ -      sqliteExprCode(pParse, pChanges->a[j].pExpr); + +    /* Compute new data for this record.   +    */ +    for(i=0; i<pTab->nCol; i++){ +      if( i==pTab->iPKey ){ +        sqliteVdbeAddOp(v, OP_String, 0, 0); +        continue; +      } +      j = aXRef[i]; +      if( j<0 ){ +        sqliteVdbeAddOp(v, OP_Column, iCur, i); +      }else{ +        sqliteExprCode(pParse, pChanges->a[j].pExpr); +      }      } -  } -  /* Do constraint checks -  */ -  sqliteGenerateConstraintChecks(pParse, pTab, base, aIdxUsed, chngRecno, 1, -                                 onError, addr); +    /* Do constraint checks +    */ +    sqliteGenerateConstraintChecks(pParse, pTab, iCur, aIdxUsed, chngRecno, 1, +                                   onError, addr); -  /* Delete the old indices for the current record. -  */ -  sqliteGenerateRowIndexDelete(db, v, pTab, base, aIdxUsed); +    /* Delete the old indices for the current record. +    */ +    sqliteGenerateRowIndexDelete(db, v, pTab, iCur, aIdxUsed); -  /* If changing the record number, delete the old record. -  */ -  if( chngRecno ){ -    sqliteVdbeAddOp(v, OP_Delete, base, 0); -  } +    /* If changing the record number, delete the old record. +    */ +    if( chngRecno ){ +      sqliteVdbeAddOp(v, OP_Delete, iCur, 0); +    } -  /* Create the new index entries and the new record. -  */ -  sqliteCompleteInsertion(pParse, pTab, base, aIdxUsed, chngRecno, 1); +    /* Create the new index entries and the new record. +    */ +    sqliteCompleteInsertion(pParse, pTab, iCur, aIdxUsed, chngRecno, 1, -1); +  }    /* Increment the row counter     */ @@ -359,14 +386,18 @@ void sqliteUpdate(      sqliteVdbeAddOp(v, OP_AddImm, 1, 0);    } +  /* If there are triggers, close all the cursors after each iteration +  ** through the loop.  The fire the after triggers. +  */    if( row_triggers_exist ){ -    for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ -      if( openAll || aIdxUsed[i] ) -        sqliteVdbeAddOp(v, OP_Close, base+i+1, 0); +    if( !isView ){ +      for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ +        if( openAll || aIdxUsed[i] ) +          sqliteVdbeAddOp(v, OP_Close, iCur+i+1, 0); +      } +      sqliteVdbeAddOp(v, OP_Close, iCur, 0); +      pParse->nTab = iCur;      } -    sqliteVdbeAddOp(v, OP_Close, base, 0); -    pParse->nTab = base; -      if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, pTab,             newIdx, oldIdx, onError, addr) ){        goto update_cleanup; @@ -384,11 +415,11 @@ void sqliteUpdate(    if( !row_triggers_exist ){      for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){        if( openAll || aIdxUsed[i] ){ -        sqliteVdbeAddOp(v, OP_Close, base+i+1, 0); +        sqliteVdbeAddOp(v, OP_Close, iCur+i+1, 0);        }      } -    sqliteVdbeAddOp(v, OP_Close, base, 0); -    pParse->nTab = base; +    sqliteVdbeAddOp(v, OP_Close, iCur, 0); +    pParse->nTab = iCur;    }else{      sqliteVdbeAddOp(v, OP_Close, newIdx, 0);      sqliteVdbeAddOp(v, OP_Close, oldIdx, 0); @@ -406,6 +437,7 @@ void sqliteUpdate(    }  update_cleanup: +  sqliteAuthContextPop(&sContext);    sqliteFree(apIdx);    sqliteFree(aXRef);    sqliteSrcListDelete(pTabList); diff --git a/ext/sqlite/libsqlite/src/util.c b/ext/sqlite/libsqlite/src/util.c index 292df5d977..8520704ea6 100644 --- a/ext/sqlite/libsqlite/src/util.c +++ b/ext/sqlite/libsqlite/src/util.c @@ -393,6 +393,134 @@ void sqliteSetNString(char **pz, ...){  }  /* +** Add an error message to pParse->zErrMsg and increment pParse->nErr. +** The following formatting characters are allowed: +** +**      %s      Insert a string +**      %z      A string that should be freed after use +**      %d      Insert an integer +**      %T      Insert a token +**      %S      Insert the first element of a SrcList +*/ +void sqliteErrorMsg(Parse *pParse, const char *zFormat, ...){ +  va_list ap; +  int nByte; +  int i, j; +  char *z; +  static char zNull[] = "NULL"; + +  pParse->nErr++; +  nByte = 1 + strlen(zFormat); +  va_start(ap, zFormat); +  for(i=0; zFormat[i]; i++){ +    if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue; +    i++; +    switch( zFormat[i] ){ +      case 'd': { +        (void)va_arg(ap, int); +        nByte += 20; +        break; +      } +      case 'z': +      case 's': { +        char *z2 = va_arg(ap, char*); +        if( z2==0 ) z2 = zNull; +        nByte += strlen(z2); +        break; +      } +      case 'T': { +        Token *p = va_arg(ap, Token*); +        nByte += p->n; +        break; +      } +      case 'S': { +        SrcList *p = va_arg(ap, SrcList*); +        int k = va_arg(ap, int); +        assert( p->nSrc>k && k>=0 ); +        nByte += strlen(p->a[k].zName); +        if( p->a[k].zDatabase && p->a[k].zDatabase[0] ){ +          nByte += strlen(p->a[k].zDatabase)+1; +        } +        break; +      } +      default: { +        nByte++; +        break; +      } +    } +  } +  va_end(ap); +  z = sqliteMalloc( nByte ); +  if( z==0 ) return; +  sqliteFree(pParse->zErrMsg); +  pParse->zErrMsg = z; +  va_start(ap, zFormat); +  for(i=j=0; zFormat[i]; i++){ +    if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue; +    if( i>j ){ +      memcpy(z, &zFormat[j], i-j); +      z += i-j; +    } +    j = i+2; +    i++; +    switch( zFormat[i] ){ +      case 'd': { +        int x = va_arg(ap, int); +        sprintf(z, "%d", x); +        z += strlen(z); +        break; +      } +      case 'z': +      case 's': { +        int len; +        char *z2 = va_arg(ap, char*); +        if( z2==0 ) z2 = zNull; +        len = strlen(z2); +        memcpy(z, z2, len); +        z += len; +        if( zFormat[i]=='z' && z2!=zNull ){ +          sqliteFree(z2); +        } +        break; +      } +      case 'T': { +        Token *p = va_arg(ap, Token*); +        memcpy(z, p->z, p->n); +        z += p->n; +        break; +      } +      case 'S': { +        int len; +        SrcList *p = va_arg(ap, SrcList*); +        int k = va_arg(ap, int); +        assert( p->nSrc>k && k>=0 ); +        if( p->a[k].zDatabase && p->a[k].zDatabase[0] ){ +          len = strlen(p->a[k].zDatabase); +          memcpy(z, p->a[k].zDatabase, len); +          z += len; +          *(z++) = '.'; +        } +        len = strlen(p->a[k].zName); +        memcpy(z, p->a[k].zName, len); +        z += len; +        break; +      } +      default: { +        *(z++) = zFormat[i]; +        break; +      } +    } +  } +  va_end(ap); +  if( i>j ){ +    memcpy(z, &zFormat[j], i-j); +    z += i-j; +  } +  assert( (z - pParse->zErrMsg) < nByte ); +  *z = 0; +} + +/*  ** Convert an SQL-style quoted string into a normal string by removing  ** the quote characters.  The conversion is done in-place.  If the  ** input does not begin with a quote character, then this routine @@ -460,8 +588,7 @@ int sqliteHashNoCase(const char *z, int n){      h = (h<<3) ^ h ^ UpperToLower[(unsigned char)*z++];      n--;    } -  if( h<0 ) h = -h; -  return h; +  return h & 0x7fffffff;  }  /* @@ -669,12 +796,12 @@ static int sortStrCmp(const char *atext, const char *btext, int useCase){  ** Return TRUE if z is a pure numeric string.  Return FALSE if the  ** string contains any character which is not part of a number.  ** -** Am empty string is considered numeric. +** Am empty string is considered non-numeric.  */ -static int sqliteIsNumber(const char *z){ +int sqliteIsNumber(const char *z){    if( *z=='-' || *z=='+' ) z++;    if( !isdigit(*z) ){ -    return *z==0; +    return 0;    }    z++;    while( isdigit(*z) ){ z++; } @@ -682,12 +809,12 @@ static int sqliteIsNumber(const char *z){      z++;      if( !isdigit(*z) ) return 0;      while( isdigit(*z) ){ z++; } -    if( *z=='e' || *z=='E' ){ -      z++; -      if( *z=='+' || *z=='-' ) z++; -      if( !isdigit(*z) ) return 0; -      while( isdigit(*z) ){ z++; } -    } +  } +  if( *z=='e' || *z=='E' ){ +    z++; +    if( *z=='+' || *z=='-' ) z++; +    if( !isdigit(*z) ) return 0; +    while( isdigit(*z) ){ z++; }    }    return *z==0;  } @@ -780,7 +907,6 @@ int sqliteCompare(const char *atext, const char *btext){  ** 2.6.3 and earlier.  */  int sqliteSortCompare(const char *a, const char *b){ -  int len;    int res = 0;    int isNumA, isNumB;    int dir = 0; @@ -832,9 +958,8 @@ int sqliteSortCompare(const char *a, const char *b){          if( res ) break;        }      } -    len = strlen(&a[1]) + 2; -    a += len; -    b += len; +    a += strlen(&a[1]) + 2; +    b += strlen(&b[1]) + 2;    }    if( dir=='-' || dir=='D' ) res = -res;    return res; diff --git a/ext/sqlite/libsqlite/src/vacuum.c b/ext/sqlite/libsqlite/src/vacuum.c new file mode 100644 index 0000000000..145b368508 --- /dev/null +++ b/ext/sqlite/libsqlite/src/vacuum.c @@ -0,0 +1,316 @@ +/* +** 2003 April 6 +** +** 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. +** +************************************************************************* +** This file contains code used to implement the VACUUM command. +** +** Most of the code in this file may be omitted by defining the +** SQLITE_OMIT_VACUUM macro. +** +** $Id$ +*/ +#include "sqliteInt.h" +#include "os.h" + +/* +** A structure for holding a dynamic string - a string that can grow +** without bound.  +*/ +typedef struct dynStr dynStr; +struct dynStr { +  char *z;        /* Text of the string in space obtained from sqliteMalloc() */ +  int nAlloc;     /* Amount of space allocated to z[] */ +  int nUsed;      /* Next unused slot in z[] */ +}; + +/* +** A structure that holds the vacuum context +*/ +typedef struct vacuumStruct vacuumStruct; +struct vacuumStruct { +  sqlite *dbOld;       /* Original database */ +  sqlite *dbNew;       /* New database */ +  Parse *pParse;       /* The parser context */ +  const char *zTable;  /* Name of a table being copied */ +  const char *zPragma; /* Pragma to execute with results */ +  dynStr s1, s2;       /* Two dynamic strings */ +}; + +#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM +/* +** Append text to a dynamic string +*/ +static void appendText(dynStr *p, const char *zText, int nText){ +  if( nText<0 ) nText = strlen(zText); +  if( p->z==0 || p->nUsed + nText + 1 >= p->nAlloc ){ +    char *zNew; +    p->nAlloc = p->nUsed + nText + 1000; +    zNew = sqliteRealloc(p->z, p->nAlloc); +    if( zNew==0 ){ +      sqliteFree(p->z); +      memset(p, 0, sizeof(*p)); +      return; +    } +    p->z = zNew; +  } +  memcpy(&p->z[p->nUsed], zText, nText+1); +  p->nUsed += nText; +} + +/* +** Append text to a dynamic string, having first put the text in quotes. +*/ +static void appendQuoted(dynStr *p, const char *zText){ +  int i, j; +  appendText(p, "'", 1); +  for(i=j=0; zText[i]; i++){ +    if( zText[i]=='\'' ){ +      appendText(p, &zText[j], i-j+1); +      j = i + 1; +      appendText(p, "'", 1); +    } +  } +  if( j<i ){ +    appendText(p, &zText[j], i-j); +  } +  appendText(p, "'", 1); +} + +/* +** Execute statements of SQL.  If an error occurs, write the error +** message into pParse->zErrMsg and return non-zero. +*/ +static int execsql(Parse *pParse, sqlite *db, const char *zSql){  +  int rc; +  char *zErrMsg = 0; + +  /* printf("***** executing *****\n%s\n", zSql); */ +  rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg); +  if( rc ){ +    sqliteErrorMsg(pParse, "%s", zErrMsg); +    sqlite_freemem(zErrMsg); +  } +  return rc; +} + +/* +** This is the second stage callback.  Each invocation contains all the +** data for a single row of a single table in the original database.  This +** routine must write that information into the new database. +*/ +static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed){ +  vacuumStruct *p = (vacuumStruct*)pArg; +  int rc = 0; +  const char *zSep = "("; +  int i; + +  p->s2.nUsed = 0; +  appendText(&p->s2, "INSERT INTO ", -1); +  appendQuoted(&p->s2, p->zTable); +  appendText(&p->s2, " VALUES", -1); +  for(i=0; i<argc; i++){ +    appendText(&p->s2, zSep, 1); +    zSep = ","; +    if( argv[i]==0 ){ +      appendText(&p->s2, "NULL", 4); +    }else{ +      appendQuoted(&p->s2, argv[i]); +    } +  } +  appendText(&p->s2,")", 1); +  rc = execsql(p->pParse, p->dbNew, p->s2.z); +  return rc; +} + +/* +** This is the first stage callback.  Each invocation contains three +** arguments where are taken from the SQLITE_MASTER table of the original +** database:  (1) the entry type, (2) the entry name, and (3) the SQL for +** the entry.  In all cases, execute the SQL of the third argument. +** For tables, run a query to select all entries in that table and  +** transfer them to the second-stage callback. +*/ +static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed){ +  vacuumStruct *p = (vacuumStruct*)pArg; +  int rc = 0; +  assert( argc==3 ); +  assert( argv[0]!=0 ); +  assert( argv[1]!=0 ); +  assert( argv[2]!=0 ); +  rc = execsql(p->pParse, p->dbNew, argv[2]); +  if( rc==SQLITE_OK && strcmp(argv[0],"table")==0 ){ +    char *zErrMsg = 0; +    p->s1.nUsed = 0; +    appendText(&p->s1, "SELECT * FROM ", -1); +    appendQuoted(&p->s1, argv[1]); +    p->zTable = argv[1]; +    rc = sqlite_exec(p->dbOld, p->s1.z, vacuumCallback2, p, &zErrMsg); +    if( rc && p->pParse->zErrMsg==0 ){ +      sqliteErrorMsg(p->pParse, "%s", zErrMsg); +    } +  } +  return rc; +} + +/* +** This callback is used to transfer PRAGMA settings from one database +** to the other.  The value in argv[0] should be passed to a pragma +** identified by ((vacuumStruct*)pArg)->zPragma. +*/ +static int vacuumCallback3(void *pArg, int argc, char **argv, char **NotUsed){ +  vacuumStruct *p = (vacuumStruct*)pArg; +  int rc = 0; +  char zBuf[200]; +  assert( argc==1 ); +  assert( argv[0]!=0 ); +  assert( strlen(p->zPragma)<100 ); +  assert( strlen(argv[0])<30 ); +  sprintf(zBuf,"PRAGMA %s=%s;", p->zPragma, argv[0]); +  rc = execsql(p->pParse, p->dbNew, zBuf); +  return rc; +} + +/* +** Generate a random name of 20 character in length. +*/ +static void randomName(char *zBuf){ +  static const char zChars[] = +    "abcdefghijklmnopqrstuvwxyz" +    "0123456789"; +  int i; +  for(i=0; i<20; i++){ +    int n = sqliteRandomByte() % (sizeof(zChars)-1); +    zBuf[i] = zChars[n]; +  } +} +#endif + +/* +** The non-standard VACUUM command is used to clean up the database, +** collapse free space, etc.  It is modelled after the VACUUM command +** in PostgreSQL. +** +** In version 1.0.x of SQLite, the VACUUM command would call +** gdbm_reorganize() on all the database tables.  But beginning +** with 2.0.0, SQLite no longer uses GDBM so this command has +** become a no-op. +*/ +void sqliteVacuum(Parse *pParse, Token *pTableName){ +#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM +  const char *zFilename;  /* full pathname of the database file */ +  int nFilename;          /* number of characters  in zFilename[] */ +  char *zTemp = 0;        /* a temporary file in same directory as zFilename */ +  sqlite *dbNew = 0;      /* The new vacuumed database */ +  sqlite *db;             /* The original database */ +  int rc = SQLITE_OK;     /* Return code from service routines */ +  int i;                  /* Loop counter */ +  char *zErrMsg = 0;      /* Error messages stored here */ +  int safety = 0;         /* TRUE if safety is off */ +  vacuumStruct sVac;      /* Information passed to callbacks */ + +  /* These are all of the pragmas that need to be transferred over +  ** to the new database */ +  static const char *zPragma[] = { +     "default_synchronous", +     "default_cache_size", +     /* "default_temp_store", */ +  }; + +  /* Initial error checks +  */ +  if( pParse->explain ){ +    return; +  } +  db = pParse->db; +  if( db->flags & SQLITE_InTrans ){ +    sqliteErrorMsg(pParse, "cannot VACUUM from within a transaction"); +    return; +  } +  memset(&sVac, 0, sizeof(sVac)); + +  /* Get the full pathname of the database file and create two +  ** temporary filenames in the same directory as the original file. +  */ +  zFilename = sqliteBtreeGetFilename(db->aDb[0].pBt); +  if( zFilename==0 ){ +    /* This only happens with the in-memory database.  VACUUM is a no-op +    ** there, so just return */ +    return; +  } +  nFilename = strlen(zFilename); +  zTemp = sqliteMalloc( nFilename+100 ); +  if( zTemp==0 ) return; +  strcpy(zTemp, zFilename); +  for(i=0; i<10; i++){ +    zTemp[nFilename] = '-'; +    randomName(&zTemp[nFilename+1]); +    if( !sqliteOsFileExists(zTemp) ) break; +  } +  if( i>=10 ){ +    sqliteErrorMsg(pParse, "unable to create a temporary database file " +       "in the same directory as the original database"); +    goto end_of_vacuum; +  } + +   +  dbNew = sqlite_open(zTemp, 0, &zErrMsg); +  if( dbNew==0 ){ +    sqliteErrorMsg(pParse, "unable to open a temporary database at %s - %s", +       zTemp, zErrMsg); +    goto end_of_vacuum; +  } +  if( sqliteSafetyOff(db) ){ +    sqliteErrorMsg(pParse, "library routines called out of sequence"); +    goto end_of_vacuum; +  } +  safety = 1; +  if( execsql(pParse, db, "BEGIN") ) goto end_of_vacuum; +  if( execsql(pParse, dbNew, "PRAGMA synchronous=off; BEGIN") ){ +    goto end_of_vacuum; +  } +  sVac.dbOld = db; +  sVac.dbNew = dbNew; +  sVac.pParse = pParse; +  for(i=0; rc==SQLITE_OK && i<sizeof(zPragma)/sizeof(zPragma[0]); i++){ +    char zBuf[200]; +    assert( strlen(zPragma[i])<100 ); +    sprintf(zBuf, "PRAGMA %s;", zPragma[i]); +    sVac.zPragma = zPragma[i]; +    rc = sqlite_exec(db, zBuf, vacuumCallback3, &sVac, &zErrMsg); +  } +  if( !rc ){ +    rc = sqlite_exec(db, "SELECT type, name, sql FROM sqlite_master " +             "WHERE sql NOT NULL", vacuumCallback1, &sVac, &zErrMsg); +  } +  if( !rc ){ +    rc = sqliteBtreeCopyFile(db->aDb[0].pBt, dbNew->aDb[0].pBt); +    sqlite_exec(db, "COMMIT", 0, 0, 0); +    sqlite_exec(db, "ROLLBACK", 0, 0, 0);  /* In case the COMMIT failed */ +    sqliteResetInternalSchema(db, 0); +  } + +end_of_vacuum: +  if( rc && pParse->zErrMsg==0 && zErrMsg!=0 ){ +    sqliteErrorMsg(pParse, "unable to vacuum database - %s", zErrMsg); +  } +  if( safety ) { +    sqlite_exec(db, "COMMIT", 0, 0, 0); +    sqlite_exec(db, "ROLLBACK", 0, 0, 0);  /* In case the COMMIT failed */ +    sqliteSafetyOn(db); +  } +  if( dbNew ) sqlite_close(dbNew); +  sqliteOsDelete(zTemp); +  sqliteFree(zTemp); +  sqliteFree(sVac.s1.z); +  sqliteFree(sVac.s2.z); +  if( zErrMsg ) sqlite_freemem(zErrMsg); +  return; +#endif +} diff --git a/ext/sqlite/libsqlite/src/vdbe.c b/ext/sqlite/libsqlite/src/vdbe.c index f9b94824c4..3ac4a3acc8 100644 --- a/ext/sqlite/libsqlite/src/vdbe.c +++ b/ext/sqlite/libsqlite/src/vdbe.c @@ -79,6 +79,11 @@ typedef unsigned char Bool;  **   ** Every cursor that the virtual machine has open is represented by an  ** instance of the following structure. +** +** If the Cursor.isTriggerRow flag is set it means that this cursor is +** really a single row that represents the NEW or OLD pseudo-table of +** a row trigger.  The data for the row is stored in Cursor.pData and +** the rowid is in Cursor.iKey.  */  struct Cursor {    BtCursor *pCursor;    /* The cursor structure of the backend */ @@ -90,7 +95,11 @@ struct Cursor {    Bool useRandomRowid;  /* Generate new record numbers semi-randomly */    Bool nullRow;         /* True if pointing to a row with no data */    Bool nextRowidValid;  /* True if the nextRowid field is valid */ +  Bool pseudoTable;     /* This is a NEW or OLD pseudo-tables of a trigger */    Btree *pBt;           /* Separate file holding temporary table */ +  int nData;            /* Number of bytes in pData */ +  char *pData;          /* Data for a NEW or OLD pseudo-table */ +  int iKey;             /* Key for the NEW or OLD pseudo-table row */  };  typedef struct Cursor Cursor; @@ -243,7 +252,6 @@ struct Keylist {  struct Vdbe {    sqlite *db;         /* The whole database */    Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ -  Btree *pBt;         /* Opaque context structure used by DB backend */    FILE *trace;        /* Write an execution trace here, if not NULL */    int nOp;            /* Number of instructions in the program */    int nOpAlloc;       /* Number of slots allocated for aOp[] */ @@ -315,7 +323,6 @@ Vdbe *sqliteVdbeCreate(sqlite *db){    Vdbe *p;    p = sqliteMalloc( sizeof(Vdbe) );    if( p==0 ) return 0; -  p->pBt = db->pBe;    p->db = db;    if( db->pVdbe ){      db->pVdbe->pPrev = p; @@ -478,6 +485,7 @@ int sqliteVdbeAddOpList(Vdbe *p, int nOp, VdbeOp const *aOp){    return addr;  } +#if 0 /* NOT USED */  /*  ** Change the value of the P1 operand for a specific instruction.  ** This routine is useful when a large program is loaded from a @@ -490,6 +498,7 @@ void sqliteVdbeChangeP1(Vdbe *p, int addr, int val){      p->aOp[addr].p1 = val;    }  } +#endif /* NOT USED */  /*  ** Change the value of the P2 operand for a specific instruction. @@ -605,18 +614,27 @@ void sqliteVdbeCompressSpace(Vdbe *p, int addr){  /*  ** Search for the current program for the given opcode and P2 -** value.  Return 1 if found and 0 if not found. +** value.  Return the address plus 1 if found and 0 if not found.  */  int sqliteVdbeFindOp(Vdbe *p, int op, int p2){    int i;    assert( p->magic==VDBE_MAGIC_INIT );    for(i=0; i<p->nOp; i++){ -    if( p->aOp[i].opcode==op && p->aOp[i].p2==p2 ) return 1; +    if( p->aOp[i].opcode==op && p->aOp[i].p2==p2 ) return i+1;    }    return 0;  }  /* +** Return the opcode for a given address. +*/ +VdbeOp *sqliteVdbeGetOp(Vdbe *p, int addr){ +  assert( p->magic==VDBE_MAGIC_INIT ); +  assert( addr>=0 && addr<p->nOp ); +  return &p->aOp[addr]; +} + +/*  ** The following group or routines are employed by installable functions  ** to return their results.  ** @@ -994,6 +1012,7 @@ static int toInt(const char *zNum, int *pNum){    }else{      neg = 0;    } +  if( *zNum==0 ) return 0;    while( isdigit(*zNum) ){      v = v*10 + *zNum - '0';      zNum++; @@ -1073,27 +1092,6 @@ static void PopStack(Vdbe *p, int N){    p->tos--;  /* -** Return TRUE if zNum is a floating-point or integer number. -*/ -static int isNumber(const char *zNum){ -  if( *zNum=='-' || *zNum=='+' ) zNum++; -  if( !isdigit(*zNum) ) return 0; -  while( isdigit(*zNum) ) zNum++; -  if( *zNum==0 ) return 1; -  if( *zNum!='.' ) return 0; -  zNum++; -  if( !isdigit(*zNum) ) return 0; -  while( isdigit(*zNum) ) zNum++; -  if( *zNum==0 ) return 1; -  if( *zNum!='e' && *zNum!='E' ) return 0; -  zNum++; -  if( *zNum=='-' || *zNum=='+' ) zNum++; -  if( !isdigit(*zNum) ) return 0; -  while( isdigit(*zNum) ) zNum++; -  return *zNum==0; -} - -/*  ** Delete a keylist  */  static void KeylistFree(Keylist *p){ @@ -1115,6 +1113,7 @@ static void cleanupCursor(Cursor *pCx){    if( pCx->pBt ){      sqliteBtreeClose(pCx->pBt);    } +  sqliteFree(pCx->pData);    memset(pCx, 0, sizeof(Cursor));  } @@ -1300,7 +1299,7 @@ int sqliteVdbeList(        p->rc = SQLITE_MISUSE;      }    } -  return p->rc==SQLITE_OK ? SQLITE_OK : SQLITE_ERROR; +  return p->rc==SQLITE_OK ? SQLITE_DONE : SQLITE_ERROR;  }  /* @@ -1498,6 +1497,9 @@ void sqliteVdbeMakeReady(    int isExplain                  /* True if the EXPLAIN keywords is present */  ){    int n; +#ifdef MEMORY_DEBUG +  extern int access(const char*,int); +#endif    assert( p!=0 );    assert( p->aStack==0 ); @@ -1569,8 +1571,8 @@ void sqliteVdbeMakeReady(  ** immediately.  There will be no error message but the p->rc field is  ** set to SQLITE_ABORT and this routine will return SQLITE_ERROR.  ** -** A memory allocation error causes p->rc to be set SQLITE_NOMEM and this -** routien to return SQLITE_ERROR. +** A memory allocation error causes p->rc to be set to SQLITE_NOMEM and this +** routine to return SQLITE_ERROR.  **  ** Other fatal errors return SQLITE_ERROR.  ** @@ -1583,7 +1585,6 @@ int sqliteVdbeExec(    int pc;                    /* The program counter */    Op *pOp;                   /* Current operation */    int rc = SQLITE_OK;        /* Value to return */ -  Btree *pBt = p->pBt;       /* The backend driver */    sqlite *db = p->db;        /* The database */    char **zStack = p->zStack; /* Text stack */    Stack *aStack = p->aStack; /* Additional stack information */ @@ -1893,6 +1894,7 @@ case OP_Push: {  ** to all column names is passed as the 4th parameter to the callback.  */  case OP_ColumnName: { +  assert( pOp->p1>=0 && pOp->p1<p->nOp );    p->azColName[pOp->p1] = pOp->p3;    p->nCallback = 0;    break; @@ -3061,7 +3063,7 @@ case OP_MakeKey: {        Stringify(p, i);        aStack[i].flags &= ~(STK_Int|STK_Real);        nByte += aStack[i].n+1; -    }else if( (flags & (STK_Real|STK_Int))!=0 || isNumber(zStack[i]) ){ +    }else if( (flags & (STK_Real|STK_Int))!=0 || sqliteIsNumber(zStack[i]) ){        if( (flags & (STK_Real|STK_Int))==STK_Int ){          aStack[i].r = aStack[i].i;        }else if( (flags & (STK_Real|STK_Int))==0 ){ @@ -3153,17 +3155,21 @@ case OP_IncrKey: {    break;  } -/* Opcode: Checkpoint * * * +/* Opcode: Checkpoint P1 * *  **  ** Begin a checkpoint.  A checkpoint is the beginning of a operation that  ** is part of a larger transaction but which might need to be rolled back  ** itself without effecting the containing transaction.  A checkpoint will  ** be automatically committed or rollback when the VDBE halts. +** +** The checkpoint is begun on the database file with index P1.  The main +** database file has an index of 0 and the file used for temporary tables +** has an index of 1.  */  case OP_Checkpoint: { -  rc = sqliteBtreeBeginCkpt(pBt); -  if( rc==SQLITE_OK && db->pBeTemp ){ -     rc = sqliteBtreeBeginCkpt(db->pBeTemp); +  int i = pOp->p1; +  if( i>=0 && i<db->nDb && db->aDb[i].pBt ){ +    rc = sqliteBtreeBeginCkpt(db->aDb[i].pBt);    }    break;  } @@ -3174,10 +3180,9 @@ case OP_Checkpoint: {  ** opcode is encountered.  Depending on the ON CONFLICT setting, the  ** transaction might also be rolled back if an error is encountered.  ** -** If P1 is true, then the transaction is started on the temporary -** tables of the database only.  The main database file is not write -** locked and other processes can continue to read the main database -** file. +** P1 is the index of the database file on which the transaction is +** started.  Index 0 is the main database file and index 1 is the +** file used for temporary tables.  **  ** A write lock is obtained on the database file when a transaction is  ** started.  No other process can read or write the file while the @@ -3187,15 +3192,11 @@ case OP_Checkpoint: {  */  case OP_Transaction: {    int busy = 1; -  if( db->pBeTemp && !p->inTempTrans ){ -    rc = sqliteBtreeBeginTrans(db->pBeTemp); -    if( rc!=SQLITE_OK ){ -      goto abort_due_to_error; -    } -    p->inTempTrans = 1; -  } -  while( pOp->p1==0 && busy ){ -    rc = sqliteBtreeBeginTrans(pBt); +  int i = pOp->p1; +  assert( i>=0 && i<db->nDb ); +  if( db->aDb[i].inTrans ) break; +  while( db->aDb[i].pBt!=0 && busy ){ +    rc = sqliteBtreeBeginTrans(db->aDb[i].pBt);      switch( rc ){        case SQLITE_BUSY: {          if( db->xBusyCallback==0 ){ @@ -3223,6 +3224,7 @@ case OP_Transaction: {        }      }    } +  db->aDb[i].inTrans = 1;    p->undoTransOnError = 1;    break;  } @@ -3236,53 +3238,47 @@ case OP_Transaction: {  ** A read lock continues to be held if there are still cursors open.  */  case OP_Commit: { -  if( db->pBeTemp==0 || (rc = sqliteBtreeCommit(db->pBeTemp))==SQLITE_OK ){ -    rc = p->inTempTrans ? SQLITE_OK : sqliteBtreeCommit(pBt); +  int i; +  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ +    if( db->aDb[i].inTrans ){ +      rc = sqliteBtreeCommit(db->aDb[i].pBt); +      db->aDb[i].inTrans = 0; +    }    }    if( rc==SQLITE_OK ){      sqliteCommitInternalChanges(db);    }else{ -    if( db->pBeTemp ) sqliteBtreeRollback(db->pBeTemp); -    sqliteBtreeRollback(pBt); -    sqliteRollbackInternalChanges(db); +    sqliteRollbackAll(db);    } -  p->inTempTrans = 0;    break;  } -/* Opcode: Rollback * * * +/* Opcode: Rollback P1 * *  **  ** Cause all modifications to the database that have been made since the  ** last Transaction to be undone. The database is restored to its state  ** before the Transaction opcode was executed.  No additional modifications  ** are allowed until another transaction is started.  ** +** P1 is the index of the database file that is committed.  An index of 0 +** is used for the main database and an index of 1 is used for the file used +** to hold temporary tables. +**  ** This instruction automatically closes all cursors and releases both -** the read and write locks on the database. +** the read and write locks on the indicated database.  */  case OP_Rollback: { -  if( db->pBeTemp ){ -    sqliteBtreeRollback(db->pBeTemp); -  } -  rc = sqliteBtreeRollback(pBt); -  sqliteRollbackInternalChanges(db); +  sqliteRollbackAll(db);    break;  } -/* Opcode: ReadCookie * P2 * -** -** When P2==0,  -** read the schema cookie from the database file and push it onto the -** stack.  The schema cookie is an integer that is used like a version -** number for the database schema.  Everytime the schema changes, the -** cookie changes to a new random value.  This opcode is used during -** initialization to read the initial cookie value so that subsequent -** database accesses can verify that the cookie has not changed. +/* Opcode: ReadCookie P1 P2 *  ** -** If P2>0, then read global database parameter number P2.  There is -** a small fixed number of global database parameters.  P2==1 is the -** database version number.  P2==2 is the recommended pager cache size. -** Other parameters are currently unused. +** Read cookie number P2 from database P1 and push it onto the stack. +** P2==0 is the schema version.  P2==1 is the database format. +** P2==2 is the recommended pager cache size, and so forth.  P1==0 is +** the main database file and P1==1 is the database file used to store +** temporary tables.  **  ** There must be a read-lock on the database (either a transaction  ** must be started or there must be an open cursor) before @@ -3292,36 +3288,35 @@ case OP_ReadCookie: {    int i = ++p->tos;    int aMeta[SQLITE_N_BTREE_META];    assert( pOp->p2<SQLITE_N_BTREE_META ); -  rc = sqliteBtreeGetMeta(pBt, aMeta); +  assert( pOp->p1>=0 && pOp->p1<db->nDb ); +  assert( db->aDb[pOp->p1].pBt!=0 ); +  rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt, aMeta);    aStack[i].i = aMeta[1+pOp->p2];    aStack[i].flags = STK_Int;    break;  } -/* Opcode: SetCookie * P2 * +/* Opcode: SetCookie P1 P2 *  ** -** When P2==0, -** this operation changes the value of the schema cookie on the database. -** The new value is top of the stack. -** When P2>0, the value of global database parameter -** number P2 is changed.  See ReadCookie for more information about -** global database parametes. -** -** The schema cookie changes its value whenever the database schema changes. -** That way, other processes can recognize when the schema has changed -** and reread it. +** Write the top of the stack into cookie number P2 of database P1. +** P2==0 is the schema version.  P2==1 is the database format. +** P2==2 is the recommended pager cache size, and so forth.  P1==0 is +** the main database file and P1==1 is the database file used to store +** temporary tables.  **  ** A transaction must be started before executing this opcode.  */  case OP_SetCookie: {    int aMeta[SQLITE_N_BTREE_META];    assert( pOp->p2<SQLITE_N_BTREE_META ); +  assert( pOp->p1>=0 && pOp->p1<db->nDb ); +  assert( db->aDb[pOp->p1].pBt!=0 );    VERIFY( if( p->tos<0 ) goto not_enough_stack; )    Integerify(p, p->tos) -  rc = sqliteBtreeGetMeta(pBt, aMeta); +  rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt, aMeta);    if( rc==SQLITE_OK ){      aMeta[1+pOp->p2] = aStack[p->tos].i; -    rc = sqliteBtreeUpdateMeta(pBt, aMeta); +    rc = sqliteBtreeUpdateMeta(db->aDb[pOp->p1].pBt, aMeta);    }    POPSTACK;    break; @@ -3329,10 +3324,11 @@ case OP_SetCookie: {  /* Opcode: VerifyCookie P1 P2 *  ** -** Check the value of global database parameter number P2 and make -** sure it is equal to P1.  P2==0 is the schema cookie.  P1==1 is -** the database version.  If the values do not match, abort with -** an SQLITE_SCHEMA error. +** Check the value of global database parameter number 0 (the +** schema version) and make sure it is equal to P2.   +** P1 is the database number which is 0 for the main database file +** and 1 for the file holding temporary tables and some higher number +** for auxiliary databases.  **  ** The cookie changes its value whenever the database schema changes.  ** This operation is used to detect when that the cookie has changed @@ -3344,23 +3340,26 @@ case OP_SetCookie: {  */  case OP_VerifyCookie: {    int aMeta[SQLITE_N_BTREE_META]; -  assert( pOp->p2<SQLITE_N_BTREE_META ); -  rc = sqliteBtreeGetMeta(pBt, aMeta); -  if( rc==SQLITE_OK && aMeta[1+pOp->p2]!=pOp->p1 ){ +  assert( pOp->p1>=0 && pOp->p1<db->nDb ); +  rc = sqliteBtreeGetMeta(db->aDb[pOp->p1].pBt, aMeta); +  if( rc==SQLITE_OK && aMeta[1]!=pOp->p2 ){      sqliteSetString(&p->zErrMsg, "database schema has changed", 0);      rc = SQLITE_SCHEMA;    }    break;  } -/* Opcode: Open P1 P2 P3 +/* Opcode: OpenRead P1 P2 P3  **  ** Open a read-only cursor for the database table whose root page is -** P2 in the main database file.  Give the new cursor an identifier -** of P1.  The P1 values need not be contiguous but all P1 values -** should be small integers.  It is an error for P1 to be negative. +** P2 in a database file.  The database file is determined by an  +** integer from the top of the stack.  0 means the main database and +** 1 means the database used for temporary tables.  Give the new  +** cursor an identifier of P1.  The P1 values need not be contiguous +** but all P1 values should be small integers.  It is an error for +** P1 to be negative.  ** -** If P2==0 then take the root page number from the top of the stack. +** If P2==0 then take the root page number from the next of the stack.  **  ** There will be a read lock on the database whenever there is an  ** open cursor.  If the database was unlocked prior to this instruction @@ -3376,52 +3375,39 @@ case OP_VerifyCookie: {  ** omitted.  But the code generator usually inserts the index or  ** table name into P3 to make the code easier to read.  ** -** See also OpenAux and OpenWrite. -*/ -/* Opcode: OpenAux P1 P2 P3 -** -** Open a read-only cursor in the auxiliary table set.  This opcode -** works exactly like OP_Open except that it opens the cursor on the -** auxiliary table set (the file used to store tables created using -** CREATE TEMPORARY TABLE) instead of in the main database file. -** See OP_Open for additional information. +** See also OpenWrite.  */  /* Opcode: OpenWrite P1 P2 P3  **  ** Open a read/write cursor named P1 on the table or index whose root  ** page is P2.  If P2==0 then take the root page number from the stack.  ** -** This instruction works just like Open except that it opens the cursor +** This instruction works just like OpenRead except that it opens the cursor  ** in read/write mode.  For a given table, there can be one or more read-only  ** cursors or a single read/write cursor but not both.  ** -** See also OpWrAux. +** See also OpenRead.  */ -/* Opcode: OpenWrAux P1 P2 P3 -** -** Open a read/write cursor in the auxiliary table set.  This opcode works -** just like OpenWrite except that the auxiliary table set (the file used -** to store tables created using CREATE TEMPORARY TABLE) is used in place -** of the main database file. -*/ -case OP_OpenAux: -case OP_OpenWrAux: -case OP_OpenWrite: -case OP_Open: { +case OP_OpenRead: +case OP_OpenWrite: {    int busy = 0;    int i = pOp->p1;    int tos = p->tos;    int p2 = pOp->p2;    int wrFlag;    Btree *pX; -  switch( pOp->opcode ){ -    case OP_Open:        wrFlag = 0;  pX = pBt;          break; -    case OP_OpenWrite:   wrFlag = 1;  pX = pBt;          break; -    case OP_OpenAux:     wrFlag = 0;  pX = db->pBeTemp;  break; -    case OP_OpenWrAux:   wrFlag = 1;  pX = db->pBeTemp;  break; -  } +  int iDb; +   +  VERIFY( if( tos<0 ) goto not_enough_stack; ); +  Integerify(p, tos); +  iDb = p->aStack[tos].i; +  tos--; +  VERIFY( if( iDb<0 || iDb>=db->nDb ) goto bad_instruction; ); +  VERIFY( if( db->aDb[iDb].pBt==0 ) goto bad_instruction; ); +  pX = db->aDb[iDb].pBt; +  wrFlag = pOp->opcode==OP_OpenWrite;    if( p2<=0 ){ -    if( tos<0 ) goto not_enough_stack; +    VERIFY( if( tos<0 ) goto not_enough_stack; );      Integerify(p, tos);      p2 = p->aStack[tos].i;      POPSTACK; @@ -3463,15 +3449,16 @@ case OP_Open: {    if( p2<=0 ){      POPSTACK;    } +  POPSTACK;    break;  }  /* Opcode: OpenTemp P1 P2 *  ** -** Open a new cursor that points to a table or index in a temporary -** database file.  The temporary file is opened read/write even if  -** the main database is read-only.  The temporary file is deleted -** when the cursor is closed. +** Open a new cursor to a transient table. +** The transient cursor is always opened read/write even if  +** the main database is read-only.  The transient table is deleted +** automatically when the cursor is closed.  **  ** The cursor points to a BTree table if P2==0 and to a BTree index  ** if P2==1.  A BTree table must have an integer key and can have arbitrary @@ -3479,7 +3466,7 @@ case OP_Open: {  **  ** This opcode is used for tables that exist for the duration of a single  ** SQL statement only.  Tables created using CREATE TEMPORARY TABLE -** are opened using OP_OpenAux or OP_OpenWrAux.  "Temporary" in the +** are opened using OP_OpenRead or OP_OpenWrite.  "Temporary" in the  ** context of this opcode means for the duration of a single SQL statement  ** whereas "Temporary" in the context of CREATE TABLE means for the duration  ** of the connection to the database.  Same word; different meanings. @@ -3493,7 +3480,8 @@ case OP_OpenTemp: {    cleanupCursor(pCx);    memset(pCx, 0, sizeof(*pCx));    pCx->nullRow = 1; -  rc = sqliteBtreeOpen(0, 1, TEMP_PAGES, &pCx->pBt); +  rc = sqliteBtreeFactory(db, 0, 1, TEMP_PAGES, &pCx->pBt); +    if( rc==SQLITE_OK ){      rc = sqliteBtreeBeginTrans(pCx->pBt);    } @@ -3511,24 +3499,26 @@ case OP_OpenTemp: {    break;  } -/* -** Opcode: RenameCursor P1 P2 * +/* Opcode: OpenPseudo P1 * *  ** -** Rename cursor number P1 as cursor number P2.  If P2 was previously -** opened is is closed before the renaming occurs. +** Open a new cursor that points to a fake table that contains a single +** row of data.  Any attempt to write a second row of data causes the +** first row to be deleted.  All data is deleted when the cursor is +** closed. +** +** A pseudo-table created by this opcode is useful for holding the +** NEW or OLD tables in a trigger.  */ -case OP_RenameCursor: { -  int from = pOp->p1; -  int to = pOp->p2; -  VERIFY( if( from<0 || to<0 ) goto bad_instruction; ) -  if( to<p->nCursor && p->aCsr[to].pCursor ){ -    cleanupCursor(&p->aCsr[to]); -  } -  expandCursorArraySize(p, to); -  if( from<p->nCursor ){ -    memcpy(&p->aCsr[to], &p->aCsr[from], sizeof(p->aCsr[0])); -    memset(&p->aCsr[from], 0, sizeof(p->aCsr[0])); -  } +case OP_OpenPseudo: { +  int i = pOp->p1; +  Cursor *pCx; +  VERIFY( if( i<0 ) goto bad_instruction; ) +  if( expandCursorArraySize(p, i) ) goto no_mem; +  pCx = &p->aCsr[i]; +  cleanupCursor(pCx); +  memset(pCx, 0, sizeof(*pCx)); +  pCx->nullRow = 1; +  pCx->pseudoTable = 1;    break;  } @@ -3539,7 +3529,7 @@ case OP_RenameCursor: {  */  case OP_Close: {    int i = pOp->p1; -  if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor ){ +  if( i>=0 && i<p->nCursor ){      cleanupCursor(&p->aCsr[i]);    }    break; @@ -3573,7 +3563,9 @@ case OP_MoveTo: {    Cursor *pC;    VERIFY( if( tos<0 ) goto not_enough_stack; ) -  if( i>=0 && i<p->nCursor && (pC = &p->aCsr[i])->pCursor!=0 ){ +  assert( i>=0 && i<p->nCursor ); +  pC = &p->aCsr[i]; +  if( pC->pCursor!=0 ){      int res, oc;      if( aStack[tos].flags & STK_Int ){        int iKey = intToKey(aStack[tos].i); @@ -3905,7 +3897,8 @@ case OP_NewRecno: {  ** be an integer.  The stack is popped twice by this instruction.  **  ** If P2==1 then the row change count is incremented.  If P2==0 the -** row change count is unmodified. +** row change count is unmodified.  The rowid is stored for subsequent +** return by the sqlite_last_insert_rowid() function if P2 is 1.  */  /* Opcode: PutStrKey P1 * *  ** @@ -3914,6 +3907,8 @@ case OP_NewRecno: {  ** entry is overwritten.  The data is the value on the top of the  ** stack.  The key is the next value down on the stack.  The key must  ** be a string.  The stack is popped twice by this instruction. +** +** P1 may not be a pseudo-table opened using the OpenPseudo opcode.  */  case OP_PutIntKey:  case OP_PutStrKey: { @@ -3922,7 +3917,8 @@ case OP_PutStrKey: {    int i = pOp->p1;    Cursor *pC;    VERIFY( if( nos<0 ) goto not_enough_stack; ) -  if( VERIFY( i>=0 && i<p->nCursor && ) (pC = &p->aCsr[i])->pCursor!=0 ){ +  if( VERIFY( i>=0 && i<p->nCursor && ) +      ((pC = &p->aCsr[i])->pCursor!=0 || pC->pseudoTable) ){      char *zKey;      int nKey, iKey;      if( pOp->opcode==OP_PutStrKey ){ @@ -3934,14 +3930,38 @@ case OP_PutStrKey: {        nKey = sizeof(int);        iKey = intToKey(aStack[nos].i);        zKey = (char*)&iKey; -      db->lastRowid = aStack[nos].i; -      if( pOp->p2 ) db->nChange++; +      if( pOp->p2 ){ +        db->nChange++; +        db->lastRowid = aStack[nos].i; +      }        if( pC->nextRowidValid && aStack[nos].i>=pC->nextRowid ){          pC->nextRowidValid = 0;        }      } -    rc = sqliteBtreeInsert(pC->pCursor, zKey, nKey, -                        zStack[tos], aStack[tos].n); +    if( pC->pseudoTable ){ +      /* PutStrKey does not work for pseudo-tables. +      ** The following assert makes sure we are not trying to use +      ** PutStrKey on a pseudo-table +      */ +      assert( pOp->opcode==OP_PutIntKey ); +      sqliteFree(pC->pData); +      pC->iKey = iKey; +      pC->nData = aStack[tos].n; +      if( aStack[tos].flags & STK_Dyn ){ +        pC->pData = zStack[tos]; +        zStack[tos] = 0; +        aStack[tos].flags = STK_Null; +      }else{ +        pC->pData = sqliteMallocRaw( pC->nData ); +        if( pC->pData ){ +          memcpy(pC->pData, zStack[tos], pC->nData); +        } +      } +      pC->nullRow = 0; +    }else{ +      rc = sqliteBtreeInsert(pC->pCursor, zKey, nKey, +                          zStack[tos], aStack[tos].n); +    }      pC->recnoIsValid = 0;    }    POPSTACK; @@ -3960,11 +3980,15 @@ case OP_PutStrKey: {  **  ** The row change counter is incremented if P2==1 and is unmodified  ** if P2==0. +** +** If P1 is a pseudo-table, then this instruction is a no-op.  */  case OP_Delete: {    int i = pOp->p1;    Cursor *pC; -  if( VERIFY( i>=0 && i<p->nCursor && ) (pC = &p->aCsr[i])->pCursor!=0 ){ +  assert( i>=0 && i<p->nCursor ); +  pC = &p->aCsr[i]; +  if( pC->pCursor!=0 ){      rc = sqliteBtreeDelete(pC->pCursor);      pC->nextRowidValid = 0;    } @@ -3975,14 +3999,67 @@ case OP_Delete: {  /* Opcode: KeyAsData P1 P2 *  **  ** Turn the key-as-data mode for cursor P1 either on (if P2==1) or -** off (if P2==0).  In key-as-data mode, the Field opcode pulls -** data off of the key rather than the data.  This is useful for +** off (if P2==0).  In key-as-data mode, the OP_Column opcode pulls +** data off of the key rather than the data.  This is used for  ** processing compound selects.  */  case OP_KeyAsData: {    int i = pOp->p1; -  if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){ -    p->aCsr[i].keyAsData = pOp->p2; +  assert( i>=0 && i<p->nCursor ); +  p->aCsr[i].keyAsData = pOp->p2; +  break; +} + +/* Opcode: RowData P1 * * +** +** Push onto the stack the complete row data for cursor P1. +** There is no interpretation of the data.  It is just copied +** onto the stack exactly as it is found in the database file. +** +** If the cursor is not pointing to a valid row, a NULL is pushed +** onto the stack. +*/ +case OP_RowData: { +  int i = pOp->p1; +  int tos = ++p->tos; +  Cursor *pC; +  int n; + +  assert( i>=0 && i<p->nCursor ); +  pC = &p->aCsr[i]; +  if( pC->nullRow ){ +    aStack[tos].flags = STK_Null; +  }else if( pC->pCursor!=0 ){ +    BtCursor *pCrsr = pC->pCursor; +    if( pC->nullRow ){ +      aStack[tos].flags = STK_Null; +      break; +    }else if( pC->keyAsData ){ +      sqliteBtreeKeySize(pCrsr, &n); +    }else{ +      sqliteBtreeDataSize(pCrsr, &n); +    } +    aStack[tos].n = n; +    if( n<=NBFS ){ +      aStack[tos].flags = STK_Str; +      zStack[tos] = aStack[tos].z; +    }else{ +      char *z = sqliteMallocRaw( n ); +      if( z==0 ) goto no_mem; +      aStack[tos].flags = STK_Str | STK_Dyn; +      zStack[tos] = z; +    } +    if( pC->keyAsData ){ +      sqliteBtreeKey(pCrsr, 0, n, zStack[tos]); +    }else{ +      sqliteBtreeData(pCrsr, 0, n, zStack[tos]); +    } +  }else if( pC->pseudoTable ){ +    aStack[tos].n = pC->nData; +    zStack[tos] = pC->pData; +    aStack[tos].flags = STK_Str|STK_Ephem; +  }else{ +    aStack[tos].flags = STK_Null;    }    break;  } @@ -4017,12 +4094,13 @@ case OP_Column: {    int idxWidth;    unsigned char aHdr[10]; +  assert( i<p->nCursor );    if( i<0 ){      VERIFY( if( tos+i<0 ) goto bad_instruction; )      VERIFY( if( (aStack[tos+i].flags & STK_Str)==0 ) goto bad_instruction; )      zRec = zStack[tos+i];      payloadSize = aStack[tos+i].n; -  }else if( VERIFY( i>=0 && i<p->nCursor && ) (pC = &p->aCsr[i])->pCursor!=0 ){ +  }else if( (pC = &p->aCsr[i])->pCursor!=0 ){      zRec = 0;      pCrsr = pC->pCursor;      if( pC->nullRow ){ @@ -4032,6 +4110,10 @@ case OP_Column: {      }else{        sqliteBtreeDataSize(pCrsr, &payloadSize);      } +  }else if( pC->pseudoTable ){ +    payloadSize = pC->nData; +    zRec = pC->pData; +    assert( payloadSize==0 || zRec!=0 );    }else{      payloadSize = 0;    } @@ -4121,22 +4203,24 @@ case OP_Column: {  case OP_Recno: {    int i = pOp->p1;    int tos = ++p->tos; -  BtCursor *pCrsr; +  Cursor *pC; +  int v; -  if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ -    int v; -    if( p->aCsr[i].recnoIsValid ){ -      v = p->aCsr[i].lastRecno; -    }else if( p->aCsr[i].nullRow ){ -      aStack[tos].flags = STK_Null; -      break; -    }else{ -      sqliteBtreeKey(pCrsr, 0, sizeof(u32), (char*)&v); -      v = keyToInt(v); -    } -    aStack[tos].i = v; -    aStack[tos].flags = STK_Int; +  assert( i>=0 && i<p->nCursor ); +  if( (pC = &p->aCsr[i])->recnoIsValid ){ +    v = pC->lastRecno; +  }else if( pC->nullRow ){ +    aStack[tos].flags = STK_Null; +    break; +  }else if( pC->pseudoTable ){ +    v = keyToInt(pC->iKey); +  }else{ +    assert( pC->pCursor!=0 ); +    sqliteBtreeKey(pC->pCursor, 0, sizeof(u32), (char*)&v); +    v = keyToInt(v);    } +  aStack[tos].i = v; +  aStack[tos].flags = STK_Int;    break;  } @@ -4148,6 +4232,8 @@ case OP_Recno: {  ** Compare this opcode to Recno.  The Recno opcode extracts the first  ** 4 bytes of the key and pushes those bytes onto the stack as an  ** integer.  This instruction pushes the entire key as a string. +** +** This opcode may not be used on a pseudo-table.  */  case OP_FullKey: {    int i = pOp->p1; @@ -4155,6 +4241,7 @@ case OP_FullKey: {    BtCursor *pCrsr;    VERIFY( if( !p->aCsr[i].keyAsData ) goto bad_instruction; ) +  VERIFY( if( p->aCsr[i].pseudoTable ) goto bad_instruction; )    if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){      int amt;      char *z; @@ -4187,11 +4274,10 @@ case OP_FullKey: {  */  case OP_NullRow: {    int i = pOp->p1; -  BtCursor *pCrsr; -  if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ -    p->aCsr[i].nullRow = 1; -  } +  assert( i>=0 && i<p->nCursor ); +  p->aCsr[i].nullRow = 1; +  p->aCsr[i].recnoIsValid = 0;    break;  } @@ -4205,15 +4291,20 @@ case OP_NullRow: {  */  case OP_Last: {    int i = pOp->p1; +  Cursor *pC;    BtCursor *pCrsr; -  if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ +  assert( i>=0 && i<p->nCursor ); +  pC = &p->aCsr[i]; +  if( (pCrsr = pC->pCursor)!=0 ){      int res; -    sqliteBtreeLast(pCrsr, &res); +    rc = sqliteBtreeLast(pCrsr, &res);      p->aCsr[i].nullRow = res;      if( res && pOp->p2>0 ){        pc = pOp->p2 - 1;      } +  }else{ +    pC->nullRow = 0;    }    break;  } @@ -4228,16 +4319,21 @@ case OP_Last: {  */  case OP_Rewind: {    int i = pOp->p1; +  Cursor *pC;    BtCursor *pCrsr; -  if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ +  assert( i>=0 && i<p->nCursor ); +  pC = &p->aCsr[i]; +  if( (pCrsr = pC->pCursor)!=0 ){      int res; -    sqliteBtreeFirst(pCrsr, &res); -    p->aCsr[i].atFirst = res==0; -    p->aCsr[i].nullRow = res; +    rc = sqliteBtreeFirst(pCrsr, &res); +    pC->atFirst = res==0; +    pC->nullRow = res;      if( res && pOp->p2>0 ){        pc = pOp->p2 - 1;      } +  }else{ +    pC->nullRow = 0;    }    break;  } @@ -4264,8 +4360,9 @@ case OP_Next: {    BtCursor *pCrsr;    CHECK_FOR_INTERRUPT; -  if( VERIFY( pOp->p1>=0 && pOp->p1<p->nCursor && )  -      (pCrsr = (pC = &p->aCsr[pOp->p1])->pCursor)!=0 ){ +  assert( pOp->p1>=0 && pOp->p1<p->nCursor ); +  pC = &p->aCsr[pOp->p1]; +  if( (pCrsr = pC->pCursor)!=0 ){      int res;      if( pC->nullRow ){        res = 1; @@ -4278,8 +4375,10 @@ case OP_Next: {        pc = pOp->p2 - 1;        sqlite_search_count++;      } -    pC->recnoIsValid = 0; +  }else{ +    pC->nullRow = 1;    } +  pC->recnoIsValid = 0;    break;  } @@ -4373,10 +4472,14 @@ case OP_IdxRecno: {      int v;      int sz;      sqliteBtreeKeySize(pCrsr, &sz); -    sqliteBtreeKey(pCrsr, sz - sizeof(u32), sizeof(u32), (char*)&v); -    v = keyToInt(v); -    aStack[tos].i = v; -    aStack[tos].flags = STK_Int; +    if( sz<sizeof(u32) ){ +      aStack[tos].flags = STK_Null; +    }else{ +      sqliteBtreeKey(pCrsr, sz - sizeof(u32), sizeof(u32), (char*)&v); +      v = keyToInt(v); +      aStack[tos].i = v; +      aStack[tos].flags = STK_Int; +    }    }    break;  } @@ -4446,7 +4549,7 @@ case OP_IdxGE: {  ** See also: Clear  */  case OP_Destroy: { -  sqliteBtreeDropTable(pOp->p2 ? db->pBeTemp : pBt, pOp->p1); +  rc = sqliteBtreeDropTable(db->aDb[pOp->p2].pBt, pOp->p1);    break;  } @@ -4463,7 +4566,7 @@ case OP_Destroy: {  ** See also: Destroy  */  case OP_Clear: { -  sqliteBtreeClearTable(pOp->p2 ? db->pBeTemp : pBt, pOp->p1); +  rc = sqliteBtreeClearTable(db->aDb[pOp->p2].pBt, pOp->p1);    break;  } @@ -4497,10 +4600,12 @@ case OP_CreateTable: {    int i = ++p->tos;    int pgno;    assert( pOp->p3!=0 && pOp->p3type==P3_POINTER ); +  assert( pOp->p2>=0 && pOp->p2<db->nDb ); +  assert( db->aDb[pOp->p2].pBt!=0 );    if( pOp->opcode==OP_CreateTable ){ -    rc = sqliteBtreeCreateTable(pOp->p2 ? db->pBeTemp : pBt, &pgno); +    rc = sqliteBtreeCreateTable(db->aDb[pOp->p2].pBt, &pgno);    }else{ -    rc = sqliteBtreeCreateIndex(pOp->p2 ? db->pBeTemp : pBt, &pgno); +    rc = sqliteBtreeCreateIndex(db->aDb[pOp->p2].pBt, &pgno);    }    if( rc==SQLITE_OK ){      aStack[i].i = pgno; @@ -4544,7 +4649,7 @@ case OP_IntegrityCk: {      toInt((char*)sqliteHashKey(i), &aRoot[j]);    }    aRoot[j] = 0; -  z = sqliteBtreeIntegrityCheck(pOp->p2 ? db->pBeTemp : pBt, aRoot, nRoot); +  z = sqliteBtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot);    if( z==0 || z[0]==0 ){      if( z ) sqliteFree(z);      zStack[tos] = "ok"; @@ -5669,8 +5774,7 @@ bad_instruction:  */  int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){    sqlite *db = p->db; -  Btree *pBt = p->pBt; -  int rc; +  int i, rc;    if( p->magic!=VDBE_MAGIC_RUN && p->magic!=VDBE_MAGIC_HALT ){      sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), 0); @@ -5689,23 +5793,24 @@ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){      switch( p->errorAction ){        case OE_Abort: {          if( !p->undoTransOnError ){ -          sqliteBtreeRollbackCkpt(pBt); -          if( db->pBeTemp ) sqliteBtreeRollbackCkpt(db->pBeTemp); +          for(i=0; i<db->nDb; i++){ +            if( db->aDb[i].pBt ){ +              sqliteBtreeRollbackCkpt(db->aDb[i].pBt); +            } +          }            break;          }          /* Fall through to ROLLBACK */        }        case OE_Rollback: { -        sqliteBtreeRollback(pBt); -        if( db->pBeTemp ) sqliteBtreeRollback(db->pBeTemp); +        sqliteRollbackAll(db);          db->flags &= ~SQLITE_InTrans;          db->onError = OE_Default;          break;        }        default: {          if( p->undoTransOnError ){ -          sqliteBtreeCommit(pBt); -          if( db->pBeTemp ) sqliteBtreeCommit(db->pBeTemp); +          sqliteRollbackAll(db);            db->flags &= ~SQLITE_InTrans;            db->onError = OE_Default;          } @@ -5714,8 +5819,11 @@ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){      }      sqliteRollbackInternalChanges(db);    } -  sqliteBtreeCommitCkpt(pBt); -  if( db->pBeTemp ) sqliteBtreeCommitCkpt(db->pBeTemp); +  for(i=0; i<db->nDb; i++){ +    if( db->aDb[i].pBt ){ +      sqliteBtreeCommitCkpt(db->aDb[i].pBt); +    } +  }    assert( p->tos<p->pc || sqlite_malloc_failed==1 );  #ifdef VDBE_PROFILE    { diff --git a/ext/sqlite/libsqlite/src/vdbe.h b/ext/sqlite/libsqlite/src/vdbe.h index 0a885e42d4..fa8ad54d4a 100644 --- a/ext/sqlite/libsqlite/src/vdbe.h +++ b/ext/sqlite/libsqlite/src/vdbe.h @@ -81,6 +81,7 @@ void sqliteVdbeChangeP2(Vdbe*, int addr, int P2);  void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);  void sqliteVdbeDequoteP3(Vdbe*, int addr);  int sqliteVdbeFindOp(Vdbe*, int, int); +VdbeOp *sqliteVdbeGetOp(Vdbe*, int);  int sqliteVdbeMakeLabel(Vdbe*);  void sqliteVdbeDelete(Vdbe*);  void sqliteVdbeMakeReady(Vdbe*,sqlite_callback,void*,int); diff --git a/ext/sqlite/libsqlite/src/where.c b/ext/sqlite/libsqlite/src/where.c index 682b33c79f..7f95dc78c3 100644 --- a/ext/sqlite/libsqlite/src/where.c +++ b/ext/sqlite/libsqlite/src/where.c @@ -10,8 +10,7 @@  **  *************************************************************************  ** This module contains C code that generates VDBE code used to process -** the WHERE clause of SQL statements.  Also found here are subroutines -** to generate VDBE code to evaluate expressions. +** the WHERE clause of SQL statements.  **  ** $Id$  */ @@ -38,6 +37,21 @@ struct ExprInfo {  };  /* +** An instance of the following structure keeps track of a mapping +** between VDBE cursor numbers and bitmasks.  The VDBE cursor numbers +** are small integers contained in SrcList_item.iCursor and Expr.iTable +** fields.  For any given WHERE clause, we want to track which cursors +** are being used, so we assign a single bit in a 32-bit word to track +** that cursor.  Then a 32-bit integer is able to show the set of all +** cursors being used. +*/ +typedef struct ExprMaskSet ExprMaskSet; +struct ExprMaskSet { +  int n;          /* Number of assigned cursor values */ +  int ix[32];     /* Cursor assigned to each bit */ +}; + +/*  ** Determine the number of elements in an array.  */  #define ARRAYSIZE(X)  (sizeof(X)/sizeof(X[0])) @@ -69,36 +83,60 @@ static int exprSplit(int nSlot, ExprInfo *aSlot, Expr *pExpr){  }  /* +** Initialize an expression mask set +*/ +#define initMaskSet(P)  memset(P, 0, sizeof(*P)) + +/* +** Return the bitmask for the given cursor.  Assign a new bitmask +** if this is the first time the cursor has been seen. +*/ +static int getMask(ExprMaskSet *pMaskSet, int iCursor){ +  int i; +  for(i=0; i<pMaskSet->n; i++){ +    if( pMaskSet->ix[i]==iCursor ) return 1<<i; +  } +  if( i==pMaskSet->n && i<ARRAYSIZE(pMaskSet->ix) ){ +    pMaskSet->n++; +    pMaskSet->ix[i] = iCursor; +    return 1<<i; +  } +  return 0; +} + +/* +** Destroy an expression mask set +*/ +#define freeMaskSet(P)   /* NO-OP */ + +/*  ** This routine walks (recursively) an expression tree and generates  ** a bitmask indicating which tables are used in that expression -** tree.  Bit 0 of the mask is set if table base+0 is used.  Bit 1 -** is set if table base+1 is used.  And so forth. +** tree.  **  ** In order for this routine to work, the calling function must have  ** previously invoked sqliteExprResolveIds() on the expression.  See  ** the header comment on that routine for additional information. -** -** "base" is the cursor number (the value of the iTable field) that -** corresponds to the first entry in the list of tables that appear -** in the FROM clause of a SELECT.  For UPDATE and DELETE statements -** there is just a single table with "base" as the cursor number. +** The sqliteExprResolveIds() routines looks for column names and +** sets their opcodes to TK_COLUMN and their Expr.iTable fields to +** the VDBE cursor number of the table.  */ -static int exprTableUsage(int base, Expr *p){ +static int exprTableUsage(ExprMaskSet *pMaskSet, Expr *p){    unsigned int mask = 0;    if( p==0 ) return 0;    if( p->op==TK_COLUMN ){ -    return 1<< (p->iTable - base); +    return getMask(pMaskSet, p->iTable);    }    if( p->pRight ){ -    mask = exprTableUsage(base, p->pRight); +    mask = exprTableUsage(pMaskSet, p->pRight);    }    if( p->pLeft ){ -    mask |= exprTableUsage(base, p->pLeft); +    mask |= exprTableUsage(pMaskSet, p->pLeft);    }    if( p->pList ){      int i;      for(i=0; i<p->pList->nExpr; i++){ -      mask |= exprTableUsage(base, p->pList->a[i].pExpr); +      mask |= exprTableUsage(pMaskSet, p->pList->a[i].pExpr);      }    }    return mask; @@ -128,25 +166,22 @@ static int allowedOp(int op){  ** "p" field filled in.  The job of this routine is to analyze the  ** subexpression and populate all the other fields of the ExprInfo  ** structure. -** -** "base" is the cursor number (the value of the iTable field) that -** corresponds to the first entry in the table list.  */ -static void exprAnalyze(int base, ExprInfo *pInfo){ +static void exprAnalyze(ExprMaskSet *pMaskSet, ExprInfo *pInfo){    Expr *pExpr = pInfo->p; -  pInfo->prereqLeft = exprTableUsage(base, pExpr->pLeft); -  pInfo->prereqRight = exprTableUsage(base, pExpr->pRight); -  pInfo->prereqAll = exprTableUsage(base, pExpr); +  pInfo->prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft); +  pInfo->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight); +  pInfo->prereqAll = exprTableUsage(pMaskSet, pExpr);    pInfo->indexable = 0;    pInfo->idxLeft = -1;    pInfo->idxRight = -1;    if( allowedOp(pExpr->op) && (pInfo->prereqRight & pInfo->prereqLeft)==0 ){      if( pExpr->pRight && pExpr->pRight->op==TK_COLUMN ){ -      pInfo->idxRight = pExpr->pRight->iTable - base; +      pInfo->idxRight = pExpr->pRight->iTable;        pInfo->indexable = 1;      }      if( pExpr->pLeft->op==TK_COLUMN ){ -      pInfo->idxLeft = pExpr->pLeft->iTable - base; +      pInfo->idxLeft = pExpr->pLeft->iTable;        pInfo->indexable = 1;      }    } @@ -263,9 +298,9 @@ static Index *findSortingIndex(  **      end                         /  **  ** There are Btree cursors associated with each table.  t1 uses cursor -** "base".  t2 uses cursor "base+1".  And so forth.  This routine generates -** the code to open those cursors.  sqliteWhereEnd() generates the code -** to close them. +** number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor. +** And so forth.  This routine generates code to open those VDBE cursors +** and sqliteWhereEnd() generates the code to close them.  **  ** If the WHERE clause is empty, the foreach loops must each scan their  ** entire tables.  Thus a three-way join is an O(N^3) operation.  But if @@ -315,7 +350,6 @@ static Index *findSortingIndex(  */  WhereInfo *sqliteWhereBegin(    Parse *pParse,       /* The parser context */ -  int base,            /* VDBE cursor index for left-most table in pTabList */    SrcList *pTabList,   /* A list of all tables to be scanned */    Expr *pWhere,        /* The WHERE clause */    int pushKey,         /* If TRUE, leave the table key on the stack */ @@ -328,6 +362,7 @@ WhereInfo *sqliteWhereBegin(    int nExpr;           /* Number of subexpressions in the WHERE clause */    int loopMask;        /* One bit set for each outer loop */    int haveKey;         /* True if KEY is on the stack */ +  ExprMaskSet maskSet; /* The expression mask set */    int iDirectEq[32];   /* Term of the form ROWID==X for the N-th table */    int iDirectLt[32];   /* Term of the form ROWID<X or ROWID<=X */    int iDirectGt[32];   /* Term of the form ROWID>X or ROWID>=X */ @@ -343,6 +378,7 @@ WhereInfo *sqliteWhereBegin(    ** array fills up, the last entry might point to an expression which    ** contains additional unfactored AND operators.    */ +  initMaskSet(&maskSet);    memset(aExpr, 0, sizeof(aExpr));    nExpr = exprSplit(ARRAYSIZE(aExpr), aExpr, pWhere);    if( nExpr==ARRAYSIZE(aExpr) ){ @@ -364,14 +400,13 @@ WhereInfo *sqliteWhereBegin(    }    pWInfo->pParse = pParse;    pWInfo->pTabList = pTabList; -  pWInfo->base = base;    pWInfo->peakNTab = pWInfo->savedNTab = pParse->nTab;    pWInfo->iBreak = sqliteVdbeMakeLabel(v);    /* Special case: a WHERE clause that is constant.  Evaluate the    ** expression and either jump over all of the code or fall thru.    */ -  if( pWhere && sqliteExprIsConstant(pWhere) ){ +  if( pWhere && (pTabList->nSrc==0 || sqliteExprIsConstant(pWhere)) ){      sqliteExprIfFalse(pParse, pWhere, pWInfo->iBreak, 1);      pWhere = 0;    } @@ -379,7 +414,7 @@ WhereInfo *sqliteWhereBegin(    /* Analyze all of the subexpressions.    */    for(i=0; i<nExpr; i++){ -    exprAnalyze(base, &aExpr[i]); +    exprAnalyze(&maskSet, &aExpr[i]);      /* If we are executing a trigger body, remove all references to      ** new.* and old.* tables from the prerequisite masks. @@ -387,13 +422,13 @@ WhereInfo *sqliteWhereBegin(      if( pParse->trigStack ){        int x;        if( (x = pParse->trigStack->newIdx) >= 0 ){ -        int mask = ~(1 << (x - base)); +        int mask = ~getMask(&maskSet, x);          aExpr[i].prereqRight &= mask;          aExpr[i].prereqLeft &= mask;          aExpr[i].prereqAll &= mask;        }        if( (x = pParse->trigStack->oldIdx) >= 0 ){ -        int mask = ~(1 << (x - base)); +        int mask = ~getMask(&maskSet, x);          aExpr[i].prereqRight &= mask;          aExpr[i].prereqLeft &= mask;          aExpr[i].prereqAll &= mask; @@ -420,8 +455,9 @@ WhereInfo *sqliteWhereBegin(    loopMask = 0;    for(i=0; i<pTabList->nSrc && i<ARRAYSIZE(iDirectEq); i++){      int j; -    int idx = i; -    Table *pTab = pTabList->a[idx].pTab; +    int iCur = pTabList->a[i].iCursor;    /* The cursor for this table */ +    int mask = getMask(&maskSet, iCur);   /* Cursor mask for this table */ +    Table *pTab = pTabList->a[i].pTab;      Index *pIdx;      Index *pBestIdx = 0;      int bestScore = 0; @@ -439,7 +475,7 @@ WhereInfo *sqliteWhereBegin(      iDirectLt[i] = -1;      iDirectGt[i] = -1;      for(j=0; j<nExpr; j++){ -      if( aExpr[j].idxLeft==idx && aExpr[j].p->pLeft->iColumn<0 +      if( aExpr[j].idxLeft==iCur && aExpr[j].p->pLeft->iColumn<0              && (aExpr[j].prereqRight & loopMask)==aExpr[j].prereqRight ){          switch( aExpr[j].p->op ){            case TK_IN: @@ -450,7 +486,7 @@ WhereInfo *sqliteWhereBegin(            case TK_GT: iDirectGt[i] = j;  break;          }        } -      if( aExpr[j].idxRight==idx && aExpr[j].p->pRight->iColumn<0 +      if( aExpr[j].idxRight==iCur && aExpr[j].p->pRight->iColumn<0              && (aExpr[j].prereqLeft & loopMask)==aExpr[j].prereqLeft ){          switch( aExpr[j].p->op ){            case TK_EQ: iDirectEq[i] = j;  break; @@ -462,7 +498,7 @@ WhereInfo *sqliteWhereBegin(        }      }      if( iDirectEq[i]>=0 ){ -      loopMask |= 1<<idx; +      loopMask |= mask;        pWInfo->a[i].pIdx = 0;        continue;      } @@ -501,7 +537,7 @@ WhereInfo *sqliteWhereBegin(        if( pIdx->nColumn>32 ) continue;  /* Ignore indices too many columns */        for(j=0; j<nExpr; j++){ -        if( aExpr[j].idxLeft==idx  +        if( aExpr[j].idxLeft==iCur                && (aExpr[j].prereqRight & loopMask)==aExpr[j].prereqRight ){            int iColumn = aExpr[j].p->pLeft->iColumn;            int k; @@ -536,7 +572,7 @@ WhereInfo *sqliteWhereBegin(              }            }          } -        if( aExpr[j].idxRight==idx  +        if( aExpr[j].idxRight==iCur                && (aExpr[j].prereqLeft & loopMask)==aExpr[j].prereqLeft ){            int iColumn = aExpr[j].p->pRight->iColumn;            int k; @@ -589,7 +625,7 @@ WhereInfo *sqliteWhereBegin(      pWInfo->a[i].pIdx = pBestIdx;      pWInfo->a[i].score = bestScore;      pWInfo->a[i].bRev = 0; -    loopMask |= 1<<idx; +    loopMask |= mask;      if( pBestIdx ){        pWInfo->a[i].iCur = pParse->nTab++;        pWInfo->peakNTab = pParse->nTab; @@ -620,7 +656,8 @@ WhereInfo *sqliteWhereBegin(         pSortIdx = 0;       }else{         int nEqCol = (pWInfo->a[0].score+4)/8; -       pSortIdx = findSortingIndex(pTab, base, *ppOrderBy, pIdx, nEqCol, &bRev); +       pSortIdx = findSortingIndex(pTab, pTabList->a[0].iCursor,  +                                   *ppOrderBy, pIdx, nEqCol, &bRev);       }       if( pSortIdx && (pIdx==0 || pIdx==pSortIdx) ){         if( pIdx==0 ){ @@ -636,21 +673,18 @@ WhereInfo *sqliteWhereBegin(    /* Open all tables in the pTabList and all indices used by those tables.    */    for(i=0; i<pTabList->nSrc; i++){ -    int openOp;      Table *pTab;      pTab = pTabList->a[i].pTab;      if( pTab->isTransient || pTab->pSelect ) continue; -    openOp = pTab->isTemp ? OP_OpenAux : OP_Open; -    sqliteVdbeAddOp(v, openOp, base+i, pTab->tnum); +    sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0); +    sqliteVdbeAddOp(v, OP_OpenRead, pTabList->a[i].iCursor, pTab->tnum);      sqliteVdbeChangeP3(v, -1, pTab->zName, P3_STATIC); -    if( i==0 && !pParse->schemaVerified && -          (pParse->db->flags & SQLITE_InTrans)==0 ){ -      sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0); -      pParse->schemaVerified = 1; -    } +    sqliteCodeVerifySchema(pParse, pTab->iDb);      if( pWInfo->a[i].pIdx!=0 ){ -      sqliteVdbeAddOp(v, openOp, pWInfo->a[i].iCur, pWInfo->a[i].pIdx->tnum); +      sqliteVdbeAddOp(v, OP_Integer, pWInfo->a[i].pIdx->iDb, 0); +      sqliteVdbeAddOp(v, OP_OpenRead, +                      pWInfo->a[i].iCur, pWInfo->a[i].pIdx->tnum);        sqliteVdbeChangeP3(v, -1, pWInfo->a[i].pIdx->zName, P3_STATIC);      }    } @@ -660,7 +694,7 @@ WhereInfo *sqliteWhereBegin(    loopMask = 0;    for(i=0; i<pTabList->nSrc; i++){      int j, k; -    int idx = i; +    int iCur = pTabList->a[i].iCursor;      Index *pIdx;      WhereLevel *pLevel = &pWInfo->a[i]; @@ -686,9 +720,9 @@ WhereInfo *sqliteWhereBegin(        k = iDirectEq[i];        assert( k<nExpr );        assert( aExpr[k].p!=0 ); -      assert( aExpr[k].idxLeft==idx || aExpr[k].idxRight==idx ); +      assert( aExpr[k].idxLeft==iCur || aExpr[k].idxRight==iCur );        brk = pLevel->brk = sqliteVdbeMakeLabel(v); -      if( aExpr[k].idxLeft==idx ){ +      if( aExpr[k].idxLeft==iCur ){          Expr *pX = aExpr[k].p;          if( pX->op!=TK_IN ){            sqliteExprCode(pParse, aExpr[k].p->pRight); @@ -712,7 +746,7 @@ WhereInfo *sqliteWhereBegin(        cont = pLevel->cont = sqliteVdbeMakeLabel(v);        sqliteVdbeAddOp(v, OP_MustBeInt, 1, brk);        haveKey = 0; -      sqliteVdbeAddOp(v, OP_NotExists, base+idx, brk); +      sqliteVdbeAddOp(v, OP_NotExists, iCur, brk);        pLevel->op = OP_Noop;      }else if( pIdx!=0 && pLevel->score>0 && pLevel->score%4==0 ){        /* Case 2:  There is an index and all terms of the WHERE clause that @@ -726,7 +760,7 @@ WhereInfo *sqliteWhereBegin(          for(k=0; k<nExpr; k++){            Expr *pX = aExpr[k].p;            if( pX==0 ) continue; -          if( aExpr[k].idxLeft==idx  +          if( aExpr[k].idxLeft==iCur               && (aExpr[k].prereqRight & loopMask)==aExpr[k].prereqRight                && pX->pLeft->iColumn==pIdx->aiColumn[j]            ){ @@ -753,7 +787,7 @@ WhereInfo *sqliteWhereBegin(                break;              }            } -          if( aExpr[k].idxRight==idx  +          if( aExpr[k].idxRight==iCur               && aExpr[k].p->op==TK_EQ               && (aExpr[k].prereqLeft & loopMask)==aExpr[k].prereqLeft               && aExpr[k].p->pRight->iColumn==pIdx->aiColumn[j] @@ -796,7 +830,7 @@ WhereInfo *sqliteWhereBegin(        if( i==pTabList->nSrc-1 && pushKey ){          haveKey = 1;        }else{ -        sqliteVdbeAddOp(v, OP_MoveTo, base+idx, 0); +        sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);          haveKey = 0;        }        pLevel->p1 = pLevel->iCur; @@ -813,8 +847,8 @@ WhereInfo *sqliteWhereBegin(          k = iDirectGt[i];          assert( k<nExpr );          assert( aExpr[k].p!=0 ); -        assert( aExpr[k].idxLeft==idx || aExpr[k].idxRight==idx ); -        if( aExpr[k].idxLeft==idx ){ +        assert( aExpr[k].idxLeft==iCur || aExpr[k].idxRight==iCur ); +        if( aExpr[k].idxLeft==iCur ){            sqliteExprCode(pParse, aExpr[k].p->pRight);          }else{            sqliteExprCode(pParse, aExpr[k].p->pLeft); @@ -823,17 +857,17 @@ WhereInfo *sqliteWhereBegin(          if( aExpr[k].p->op==TK_LT || aExpr[k].p->op==TK_GT ){            sqliteVdbeAddOp(v, OP_AddImm, 1, 0);          } -        sqliteVdbeAddOp(v, OP_MoveTo, base+idx, brk); +        sqliteVdbeAddOp(v, OP_MoveTo, iCur, brk);          aExpr[k].p = 0;        }else{ -        sqliteVdbeAddOp(v, OP_Rewind, base+idx, brk); +        sqliteVdbeAddOp(v, OP_Rewind, iCur, brk);        }        if( iDirectLt[i]>=0 ){          k = iDirectLt[i];          assert( k<nExpr );          assert( aExpr[k].p!=0 ); -        assert( aExpr[k].idxLeft==idx || aExpr[k].idxRight==idx ); -        if( aExpr[k].idxLeft==idx ){ +        assert( aExpr[k].idxLeft==iCur || aExpr[k].idxRight==iCur ); +        if( aExpr[k].idxLeft==iCur ){            sqliteExprCode(pParse, aExpr[k].p->pRight);          }else{            sqliteExprCode(pParse, aExpr[k].p->pLeft); @@ -850,10 +884,10 @@ WhereInfo *sqliteWhereBegin(        }        start = sqliteVdbeCurrentAddr(v);        pLevel->op = OP_Next; -      pLevel->p1 = base+idx; +      pLevel->p1 = iCur;        pLevel->p2 = start;        if( testOp!=OP_Noop ){ -        sqliteVdbeAddOp(v, OP_Recno, base+idx, 0); +        sqliteVdbeAddOp(v, OP_Recno, iCur, 0);          sqliteVdbeAddOp(v, OP_MemLoad, pLevel->iMem, 0);          sqliteVdbeAddOp(v, testOp, 0, brk);        } @@ -866,10 +900,10 @@ WhereInfo *sqliteWhereBegin(        brk = pLevel->brk = sqliteVdbeMakeLabel(v);        cont = pLevel->cont = sqliteVdbeMakeLabel(v); -      sqliteVdbeAddOp(v, OP_Rewind, base+idx, brk); +      sqliteVdbeAddOp(v, OP_Rewind, iCur, brk);        start = sqliteVdbeCurrentAddr(v);        pLevel->op = OP_Next; -      pLevel->p1 = base+idx; +      pLevel->p1 = iCur;        pLevel->p2 = start;        haveKey = 0;      }else{ @@ -895,7 +929,7 @@ WhereInfo *sqliteWhereBegin(        for(j=0; j<nEqColumn; j++){          for(k=0; k<nExpr; k++){            if( aExpr[k].p==0 ) continue; -          if( aExpr[k].idxLeft==idx  +          if( aExpr[k].idxLeft==iCur               && aExpr[k].p->op==TK_EQ               && (aExpr[k].prereqRight & loopMask)==aExpr[k].prereqRight                && aExpr[k].p->pLeft->iColumn==pIdx->aiColumn[j] @@ -904,7 +938,7 @@ WhereInfo *sqliteWhereBegin(              aExpr[k].p = 0;              break;            } -          if( aExpr[k].idxRight==idx  +          if( aExpr[k].idxRight==iCur               && aExpr[k].p->op==TK_EQ               && (aExpr[k].prereqLeft & loopMask)==aExpr[k].prereqLeft               && aExpr[k].p->pRight->iColumn==pIdx->aiColumn[j] @@ -940,7 +974,7 @@ WhereInfo *sqliteWhereBegin(          for(k=0; k<nExpr; k++){            Expr *pExpr = aExpr[k].p;            if( pExpr==0 ) continue; -          if( aExpr[k].idxLeft==idx  +          if( aExpr[k].idxLeft==iCur               && (pExpr->op==TK_LT || pExpr->op==TK_LE)               && (aExpr[k].prereqRight & loopMask)==aExpr[k].prereqRight                && pExpr->pLeft->iColumn==pIdx->aiColumn[j] @@ -950,7 +984,7 @@ WhereInfo *sqliteWhereBegin(              aExpr[k].p = 0;              break;            } -          if( aExpr[k].idxRight==idx  +          if( aExpr[k].idxRight==iCur               && (pExpr->op==TK_GT || pExpr->op==TK_GE)               && (aExpr[k].prereqLeft & loopMask)==aExpr[k].prereqLeft               && pExpr->pRight->iColumn==pIdx->aiColumn[j] @@ -995,7 +1029,7 @@ WhereInfo *sqliteWhereBegin(          for(k=0; k<nExpr; k++){            Expr *pExpr = aExpr[k].p;            if( pExpr==0 ) continue; -          if( aExpr[k].idxLeft==idx  +          if( aExpr[k].idxLeft==iCur               && (pExpr->op==TK_GT || pExpr->op==TK_GE)               && (aExpr[k].prereqRight & loopMask)==aExpr[k].prereqRight                && pExpr->pLeft->iColumn==pIdx->aiColumn[j] @@ -1005,7 +1039,7 @@ WhereInfo *sqliteWhereBegin(              aExpr[k].p = 0;              break;            } -          if( aExpr[k].idxRight==idx  +          if( aExpr[k].idxRight==iCur               && (pExpr->op==TK_LT || pExpr->op==TK_LE)               && (aExpr[k].prereqLeft & loopMask)==aExpr[k].prereqLeft               && pExpr->pRight->iColumn==pIdx->aiColumn[j] @@ -1051,7 +1085,7 @@ WhereInfo *sqliteWhereBegin(        if( i==pTabList->nSrc-1 && pushKey ){          haveKey = 1;        }else{ -        sqliteVdbeAddOp(v, OP_MoveTo, base+idx, 0); +        sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);          haveKey = 0;        } @@ -1061,7 +1095,7 @@ WhereInfo *sqliteWhereBegin(        pLevel->p1 = pLevel->iCur;        pLevel->p2 = start;      } -    loopMask |= 1<<idx; +    loopMask |= getMask(&maskSet, iCur);      /* Insert code to test every subexpression that can be completely      ** computed using the current set of tables. @@ -1074,7 +1108,7 @@ WhereInfo *sqliteWhereBegin(        }        if( haveKey ){          haveKey = 0; -        sqliteVdbeAddOp(v, OP_MoveTo, base+idx, 0); +        sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);        }        sqliteExprIfFalse(pParse, aExpr[j].p, cont, 1);        aExpr[j].p = 0; @@ -1097,7 +1131,7 @@ WhereInfo *sqliteWhereBegin(            ** no outer joins with DELETE and UPDATE.            */            haveKey = 0; -          sqliteVdbeAddOp(v, OP_MoveTo, base+idx, 0); +          sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);          }          sqliteExprIfFalse(pParse, aExpr[j].p, cont, 1);          aExpr[j].p = 0; @@ -1106,8 +1140,9 @@ WhereInfo *sqliteWhereBegin(    }    pWInfo->iContinue = cont;    if( pushKey && !haveKey ){ -    sqliteVdbeAddOp(v, OP_Recno, base, 0); +    sqliteVdbeAddOp(v, OP_Recno, pTabList->a[0].iCursor, 0);    } +  freeMaskSet(&maskSet);    return pWInfo;  } @@ -1118,7 +1153,6 @@ WhereInfo *sqliteWhereBegin(  void sqliteWhereEnd(WhereInfo *pWInfo){    Vdbe *v = pWInfo->pParse->pVdbe;    int i; -  int base = pWInfo->base;    WhereLevel *pLevel;    SrcList *pTabList = pWInfo->pTabList; @@ -1136,7 +1170,7 @@ void sqliteWhereEnd(WhereInfo *pWInfo){        int addr;        addr = sqliteVdbeAddOp(v, OP_MemLoad, pLevel->iLeftJoin, 0);        sqliteVdbeAddOp(v, OP_NotNull, 1, addr+4 + (pLevel->iCur>=0)); -      sqliteVdbeAddOp(v, OP_NullRow, base+i, 0); +      sqliteVdbeAddOp(v, OP_NullRow, pTabList->a[i].iCursor, 0);        if( pLevel->iCur>=0 ){          sqliteVdbeAddOp(v, OP_NullRow, pLevel->iCur, 0);        } @@ -1145,9 +1179,11 @@ void sqliteWhereEnd(WhereInfo *pWInfo){    }    sqliteVdbeResolveLabel(v, pWInfo->iBreak);    for(i=0; i<pTabList->nSrc; i++){ -    if( pTabList->a[i].pTab->isTransient ) continue; +    Table *pTab = pTabList->a[i].pTab; +    assert( pTab!=0 ); +    if( pTab->isTransient || pTab->pSelect ) continue;      pLevel = &pWInfo->a[i]; -    sqliteVdbeAddOp(v, OP_Close, base+i, 0); +    sqliteVdbeAddOp(v, OP_Close, pTabList->a[i].iCursor, 0);      if( pLevel->pIdx!=0 ){        sqliteVdbeAddOp(v, OP_Close, pLevel->iCur, 0);      } diff --git a/ext/sqlite/php_sqlite.h b/ext/sqlite/php_sqlite.h index e6aae260c3..4755d53ef8 100644 --- a/ext/sqlite/php_sqlite.h +++ b/ext/sqlite/php_sqlite.h @@ -77,7 +77,7 @@ PHP_FUNCTION(sqlite_create_aggregate);  PHP_FUNCTION(sqlite_create_function);  ZEND_BEGIN_MODULE_GLOBALS(sqlite) -	 int assoc_case; +	 long assoc_case;  ZEND_END_MODULE_GLOBALS(sqlite)  #ifdef ZTS diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 5aa2a55b21..7d5d1b382c 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -42,6 +42,10 @@  #define safe_emalloc(a,b,c) emalloc((a)*(b)+(c))  #endif +#ifndef OnUpdateLong +# define OnUpdateLong OnUpdateInt +#endif +  ZEND_DECLARE_MODULE_GLOBALS(sqlite)  extern int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out); @@ -70,7 +74,7 @@ static inline void php_sqlite_strtolower(char *s)  /* {{{ PHP_INI   */  PHP_INI_BEGIN() -STD_PHP_INI_ENTRY_EX("sqlite.assoc_case", "0", PHP_INI_ALL, OnUpdateInt, assoc_case, zend_sqlite_globals, sqlite_globals, display_link_numbers) +STD_PHP_INI_ENTRY_EX("sqlite.assoc_case", "0", PHP_INI_ALL, OnUpdateLong, assoc_case, zend_sqlite_globals, sqlite_globals, display_link_numbers)  PHP_INI_END()  /* }}} */ @@ -553,7 +557,8 @@ static void php_sqlite_agg_fini_function_callback(sqlite_func *func)  /* }}} */  /* {{{ Authorization Callback */ -static int php_sqlite_authorizer(void *autharg, int access_type, const char *arg3, const char *arg4) +static int php_sqlite_authorizer(void *autharg, int access_type, const char *arg3, const char *arg4, +		const char *arg5, const char *arg6)  {  	switch (access_type) {  		case SQLITE_COPY: @@ -674,7 +679,9 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per  	 * then fail with a busy status code */  	sqlite_busy_timeout(sdb, 500); -	/* authorizer hook so we can enforce safe mode */ +	/* authorizer hook so we can enforce safe mode. +     * Note: the declaration of php_sqlite_authorizer is correct for 2.8.2 of libsqlite, +     * and IS backwards binary compatible with earlier versions */  	sqlite_set_authorizer(sdb, php_sqlite_authorizer, NULL);  	db->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, db, persistent_id ? le_sqlite_pdb : le_sqlite_db);  | 
