Fossil

Check-in [f8994f89]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the built-in SQLite to the latest trunk version which includes the fix for EXPLAIN QUERY PLAN for the query that runs the /forum page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f8994f8975d86d224965b89d5a616fef7ec55a3760b066a5c91058a1f921638e
User & Date: drh 2018-08-16 16:26:05.579
Context
2018-08-16
16:45
Do not show posts that are awaiting moderation to users without moderator privilege unless they are the same user that generated the post in the first place. ... (check-in: 16c42a08 user: drh tags: trunk)
16:26
Update the built-in SQLite to the latest trunk version which includes the fix for EXPLAIN QUERY PLAN for the query that runs the /forum page. ... (check-in: f8994f89 user: drh tags: trunk)
16:13
Adjust the /forum page so that it for users without forum moderator privilege, it pretends that unmoderated posts do not exist, and for user with moderator privilege it paints an "Awaiting Moderator Approval" message on posts that need moderation. ... (check-in: ef7f85ee user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/shell.c.
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
  int nLine = zLine==0 ? 0 : 100;
  int n = 0;

  while( 1 ){
    if( n+100>nLine ){
      nLine = nLine*2 + 100;
      zLine = realloc(zLine, nLine);
      if( zLine==0 ) return 0;
    }
    if( fgets(&zLine[n], nLine - n, in)==0 ){
      if( n==0 ){
        free(zLine);
        return 0;
      }
      zLine[n] = 0;







|







582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
  int nLine = zLine==0 ? 0 : 100;
  int n = 0;

  while( 1 ){
    if( n+100>nLine ){
      nLine = nLine*2 + 100;
      zLine = realloc(zLine, nLine);
      if( zLine==0 ) shell_out_of_memory();
    }
    if( fgets(&zLine[n], nLine - n, in)==0 ){
      if( n==0 ){
        free(zLine);
        return 0;
      }
      zLine[n] = 0;
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
  ** multi-byte characterset characters into UTF-8. */
  if( stdin_is_interactive && in==stdin ){
    char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
    if( zTrans ){
      int nTrans = strlen30(zTrans)+1;
      if( nTrans>nLine ){
        zLine = realloc(zLine, nTrans);
        if( zLine==0 ){
          sqlite3_free(zTrans);
          return 0;
        }
      }
      memcpy(zLine, zTrans, nTrans);
      sqlite3_free(zTrans);
    }
  }
#endif /* defined(_WIN32) || defined(WIN32) */
  return zLine;







|
<
<
<







609
610
611
612
613
614
615
616



617
618
619
620
621
622
623
  ** multi-byte characterset characters into UTF-8. */
  if( stdin_is_interactive && in==stdin ){
    char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
    if( zTrans ){
      int nTrans = strlen30(zTrans)+1;
      if( nTrans>nLine ){
        zLine = realloc(zLine, nTrans);
        if( zLine==0 ) shell_out_of_memory();



      }
      memcpy(zLine, zTrans, nTrans);
      sqlite3_free(zTrans);
    }
  }
#endif /* defined(_WIN32) || defined(WIN32) */
  return zLine;
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
      if( zAppend[i]==quote ) len++;
    }
  }

  if( p->n+len>=p->nAlloc ){
    p->nAlloc = p->nAlloc*2 + len + 20;
    p->z = realloc(p->z, p->nAlloc);
    if( p->z==0 ){
      memset(p, 0, sizeof(*p));
      return;
    }
  }

  if( quote ){
    char *zCsr = p->z+p->n;
    *zCsr++ = quote;
    for(i=0; i<nAppend; i++){
      *zCsr++ = zAppend[i];







|
<
<
<







756
757
758
759
760
761
762
763



764
765
766
767
768
769
770
      if( zAppend[i]==quote ) len++;
    }
  }

  if( p->n+len>=p->nAlloc ){
    p->nAlloc = p->nAlloc*2 + len + 20;
    p->z = realloc(p->z, p->nAlloc);
    if( p->z==0 ) shell_out_of_memory();



  }

  if( quote ){
    char *zCsr = p->z+p->n;
    *zCsr++ = quote;
    for(i=0; i<nAppend; i++){
      *zCsr++ = zAppend[i];
8688
8689
8690
8691
8692
8693
8694

8695
8696
8697
8698
8699
8700
8701
){
  const char *zEditor;
  char *zTempFile = 0;
  sqlite3 *db;
  char *zCmd = 0;
  int bBin;
  int rc;

  FILE *f = 0;
  sqlite3_int64 sz;
  sqlite3_int64 x;
  unsigned char *p = 0;

  if( argc==2 ){
    zEditor = (const char*)sqlite3_value_text(argv[1]);







>







8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
){
  const char *zEditor;
  char *zTempFile = 0;
  sqlite3 *db;
  char *zCmd = 0;
  int bBin;
  int rc;
  int hasCRNL = 0;
  FILE *f = 0;
  sqlite3_int64 sz;
  sqlite3_int64 x;
  unsigned char *p = 0;

  if( argc==2 ){
    zEditor = (const char*)sqlite3_value_text(argv[1]);
8719
8720
8721
8722
8723
8724
8725


8726
8727
8728
8729
8730
8731
8732
8733
8734



8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782














8783
8784
8785
8786
8787
8788
8789
    zTempFile = sqlite3_mprintf("temp%llx", r);
    if( zTempFile==0 ){
      sqlite3_result_error_nomem(context);
      return;
    }
  }
  bBin = sqlite3_value_type(argv[0])==SQLITE_BLOB;


  f = fopen(zTempFile, bBin ? "wb" : "w");
  if( f==0 ){
    sqlite3_result_error(context, "edit() cannot open temp file", -1);
    goto edit_func_end;
  }
  sz = sqlite3_value_bytes(argv[0]);
  if( bBin ){
    x = fwrite(sqlite3_value_blob(argv[0]), 1, sz, f);
  }else{



    x = fwrite(sqlite3_value_text(argv[0]), 1, sz, f);
  }
  fclose(f);
  f = 0;
  if( x!=sz ){
    sqlite3_result_error(context, "edit() could not write the whole file", -1);
    goto edit_func_end;
  }
  zCmd = sqlite3_mprintf("%s \"%s\"", zEditor, zTempFile);
  if( zCmd==0 ){
    sqlite3_result_error_nomem(context);
    goto edit_func_end;
  }
  rc = system(zCmd);
  sqlite3_free(zCmd);
  if( rc ){
    sqlite3_result_error(context, "EDITOR returned non-zero", -1);
    goto edit_func_end;
  }
  f = fopen(zTempFile, bBin ? "rb" : "r");
  if( f==0 ){
    sqlite3_result_error(context,
      "edit() cannot reopen temp file after edit", -1);
    goto edit_func_end;
  }
  fseek(f, 0, SEEK_END);
  sz = ftell(f);
  rewind(f);
  p = sqlite3_malloc64( sz+(bBin==0) );
  if( p==0 ){
    sqlite3_result_error_nomem(context);
    goto edit_func_end;
  }
  if( bBin ){
    x = fread(p, 1, sz, f);
  }else{
    x = fread(p, 1, sz, f);
    p[sz] = 0;
  }
  fclose(f);
  f = 0;
  if( x!=sz ){
    sqlite3_result_error(context, "could not read back the whole file", -1);
    goto edit_func_end;
  }
  if( bBin ){
    sqlite3_result_blob64(context, p, sz, sqlite3_free);
  }else{














    sqlite3_result_text64(context, (const char*)p, sz,
                          sqlite3_free, SQLITE_UTF8);
  }
  p = 0;

edit_func_end:
  if( f ) fclose(f);







>
>









>
>
>



















|













<
|
<
<
<
<









>
>
>
>
>
>
>
>
>
>
>
>
>
>







8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767

8768




8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
    zTempFile = sqlite3_mprintf("temp%llx", r);
    if( zTempFile==0 ){
      sqlite3_result_error_nomem(context);
      return;
    }
  }
  bBin = sqlite3_value_type(argv[0])==SQLITE_BLOB;
  /* When writing the file to be edited, do \n to \r\n conversions on systems
  ** that want \r\n line endings */
  f = fopen(zTempFile, bBin ? "wb" : "w");
  if( f==0 ){
    sqlite3_result_error(context, "edit() cannot open temp file", -1);
    goto edit_func_end;
  }
  sz = sqlite3_value_bytes(argv[0]);
  if( bBin ){
    x = fwrite(sqlite3_value_blob(argv[0]), 1, sz, f);
  }else{
    const char *z = (const char*)sqlite3_value_text(argv[0]);
    /* Remember whether or not the value originally contained \r\n */
    if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
    x = fwrite(sqlite3_value_text(argv[0]), 1, sz, f);
  }
  fclose(f);
  f = 0;
  if( x!=sz ){
    sqlite3_result_error(context, "edit() could not write the whole file", -1);
    goto edit_func_end;
  }
  zCmd = sqlite3_mprintf("%s \"%s\"", zEditor, zTempFile);
  if( zCmd==0 ){
    sqlite3_result_error_nomem(context);
    goto edit_func_end;
  }
  rc = system(zCmd);
  sqlite3_free(zCmd);
  if( rc ){
    sqlite3_result_error(context, "EDITOR returned non-zero", -1);
    goto edit_func_end;
  }
  f = fopen(zTempFile, "rb");
  if( f==0 ){
    sqlite3_result_error(context,
      "edit() cannot reopen temp file after edit", -1);
    goto edit_func_end;
  }
  fseek(f, 0, SEEK_END);
  sz = ftell(f);
  rewind(f);
  p = sqlite3_malloc64( sz+(bBin==0) );
  if( p==0 ){
    sqlite3_result_error_nomem(context);
    goto edit_func_end;
  }

  x = fread(p, 1, sz, f);




  fclose(f);
  f = 0;
  if( x!=sz ){
    sqlite3_result_error(context, "could not read back the whole file", -1);
    goto edit_func_end;
  }
  if( bBin ){
    sqlite3_result_blob64(context, p, sz, sqlite3_free);
  }else{
    int i, j;
    if( hasCRNL ){
      /* If the original contains \r\n then do no conversions back to \n */
      j = sz;
    }else{
      /* If the file did not originally contain \r\n then convert any new
      ** \r\n back into \n */
      for(i=j=0; i<sz; i++){
        if( p[i]=='\r' && p[i+1]=='\n' ) i++;
        p[j++] = p[i];
      }
      sz = j;
      p[sz] = 0;
    } 
    sqlite3_result_text64(context, (const char*)p, sz,
                          sqlite3_free, SQLITE_UTF8);
  }
  p = 0;

edit_func_end:
  if( f ) fclose(f);
10126
10127
10128
10129
10130
10131
10132

10133

10134
10135
10136
10137
10138
10139
10140
            sqlite3_reset(pSql);
            return;
          }
        }
      }
      nAlloc += 100;
      p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));

      abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));

    }
    abYield[iOp] = str_in_array(zOp, azYield);
    p->aiIndent[iOp] = 0;
    p->nIndent = iOp+1;

    if( str_in_array(zOp, azNext) ){
      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;







>

>







10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
            sqlite3_reset(pSql);
            return;
          }
        }
      }
      nAlloc += 100;
      p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
      if( p->aiIndent==0 ) shell_out_of_memory();
      abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
      if( abYield==0 ) shell_out_of_memory();
    }
    abYield[iOp] = str_in_array(zOp, azYield);
    p->aiIndent[iOp] = 0;
    p->nIndent = iOp+1;

    if( str_in_array(zOp, azNext) ){
      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
Changes to src/sqlite3.c.
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.25.0"
#define SQLITE_VERSION_NUMBER 3025000
#define SQLITE_SOURCE_ID      "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros







|







1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.25.0"
#define SQLITE_VERSION_NUMBER 3025000
#define SQLITE_SOURCE_ID      "2018-08-16 16:24:24 456842924bb33c0af8af29402f06e5f25b6791f698a0d12a080258b20b0cfb61"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
**
** The following must be true for this function to succeed. If any of
** the following statements are false when sqlite3_snapshot_get() is
** called, SQLITE_ERROR is returned. The final value of *P is undefined
** in this case. 
**
** <ul>
**   <li> The database handle must be in [autocommit mode].
**
**   <li> Schema S of [database connection] D must be a [WAL mode] database.
**
**   <li> There must not be a write transaction open on schema S of database
**        connection D.
**
**   <li> One or more transactions must have been written to the current wal







|







10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
**
** The following must be true for this function to succeed. If any of
** the following statements are false when sqlite3_snapshot_get() is
** called, SQLITE_ERROR is returned. The final value of *P is undefined
** in this case. 
**
** <ul>
**   <li> The database handle must not be in [autocommit mode].
**
**   <li> Schema S of [database connection] D must be a [WAL mode] database.
**
**   <li> There must not be a write transaction open on schema S of database
**        connection D.
**
**   <li> One or more transactions must have been written to the current wal
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081




10082

10083
10084
10085

10086








10087
10088
10089
10090
10091
10092
10093
  sqlite3_snapshot **ppSnapshot
);

/*
** CAPI3REF: Start a read transaction on an historical snapshot
** METHOD: sqlite3_snapshot
**
** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
** read transaction for schema S of
** [database connection] D such that the read transaction
** refers to historical [snapshot] P, rather than the most
** recent change to the database.
** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
** or an appropriate [error code] if it fails.
**
** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
** the first operation following the [BEGIN] that takes the schema S
** out of [autocommit mode].




** ^In other words, schema S must not currently be in

** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the
** database connection D must be out of [autocommit mode].
** ^A [snapshot] will fail to open if it has been overwritten by a

** [checkpoint].








** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
** database connection D does not know that the database file for
** schema S is in [WAL mode].  A database connection might not know
** that the database file is in [WAL mode] if there has been no prior
** I/O on that database connection, or if the database entered [WAL mode] 
** after the most recent I/O on the database connection.)^
** (Hint: Run "[PRAGMA application_id]" against a newly opened







|
|
|
|
<
|
|

|
<
|
>
>
>
>
|
>
|
<
|
>
|
>
>
>
>
>
>
>
>







10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074

10075
10076
10077
10078

10079
10080
10081
10082
10083
10084
10085
10086

10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
  sqlite3_snapshot **ppSnapshot
);

/*
** CAPI3REF: Start a read transaction on an historical snapshot
** METHOD: sqlite3_snapshot
**
** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read 
** transaction or upgrades an existing one for schema S of 
** [database connection] D such that the read transaction refers to 
** historical [snapshot] P, rather than the most recent change to the 

** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK 
** on success or an appropriate [error code] if it fails.
**
** ^In order to succeed, the database connection must not be in 

** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there
** is already a read transaction open on schema S, then the database handle
** must have no active statements (SELECT statements that have been passed
** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). 
** SQLITE_ERROR is returned if either of these conditions is violated, or
** if schema S does not exist, or if the snapshot object is invalid.
**
** ^A call to sqlite3_snapshot_open() will fail to open if the specified

** snapshot has been overwritten by a [checkpoint]. In this case 
** SQLITE_BUSY_SNAPSHOT is returned.
**
** If there is already a read transaction open when this function is 
** invoked, then the same read transaction remains open (on the same
** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
** is returned. If another error code - for example SQLITE_PROTOCOL or an
** SQLITE_IOERR error code - is returned, then the final state of the
** read transaction is undefined. If SQLITE_OK is returned, then the 
** read transaction is now open on database snapshot P.
**
** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
** database connection D does not know that the database file for
** schema S is in [WAL mode].  A database connection might not know
** that the database file is in [WAL mode] if there has been no prior
** I/O on that database connection, or if the database entered [WAL mode] 
** after the most recent I/O on the database connection.)^
** (Hint: Run "[PRAGMA application_id]" against a newly opened
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
# define NDEBUG 1
#endif
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
# undef NDEBUG
#endif

/* SQLITE_DEBUG_COLUMNCACHE is synomous with SQLITE_DEBUG.  The 
** SQLITE_DEBUG_COLUMNCACHE symbol only exists to provide a convenient
** way to search for all code that deals with verifying correct behavior
** of the column cache.
*/
#ifdef SQLITE_DEBUG
# define SQLITE_DEBUG_COLUMNCACHE 1
#else
# undef SQLIT_DEBUG_COLUMNCACHE
#endif

/*
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
*/
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#endif








<
<
<
<
<
<
<
<
<
<
<







13017
13018
13019
13020
13021
13022
13023











13024
13025
13026
13027
13028
13029
13030
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
# define NDEBUG 1
#endif
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
# undef NDEBUG
#endif












/*
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
*/
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#endif

14718
14719
14720
14721
14722
14723
14724




14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769




14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804




14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865

14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
#define OP_Lt             56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
#define OP_Ge             57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
#define OP_ElseNotEq      58 /* jump, same as TK_ESCAPE                    */
#define OP_IncrVacuum     59 /* jump                                       */
#define OP_VNext          60 /* jump                                       */
#define OP_Init           61 /* jump, synopsis: Start at P2                */




#define OP_Return         62
#define OP_EndCoroutine   63
#define OP_HaltIfNull     64 /* synopsis: if r[P3]=null halt               */
#define OP_Halt           65
#define OP_Integer        66 /* synopsis: r[P2]=P1                         */
#define OP_Int64          67 /* synopsis: r[P2]=P4                         */
#define OP_String         68 /* synopsis: r[P2]='P4' (len=P1)              */
#define OP_Null           69 /* synopsis: r[P2..P3]=NULL                   */
#define OP_SoftNull       70 /* synopsis: r[P1]=NULL                       */
#define OP_Blob           71 /* synopsis: r[P2]=P4 (len=P1)                */
#define OP_Variable       72 /* synopsis: r[P2]=parameter(P1,P4)           */
#define OP_Move           73 /* synopsis: r[P2@P3]=r[P1@P3]                */
#define OP_Copy           74 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
#define OP_SCopy          75 /* synopsis: r[P2]=r[P1]                      */
#define OP_IntCopy        76 /* synopsis: r[P2]=r[P1]                      */
#define OP_ResultRow      77 /* synopsis: output=r[P1@P2]                  */
#define OP_CollSeq        78
#define OP_AddImm         79 /* synopsis: r[P1]=r[P1]+P2                   */
#define OP_RealAffinity   80
#define OP_Cast           81 /* synopsis: affinity(r[P1])                  */
#define OP_Permutation    82
#define OP_Compare        83 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
#define OP_IsTrue         84 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_Offset         85 /* synopsis: r[P3] = sqlite_offset(P1)        */
#define OP_Column         86 /* synopsis: r[P3]=PX                         */
#define OP_Affinity       87 /* synopsis: affinity(r[P1@P2])               */
#define OP_MakeRecord     88 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
#define OP_Count          89 /* synopsis: r[P2]=count()                    */
#define OP_ReadCookie     90
#define OP_SetCookie      91
#define OP_BitAnd         92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr          93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft      94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight     95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add            96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract       97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply       98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide         99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder     100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat        101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_ReopenIdx     102 /* synopsis: root=P2 iDb=P3                   */
#define OP_BitNot        103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
#define OP_OpenRead      104 /* synopsis: root=P2 iDb=P3                   */
#define OP_OpenWrite     105 /* synopsis: root=P2 iDb=P3                   */
#define OP_String8       106 /* same as TK_STRING, synopsis: r[P2]='P4'    */




#define OP_OpenDup       107
#define OP_OpenAutoindex 108 /* synopsis: nColumn=P2                       */
#define OP_OpenEphemeral 109 /* synopsis: nColumn=P2                       */
#define OP_SorterOpen    110
#define OP_SequenceTest  111 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */
#define OP_OpenPseudo    112 /* synopsis: P3 columns in r[P2]              */
#define OP_Close         113
#define OP_ColumnsUsed   114
#define OP_SeekHit       115 /* synopsis: seekHit=P2                       */
#define OP_Sequence      116 /* synopsis: r[P2]=cursor[P1].ctr++           */
#define OP_NewRowid      117 /* synopsis: r[P2]=rowid                      */
#define OP_Insert        118 /* synopsis: intkey=r[P3] data=r[P2]          */
#define OP_InsertInt     119 /* synopsis: intkey=P3 data=r[P2]             */
#define OP_Delete        120
#define OP_ResetCount    121
#define OP_SorterCompare 122 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
#define OP_SorterData    123 /* synopsis: r[P2]=data                       */
#define OP_RowData       124 /* synopsis: r[P2]=data                       */
#define OP_Rowid         125 /* synopsis: r[P2]=rowid                      */
#define OP_NullRow       126
#define OP_SeekEnd       127
#define OP_SorterInsert  128 /* synopsis: key=r[P2]                        */
#define OP_IdxInsert     129 /* synopsis: key=r[P2]                        */
#define OP_IdxDelete     130 /* synopsis: key=r[P2@P3]                     */
#define OP_DeferredSeek  131 /* synopsis: Move P3 to P1.rowid if needed    */
#define OP_IdxRowid      132 /* synopsis: r[P2]=rowid                      */
#define OP_Destroy       133
#define OP_Clear         134
#define OP_ResetSorter   135
#define OP_CreateBtree   136 /* synopsis: r[P2]=root iDb=P1 flags=P3       */
#define OP_SqlExec       137
#define OP_ParseSchema   138
#define OP_LoadAnalysis  139
#define OP_DropTable     140
#define OP_Real          141 /* same as TK_FLOAT, synopsis: r[P2]=P4       */




#define OP_DropIndex     142
#define OP_DropTrigger   143
#define OP_IntegrityCk   144
#define OP_RowSetAdd     145 /* synopsis: rowset(P1)=r[P2]                 */
#define OP_Param         146
#define OP_FkCounter     147 /* synopsis: fkctr[P1]+=P2                    */
#define OP_MemMax        148 /* synopsis: r[P1]=max(r[P1],r[P2])           */
#define OP_OffsetLimit   149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
#define OP_AggInverse    150 /* synopsis: accum=r[P3] inverse(r[P2@P5])    */
#define OP_AggStep       151 /* synopsis: accum=r[P3] step(r[P2@P5])       */
#define OP_AggStep1      152 /* synopsis: accum=r[P3] step(r[P2@P5])       */
#define OP_AggValue      153 /* synopsis: r[P3]=value N=P2                 */
#define OP_AggFinal      154 /* synopsis: accum=r[P1] N=P2                 */
#define OP_Expire        155
#define OP_TableLock     156 /* synopsis: iDb=P1 root=P2 write=P3          */
#define OP_VBegin        157
#define OP_VCreate       158
#define OP_VDestroy      159
#define OP_VOpen         160
#define OP_VColumn       161 /* synopsis: r[P3]=vcolumn(P2)                */
#define OP_VRename       162
#define OP_Pagecount     163
#define OP_MaxPgcnt      164
#define OP_PureFunc0     165
#define OP_Function0     166 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_PureFunc      167
#define OP_Function      168 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_Trace         169
#define OP_CursorHint    170
#define OP_SetTabCol     171
#define OP_VerifyTabCol  172
#define OP_Noop          173
#define OP_Explain       174
#define OP_Abortable     175

/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
#define OPFLG_INITIALIZER {\
/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
/*   8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
/*  16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
/*  32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
/*  40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/*  56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,\
/*  64 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
/*  72 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x02,\
/*  80 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x20, 0x00, 0x00,\
/*  88 */ 0x00, 0x10, 0x10, 0x00, 0x26, 0x26, 0x26, 0x26,\
/*  96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
/* 104 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\

/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
/* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
/* 136 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 160 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
}

/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode.  The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/







>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<










|

|
|

>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<

>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<


<
<
|
|
|



















|
|
|
|
|

|
|
>
|
|
|
|
<
|
|
<







14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754




14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803




14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831




14832
14833


14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868

14869
14870

14871
14872
14873
14874
14875
14876
14877
#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
#define OP_Lt             56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
#define OP_Ge             57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
#define OP_ElseNotEq      58 /* jump, same as TK_ESCAPE                    */
#define OP_IncrVacuum     59 /* jump                                       */
#define OP_VNext          60 /* jump                                       */
#define OP_Init           61 /* jump, synopsis: Start at P2                */
#define OP_PureFunc0      62
#define OP_Function0      63 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_PureFunc       64
#define OP_Function       65 /* synopsis: r[P3]=func(r[P2@P5])             */
#define OP_Return         66
#define OP_EndCoroutine   67
#define OP_HaltIfNull     68 /* synopsis: if r[P3]=null halt               */
#define OP_Halt           69
#define OP_Integer        70 /* synopsis: r[P2]=P1                         */
#define OP_Int64          71 /* synopsis: r[P2]=P4                         */
#define OP_String         72 /* synopsis: r[P2]='P4' (len=P1)              */
#define OP_Null           73 /* synopsis: r[P2..P3]=NULL                   */
#define OP_SoftNull       74 /* synopsis: r[P1]=NULL                       */
#define OP_Blob           75 /* synopsis: r[P2]=P4 (len=P1)                */
#define OP_Variable       76 /* synopsis: r[P2]=parameter(P1,P4)           */
#define OP_Move           77 /* synopsis: r[P2@P3]=r[P1@P3]                */
#define OP_Copy           78 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
#define OP_SCopy          79 /* synopsis: r[P2]=r[P1]                      */
#define OP_IntCopy        80 /* synopsis: r[P2]=r[P1]                      */
#define OP_ResultRow      81 /* synopsis: output=r[P1@P2]                  */
#define OP_CollSeq        82
#define OP_AddImm         83 /* synopsis: r[P1]=r[P1]+P2                   */
#define OP_RealAffinity   84
#define OP_Cast           85 /* synopsis: affinity(r[P1])                  */
#define OP_Permutation    86
#define OP_Compare        87 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
#define OP_IsTrue         88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_Offset         89 /* synopsis: r[P3] = sqlite_offset(P1)        */
#define OP_Column         90 /* synopsis: r[P3]=PX                         */
#define OP_Affinity       91 /* synopsis: affinity(r[P1@P2])               */




#define OP_BitAnd         92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr          93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft      94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight     95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add            96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract       97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply       98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide         99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder     100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat        101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_MakeRecord    102 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
#define OP_BitNot        103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
#define OP_Count         104 /* synopsis: r[P2]=count()                    */
#define OP_ReadCookie    105
#define OP_String8       106 /* same as TK_STRING, synopsis: r[P2]='P4'    */
#define OP_SetCookie     107
#define OP_ReopenIdx     108 /* synopsis: root=P2 iDb=P3                   */
#define OP_OpenRead      109 /* synopsis: root=P2 iDb=P3                   */
#define OP_OpenWrite     110 /* synopsis: root=P2 iDb=P3                   */
#define OP_OpenDup       111
#define OP_OpenAutoindex 112 /* synopsis: nColumn=P2                       */
#define OP_OpenEphemeral 113 /* synopsis: nColumn=P2                       */
#define OP_SorterOpen    114
#define OP_SequenceTest  115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */
#define OP_OpenPseudo    116 /* synopsis: P3 columns in r[P2]              */
#define OP_Close         117
#define OP_ColumnsUsed   118
#define OP_SeekHit       119 /* synopsis: seekHit=P2                       */
#define OP_Sequence      120 /* synopsis: r[P2]=cursor[P1].ctr++           */
#define OP_NewRowid      121 /* synopsis: r[P2]=rowid                      */
#define OP_Insert        122 /* synopsis: intkey=r[P3] data=r[P2]          */
#define OP_InsertInt     123 /* synopsis: intkey=P3 data=r[P2]             */
#define OP_Delete        124
#define OP_ResetCount    125
#define OP_SorterCompare 126 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
#define OP_SorterData    127 /* synopsis: r[P2]=data                       */
#define OP_RowData       128 /* synopsis: r[P2]=data                       */
#define OP_Rowid         129 /* synopsis: r[P2]=rowid                      */
#define OP_NullRow       130
#define OP_SeekEnd       131
#define OP_SorterInsert  132 /* synopsis: key=r[P2]                        */
#define OP_IdxInsert     133 /* synopsis: key=r[P2]                        */
#define OP_IdxDelete     134 /* synopsis: key=r[P2@P3]                     */
#define OP_DeferredSeek  135 /* synopsis: Move P3 to P1.rowid if needed    */
#define OP_IdxRowid      136 /* synopsis: r[P2]=rowid                      */
#define OP_Destroy       137
#define OP_Clear         138
#define OP_ResetSorter   139
#define OP_CreateBtree   140 /* synopsis: r[P2]=root iDb=P1 flags=P3       */




#define OP_Real          141 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
#define OP_SqlExec       142
#define OP_ParseSchema   143
#define OP_LoadAnalysis  144
#define OP_DropTable     145
#define OP_DropIndex     146
#define OP_DropTrigger   147
#define OP_IntegrityCk   148
#define OP_RowSetAdd     149 /* synopsis: rowset(P1)=r[P2]                 */
#define OP_Param         150
#define OP_FkCounter     151 /* synopsis: fkctr[P1]+=P2                    */
#define OP_MemMax        152 /* synopsis: r[P1]=max(r[P1],r[P2])           */
#define OP_OffsetLimit   153 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
#define OP_AggInverse    154 /* synopsis: accum=r[P3] inverse(r[P2@P5])    */
#define OP_AggStep       155 /* synopsis: accum=r[P3] step(r[P2@P5])       */
#define OP_AggStep1      156 /* synopsis: accum=r[P3] step(r[P2@P5])       */
#define OP_AggValue      157 /* synopsis: r[P3]=value N=P2                 */
#define OP_AggFinal      158 /* synopsis: accum=r[P1] N=P2                 */
#define OP_Expire        159
#define OP_TableLock     160 /* synopsis: iDb=P1 root=P2 write=P3          */
#define OP_VBegin        161
#define OP_VCreate       162
#define OP_VDestroy      163
#define OP_VOpen         164
#define OP_VColumn       165 /* synopsis: r[P3]=vcolumn(P2)                */
#define OP_VRename       166
#define OP_Pagecount     167
#define OP_MaxPgcnt      168




#define OP_Trace         169
#define OP_CursorHint    170


#define OP_Noop          171
#define OP_Explain       172
#define OP_Abortable     173

/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
#define OPFLG_INITIALIZER {\
/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
/*   8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
/*  16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
/*  32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
/*  40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/*  56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
/*  64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
/*  72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
/*  80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
/*  88 */ 0x12, 0x20, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26,\
/*  96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
/* 104 */ 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 128 */ 0x00, 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00,\
/* 136 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
/* 152 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\

/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
/* 168 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,}


/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode.  The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
#ifdef SQLITE_COVERAGE_TEST
SQLITE_PRIVATE   int sqlite3VdbeLabelHasBeenResolved(Vdbe*,int);
#endif
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);
#endif
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);







<
<
<







14945
14946
14947
14948
14949
14950
14951



14952
14953
14954
14955
14956
14957
14958
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);



SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);
#endif
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
15281
15282
15283
15284
15285
15286
15287


15288
15289
15290
15291
15292
15293
15294
# ifdef SQLITE_DIRECT_OVERFLOW_READ
SQLITE_PRIVATE   int sqlite3PagerUseWal(Pager *pPager, Pgno);
# endif
# ifdef SQLITE_ENABLE_SNAPSHOT
SQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
SQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE   int sqlite3PagerSnapshotRecover(Pager *pPager);


# endif
#else
# define sqlite3PagerUseWal(x,y) 0
#endif

#ifdef SQLITE_ENABLE_ZIPVFS
SQLITE_PRIVATE   int sqlite3PagerWalFramesize(Pager *pPager);







>
>







15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
# ifdef SQLITE_DIRECT_OVERFLOW_READ
SQLITE_PRIVATE   int sqlite3PagerUseWal(Pager *pPager, Pgno);
# endif
# ifdef SQLITE_ENABLE_SNAPSHOT
SQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
SQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE   int sqlite3PagerSnapshotRecover(Pager *pPager);
SQLITE_PRIVATE   int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE   void sqlite3PagerSnapshotUnlock(Pager *pPager);
# endif
#else
# define sqlite3PagerUseWal(x,y) 0
#endif

#ifdef SQLITE_ENABLE_ZIPVFS
SQLITE_PRIVATE   int sqlite3PagerWalFramesize(Pager *pPager);
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309

16310
16311
16312
16313
16314
16315
16316

/*
** Bits of the sqlite3.dbOptFlags field that are used by the
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
** selectively disable various optimizations.
*/
#define SQLITE_QueryFlattener 0x0001   /* Query flattening */
#define SQLITE_ColumnCache    0x0002   /* Column cache */
#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */
#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */
#define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */
#define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */
#define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */
#define SQLITE_Transitive     0x0080   /* Transitive constraints */
#define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */
#define SQLITE_CountOfView    0x0200   /* The count-of-view optimization */
#define SQLITE_CursorHints    0x0400   /* Add OP_CursorHint opcodes */
#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */
   /* TH3 expects the Stat34  ^^^^^^ value to be 0x0800.  Don't change it */
#define SQLITE_PushDown       0x1000   /* The push-down optimization */
#define SQLITE_SimplifyJoin   0x2000   /* Convert LEFT JOIN to JOIN */
#define SQLITE_SkipScan       0x4000   /* Skip-scans */

#define SQLITE_AllOpts        0xffff   /* All optimizations */

/*
** Macros for testing whether or not optimizations are enabled or disabled.
*/
#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)
#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)







|














>







16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313

/*
** Bits of the sqlite3.dbOptFlags field that are used by the
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
** selectively disable various optimizations.
*/
#define SQLITE_QueryFlattener 0x0001   /* Query flattening */
                          /*  0x0002   available for reuse */
#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */
#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */
#define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */
#define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */
#define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */
#define SQLITE_Transitive     0x0080   /* Transitive constraints */
#define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */
#define SQLITE_CountOfView    0x0200   /* The count-of-view optimization */
#define SQLITE_CursorHints    0x0400   /* Add OP_CursorHint opcodes */
#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */
   /* TH3 expects the Stat34  ^^^^^^ value to be 0x0800.  Don't change it */
#define SQLITE_PushDown       0x1000   /* The push-down optimization */
#define SQLITE_SimplifyJoin   0x2000   /* Convert LEFT JOIN to JOIN */
#define SQLITE_SkipScan       0x4000   /* Skip-scans */
#define SQLITE_PropagateConst 0x8000   /* The constant propagation opt */
#define SQLITE_AllOpts        0xffff   /* All optimizations */

/*
** Macros for testing whether or not optimizations are enabled or disabled.
*/
#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)
#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211

/*
** The following are the meanings of bits in the Expr.flags field.
*/
#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */
#define EP_Agg       0x000002 /* Contains one or more aggregate functions */
#define EP_HasFunc   0x000004 /* Contains one or more functions of any kind */
                  /* 0x000008 // available for use */
#define EP_Distinct  0x000010 /* Aggregate function with DISTINCT keyword */
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
#define EP_Collate   0x000100 /* Tree contains a TK_COLLATE operator */
#define EP_Generic   0x000200 /* Ignore COLLATE or affinity on this tree */
#define EP_IntValue  0x000400 /* Integer value contained in u.iValue */







|







17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208

/*
** The following are the meanings of bits in the Expr.flags field.
*/
#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */
#define EP_Agg       0x000002 /* Contains one or more aggregate functions */
#define EP_HasFunc   0x000004 /* Contains one or more functions of any kind */
#define EP_FixedCol  0x000008 /* TK_Column with a known fixed value */
#define EP_Distinct  0x000010 /* Aggregate function with DISTINCT keyword */
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
#define EP_Collate   0x000100 /* Tree contains a TK_COLLATE operator */
#define EP_Generic   0x000200 /* Ignore COLLATE or affinity on this tree */
#define EP_IntValue  0x000400 /* Integer value contained in u.iValue */
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
struct AutoincInfo {
  AutoincInfo *pNext;   /* Next info block in a list of them all */
  Table *pTab;          /* Table this info block refers to */
  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */
  int regCtr;           /* Memory register holding the rowid counter */
};

/*
** Size of the column cache
*/
#ifndef SQLITE_N_COLCACHE
# define SQLITE_N_COLCACHE 10
#endif

/*
** At least one instance of the following structure is created for each
** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
** statement. All such objects are stored in the linked list headed at
** Parse.pTriggerPrg and deleted once statement compilation has been
** completed.
**







<
<
<
<
<
<
<







17683
17684
17685
17686
17687
17688
17689







17690
17691
17692
17693
17694
17695
17696
struct AutoincInfo {
  AutoincInfo *pNext;   /* Next info block in a list of them all */
  Table *pTab;          /* Table this info block refers to */
  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */
  int regCtr;           /* Memory register holding the rowid counter */
};








/*
** At least one instance of the following structure is created for each
** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
** statement. All such objects are stored in the linked list headed at
** Parse.pTriggerPrg and deleted once statement compilation has been
** completed.
**
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
  u8 nested;           /* Number of nested calls to the parser/code generator */
  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */
  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */
  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */
  u8 okConstFactor;    /* OK to factor out constants */
  u8 disableLookaside; /* Number of times lookaside has been disabled */
  u8 nColCache;        /* Number of entries in aColCache[] */
  int nRangeReg;       /* Size of the temporary register block */
  int iRangeReg;       /* First register in temporary register block */
  int nErr;            /* Number of errors seen */
  int nTab;            /* Number of previously allocated VDBE cursors */
  int nMem;            /* Number of memory cells used so far */
  int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */
  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */
  int iSelfTab;        /* Table associated with an index on expr, or negative
                       ** of the base register during check-constraint eval */
  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  int nLabel;          /* Number of labels used */
  int *aLabel;         /* Space to hold the labels */
  ExprList *pConstExpr;/* Constant expressions */
  Token constraintName;/* Name of the constraint currently being parsed */
  yDbMask writeMask;   /* Start a write transaction on these databases */
  yDbMask cookieMask;  /* Bitmask of schema verified databases */
  int regRowid;        /* Register holding rowid of CREATE TABLE entry */







<









<
<







17758
17759
17760
17761
17762
17763
17764

17765
17766
17767
17768
17769
17770
17771
17772
17773


17774
17775
17776
17777
17778
17779
17780
  u8 nested;           /* Number of nested calls to the parser/code generator */
  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */
  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */
  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */
  u8 okConstFactor;    /* OK to factor out constants */
  u8 disableLookaside; /* Number of times lookaside has been disabled */

  int nRangeReg;       /* Size of the temporary register block */
  int iRangeReg;       /* First register in temporary register block */
  int nErr;            /* Number of errors seen */
  int nTab;            /* Number of previously allocated VDBE cursors */
  int nMem;            /* Number of memory cells used so far */
  int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */
  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */
  int iSelfTab;        /* Table associated with an index on expr, or negative
                       ** of the base register during check-constraint eval */


  int nLabel;          /* Number of labels used */
  int *aLabel;         /* Space to hold the labels */
  ExprList *pConstExpr;/* Constant expressions */
  Token constraintName;/* Name of the constraint currently being parsed */
  yDbMask writeMask;   /* Start a write transaction on these databases */
  yDbMask cookieMask;  /* Bitmask of schema verified databases */
  int regRowid;        /* Register holding rowid of CREATE TABLE entry */
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */
  u8 disableTriggers;  /* True to disable triggers */

  /**************************************************************************
  ** Fields above must be initialized to zero.  The fields that follow,
  ** down to the beginning of the recursive section, do not need to be
  ** initialized as they will be set before being used.  The boundary is
  ** determined by offsetof(Parse,aColCache).
  **************************************************************************/

  struct yColCache {
    int iTable;           /* Table cursor number */
    i16 iColumn;          /* Table column number */
    u8 tempReg;           /* iReg is a temp register that needs to be freed */
    int iLevel;           /* Nesting level */
    int iReg;             /* Reg with value of this column. 0 means none. */
    int lru;              /* Least recently used entry has the smallest value */
  } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */
  int aTempReg[8];        /* Holding area for temporary registers */
  Token sNameToken;       /* Token with unqualified schema object name */

  /************************************************************************
  ** Above is constant between recursions.  Below is reset before and after
  ** each recursion.  The boundary between these two regions is determined
  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the







|


<
<
<
<
<
<
<
<







17796
17797
17798
17799
17800
17801
17802
17803
17804
17805








17806
17807
17808
17809
17810
17811
17812
  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */
  u8 disableTriggers;  /* True to disable triggers */

  /**************************************************************************
  ** Fields above must be initialized to zero.  The fields that follow,
  ** down to the beginning of the recursive section, do not need to be
  ** initialized as they will be set before being used.  The boundary is
  ** determined by offsetof(Parse,aTempReg).
  **************************************************************************/









  int aTempReg[8];        /* Holding area for temporary registers */
  Token sNameToken;       /* Token with unqualified schema object name */

  /************************************************************************
  ** Above is constant between recursions.  Below is reset before and after
  ** each recursion.  The boundary between these two regions is determined
  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
  With *pWith;              /* Current WITH clause, or NULL */
  With *pWithToFree;        /* Free this WITH object at the end of the parse */
};

/*
** Sizes and pointers of various parts of the Parse object.
*/
#define PARSE_HDR_SZ offsetof(Parse,aColCache) /* Recursive part w/o aColCache*/
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */

/*
** Return true if currently inside an sqlite3_declare_vtab() call.
*/







|







17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
  With *pWith;              /* Current WITH clause, or NULL */
  With *pWithToFree;        /* Free this WITH object at the end of the parse */
};

/*
** Sizes and pointers of various parts of the Parse object.
*/
#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */

/*
** Return true if currently inside an sqlite3_declare_vtab() call.
*/
18155
18156
18157
18158
18159
18160
18161

18162
18163
18164
18165
18166
18167
18168
    struct CCurHint *pCCurHint;               /* Used by codeCursorHint() */
    int *aiCol;                               /* array of column indexes */
    struct IdxCover *pIdxCover;               /* Check for index coverage */
    struct IdxExprTrans *pIdxTrans;           /* Convert idxed expr to column */
    ExprList *pGroupBy;                       /* GROUP BY clause */
    Select *pSelect;                          /* HAVING to WHERE clause ctx */
    struct WindowRewrite *pRewrite;           /* Window rewrite context */

  } u;
};

/* Forward declarations */
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);







>







18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
    struct CCurHint *pCCurHint;               /* Used by codeCursorHint() */
    int *aiCol;                               /* array of column indexes */
    struct IdxCover *pIdxCover;               /* Check for index coverage */
    struct IdxExprTrans *pIdxTrans;           /* Convert idxed expr to column */
    ExprList *pGroupBy;                       /* GROUP BY clause */
    Select *pSelect;                          /* HAVING to WHERE clause ctx */
    struct WindowRewrite *pRewrite;           /* Window rewrite context */
    struct WhereConst *pConst;                /* WHERE clause constants */
  } u;
};

/* Forward declarations */
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
#endif
SQLITE_PRIVATE Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);
SQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*,int,const char*);
SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);
SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);
SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);







|







18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
#endif
SQLITE_PRIVATE Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);
SQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*,int,const char*);
SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);
SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);
SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int);
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */
#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */
#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */
SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*);
SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);







<


<
<
<
<
<
<







18624
18625
18626
18627
18628
18629
18630

18631
18632






18633
18634
18635
18636
18637
18638
18639
SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */
#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */
#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */
SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);

SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);






SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
18888
18889
18890
18891
18892
18893
18894

18895
18896
18897
18898
18899
18900
18901
#ifdef SQLITE_ENABLE_DESERIALIZE
SQLITE_PRIVATE int sqlite3MemdbInit(void);
#endif

SQLITE_PRIVATE const char *sqlite3ErrStr(int);
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);

SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);
SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);







>







18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
#ifdef SQLITE_ENABLE_DESERIALIZE
SQLITE_PRIVATE int sqlite3MemdbInit(void);
#endif

SQLITE_PRIVATE const char *sqlite3ErrStr(int);
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
SQLITE_PRIVATE int sqlite3IsBinary(const CollSeq*);
SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);
SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
  u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */
  sqlite3 *db;        /* The associated database connection */
  void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
#ifdef SQLITE_DEBUG
  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
  u16 mScopyFlags;    /* flags value immediately after the shallow copy */
#endif
#ifdef SQLITE_DEBUG_COLUMNCACHE
  u32 iTabColHash;    /* Hash of table.column that is origin of this value */
  u32 iPadding;       /* sqlite3_value objects must be 8-byte aligned */
#endif
};

/*
** Size of struct Mem not including the Mem.zMalloc member or anything that
** follows.
*/
#define MEMCELLSIZE offsetof(Mem,zMalloc)







<
<
<
<







19825
19826
19827
19828
19829
19830
19831




19832
19833
19834
19835
19836
19837
19838
  u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */
  sqlite3 *db;        /* The associated database connection */
  void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
#ifdef SQLITE_DEBUG
  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
  u16 mScopyFlags;    /* flags value immediately after the shallow copy */
#endif




};

/*
** Size of struct Mem not including the Mem.zMalloc member or anything that
** follows.
*/
#define MEMCELLSIZE offsetof(Mem,zMalloc)
28511
28512
28513
28514
28515
28516
28517



28518
28519
28520
28521
28522
28523
28524
      if( pExpr->iTable<0 ){
        /* This only happens when coding check constraints */
        sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs);
      }else{
        sqlite3TreeViewLine(pView, "{%d:%d}%s",
                             pExpr->iTable, pExpr->iColumn, zFlgs);
      }



      break;
    }
    case TK_INTEGER: {
      if( pExpr->flags & EP_IntValue ){
        sqlite3TreeViewLine(pView, "%d", pExpr->u.iValue);
      }else{
        sqlite3TreeViewLine(pView, "%s", pExpr->u.zToken);







>
>
>







28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
      if( pExpr->iTable<0 ){
        /* This only happens when coding check constraints */
        sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs);
      }else{
        sqlite3TreeViewLine(pView, "{%d:%d}%s",
                             pExpr->iTable, pExpr->iColumn, zFlgs);
      }
      if( ExprHasProperty(pExpr, EP_FixedCol) ){
        sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
      }
      break;
    }
    case TK_INTEGER: {
      if( pExpr->flags & EP_IntValue ){
        sqlite3TreeViewLine(pView, "%d", pExpr->u.iValue);
      }else{
        sqlite3TreeViewLine(pView, "%s", pExpr->u.zToken);
31739
31740
31741
31742
31743
31744
31745




31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790




31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825




31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
    /*  55 */ "Le"               OpHelp("IF r[P3]<=r[P1]"),
    /*  56 */ "Lt"               OpHelp("IF r[P3]<r[P1]"),
    /*  57 */ "Ge"               OpHelp("IF r[P3]>=r[P1]"),
    /*  58 */ "ElseNotEq"        OpHelp(""),
    /*  59 */ "IncrVacuum"       OpHelp(""),
    /*  60 */ "VNext"            OpHelp(""),
    /*  61 */ "Init"             OpHelp("Start at P2"),




    /*  62 */ "Return"           OpHelp(""),
    /*  63 */ "EndCoroutine"     OpHelp(""),
    /*  64 */ "HaltIfNull"       OpHelp("if r[P3]=null halt"),
    /*  65 */ "Halt"             OpHelp(""),
    /*  66 */ "Integer"          OpHelp("r[P2]=P1"),
    /*  67 */ "Int64"            OpHelp("r[P2]=P4"),
    /*  68 */ "String"           OpHelp("r[P2]='P4' (len=P1)"),
    /*  69 */ "Null"             OpHelp("r[P2..P3]=NULL"),
    /*  70 */ "SoftNull"         OpHelp("r[P1]=NULL"),
    /*  71 */ "Blob"             OpHelp("r[P2]=P4 (len=P1)"),
    /*  72 */ "Variable"         OpHelp("r[P2]=parameter(P1,P4)"),
    /*  73 */ "Move"             OpHelp("r[P2@P3]=r[P1@P3]"),
    /*  74 */ "Copy"             OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
    /*  75 */ "SCopy"            OpHelp("r[P2]=r[P1]"),
    /*  76 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
    /*  77 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
    /*  78 */ "CollSeq"          OpHelp(""),
    /*  79 */ "AddImm"           OpHelp("r[P1]=r[P1]+P2"),
    /*  80 */ "RealAffinity"     OpHelp(""),
    /*  81 */ "Cast"             OpHelp("affinity(r[P1])"),
    /*  82 */ "Permutation"      OpHelp(""),
    /*  83 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
    /*  84 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
    /*  85 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
    /*  86 */ "Column"           OpHelp("r[P3]=PX"),
    /*  87 */ "Affinity"         OpHelp("affinity(r[P1@P2])"),
    /*  88 */ "MakeRecord"       OpHelp("r[P3]=mkrec(r[P1@P2])"),
    /*  89 */ "Count"            OpHelp("r[P2]=count()"),
    /*  90 */ "ReadCookie"       OpHelp(""),
    /*  91 */ "SetCookie"        OpHelp(""),
    /*  92 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
    /*  93 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
    /*  94 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
    /*  95 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
    /*  96 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
    /*  97 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
    /*  98 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
    /*  99 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
    /* 100 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
    /* 101 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
    /* 102 */ "ReopenIdx"        OpHelp("root=P2 iDb=P3"),
    /* 103 */ "BitNot"           OpHelp("r[P2]= ~r[P1]"),
    /* 104 */ "OpenRead"         OpHelp("root=P2 iDb=P3"),
    /* 105 */ "OpenWrite"        OpHelp("root=P2 iDb=P3"),
    /* 106 */ "String8"          OpHelp("r[P2]='P4'"),




    /* 107 */ "OpenDup"          OpHelp(""),
    /* 108 */ "OpenAutoindex"    OpHelp("nColumn=P2"),
    /* 109 */ "OpenEphemeral"    OpHelp("nColumn=P2"),
    /* 110 */ "SorterOpen"       OpHelp(""),
    /* 111 */ "SequenceTest"     OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
    /* 112 */ "OpenPseudo"       OpHelp("P3 columns in r[P2]"),
    /* 113 */ "Close"            OpHelp(""),
    /* 114 */ "ColumnsUsed"      OpHelp(""),
    /* 115 */ "SeekHit"          OpHelp("seekHit=P2"),
    /* 116 */ "Sequence"         OpHelp("r[P2]=cursor[P1].ctr++"),
    /* 117 */ "NewRowid"         OpHelp("r[P2]=rowid"),
    /* 118 */ "Insert"           OpHelp("intkey=r[P3] data=r[P2]"),
    /* 119 */ "InsertInt"        OpHelp("intkey=P3 data=r[P2]"),
    /* 120 */ "Delete"           OpHelp(""),
    /* 121 */ "ResetCount"       OpHelp(""),
    /* 122 */ "SorterCompare"    OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
    /* 123 */ "SorterData"       OpHelp("r[P2]=data"),
    /* 124 */ "RowData"          OpHelp("r[P2]=data"),
    /* 125 */ "Rowid"            OpHelp("r[P2]=rowid"),
    /* 126 */ "NullRow"          OpHelp(""),
    /* 127 */ "SeekEnd"          OpHelp(""),
    /* 128 */ "SorterInsert"     OpHelp("key=r[P2]"),
    /* 129 */ "IdxInsert"        OpHelp("key=r[P2]"),
    /* 130 */ "IdxDelete"        OpHelp("key=r[P2@P3]"),
    /* 131 */ "DeferredSeek"     OpHelp("Move P3 to P1.rowid if needed"),
    /* 132 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
    /* 133 */ "Destroy"          OpHelp(""),
    /* 134 */ "Clear"            OpHelp(""),
    /* 135 */ "ResetSorter"      OpHelp(""),
    /* 136 */ "CreateBtree"      OpHelp("r[P2]=root iDb=P1 flags=P3"),
    /* 137 */ "SqlExec"          OpHelp(""),
    /* 138 */ "ParseSchema"      OpHelp(""),
    /* 139 */ "LoadAnalysis"     OpHelp(""),
    /* 140 */ "DropTable"        OpHelp(""),
    /* 141 */ "Real"             OpHelp("r[P2]=P4"),




    /* 142 */ "DropIndex"        OpHelp(""),
    /* 143 */ "DropTrigger"      OpHelp(""),
    /* 144 */ "IntegrityCk"      OpHelp(""),
    /* 145 */ "RowSetAdd"        OpHelp("rowset(P1)=r[P2]"),
    /* 146 */ "Param"            OpHelp(""),
    /* 147 */ "FkCounter"        OpHelp("fkctr[P1]+=P2"),
    /* 148 */ "MemMax"           OpHelp("r[P1]=max(r[P1],r[P2])"),
    /* 149 */ "OffsetLimit"      OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
    /* 150 */ "AggInverse"       OpHelp("accum=r[P3] inverse(r[P2@P5])"),
    /* 151 */ "AggStep"          OpHelp("accum=r[P3] step(r[P2@P5])"),
    /* 152 */ "AggStep1"         OpHelp("accum=r[P3] step(r[P2@P5])"),
    /* 153 */ "AggValue"         OpHelp("r[P3]=value N=P2"),
    /* 154 */ "AggFinal"         OpHelp("accum=r[P1] N=P2"),
    /* 155 */ "Expire"           OpHelp(""),
    /* 156 */ "TableLock"        OpHelp("iDb=P1 root=P2 write=P3"),
    /* 157 */ "VBegin"           OpHelp(""),
    /* 158 */ "VCreate"          OpHelp(""),
    /* 159 */ "VDestroy"         OpHelp(""),
    /* 160 */ "VOpen"            OpHelp(""),
    /* 161 */ "VColumn"          OpHelp("r[P3]=vcolumn(P2)"),
    /* 162 */ "VRename"          OpHelp(""),
    /* 163 */ "Pagecount"        OpHelp(""),
    /* 164 */ "MaxPgcnt"         OpHelp(""),
    /* 165 */ "PureFunc0"        OpHelp(""),
    /* 166 */ "Function0"        OpHelp("r[P3]=func(r[P2@P5])"),
    /* 167 */ "PureFunc"         OpHelp(""),
    /* 168 */ "Function"         OpHelp("r[P3]=func(r[P2@P5])"),
    /* 169 */ "Trace"            OpHelp(""),
    /* 170 */ "CursorHint"       OpHelp(""),
    /* 171 */ "SetTabCol"        OpHelp(""),
    /* 172 */ "VerifyTabCol"     OpHelp(""),
    /* 173 */ "Noop"             OpHelp(""),
    /* 174 */ "Explain"          OpHelp(""),
    /* 175 */ "Abortable"        OpHelp(""),
  };
  return azName[i];
}
#endif

/************** End of opcodes.c *********************************************/
/************** Begin file os_unix.c *****************************************/







>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<










|

|
|

>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<

>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<


<
<
|
|
|







31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748




31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797




31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825




31826
31827


31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
    /*  55 */ "Le"               OpHelp("IF r[P3]<=r[P1]"),
    /*  56 */ "Lt"               OpHelp("IF r[P3]<r[P1]"),
    /*  57 */ "Ge"               OpHelp("IF r[P3]>=r[P1]"),
    /*  58 */ "ElseNotEq"        OpHelp(""),
    /*  59 */ "IncrVacuum"       OpHelp(""),
    /*  60 */ "VNext"            OpHelp(""),
    /*  61 */ "Init"             OpHelp("Start at P2"),
    /*  62 */ "PureFunc0"        OpHelp(""),
    /*  63 */ "Function0"        OpHelp("r[P3]=func(r[P2@P5])"),
    /*  64 */ "PureFunc"         OpHelp(""),
    /*  65 */ "Function"         OpHelp("r[P3]=func(r[P2@P5])"),
    /*  66 */ "Return"           OpHelp(""),
    /*  67 */ "EndCoroutine"     OpHelp(""),
    /*  68 */ "HaltIfNull"       OpHelp("if r[P3]=null halt"),
    /*  69 */ "Halt"             OpHelp(""),
    /*  70 */ "Integer"          OpHelp("r[P2]=P1"),
    /*  71 */ "Int64"            OpHelp("r[P2]=P4"),
    /*  72 */ "String"           OpHelp("r[P2]='P4' (len=P1)"),
    /*  73 */ "Null"             OpHelp("r[P2..P3]=NULL"),
    /*  74 */ "SoftNull"         OpHelp("r[P1]=NULL"),
    /*  75 */ "Blob"             OpHelp("r[P2]=P4 (len=P1)"),
    /*  76 */ "Variable"         OpHelp("r[P2]=parameter(P1,P4)"),
    /*  77 */ "Move"             OpHelp("r[P2@P3]=r[P1@P3]"),
    /*  78 */ "Copy"             OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
    /*  79 */ "SCopy"            OpHelp("r[P2]=r[P1]"),
    /*  80 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
    /*  81 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
    /*  82 */ "CollSeq"          OpHelp(""),
    /*  83 */ "AddImm"           OpHelp("r[P1]=r[P1]+P2"),
    /*  84 */ "RealAffinity"     OpHelp(""),
    /*  85 */ "Cast"             OpHelp("affinity(r[P1])"),
    /*  86 */ "Permutation"      OpHelp(""),
    /*  87 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
    /*  88 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
    /*  89 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
    /*  90 */ "Column"           OpHelp("r[P3]=PX"),
    /*  91 */ "Affinity"         OpHelp("affinity(r[P1@P2])"),




    /*  92 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
    /*  93 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
    /*  94 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
    /*  95 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
    /*  96 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
    /*  97 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
    /*  98 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
    /*  99 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
    /* 100 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
    /* 101 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
    /* 102 */ "MakeRecord"       OpHelp("r[P3]=mkrec(r[P1@P2])"),
    /* 103 */ "BitNot"           OpHelp("r[P2]= ~r[P1]"),
    /* 104 */ "Count"            OpHelp("r[P2]=count()"),
    /* 105 */ "ReadCookie"       OpHelp(""),
    /* 106 */ "String8"          OpHelp("r[P2]='P4'"),
    /* 107 */ "SetCookie"        OpHelp(""),
    /* 108 */ "ReopenIdx"        OpHelp("root=P2 iDb=P3"),
    /* 109 */ "OpenRead"         OpHelp("root=P2 iDb=P3"),
    /* 110 */ "OpenWrite"        OpHelp("root=P2 iDb=P3"),
    /* 111 */ "OpenDup"          OpHelp(""),
    /* 112 */ "OpenAutoindex"    OpHelp("nColumn=P2"),
    /* 113 */ "OpenEphemeral"    OpHelp("nColumn=P2"),
    /* 114 */ "SorterOpen"       OpHelp(""),
    /* 115 */ "SequenceTest"     OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
    /* 116 */ "OpenPseudo"       OpHelp("P3 columns in r[P2]"),
    /* 117 */ "Close"            OpHelp(""),
    /* 118 */ "ColumnsUsed"      OpHelp(""),
    /* 119 */ "SeekHit"          OpHelp("seekHit=P2"),
    /* 120 */ "Sequence"         OpHelp("r[P2]=cursor[P1].ctr++"),
    /* 121 */ "NewRowid"         OpHelp("r[P2]=rowid"),
    /* 122 */ "Insert"           OpHelp("intkey=r[P3] data=r[P2]"),
    /* 123 */ "InsertInt"        OpHelp("intkey=P3 data=r[P2]"),
    /* 124 */ "Delete"           OpHelp(""),
    /* 125 */ "ResetCount"       OpHelp(""),
    /* 126 */ "SorterCompare"    OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
    /* 127 */ "SorterData"       OpHelp("r[P2]=data"),
    /* 128 */ "RowData"          OpHelp("r[P2]=data"),
    /* 129 */ "Rowid"            OpHelp("r[P2]=rowid"),
    /* 130 */ "NullRow"          OpHelp(""),
    /* 131 */ "SeekEnd"          OpHelp(""),
    /* 132 */ "SorterInsert"     OpHelp("key=r[P2]"),
    /* 133 */ "IdxInsert"        OpHelp("key=r[P2]"),
    /* 134 */ "IdxDelete"        OpHelp("key=r[P2@P3]"),
    /* 135 */ "DeferredSeek"     OpHelp("Move P3 to P1.rowid if needed"),
    /* 136 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
    /* 137 */ "Destroy"          OpHelp(""),
    /* 138 */ "Clear"            OpHelp(""),
    /* 139 */ "ResetSorter"      OpHelp(""),
    /* 140 */ "CreateBtree"      OpHelp("r[P2]=root iDb=P1 flags=P3"),




    /* 141 */ "Real"             OpHelp("r[P2]=P4"),
    /* 142 */ "SqlExec"          OpHelp(""),
    /* 143 */ "ParseSchema"      OpHelp(""),
    /* 144 */ "LoadAnalysis"     OpHelp(""),
    /* 145 */ "DropTable"        OpHelp(""),
    /* 146 */ "DropIndex"        OpHelp(""),
    /* 147 */ "DropTrigger"      OpHelp(""),
    /* 148 */ "IntegrityCk"      OpHelp(""),
    /* 149 */ "RowSetAdd"        OpHelp("rowset(P1)=r[P2]"),
    /* 150 */ "Param"            OpHelp(""),
    /* 151 */ "FkCounter"        OpHelp("fkctr[P1]+=P2"),
    /* 152 */ "MemMax"           OpHelp("r[P1]=max(r[P1],r[P2])"),
    /* 153 */ "OffsetLimit"      OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
    /* 154 */ "AggInverse"       OpHelp("accum=r[P3] inverse(r[P2@P5])"),
    /* 155 */ "AggStep"          OpHelp("accum=r[P3] step(r[P2@P5])"),
    /* 156 */ "AggStep1"         OpHelp("accum=r[P3] step(r[P2@P5])"),
    /* 157 */ "AggValue"         OpHelp("r[P3]=value N=P2"),
    /* 158 */ "AggFinal"         OpHelp("accum=r[P1] N=P2"),
    /* 159 */ "Expire"           OpHelp(""),
    /* 160 */ "TableLock"        OpHelp("iDb=P1 root=P2 write=P3"),
    /* 161 */ "VBegin"           OpHelp(""),
    /* 162 */ "VCreate"          OpHelp(""),
    /* 163 */ "VDestroy"         OpHelp(""),
    /* 164 */ "VOpen"            OpHelp(""),
    /* 165 */ "VColumn"          OpHelp("r[P3]=vcolumn(P2)"),
    /* 166 */ "VRename"          OpHelp(""),
    /* 167 */ "Pagecount"        OpHelp(""),
    /* 168 */ "MaxPgcnt"         OpHelp(""),




    /* 169 */ "Trace"            OpHelp(""),
    /* 170 */ "CursorHint"       OpHelp(""),


    /* 171 */ "Noop"             OpHelp(""),
    /* 172 */ "Explain"          OpHelp(""),
    /* 173 */ "Abortable"        OpHelp(""),
  };
  return azName[i];
}
#endif

/************** End of opcodes.c *********************************************/
/************** Begin file os_unix.c *****************************************/
32762
32763
32764
32765
32766
32767
32768











32769
32770
32771

32772
32773
32774

32775
32776
32777
32778
32779
32780
32781
** Function unixMutexHeld() is used to assert() that the global mutex 
** is held when required. This function is only used as part of assert() 
** statements. e.g.
**
**   unixEnterMutex()
**     assert( unixMutexHeld() );
**   unixEnterLeave()











*/
static sqlite3_mutex *unixBigLock = 0;
static void unixEnterMutex(void){

  sqlite3_mutex_enter(unixBigLock);
}
static void unixLeaveMutex(void){

  sqlite3_mutex_leave(unixBigLock);
}
#ifdef SQLITE_DEBUG
static int unixMutexHeld(void) {
  return sqlite3_mutex_held(unixBigLock);
}
#endif







>
>
>
>
>
>
>
>
>
>
>



>



>







32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
** Function unixMutexHeld() is used to assert() that the global mutex 
** is held when required. This function is only used as part of assert() 
** statements. e.g.
**
**   unixEnterMutex()
**     assert( unixMutexHeld() );
**   unixEnterLeave()
**
** To prevent deadlock, the global unixBigLock must must be acquired
** before the unixInodeInfo.pLockMutex mutex, if both are held.  It is
** OK to get the pLockMutex without holding unixBigLock first, but if
** that happens, the unixBigLock mutex must not be acquired until after
** pLockMutex is released.
**
**      OK:     enter(unixBigLock),  enter(pLockInfo)
**      OK:     enter(unixBigLock)
**      OK:     enter(pLockInfo)
**   ERROR:     enter(pLockInfo), enter(unixBigLock)
*/
static sqlite3_mutex *unixBigLock = 0;
static void unixEnterMutex(void){
  assert( sqlite3_mutex_notheld(unixBigLock) );  /* Not a recursive mutex */
  sqlite3_mutex_enter(unixBigLock);
}
static void unixLeaveMutex(void){
  assert( sqlite3_mutex_held(unixBigLock) );
  sqlite3_mutex_leave(unixBigLock);
}
#ifdef SQLITE_DEBUG
static int unixMutexHeld(void) {
  return sqlite3_mutex_held(unixBigLock);
}
#endif
33168
33169
33170
33171
33172
33173
33174

















33175
33176
33177

33178

33179
33180

33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200














33201
33202
33203
33204
33205
33206
33207
** An instance of the following structure is allocated for each open
** inode.  Or, on LinuxThreads, there is one of these structures for
** each inode opened by each thread.
**
** A single inode can have multiple file descriptors, so each unixFile
** structure contains a pointer to an instance of this object and this
** object keeps a count of the number of unixFile pointing to it.

















*/
struct unixInodeInfo {
  struct unixFileId fileId;       /* The lookup key */

  int nShared;                    /* Number of SHARED locks held */

  unsigned char eFileLock;        /* One of SHARED_LOCK, RESERVED_LOCK etc. */
  unsigned char bProcessLock;     /* An exclusive process lock is held */

  int nRef;                       /* Number of pointers to this structure */
  unixShmNode *pShmNode;          /* Shared memory associated with this inode */
  int nLock;                      /* Number of outstanding file locks */
  UnixUnusedFd *pUnused;          /* Unused file descriptors to close */
  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */
  unixInodeInfo *pPrev;           /*    .... doubly linked */
#if SQLITE_ENABLE_LOCKING_STYLE
  unsigned long long sharedByte;  /* for AFP simulated shared lock */
#endif
#if OS_VXWORKS
  sem_t *pSem;                    /* Named POSIX semaphore */
  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */
#endif
};

/*
** A lists of all unixInodeInfo objects.
*/
static unixInodeInfo *inodeList = 0;  /* All unixInodeInfo objects */
static unsigned int nUnusedFd = 0;    /* Total unused file descriptors */















/*
**
** This function - unixLogErrorAtLine(), is only ever called via the macro
** unixLogError().
**
** It is invoked after an error occurs in an OS function and errno has been







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
|
>
|
|
>


<
<















|
>
>
>
>
>
>
>
>
>
>
>
>
>
>







33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186


33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
** An instance of the following structure is allocated for each open
** inode.  Or, on LinuxThreads, there is one of these structures for
** each inode opened by each thread.
**
** A single inode can have multiple file descriptors, so each unixFile
** structure contains a pointer to an instance of this object and this
** object keeps a count of the number of unixFile pointing to it.
**
** Mutex rules:
**
**  (1) Only the pLockMutex mutex must be held in order to read or write
**      any of the locking fields:
**          nShared, nLock, eFileLock, bProcessLock, pUnused
**
**  (2) When nRef>0, then the following fields are unchanging and can
**      be read (but not written) without holding any mutex:
**          fileId, pLockMutex
**
**  (3) With the exceptions above, all the fields may only be read
**      or written while holding the global unixBigLock mutex.
**
** Deadlock prevention:  The global unixBigLock mutex may not
** be acquired while holding the pLockMutex mutex.  If both unixBigLock
** and pLockMutex are needed, then unixBigLock must be acquired first.
*/
struct unixInodeInfo {
  struct unixFileId fileId;       /* The lookup key */
  sqlite3_mutex *pLockMutex;      /* Hold this mutex for... */
  int nShared;                      /* Number of SHARED locks held */
  int nLock;                        /* Number of outstanding file locks */
  unsigned char eFileLock;          /* One of SHARED_LOCK, RESERVED_LOCK etc. */
  unsigned char bProcessLock;       /* An exclusive process lock is held */
  UnixUnusedFd *pUnused;            /* Unused file descriptors to close */
  int nRef;                       /* Number of pointers to this structure */
  unixShmNode *pShmNode;          /* Shared memory associated with this inode */


  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */
  unixInodeInfo *pPrev;           /*    .... doubly linked */
#if SQLITE_ENABLE_LOCKING_STYLE
  unsigned long long sharedByte;  /* for AFP simulated shared lock */
#endif
#if OS_VXWORKS
  sem_t *pSem;                    /* Named POSIX semaphore */
  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */
#endif
};

/*
** A lists of all unixInodeInfo objects.
*/
static unixInodeInfo *inodeList = 0;  /* All unixInodeInfo objects */

#ifdef SQLITE_DEBUG
/*
** True if the inode mutex is held, or not.  Used only within assert()
** to help verify correct mutex usage.
*/
int unixFileMutexHeld(unixFile *pFile){
  assert( pFile->pInode );
  return sqlite3_mutex_held(pFile->pInode->pLockMutex);
}
int unixFileMutexNotheld(unixFile *pFile){
  assert( pFile->pInode );
  return sqlite3_mutex_notheld(pFile->pInode->pLockMutex);
}
#endif

/*
**
** This function - unixLogErrorAtLine(), is only ever called via the macro
** unixLogError().
**
** It is invoked after an error occurs in an OS function and errno has been
33299
33300
33301
33302
33303
33304
33305

33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323

33324
33325
33326
33327

33328

33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339

33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
/*
** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
*/ 
static void closePendingFds(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  UnixUnusedFd *p;
  UnixUnusedFd *pNext;

  for(p=pInode->pUnused; p; p=pNext){
    pNext = p->pNext;
    robust_close(pFile, p->fd, __LINE__);
    sqlite3_free(p);
    nUnusedFd--;
  }
  pInode->pUnused = 0;
}

/*
** Release a unixInodeInfo structure previously allocated by findInodeInfo().
**
** The mutex entered using the unixEnterMutex() function must be held
** when this function is called.
*/
static void releaseInodeInfo(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  assert( unixMutexHeld() );

  if( ALWAYS(pInode) ){
    pInode->nRef--;
    if( pInode->nRef==0 ){
      assert( pInode->pShmNode==0 );

      closePendingFds(pFile);

      if( pInode->pPrev ){
        assert( pInode->pPrev->pNext==pInode );
        pInode->pPrev->pNext = pInode->pNext;
      }else{
        assert( inodeList==pInode );
        inodeList = pInode->pNext;
      }
      if( pInode->pNext ){
        assert( pInode->pNext->pPrev==pInode );
        pInode->pNext->pPrev = pInode->pPrev;
      }

      sqlite3_free(pInode);
    }
  }
  assert( inodeList!=0 || nUnusedFd==0 );
}

/*
** Given a file descriptor, locate the unixInodeInfo object that
** describes that file descriptor.  Create a new one if necessary.  The
** return value might be uninitialized if an error occurs.
**







>




<













>




>

>











>



<







33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326

33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362

33363
33364
33365
33366
33367
33368
33369
/*
** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
*/ 
static void closePendingFds(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  UnixUnusedFd *p;
  UnixUnusedFd *pNext;
  assert( unixFileMutexHeld(pFile) );
  for(p=pInode->pUnused; p; p=pNext){
    pNext = p->pNext;
    robust_close(pFile, p->fd, __LINE__);
    sqlite3_free(p);

  }
  pInode->pUnused = 0;
}

/*
** Release a unixInodeInfo structure previously allocated by findInodeInfo().
**
** The mutex entered using the unixEnterMutex() function must be held
** when this function is called.
*/
static void releaseInodeInfo(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  assert( unixMutexHeld() );
  assert( unixFileMutexNotheld(pFile) );
  if( ALWAYS(pInode) ){
    pInode->nRef--;
    if( pInode->nRef==0 ){
      assert( pInode->pShmNode==0 );
      sqlite3_mutex_enter(pInode->pLockMutex);
      closePendingFds(pFile);
      sqlite3_mutex_leave(pInode->pLockMutex);
      if( pInode->pPrev ){
        assert( pInode->pPrev->pNext==pInode );
        pInode->pPrev->pNext = pInode->pNext;
      }else{
        assert( inodeList==pInode );
        inodeList = pInode->pNext;
      }
      if( pInode->pNext ){
        assert( pInode->pNext->pPrev==pInode );
        pInode->pNext->pPrev = pInode->pPrev;
      }
      sqlite3_mutex_free(pInode->pLockMutex);
      sqlite3_free(pInode);
    }
  }

}

/*
** Given a file descriptor, locate the unixInodeInfo object that
** describes that file descriptor.  Create a new one if necessary.  The
** return value might be uninitialized if an error occurs.
**
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424







33425
33426
33427
33428
33429
33430
33431
  memset(&fileId, 0, sizeof(fileId));
  fileId.dev = statbuf.st_dev;
#if OS_VXWORKS
  fileId.pId = pFile->pId;
#else
  fileId.ino = (u64)statbuf.st_ino;
#endif
  assert( inodeList!=0 || nUnusedFd==0 );
  pInode = inodeList;
  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
    pInode = pInode->pNext;
  }
  if( pInode==0 ){
    pInode = sqlite3_malloc64( sizeof(*pInode) );
    if( pInode==0 ){
      return SQLITE_NOMEM_BKPT;
    }
    memset(pInode, 0, sizeof(*pInode));
    memcpy(&pInode->fileId, &fileId, sizeof(fileId));







    pInode->nRef = 1;
    pInode->pNext = inodeList;
    pInode->pPrev = 0;
    if( inodeList ) inodeList->pPrev = pInode;
    inodeList = pInode;
  }else{
    pInode->nRef++;







<











>
>
>
>
>
>
>







33425
33426
33427
33428
33429
33430
33431

33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
  memset(&fileId, 0, sizeof(fileId));
  fileId.dev = statbuf.st_dev;
#if OS_VXWORKS
  fileId.pId = pFile->pId;
#else
  fileId.ino = (u64)statbuf.st_ino;
#endif

  pInode = inodeList;
  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
    pInode = pInode->pNext;
  }
  if( pInode==0 ){
    pInode = sqlite3_malloc64( sizeof(*pInode) );
    if( pInode==0 ){
      return SQLITE_NOMEM_BKPT;
    }
    memset(pInode, 0, sizeof(*pInode));
    memcpy(&pInode->fileId, &fileId, sizeof(fileId));
    if( sqlite3GlobalConfig.bCoreMutex ){
      pInode->pLockMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
      if( pInode->pLockMutex==0 ){
        sqlite3_free(pInode);
        return SQLITE_NOMEM_BKPT;
      }
    }
    pInode->nRef = 1;
    pInode->pNext = inodeList;
    pInode->pPrev = 0;
    if( inodeList ) inodeList->pPrev = pInode;
    inodeList = pInode;
  }else{
    pInode->nRef++;
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
  int reserved = 0;
  unixFile *pFile = (unixFile*)id;

  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );

  assert( pFile );
  assert( pFile->eFileLock<=SHARED_LOCK );
  unixEnterMutex(); /* Because pFile->pInode is shared across threads */

  /* Check if a thread in this process holds such a lock */
  if( pFile->pInode->eFileLock>SHARED_LOCK ){
    reserved = 1;
  }

  /* Otherwise see if some other process holds it.







|







33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
  int reserved = 0;
  unixFile *pFile = (unixFile*)id;

  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );

  assert( pFile );
  assert( pFile->eFileLock<=SHARED_LOCK );
  sqlite3_mutex_enter(pFile->pInode->pLockMutex);

  /* Check if a thread in this process holds such a lock */
  if( pFile->pInode->eFileLock>SHARED_LOCK ){
    reserved = 1;
  }

  /* Otherwise see if some other process holds it.
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
      storeLastErrno(pFile, errno);
    } else if( lock.l_type!=F_UNLCK ){
      reserved = 1;
    }
  }
#endif
  
  unixLeaveMutex();
  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));

  *pResOut = reserved;
  return rc;
}

/*







|







33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
      storeLastErrno(pFile, errno);
    } else if( lock.l_type!=F_UNLCK ){
      reserved = 1;
    }
  }
#endif
  
  sqlite3_mutex_leave(pFile->pInode->pLockMutex);
  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));

  *pResOut = reserved;
  return rc;
}

/*
33587
33588
33589
33590
33591
33592
33593
33594
33595

33596
33597
33598
33599
33600
33601
33602
**
** Zero is returned if the call completes successfully, or -1 if a call
** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).
*/
static int unixFileLock(unixFile *pFile, struct flock *pLock){
  int rc;
  unixInodeInfo *pInode = pFile->pInode;
  assert( unixMutexHeld() );
  assert( pInode!=0 );

  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;







<

>







33612
33613
33614
33615
33616
33617
33618

33619
33620
33621
33622
33623
33624
33625
33626
33627
**
** Zero is returned if the call completes successfully, or -1 if a call
** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).
*/
static int unixFileLock(unixFile *pFile, struct flock *pLock){
  int rc;
  unixInodeInfo *pInode = pFile->pInode;

  assert( pInode!=0 );
  assert( sqlite3_mutex_held(pInode->pLockMutex) );
  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
33707
33708
33709
33710
33711
33712
33713
33714
33715

33716
33717
33718
33719
33720
33721
33722
  */
  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
  assert( eFileLock!=PENDING_LOCK );
  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );

  /* This mutex is needed because pFile->pInode is shared across threads
  */
  unixEnterMutex();
  pInode = pFile->pInode;


  /* If some thread using this PID has a lock via a different unixFile*
  ** handle that precludes the requested lock, return BUSY.
  */
  if( (pFile->eFileLock!=pInode->eFileLock && 
          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
  ){







<

>







33732
33733
33734
33735
33736
33737
33738

33739
33740
33741
33742
33743
33744
33745
33746
33747
  */
  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
  assert( eFileLock!=PENDING_LOCK );
  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );

  /* This mutex is needed because pFile->pInode is shared across threads
  */

  pInode = pFile->pInode;
  sqlite3_mutex_enter(pInode->pLockMutex);

  /* If some thread using this PID has a lock via a different unixFile*
  ** handle that precludes the requested lock, return BUSY.
  */
  if( (pFile->eFileLock!=pInode->eFileLock && 
          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
  ){
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870

33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
    pInode->eFileLock = eFileLock;
  }else if( eFileLock==EXCLUSIVE_LOCK ){
    pFile->eFileLock = PENDING_LOCK;
    pInode->eFileLock = PENDING_LOCK;
  }

end_lock:
  unixLeaveMutex();
  OSTRACE(("LOCK    %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock), 
      rc==SQLITE_OK ? "ok" : "failed"));
  return rc;
}

/*
** Add the file descriptor used by file handle pFile to the corresponding
** pUnused list.
*/
static void setPendingFd(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  UnixUnusedFd *p = pFile->pPreallocatedUnused;

  p->pNext = pInode->pUnused;
  pInode->pUnused = p;
  pFile->h = -1;
  pFile->pPreallocatedUnused = 0;
  nUnusedFd++;
}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
** must be either NO_LOCK or SHARED_LOCK.
**
** If the locking level of the file descriptor is already at or below







|












>




<







33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900

33901
33902
33903
33904
33905
33906
33907
    pInode->eFileLock = eFileLock;
  }else if( eFileLock==EXCLUSIVE_LOCK ){
    pFile->eFileLock = PENDING_LOCK;
    pInode->eFileLock = PENDING_LOCK;
  }

end_lock:
  sqlite3_mutex_leave(pInode->pLockMutex);
  OSTRACE(("LOCK    %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock), 
      rc==SQLITE_OK ? "ok" : "failed"));
  return rc;
}

/*
** Add the file descriptor used by file handle pFile to the corresponding
** pUnused list.
*/
static void setPendingFd(unixFile *pFile){
  unixInodeInfo *pInode = pFile->pInode;
  UnixUnusedFd *p = pFile->pPreallocatedUnused;
  assert( unixFileMutexHeld(pFile) );
  p->pNext = pInode->pUnused;
  pInode->pUnused = p;
  pFile->h = -1;
  pFile->pPreallocatedUnused = 0;

}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
** must be either NO_LOCK or SHARED_LOCK.
**
** If the locking level of the file descriptor is already at or below
33899
33900
33901
33902
33903
33904
33905
33906
33907

33908
33909
33910
33911
33912
33913
33914
      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
      osGetpid(0)));

  assert( eFileLock<=SHARED_LOCK );
  if( pFile->eFileLock<=eFileLock ){
    return SQLITE_OK;
  }
  unixEnterMutex();
  pInode = pFile->pInode;

  assert( pInode->nShared!=0 );
  if( pFile->eFileLock>SHARED_LOCK ){
    assert( pInode->eFileLock==pFile->eFileLock );

#ifdef SQLITE_DEBUG
    /* When reducing a lock such that other processes can start
    ** reading the database file again, make sure that the







<

>







33924
33925
33926
33927
33928
33929
33930

33931
33932
33933
33934
33935
33936
33937
33938
33939
      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
      osGetpid(0)));

  assert( eFileLock<=SHARED_LOCK );
  if( pFile->eFileLock<=eFileLock ){
    return SQLITE_OK;
  }

  pInode = pFile->pInode;
  sqlite3_mutex_enter(pInode->pLockMutex);
  assert( pInode->nShared!=0 );
  if( pFile->eFileLock>SHARED_LOCK ){
    assert( pInode->eFileLock==pFile->eFileLock );

#ifdef SQLITE_DEBUG
    /* When reducing a lock such that other processes can start
    ** reading the database file again, make sure that the
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040


34041
34042
34043
34044
34045
34046
34047

    /* Decrement the count of locks against this same file.  When the
    ** count reaches zero, close any other file descriptors whose close
    ** was deferred because of outstanding locks.
    */
    pInode->nLock--;
    assert( pInode->nLock>=0 );
    if( pInode->nLock==0 ){
      closePendingFds(pFile);
    }
  }

end_unlock:
  unixLeaveMutex();
  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;


  return rc;
}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
** must be either NO_LOCK or SHARED_LOCK.
**







|
<
<



|
|
>
>







34051
34052
34053
34054
34055
34056
34057
34058


34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072

    /* Decrement the count of locks against this same file.  When the
    ** count reaches zero, close any other file descriptors whose close
    ** was deferred because of outstanding locks.
    */
    pInode->nLock--;
    assert( pInode->nLock>=0 );
    if( pInode->nLock==0 ) closePendingFds(pFile);


  }

end_unlock:
  sqlite3_mutex_leave(pInode->pLockMutex);
  if( rc==SQLITE_OK ){
    pFile->eFileLock = eFileLock;
  }
  return rc;
}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
** must be either NO_LOCK or SHARED_LOCK.
**
34104
34105
34106
34107
34108
34109
34110



34111
34112

34113
34114
34115
34116
34117
34118

34119
34120
34121
34122
34123
34124
34125
34126

34127
34128
34129
34130
34131
34132
34133

/*
** Close a file.
*/
static int unixClose(sqlite3_file *id){
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile *)id;



  verifyDbFile(pFile);
  unixUnlock(id, NO_LOCK);

  unixEnterMutex();

  /* unixFile.pInode is always valid here. Otherwise, a different close
  ** routine (e.g. nolockClose()) would be called instead.
  */
  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );

  if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){
    /* If there are outstanding locks, do not actually close the file just
    ** yet because that would clear those locks.  Instead, add the file
    ** descriptor to pInode->pUnused list.  It will be automatically closed 
    ** when the last lock is cleared.
    */
    setPendingFd(pFile);
  }

  releaseInodeInfo(pFile);
  rc = closeUnixFile(id);
  unixLeaveMutex();
  return rc;
}

/************** End of the posix advisory lock implementation *****************







>
>
>


>






>
|







>







34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164

/*
** Close a file.
*/
static int unixClose(sqlite3_file *id){
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile *)id;
  unixInodeInfo *pInode = pFile->pInode;

  assert( pInode!=0 );
  verifyDbFile(pFile);
  unixUnlock(id, NO_LOCK);
  assert( unixFileMutexNotheld(pFile) );
  unixEnterMutex();

  /* unixFile.pInode is always valid here. Otherwise, a different close
  ** routine (e.g. nolockClose()) would be called instead.
  */
  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );
  sqlite3_mutex_enter(pInode->pLockMutex);
  if( pInode->nLock ){
    /* If there are outstanding locks, do not actually close the file just
    ** yet because that would clear those locks.  Instead, add the file
    ** descriptor to pInode->pUnused list.  It will be automatically closed 
    ** when the last lock is cleared.
    */
    setPendingFd(pFile);
  }
  sqlite3_mutex_leave(pInode->pLockMutex);
  releaseInodeInfo(pFile);
  rc = closeUnixFile(id);
  unixLeaveMutex();
  return rc;
}

/************** End of the posix advisory lock implementation *****************
34717
34718
34719
34720
34721
34722
34723

34724
34725
34726
34727
34728
34729
34730
 ** Close a file.
 */
static int semXClose(sqlite3_file *id) {
  if( id ){
    unixFile *pFile = (unixFile*)id;
    semXUnlock(id, NO_LOCK);
    assert( pFile );

    unixEnterMutex();
    releaseInodeInfo(pFile);
    unixLeaveMutex();
    closeUnixFile(id);
  }
  return SQLITE_OK;
}







>







34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
 ** Close a file.
 */
static int semXClose(sqlite3_file *id) {
  if( id ){
    unixFile *pFile = (unixFile*)id;
    semXUnlock(id, NO_LOCK);
    assert( pFile );
    assert( unixFileMutexNotheld(pFile) );
    unixEnterMutex();
    releaseInodeInfo(pFile);
    unixLeaveMutex();
    closeUnixFile(id);
  }
  return SQLITE_OK;
}
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
  
  assert( pFile );
  context = (afpLockingContext *) pFile->lockingContext;
  if( context->reserved ){
    *pResOut = 1;
    return SQLITE_OK;
  }
  unixEnterMutex(); /* Because pFile->pInode is shared across threads */
  
  /* Check if a thread in this process holds such a lock */
  if( pFile->pInode->eFileLock>SHARED_LOCK ){
    reserved = 1;
  }
  
  /* Otherwise see if some other process holds it.
   */







<
|







34863
34864
34865
34866
34867
34868
34869

34870
34871
34872
34873
34874
34875
34876
34877
  
  assert( pFile );
  context = (afpLockingContext *) pFile->lockingContext;
  if( context->reserved ){
    *pResOut = 1;
    return SQLITE_OK;
  }

  sqlite3_mutex_enter(pFile->pInode->pLockMutex);
  /* Check if a thread in this process holds such a lock */
  if( pFile->pInode->eFileLock>SHARED_LOCK ){
    reserved = 1;
  }
  
  /* Otherwise see if some other process holds it.
   */
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
      reserved = 1;
    }
    if( IS_LOCK_ERROR(lrc) ){
      rc=lrc;
    }
  }
  
  unixLeaveMutex();
  OSTRACE(("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved));
  
  *pResOut = reserved;
  return rc;
}

/*







|







34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
      reserved = 1;
    }
    if( IS_LOCK_ERROR(lrc) ){
      rc=lrc;
    }
  }
  
  sqlite3_mutex_leave(pFile->pInode->pLockMutex);
  OSTRACE(("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved));
  
  *pResOut = reserved;
  return rc;
}

/*
34919
34920
34921
34922
34923
34924
34925
34926
34927

34928
34929
34930
34931
34932
34933
34934
  */
  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
  assert( eFileLock!=PENDING_LOCK );
  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );
  
  /* This mutex is needed because pFile->pInode is shared across threads
  */
  unixEnterMutex();
  pInode = pFile->pInode;


  /* If some thread using this PID has a lock via a different unixFile*
  ** handle that precludes the requested lock, return BUSY.
  */
  if( (pFile->eFileLock!=pInode->eFileLock && 
       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
     ){







<

>







34950
34951
34952
34953
34954
34955
34956

34957
34958
34959
34960
34961
34962
34963
34964
34965
  */
  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
  assert( eFileLock!=PENDING_LOCK );
  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );
  
  /* This mutex is needed because pFile->pInode is shared across threads
  */

  pInode = pFile->pInode;
  sqlite3_mutex_enter(pInode->pLockMutex);

  /* If some thread using this PID has a lock via a different unixFile*
  ** handle that precludes the requested lock, return BUSY.
  */
  if( (pFile->eFileLock!=pInode->eFileLock && 
       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
     ){
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
    pInode->eFileLock = eFileLock;
  }else if( eFileLock==EXCLUSIVE_LOCK ){
    pFile->eFileLock = PENDING_LOCK;
    pInode->eFileLock = PENDING_LOCK;
  }
  
afp_end_lock:
  unixLeaveMutex();
  OSTRACE(("LOCK    %d %s %s (afp)\n", pFile->h, azFileLock(eFileLock), 
         rc==SQLITE_OK ? "ok" : "failed"));
  return rc;
}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock







|







35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
    pInode->eFileLock = eFileLock;
  }else if( eFileLock==EXCLUSIVE_LOCK ){
    pFile->eFileLock = PENDING_LOCK;
    pInode->eFileLock = PENDING_LOCK;
  }
  
afp_end_lock:
  sqlite3_mutex_leave(pInode->pLockMutex);
  OSTRACE(("LOCK    %d %s %s (afp)\n", pFile->h, azFileLock(eFileLock), 
         rc==SQLITE_OK ? "ok" : "failed"));
  return rc;
}

/*
** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
35088
35089
35090
35091
35092
35093
35094
35095
35096

35097
35098
35099
35100
35101
35102
35103
           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
           osGetpid(0)));

  assert( eFileLock<=SHARED_LOCK );
  if( pFile->eFileLock<=eFileLock ){
    return SQLITE_OK;
  }
  unixEnterMutex();
  pInode = pFile->pInode;

  assert( pInode->nShared!=0 );
  if( pFile->eFileLock>SHARED_LOCK ){
    assert( pInode->eFileLock==pFile->eFileLock );
    SimulateIOErrorBenign(1);
    SimulateIOError( h=(-1) )
    SimulateIOErrorBenign(0);
    







<

>







35119
35120
35121
35122
35123
35124
35125

35126
35127
35128
35129
35130
35131
35132
35133
35134
           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
           osGetpid(0)));

  assert( eFileLock<=SHARED_LOCK );
  if( pFile->eFileLock<=eFileLock ){
    return SQLITE_OK;
  }

  pInode = pFile->pInode;
  sqlite3_mutex_enter(pInode->pLockMutex);
  assert( pInode->nShared!=0 );
  if( pFile->eFileLock>SHARED_LOCK ){
    assert( pInode->eFileLock==pFile->eFileLock );
    SimulateIOErrorBenign(1);
    SimulateIOError( h=(-1) )
    SimulateIOErrorBenign(0);
    
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172


35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183

35184
35185



35186
35187
35188
35189
35190
35191


35192
35193
35194
35195
35196
35197
35198
        pInode->eFileLock = NO_LOCK;
        pFile->eFileLock = NO_LOCK;
      }
    }
    if( rc==SQLITE_OK ){
      pInode->nLock--;
      assert( pInode->nLock>=0 );
      if( pInode->nLock==0 ){
        closePendingFds(pFile);
      }
    }
  }
  
  unixLeaveMutex();
  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;


  return rc;
}

/*
** Close a file & cleanup AFP specific locking context 
*/
static int afpClose(sqlite3_file *id) {
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile*)id;
  assert( id!=0 );
  afpUnlock(id, NO_LOCK);

  unixEnterMutex();
  if( pFile->pInode && pFile->pInode->nLock ){



    /* If there are outstanding locks, do not actually close the file just
    ** yet because that would clear those locks.  Instead, add the file
    ** descriptor to pInode->aPending.  It will be automatically closed when
    ** the last lock is cleared.
    */
    setPendingFd(pFile);


  }
  releaseInodeInfo(pFile);
  sqlite3_free(pFile->lockingContext);
  rc = closeUnixFile(id);
  unixLeaveMutex();
  return rc;
}







|
<
<



|
|
>
>











>

|
>
>
>
|
|
|
|
|
|
>
>







35189
35190
35191
35192
35193
35194
35195
35196


35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
        pInode->eFileLock = NO_LOCK;
        pFile->eFileLock = NO_LOCK;
      }
    }
    if( rc==SQLITE_OK ){
      pInode->nLock--;
      assert( pInode->nLock>=0 );
      if( pInode->nLock==0 ) closePendingFds(pFile);


    }
  }
  
  sqlite3_mutex_leave(pInode->pLockMutex);
  if( rc==SQLITE_OK ){
    pFile->eFileLock = eFileLock;
  }
  return rc;
}

/*
** Close a file & cleanup AFP specific locking context 
*/
static int afpClose(sqlite3_file *id) {
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile*)id;
  assert( id!=0 );
  afpUnlock(id, NO_LOCK);
  assert( unixFileMutexNotheld(pFile) );
  unixEnterMutex();
  if( pFile->pInode ){
    unixInodeInfo *pInode = pFile->pInode;
    sqlite3_mutex_enter(pInode->pLockMutex);
    if( pFile->pInode->nLock ){
      /* If there are outstanding locks, do not actually close the file just
      ** yet because that would clear those locks.  Instead, add the file
      ** descriptor to pInode->aPending.  It will be automatically closed when
      ** the last lock is cleared.
      */
      setPendingFd(pFile);
    }
    sqlite3_mutex_leave(pInode->pLockMutex);
  }
  releaseInodeInfo(pFile);
  sqlite3_free(pFile->lockingContext);
  rc = closeUnixFile(id);
  unixLeaveMutex();
  return rc;
}
36490
36491
36492
36493
36494
36495
36496

36497
36498
36499
36500
36501
36502
36503
  if( p==0 ) return SQLITE_NOMEM_BKPT;
  memset(p, 0, sizeof(*p));
  assert( pDbFd->pShm==0 );

  /* Check to see if a unixShmNode object already exists. Reuse an existing
  ** one if present. Create a new one if necessary.
  */

  unixEnterMutex();
  pInode = pDbFd->pInode;
  pShmNode = pInode->pShmNode;
  if( pShmNode==0 ){
    struct stat sStat;                 /* fstat() info for database file */
#ifndef SQLITE_SHM_DIRECTORY
    const char *zBasePath = pDbFd->zPath;







>







36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
  if( p==0 ) return SQLITE_NOMEM_BKPT;
  memset(p, 0, sizeof(*p));
  assert( pDbFd->pShm==0 );

  /* Check to see if a unixShmNode object already exists. Reuse an existing
  ** one if present. Create a new one if necessary.
  */
  assert( unixFileMutexNotheld(pDbFd) );
  unixEnterMutex();
  pInode = pDbFd->pInode;
  pShmNode = pInode->pShmNode;
  if( pShmNode==0 ){
    struct stat sStat;                 /* fstat() info for database file */
#ifndef SQLITE_SHM_DIRECTORY
    const char *zBasePath = pDbFd->zPath;
36872
36873
36874
36875
36876
36877
36878

36879
36880
36881
36882
36883
36884
36885
** any load or store begun after the barrier.
*/
static void unixShmBarrier(
  sqlite3_file *fd                /* Database file holding the shared memory */
){
  UNUSED_PARAMETER(fd);
  sqlite3MemoryBarrier();         /* compiler-defined memory barrier */

  unixEnterMutex();               /* Also mutex, for redundancy */
  unixLeaveMutex();
}

/*
** Close a connection to shared-memory.  Delete the underlying 
** storage if deleteFlag is true.







>







36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
** any load or store begun after the barrier.
*/
static void unixShmBarrier(
  sqlite3_file *fd                /* Database file holding the shared memory */
){
  UNUSED_PARAMETER(fd);
  sqlite3MemoryBarrier();         /* compiler-defined memory barrier */
  assert( unixFileMutexNotheld((unixFile*)fd) );
  unixEnterMutex();               /* Also mutex, for redundancy */
  unixLeaveMutex();
}

/*
** Close a connection to shared-memory.  Delete the underlying 
** storage if deleteFlag is true.
36913
36914
36915
36916
36917
36918
36919

36920
36921
36922
36923
36924
36925
36926
  /* Free the connection p */
  sqlite3_free(p);
  pDbFd->pShm = 0;
  sqlite3_mutex_leave(pShmNode->mutex);

  /* If pShmNode->nRef has reached 0, then close the underlying
  ** shared-memory file, too */

  unixEnterMutex();
  assert( pShmNode->nRef>0 );
  pShmNode->nRef--;
  if( pShmNode->nRef==0 ){
    if( deleteFlag && pShmNode->h>=0 ){
      osUnlink(pShmNode->zFilename);
    }







>







36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
  /* Free the connection p */
  sqlite3_free(p);
  pDbFd->pShm = 0;
  sqlite3_mutex_leave(pShmNode->mutex);

  /* If pShmNode->nRef has reached 0, then close the underlying
  ** shared-memory file, too */
  assert( unixFileMutexNotheld(pDbFd) );
  unixEnterMutex();
  assert( pShmNode->nRef>0 );
  pShmNode->nRef--;
  if( pShmNode->nRef==0 ){
    if( deleteFlag && pShmNode->h>=0 ){
      osUnlink(pShmNode->zFilename);
    }
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
  unixUnlock,               /* xUnlock method */
  unixCheckReservedLock,    /* xCheckReservedLock method */
  unixShmMap                /* xShmMap method */
)
IOMETHODS(
  nolockIoFinder,           /* Finder function name */
  nolockIoMethods,          /* sqlite3_io_methods object name */
  3,                        /* shared memory is disabled */
  nolockClose,              /* xClose method */
  nolockLock,               /* xLock method */
  nolockUnlock,             /* xUnlock method */
  nolockCheckReservedLock,  /* xCheckReservedLock method */
  0                         /* xShmMap method */
)
IOMETHODS(







|







37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
  unixUnlock,               /* xUnlock method */
  unixCheckReservedLock,    /* xCheckReservedLock method */
  unixShmMap                /* xShmMap method */
)
IOMETHODS(
  nolockIoFinder,           /* Finder function name */
  nolockIoMethods,          /* sqlite3_io_methods object name */
  3,                        /* shared memory and mmap are enabled */
  nolockClose,              /* xClose method */
  nolockLock,               /* xLock method */
  nolockUnlock,             /* xUnlock method */
  nolockCheckReservedLock,  /* xCheckReservedLock method */
  0                         /* xShmMap method */
)
IOMETHODS(
37735
37736
37737
37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
37750
37751


37752
37753
37754
37755
37756
37757

37758
37759
37760
37761
37762
37763
37764
  ** almost certain that an open() call on the same path will also fail.
  ** For this reason, if an error occurs in the stat() call here, it is
  ** ignored and -1 is returned. The caller will try to open a new file
  ** descriptor on the same path, fail, and return an error to SQLite.
  **
  ** Even if a subsequent open() call does succeed, the consequences of
  ** not searching for a reusable file descriptor are not dire.  */
  if( nUnusedFd>0 && 0==osStat(zPath, &sStat) ){
    unixInodeInfo *pInode;

    pInode = inodeList;
    while( pInode && (pInode->fileId.dev!=sStat.st_dev
                     || pInode->fileId.ino!=(u64)sStat.st_ino) ){
       pInode = pInode->pNext;
    }
    if( pInode ){
      UnixUnusedFd **pp;


      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
      pUnused = *pp;
      if( pUnused ){
        nUnusedFd--;
        *pp = pUnused->pNext;
      }

    }
  }
  unixLeaveMutex();
#endif    /* if !OS_VXWORKS */
  return pUnused;
}








|









>
>



<


>







37775
37776
37777
37778
37779
37780
37781
37782
37783
37784
37785
37786
37787
37788
37789
37790
37791
37792
37793
37794
37795
37796

37797
37798
37799
37800
37801
37802
37803
37804
37805
37806
  ** almost certain that an open() call on the same path will also fail.
  ** For this reason, if an error occurs in the stat() call here, it is
  ** ignored and -1 is returned. The caller will try to open a new file
  ** descriptor on the same path, fail, and return an error to SQLite.
  **
  ** Even if a subsequent open() call does succeed, the consequences of
  ** not searching for a reusable file descriptor are not dire.  */
  if( inodeList!=0 && 0==osStat(zPath, &sStat) ){
    unixInodeInfo *pInode;

    pInode = inodeList;
    while( pInode && (pInode->fileId.dev!=sStat.st_dev
                     || pInode->fileId.ino!=(u64)sStat.st_ino) ){
       pInode = pInode->pNext;
    }
    if( pInode ){
      UnixUnusedFd **pp;
      assert( sqlite3_mutex_notheld(pInode->pLockMutex) );
      sqlite3_mutex_enter(pInode->pLockMutex);
      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
      pUnused = *pp;
      if( pUnused ){

        *pp = pUnused->pNext;
      }
      sqlite3_mutex_leave(pInode->pLockMutex);
    }
  }
  unixLeaveMutex();
#endif    /* if !OS_VXWORKS */
  return pUnused;
}

49967
49968
49969
49970
49971
49972
49973


49974
49975
49976
49977
49978
49979
49980
*/
SQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal);

#ifdef SQLITE_ENABLE_SNAPSHOT
SQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);
SQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal);


#endif

#ifdef SQLITE_ENABLE_ZIPVFS
/* If the WAL file is not empty, return the number of bytes of content
** stored in each frame (i.e. the db page-size when the WAL was created).
*/
SQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal);







>
>







50009
50010
50011
50012
50013
50014
50015
50016
50017
50018
50019
50020
50021
50022
50023
50024
*/
SQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal);

#ifdef SQLITE_ENABLE_SNAPSHOT
SQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);
SQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal);
SQLITE_PRIVATE int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot);
SQLITE_PRIVATE void sqlite3WalSnapshotUnlock(Wal *pWal);
#endif

#ifdef SQLITE_ENABLE_ZIPVFS
/* If the WAL file is not empty, return the number of bytes of content
** stored in each frame (i.e. the db page-size when the WAL was created).
*/
SQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal);
57616
57617
57618
57619
57620
57621
57622
































57623
57624
57625
57626
57627
57628
57629
  if( pPager->pWal ){
    rc = sqlite3WalSnapshotRecover(pPager->pWal);
  }else{
    rc = SQLITE_ERROR;
  }
  return rc;
}
































#endif /* SQLITE_ENABLE_SNAPSHOT */
#endif /* !SQLITE_OMIT_WAL */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** A read-lock must be held on the pager when this function is called. If
** the pager is in WAL mode and the WAL file currently contains one or more







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







57660
57661
57662
57663
57664
57665
57666
57667
57668
57669
57670
57671
57672
57673
57674
57675
57676
57677
57678
57679
57680
57681
57682
57683
57684
57685
57686
57687
57688
57689
57690
57691
57692
57693
57694
57695
57696
57697
57698
57699
57700
57701
57702
57703
57704
57705
  if( pPager->pWal ){
    rc = sqlite3WalSnapshotRecover(pPager->pWal);
  }else{
    rc = SQLITE_ERROR;
  }
  return rc;
}

/*
** The caller currently has a read transaction open on the database.
** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,
** this function takes a SHARED lock on the CHECKPOINTER slot and then
** checks if the snapshot passed as the second argument is still 
** available. If so, SQLITE_OK is returned.
**
** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
** lock is released before returning.
*/
SQLITE_PRIVATE int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot){
  int rc;
  if( pPager->pWal ){
    rc = sqlite3WalSnapshotCheck(pPager->pWal, pSnapshot);
  }else{
    rc = SQLITE_ERROR;
  }
  return rc;
}

/*
** Release a lock obtained by an earlier successful call to
** sqlite3PagerSnapshotCheck().
*/
SQLITE_PRIVATE void sqlite3PagerSnapshotUnlock(Pager *pPager){
  assert( pPager->pWal );
  return sqlite3WalSnapshotUnlock(pPager->pWal);
}

#endif /* SQLITE_ENABLE_SNAPSHOT */
#endif /* !SQLITE_OMIT_WAL */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** A read-lock must be held on the pager when this function is called. If
** the pager is in WAL mode and the WAL file currently contains one or more
59474
59475
59476
59477
59478
59479
59480
59481
59482
59483
59484
59485
59486
59487
59488
59489
59490
59491
59492
59493

59494
59495
59496
59497
59498
59499
59500
      rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
      assert( rc==SQLITE_OK || pIter==0 );
    }

    if( pIter
     && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
    ){
      i64 nSize;                    /* Current size of database file */
      u32 nBackfill = pInfo->nBackfill;

      pInfo->nBackfillAttempted = mxSafeFrame;

      /* Sync the WAL to disk */
      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));

      /* If the database may grow as a result of this checkpoint, hint
      ** about the eventual size of the db file to the VFS layer.
      */
      if( rc==SQLITE_OK ){
        i64 nReq = ((i64)mxPage * szPage);

        rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
        if( rc==SQLITE_OK && nSize<nReq ){
          sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
        }
      }









<












>







59550
59551
59552
59553
59554
59555
59556

59557
59558
59559
59560
59561
59562
59563
59564
59565
59566
59567
59568
59569
59570
59571
59572
59573
59574
59575
59576
      rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
      assert( rc==SQLITE_OK || pIter==0 );
    }

    if( pIter
     && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
    ){

      u32 nBackfill = pInfo->nBackfill;

      pInfo->nBackfillAttempted = mxSafeFrame;

      /* Sync the WAL to disk */
      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));

      /* If the database may grow as a result of this checkpoint, hint
      ** about the eventual size of the db file to the VFS layer.
      */
      if( rc==SQLITE_OK ){
        i64 nReq = ((i64)mxPage * szPage);
        i64 nSize;                    /* Current size of database file */
        rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
        if( rc==SQLITE_OK && nSize<nReq ){
          sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
        }
      }


61408
61409
61410
61411
61412
61413
61414





































61415
61416
61417
61418
61419
61420
61421
  ** is incremented each time the wal file is restarted.  */
  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;
  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;
  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;
  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;
  return 0;
}





































#endif /* SQLITE_ENABLE_SNAPSHOT */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** If the argument is not NULL, it points to a Wal object that holds a
** read-lock. This function returns the database page-size if it is known,
** or zero if it is not (or if pWal is NULL).







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







61484
61485
61486
61487
61488
61489
61490
61491
61492
61493
61494
61495
61496
61497
61498
61499
61500
61501
61502
61503
61504
61505
61506
61507
61508
61509
61510
61511
61512
61513
61514
61515
61516
61517
61518
61519
61520
61521
61522
61523
61524
61525
61526
61527
61528
61529
61530
61531
61532
61533
61534
  ** is incremented each time the wal file is restarted.  */
  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;
  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;
  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;
  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;
  return 0;
}

/*
** The caller currently has a read transaction open on the database.
** This function takes a SHARED lock on the CHECKPOINTER slot and then
** checks if the snapshot passed as the second argument is still 
** available. If so, SQLITE_OK is returned.
**
** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
** lock is released before returning.
*/
SQLITE_PRIVATE int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){
  int rc;
  rc = walLockShared(pWal, WAL_CKPT_LOCK);
  if( rc==SQLITE_OK ){
    WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
    if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
     || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
    ){
      rc = SQLITE_BUSY_SNAPSHOT;
      walUnlockShared(pWal, WAL_CKPT_LOCK);
    }
  }
  return rc;
}

/*
** Release a lock obtained by an earlier successful call to
** sqlite3WalSnapshotCheck().
*/
SQLITE_PRIVATE void sqlite3WalSnapshotUnlock(Wal *pWal){
  assert( pWal );
  walUnlockShared(pWal, WAL_CKPT_LOCK);
}


#endif /* SQLITE_ENABLE_SNAPSHOT */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** If the argument is not NULL, it points to a Wal object that holds a
** read-lock. This function returns the database page-size if it is known,
** or zero if it is not (or if pWal is NULL).
74391
74392
74393
74394
74395
74396
74397
74398
74399
74400
74401
74402
74403
74404
74405
74406
74407
74408
74409
74410
74411
74412
74413
74414
74415
74416
74417
74418
74419
74420
74421
74422
74423
74424
74425
74426
74427
74428
74429
74430
74431
74432
74433
74434
74435
74436
74437
74438
74439
74440
74441
74442
74443
74444
74445
74446
74447
74448
74449
74450
      /* pMem is the register that is changing.  But also mark pX as
      ** undefined so that we can quickly detect the shallow-copy error */
      pX->flags = MEM_Undefined;
      pX->pScopyFrom = 0;
    }
  }
  pMem->pScopyFrom = 0;
#ifdef SQLITE_DEBUG_COLUMN_CACHE
  pMem->iTabColHash = 0;
#endif
}
#endif /* SQLITE_DEBUG */


/*
** Make an shallow copy of pFrom into pTo.  Prior contents of
** pTo are freed.  The pFrom->z field is not duplicated.  If
** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
** and flags gets srcType (either MEM_Ephem or MEM_Static).
*/
static SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int eType){
  vdbeMemClearExternAndSetNull(pTo);
  assert( !VdbeMemDynamic(pTo) );
  sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);
}
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
  assert( (pFrom->flags & MEM_RowSet)==0 );
  assert( pTo->db==pFrom->db );
  if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
  memcpy(pTo, pFrom, MEMCELLSIZE);
#ifdef SQLITE_DEBUG_COLUMNCACHE
  pTo->iTabColHash = pFrom->iTabColHash;
#endif
  if( (pFrom->flags&MEM_Static)==0 ){
    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
    assert( srcType==MEM_Ephem || srcType==MEM_Static );
    pTo->flags |= srcType;
  }
}

/*
** Make a full copy of pFrom into pTo.  Prior contents of pTo are
** freed before the copy is made.
*/
SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
  int rc = SQLITE_OK;

  assert( (pFrom->flags & MEM_RowSet)==0 );
  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
  memcpy(pTo, pFrom, MEMCELLSIZE);
#ifdef SQLITE_DEBUG_COLUMNCACHE
  pTo->iTabColHash = pFrom->iTabColHash;
#endif
  pTo->flags &= ~MEM_Dyn;
  if( pTo->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pFrom->flags&MEM_Static) ){
      pTo->flags |= MEM_Ephem;
      rc = sqlite3VdbeMemMakeWriteable(pTo);
    }
  }







<
<
<




















<
<
<

















<
<
<







74504
74505
74506
74507
74508
74509
74510



74511
74512
74513
74514
74515
74516
74517
74518
74519
74520
74521
74522
74523
74524
74525
74526
74527
74528
74529
74530



74531
74532
74533
74534
74535
74536
74537
74538
74539
74540
74541
74542
74543
74544
74545
74546
74547



74548
74549
74550
74551
74552
74553
74554
      /* pMem is the register that is changing.  But also mark pX as
      ** undefined so that we can quickly detect the shallow-copy error */
      pX->flags = MEM_Undefined;
      pX->pScopyFrom = 0;
    }
  }
  pMem->pScopyFrom = 0;



}
#endif /* SQLITE_DEBUG */


/*
** Make an shallow copy of pFrom into pTo.  Prior contents of
** pTo are freed.  The pFrom->z field is not duplicated.  If
** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
** and flags gets srcType (either MEM_Ephem or MEM_Static).
*/
static SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int eType){
  vdbeMemClearExternAndSetNull(pTo);
  assert( !VdbeMemDynamic(pTo) );
  sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);
}
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
  assert( (pFrom->flags & MEM_RowSet)==0 );
  assert( pTo->db==pFrom->db );
  if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
  memcpy(pTo, pFrom, MEMCELLSIZE);



  if( (pFrom->flags&MEM_Static)==0 ){
    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
    assert( srcType==MEM_Ephem || srcType==MEM_Static );
    pTo->flags |= srcType;
  }
}

/*
** Make a full copy of pFrom into pTo.  Prior contents of pTo are
** freed before the copy is made.
*/
SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
  int rc = SQLITE_OK;

  assert( (pFrom->flags & MEM_RowSet)==0 );
  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
  memcpy(pTo, pFrom, MEMCELLSIZE);



  pTo->flags &= ~MEM_Dyn;
  if( pTo->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pFrom->flags&MEM_Static) ){
      pTo->flags |= MEM_Ephem;
      rc = sqlite3VdbeMemMakeWriteable(pTo);
    }
  }
75545
75546
75547
75548
75549
75550
75551
75552
75553
75554
75555
75556
75557
75558
75559
75560
75561
75562
75563
75564
75565
75566
  pOp->p4.p = 0;
  pOp->p4type = P4_NOTUSED;
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  pOp->zComment = 0;
#endif
#ifdef SQLITE_DEBUG
  if( p->db->flags & SQLITE_VdbeAddopTrace ){
    int jj, kk;
    Parse *pParse = p->pParse;
    for(jj=kk=0; jj<pParse->nColCache; jj++){
      struct yColCache *x = pParse->aColCache + jj;
      printf(" r[%d]={%d:%d}", x->iReg, x->iTable, x->iColumn);
      kk++;
    }
    if( kk ) printf("\n");
    sqlite3VdbePrintOp(0, i, &p->aOp[i]);
    test_addop_breakpoint();
  }
#endif
#ifdef VDBE_PROFILE
  pOp->cycles = 0;
  pOp->cnt = 0;







<
<
<
<
<
<
<
<







75649
75650
75651
75652
75653
75654
75655








75656
75657
75658
75659
75660
75661
75662
  pOp->p4.p = 0;
  pOp->p4type = P4_NOTUSED;
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  pOp->zComment = 0;
#endif
#ifdef SQLITE_DEBUG
  if( p->db->flags & SQLITE_VdbeAddopTrace ){








    sqlite3VdbePrintOp(0, i, &p->aOp[i]);
    test_addop_breakpoint();
  }
#endif
#ifdef VDBE_PROFILE
  pOp->cycles = 0;
  pOp->cnt = 0;
75797
75798
75799
75800
75801
75802
75803
75804
75805
75806
75807
75808
75809
75810
75811
75812
75813
75814
75815
75816
75817
75818
75819
75820
75821
75822
75823
    }
#endif
    assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
    p->aLabel[j] = v->nOp;
  }
}

#ifdef SQLITE_COVERAGE_TEST
/*
** Return TRUE if and only if the label x has already been resolved.
** Return FALSE (zero) if label x is still unresolved.
**
** This routine is only used inside of testcase() macros, and so it
** only exists when measuring test coverage.
*/
SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe *v, int x){
  return v->pParse->aLabel && v->pParse->aLabel[ADDR(x)]>=0;
}
#endif /* SQLITE_COVERAGE_TEST */

/*
** Mark the VDBE as one that can only be run one time.
*/
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
  p->runOnlyOnce = 1;
}








<
<
<
<
<
<
<
<
<
<
<
<
<







75893
75894
75895
75896
75897
75898
75899













75900
75901
75902
75903
75904
75905
75906
    }
#endif
    assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
    p->aLabel[j] = v->nOp;
  }
}














/*
** Mark the VDBE as one that can only be run one time.
*/
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
  p->runOnlyOnce = 1;
}

76999
77000
77001
77002
77003
77004
77005
77006
77007
77008
77009
77010
77011
77012
77013
77014
77015
  while( (N--)>0 ){
    p->db = db;
    p->flags = flags;
    p->szMalloc = 0;
#ifdef SQLITE_DEBUG
    p->pScopyFrom = 0;
#endif
#ifdef SQLITE_DEBUG_COLUMNCACHE
    p->iTabColHash = 0;
#endif
    p++;
  }
}

/*
** Release an array of N Mem elements
*/







<
<
<







77082
77083
77084
77085
77086
77087
77088



77089
77090
77091
77092
77093
77094
77095
  while( (N--)>0 ){
    p->db = db;
    p->flags = flags;
    p->szMalloc = 0;
#ifdef SQLITE_DEBUG
    p->pScopyFrom = 0;
#endif



    p++;
  }
}

/*
** Release an array of N Mem elements
*/
81185
81186
81187
81188
81189
81190
81191
81192
81193
81194
81195
81196
81197
81198
81199
81200
81201
        /* .uTemp      = */ (u32)0,
        /* .db         = */ (sqlite3*)0,
        /* .xDel       = */ (void(*)(void*))0,
#ifdef SQLITE_DEBUG
        /* .pScopyFrom = */ (Mem*)0,
        /* .mScopyFlags= */ 0,
#endif
#ifdef SQLITE_DEBUG_COLUMNCACHE
        /* .iTabColHash= */ 0,
#endif
      };
  return &nullMem;
}

/*
** Check to see if column iCol of the given statement is valid.  If
** it is, return a pointer to the Mem for the value of that column.







<
<
<







81265
81266
81267
81268
81269
81270
81271



81272
81273
81274
81275
81276
81277
81278
        /* .uTemp      = */ (u32)0,
        /* .db         = */ (sqlite3*)0,
        /* .xDel       = */ (void(*)(void*))0,
#ifdef SQLITE_DEBUG
        /* .pScopyFrom = */ (Mem*)0,
        /* .mScopyFlags= */ 0,
#endif



      };
  return &nullMem;
}

/*
** Check to see if column iCol of the given statement is valid.  If
** it is, return a pointer to the Mem for the value of that column.
82410
82411
82412
82413
82414
82415
82416
82417
82418
82419
82420
82421
82422
82423
82424
82425
82426
82427
82428
82429
82430
82431
82432
82433
82434
82435
*/
#ifdef SQLITE_DEBUG
# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
#else
# define memAboutToChange(P,M)
#endif

/*
** Given a cursor number and a column for a table or index, compute a
** hash value for use in the Mem.iTabColHash value.  The iTabColHash
** column is only used for verification - it is omitted from production
** builds.  Collisions are harmless in the sense that the correct answer
** still results.  The only harm of collisions is that they can potential
** reduce column-cache error detection during SQLITE_DEBUG builds.
**
** No valid hash should be 0.
*/
#define TableColumnHash(T,C)  (((u32)(T)<<16)^(u32)(C+2))

/*
** The following global variable is incremented every time a cursor
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
** procedures use this information to make sure that indices are
** working correctly.  This variable has no function other than to
** help verify the correct operation of the library.
*/







<
<
<
<
<
<
<
<
<
<
<
<







82487
82488
82489
82490
82491
82492
82493












82494
82495
82496
82497
82498
82499
82500
*/
#ifdef SQLITE_DEBUG
# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
#else
# define memAboutToChange(P,M)
#endif













/*
** The following global variable is incremented every time a cursor
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
** procedures use this information to make sure that indices are
** working correctly.  This variable has no function other than to
** help verify the correct operation of the library.
*/
83771
83772
83773
83774
83775
83776
83777
83778
83779
83780
83781
83782
83783
83784
83785
  assert( pOut!=pIn1 );
  while( 1 ){
    memAboutToChange(p, pOut);
    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
    Deephemeralize(pOut);
#ifdef SQLITE_DEBUG
    pOut->pScopyFrom = 0;
    pOut->iTabColHash = 0;
#endif
    REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
    if( (n--)==0 ) break;
    pOut++;
    pIn1++;
  }
  break;







<







83836
83837
83838
83839
83840
83841
83842

83843
83844
83845
83846
83847
83848
83849
  assert( pOut!=pIn1 );
  while( 1 ){
    memAboutToChange(p, pOut);
    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
    Deephemeralize(pOut);
#ifdef SQLITE_DEBUG
    pOut->pScopyFrom = 0;

#endif
    REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
    if( (n--)==0 ) break;
    pOut++;
    pIn1++;
  }
  break;
84435
84436
84437
84438
84439
84440
84441

84442




84443
84444
84445
84446
84447
84448
84449
  }else{
    /* Neither operand is NULL.  Do a comparison. */
    affinity = pOp->p5 & SQLITE_AFF_MASK;
    if( affinity>=SQLITE_AFF_NUMERIC ){
      if( (flags1 | flags3)&MEM_Str ){
        if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
          applyNumericAffinity(pIn1,0);

          testcase( flags3!=pIn3->flags ); /* Possible if pIn1==pIn3 */




          flags3 = pIn3->flags;
        }
        if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
          applyNumericAffinity(pIn3,0);
        }
      }
      /* Handle the common case of integer comparison here, as an







>
|
>
>
>
>







84499
84500
84501
84502
84503
84504
84505
84506
84507
84508
84509
84510
84511
84512
84513
84514
84515
84516
84517
84518
  }else{
    /* Neither operand is NULL.  Do a comparison. */
    affinity = pOp->p5 & SQLITE_AFF_MASK;
    if( affinity>=SQLITE_AFF_NUMERIC ){
      if( (flags1 | flags3)&MEM_Str ){
        if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
          applyNumericAffinity(pIn1,0);
          assert( flags3==pIn3->flags );
          /* testcase( flags3!=pIn3->flags );
          ** this used to be possible with pIn1==pIn3, but not since
          ** the column cache was removed.  The following assignment
          ** is essentially a no-op.  But, it provides defense-in-depth
          ** in case our analysis is incorrect, so it is left in. */
          flags3 = pIn3->flags;
        }
        if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
          applyNumericAffinity(pIn3,0);
        }
      }
      /* Handle the common case of integer comparison here, as an
86355
86356
86357
86358
86359
86360
86361
86362
86363
86364
86365
86366
86367
86368
86369
86370
86371
86372
** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this
** opcode must be followed by an IdxGE opcode with the same arguments.
** The IdxGE opcode will be skipped if this opcode succeeds, but the
** IdxGE opcode will be used on subsequent loop iterations.
**
** See also: Found, NotFound, SeekGt, SeekGe, SeekLt
*/
case OP_SeekLT:         /* jump, in3 */
case OP_SeekLE:         /* jump, in3 */
case OP_SeekGE:         /* jump, in3 */
case OP_SeekGT: {       /* jump, in3 */
  int res;           /* Comparison result */
  int oc;            /* Opcode */
  VdbeCursor *pC;    /* The cursor to seek */
  UnpackedRecord r;  /* The key to seek for */
  int nField;        /* Number of columns or fields in the key */
  i64 iKey;          /* The rowid we are to seek to */
  int eqOnly;        /* Only interested in == results */







|
|
|
|







86424
86425
86426
86427
86428
86429
86430
86431
86432
86433
86434
86435
86436
86437
86438
86439
86440
86441
** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this
** opcode must be followed by an IdxGE opcode with the same arguments.
** The IdxGE opcode will be skipped if this opcode succeeds, but the
** IdxGE opcode will be used on subsequent loop iterations.
**
** See also: Found, NotFound, SeekGt, SeekGe, SeekLt
*/
case OP_SeekLT:         /* jump, in3, group */
case OP_SeekLE:         /* jump, in3, group */
case OP_SeekGE:         /* jump, in3, group */
case OP_SeekGT: {       /* jump, in3, group */
  int res;           /* Comparison result */
  int oc;            /* Opcode */
  VdbeCursor *pC;    /* The cursor to seek */
  UnpackedRecord r;  /* The key to seek for */
  int nField;        /* Number of columns or fields in the key */
  i64 iKey;          /* The rowid we are to seek to */
  int eqOnly;        /* Only interested in == results */
86786
86787
86788
86789
86790
86791
86792






86793
86794


86795
86796
86797
86798
86799
86800
86801
86802
86803
86804
86805
86806
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  u64 iKey;

  pIn3 = &aMem[pOp->p3];
  if( (pIn3->flags & MEM_Int)==0 ){






    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
    if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;


  }
  /* Fall through into OP_NotExists */
case OP_NotExists:          /* jump, in3 */
  pIn3 = &aMem[pOp->p3];
  assert( pIn3->flags & MEM_Int );
  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
#ifdef SQLITE_DEBUG
  pC->seekOp = OP_SeekRowid;
#endif
  assert( pC->isTable );







>
>
>
>
>
>

|
>
>




|







86855
86856
86857
86858
86859
86860
86861
86862
86863
86864
86865
86866
86867
86868
86869
86870
86871
86872
86873
86874
86875
86876
86877
86878
86879
86880
86881
86882
86883
  VdbeCursor *pC;
  BtCursor *pCrsr;
  int res;
  u64 iKey;

  pIn3 = &aMem[pOp->p3];
  if( (pIn3->flags & MEM_Int)==0 ){
    /* Make sure pIn3->u.i contains a valid integer representation of
    ** the key value, but do not change the datatype of the register, as
    ** other parts of the perpared statement might be depending on the
    ** current datatype. */
    u16 origFlags = pIn3->flags;
    int isNotInt;
    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
    isNotInt = (pIn3->flags & MEM_Int)==0;
    pIn3->flags = origFlags;
    if( isNotInt ) goto jump_to_p2;
  }
  /* Fall through into OP_NotExists */
case OP_NotExists:          /* jump, in3 */
  pIn3 = &aMem[pOp->p3];
  assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );
  assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  pC = p->apCsr[pOp->p1];
  assert( pC!=0 );
#ifdef SQLITE_DEBUG
  pC->seekOp = OP_SeekRowid;
#endif
  assert( pC->isTable );
87992
87993
87994
87995
87996
87997
87998



87999



88000
88001
88002
88003
88004
88005
88006
    r.default_rc = -1;
  }else{
    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxLT );
    r.default_rc = 0;
  }
  r.aMem = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG



  { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }



#endif
  res = 0;  /* Not needed.  Only used to silence a warning. */
  rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
  assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
  if( (pOp->opcode&1)==(OP_IdxLT&1) ){
    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
    res = -res;







>
>
>
|
>
>
>







88069
88070
88071
88072
88073
88074
88075
88076
88077
88078
88079
88080
88081
88082
88083
88084
88085
88086
88087
88088
88089
    r.default_rc = -1;
  }else{
    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxLT );
    r.default_rc = 0;
  }
  r.aMem = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG
  {
    int i;
    for(i=0; i<r.nField; i++){
      assert( memIsValid(&r.aMem[i]) );
      REGISTER_TRACE(pOp->p3+i, &aMem[pOp->p3+i]);
    }
  }
#endif
  res = 0;  /* Not needed.  Only used to silence a warning. */
  rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
  assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
  if( (pOp->opcode&1)==(OP_IdxLT&1) ){
    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
    res = -res;
89682
89683
89684
89685
89686
89687
89688
89689
89690
89691
89692
89693
89694
89695
89696
89697
** automatically converted into an sqlite3_context object and the operation
** changed to this OP_Function opcode.  In this way, the initialization of
** the sqlite3_context object occurs only once, rather than once for each
** evaluation of the function.
**
** See also: Function0, AggStep, AggFinal
*/
case OP_PureFunc0:
case OP_Function0: {
  int n;
  sqlite3_context *pCtx;

  assert( pOp->p4type==P4_FUNCDEF );
  n = pOp->p5;
  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );







|
|







89765
89766
89767
89768
89769
89770
89771
89772
89773
89774
89775
89776
89777
89778
89779
89780
** automatically converted into an sqlite3_context object and the operation
** changed to this OP_Function opcode.  In this way, the initialization of
** the sqlite3_context object occurs only once, rather than once for each
** evaluation of the function.
**
** See also: Function0, AggStep, AggFinal
*/
case OP_PureFunc0:              /* group */
case OP_Function0: {            /* group */
  int n;
  sqlite3_context *pCtx;

  assert( pOp->p4type==P4_FUNCDEF );
  n = pOp->p5;
  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );
89707
89708
89709
89710
89711
89712
89713
89714
89715
89716
89717
89718
89719
89720
89721
89722
  pOp->p4type = P4_FUNCCTX;
  pOp->p4.pCtx = pCtx;
  assert( OP_PureFunc == OP_PureFunc0+2 );
  assert( OP_Function == OP_Function0+2 );
  pOp->opcode += 2;
  /* Fall through into OP_Function */
}
case OP_PureFunc:
case OP_Function: {
  int i;
  sqlite3_context *pCtx;

  assert( pOp->p4type==P4_FUNCCTX );
  pCtx = pOp->p4.pCtx;

  /* If this function is inside of a trigger, the register array in aMem[]







|
|







89790
89791
89792
89793
89794
89795
89796
89797
89798
89799
89800
89801
89802
89803
89804
89805
  pOp->p4type = P4_FUNCCTX;
  pOp->p4.pCtx = pCtx;
  assert( OP_PureFunc == OP_PureFunc0+2 );
  assert( OP_Function == OP_Function0+2 );
  pOp->opcode += 2;
  /* Fall through into OP_Function */
}
case OP_PureFunc:              /* group */
case OP_Function: {            /* group */
  int i;
  sqlite3_context *pCtx;

  assert( pOp->p4type==P4_FUNCCTX );
  pCtx = pOp->p4.pCtx;

  /* If this function is inside of a trigger, the register array in aMem[]
89893
89894
89895
89896
89897
89898
89899
89900
89901
89902
89903
89904
89905
89906
89907
89908
89909
89910
89911
89912
89913
89914
89915
89916
89917
89918
89919
89920
89921
89922
89923
89924
89925
89926
89927
89928
89929
89930
89931
89932
89933
89934
** An Abort is safe if either there have been no writes, or if there is
** an active statement journal.
*/
case OP_Abortable: {
  sqlite3VdbeAssertAbortable(p);
  break;
}
#endif

#ifdef SQLITE_DEBUG_COLUMNCACHE
/* Opcode:  SetTabCol   P1 P2 P3 * *
**
** Set a flag in register REG[P3] indicating that it holds the value
** of column P2 from the table on cursor P1.  This flag is checked
** by a subsequent VerifyTabCol opcode.
**
** This opcode only appears SQLITE_DEBUG builds.  It is used to verify
** that the expression table column cache is working correctly.
*/
case OP_SetTabCol: {
  aMem[pOp->p3].iTabColHash = TableColumnHash(pOp->p1,pOp->p2);
  break;
}
/* Opcode:  VerifyTabCol   P1 P2 P3 * *
**
** Verify that register REG[P3] contains the value of column P2 from
** cursor P1.  Assert() if this is not the case.
**
** This opcode only appears SQLITE_DEBUG builds.  It is used to verify
** that the expression table column cache is working correctly.
*/
case OP_VerifyTabCol: {
  assert( aMem[pOp->p3].iTabColHash == TableColumnHash(pOp->p1,pOp->p2) );
  break;
}
#endif

/* Opcode: Noop * * * * *
**
** Do nothing.  This instruction is often useful as a jump
** destination.
*/







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







89976
89977
89978
89979
89980
89981
89982




























89983
89984
89985
89986
89987
89988
89989
** An Abort is safe if either there have been no writes, or if there is
** an active statement journal.
*/
case OP_Abortable: {
  sqlite3VdbeAssertAbortable(p);
  break;
}




























#endif

/* Opcode: Noop * * * * *
**
** Do nothing.  This instruction is often useful as a jump
** destination.
*/
95710
95711
95712
95713
95714
95715
95716
95717
95718
95719
95720
95721
95722
95723
95724
95725
95726
95727
95728
95729
95730
95731
95732
95733
95734
95735
95736








95737
95738
95739
95740
95741
95742
95743
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
  sqlite3 *db = pParse->db;
  CollSeq *pColl = 0;
  Expr *p = pExpr;
  while( p ){
    int op = p->op;
    if( p->flags & EP_Generic ) break;
    if( op==TK_CAST || op==TK_UPLUS ){
      p = p->pLeft;
      continue;
    }
    if( op==TK_COLLATE || (op==TK_REGISTER && p->op2==TK_COLLATE) ){
      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
      break;
    }
    if( (op==TK_AGG_COLUMN || op==TK_COLUMN
          || op==TK_REGISTER || op==TK_TRIGGER)
     && p->pTab!=0
    ){
      /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
      ** a TK_COLUMN but was previously evaluated and cached in a register */
      int j = p->iColumn;
      if( j>=0 ){
        const char *zColl = p->pTab->aCol[j].zColl;
        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
      }
      break;








    }
    if( p->flags & EP_Collate ){
      if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
        p = p->pLeft;
      }else{
        Expr *pNext  = p->pRight;
        /* The Expr.x union is never used at the same time as Expr.pRight */







<
<
<
<
<
<
<
<












>
>
>
>
>
>
>
>







95765
95766
95767
95768
95769
95770
95771








95772
95773
95774
95775
95776
95777
95778
95779
95780
95781
95782
95783
95784
95785
95786
95787
95788
95789
95790
95791
95792
95793
95794
95795
95796
95797
95798
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
  sqlite3 *db = pParse->db;
  CollSeq *pColl = 0;
  Expr *p = pExpr;
  while( p ){
    int op = p->op;
    if( p->flags & EP_Generic ) break;








    if( (op==TK_AGG_COLUMN || op==TK_COLUMN
          || op==TK_REGISTER || op==TK_TRIGGER)
     && p->pTab!=0
    ){
      /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
      ** a TK_COLUMN but was previously evaluated and cached in a register */
      int j = p->iColumn;
      if( j>=0 ){
        const char *zColl = p->pTab->aCol[j].zColl;
        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
      }
      break;
    }
    if( op==TK_CAST || op==TK_UPLUS ){
      p = p->pLeft;
      continue;
    }
    if( op==TK_COLLATE || (op==TK_REGISTER && p->op2==TK_COLLATE) ){
      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
      break;
    }
    if( p->flags & EP_Collate ){
      if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
        p = p->pLeft;
      }else{
        Expr *pNext  = p->pRight;
        /* The Expr.x union is never used at the same time as Expr.pRight */
96150
96151
96152
96153
96154
96155
96156
96157
96158
96159
96160
96161
96162
96163
96164
96165
96166
96167
96168
96169
96170
96171
96172
96173
96174
96175
96176
  regRight = exprCodeSubselect(pParse, pRight);

  for(i=0; 1 /*Loop exits by "break"*/; i++){
    int regFree1 = 0, regFree2 = 0;
    Expr *pL, *pR; 
    int r1, r2;
    assert( i>=0 && i<nLeft );
    if( i>0 ) sqlite3ExprCachePush(pParse);
    r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
    r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
    codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
    testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
    testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
    testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
    testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
    testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
    testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
    sqlite3ReleaseTempReg(pParse, regFree1);
    sqlite3ReleaseTempReg(pParse, regFree2);
    if( i>0 ) sqlite3ExprCachePop(pParse);
    if( i==nLeft-1 ){
      break;
    }
    if( opx==TK_EQ ){
      sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);
      p5 |= SQLITE_KEEPNULL;
    }else if( opx==TK_NE ){







<











<







96205
96206
96207
96208
96209
96210
96211

96212
96213
96214
96215
96216
96217
96218
96219
96220
96221
96222

96223
96224
96225
96226
96227
96228
96229
  regRight = exprCodeSubselect(pParse, pRight);

  for(i=0; 1 /*Loop exits by "break"*/; i++){
    int regFree1 = 0, regFree2 = 0;
    Expr *pL, *pR; 
    int r1, r2;
    assert( i>=0 && i<nLeft );

    r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
    r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
    codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
    testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
    testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
    testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
    testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
    testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
    testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
    sqlite3ReleaseTempReg(pParse, regFree1);
    sqlite3ReleaseTempReg(pParse, regFree2);

    if( i==nLeft-1 ){
      break;
    }
    if( opx==TK_EQ ){
      sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);
      p5 |= SQLITE_KEEPNULL;
    }else if( opx==TK_NE ){
96510
96511
96512
96513
96514
96515
96516
96517





96518
96519
96520
96521
96522
96523
96524
96525



96526
96527
96528
96529

96530
96531
96532
96533
96534
96535
96536
  }
}

/*
** Construct a new expression node for a function with multiple
** arguments.
*/
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){





  Expr *pNew;
  sqlite3 *db = pParse->db;
  assert( pToken );
  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);
  if( pNew==0 ){
    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
    return 0;
  }



  pNew->x.pList = pList;
  ExprSetProperty(pNew, EP_HasFunc);
  assert( !ExprHasProperty(pNew, EP_xIsSelect) );
  sqlite3ExprSetHeightAndFlags(pParse, pNew);

  return pNew;
}

/*
** Assign a variable number to an expression that encodes a wildcard
** in the original SQL statement.  
**







|
>
>
>
>
>








>
>
>




>







96563
96564
96565
96566
96567
96568
96569
96570
96571
96572
96573
96574
96575
96576
96577
96578
96579
96580
96581
96582
96583
96584
96585
96586
96587
96588
96589
96590
96591
96592
96593
96594
96595
96596
96597
96598
  }
}

/*
** Construct a new expression node for a function with multiple
** arguments.
*/
SQLITE_PRIVATE Expr *sqlite3ExprFunction(
  Parse *pParse,        /* Parsing context */
  ExprList *pList,      /* Argument list */
  Token *pToken,        /* Name of the function */
  int eDistinct         /* SF_Distinct or SF_ALL or 0 */
){
  Expr *pNew;
  sqlite3 *db = pParse->db;
  assert( pToken );
  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);
  if( pNew==0 ){
    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
    return 0;
  }
  if( pList && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken);
  }
  pNew->x.pList = pList;
  ExprSetProperty(pNew, EP_HasFunc);
  assert( !ExprHasProperty(pNew, EP_xIsSelect) );
  sqlite3ExprSetHeightAndFlags(pParse, pNew);
  if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct);
  return pNew;
}

/*
** Assign a variable number to an expression that encodes a wildcard
** in the original SQL statement.  
**
97408
97409
97410
97411
97412
97413
97414



97415
97416
97417
97418
97419
97420
97421
    case TK_COLUMN:
    case TK_AGG_FUNCTION:
    case TK_AGG_COLUMN:
      testcase( pExpr->op==TK_ID );
      testcase( pExpr->op==TK_COLUMN );
      testcase( pExpr->op==TK_AGG_FUNCTION );
      testcase( pExpr->op==TK_AGG_COLUMN );



      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
        return WRC_Continue;
      }
      /* Fall through */
    case TK_IF_NULL_ROW:
    case TK_REGISTER:
      testcase( pExpr->op==TK_REGISTER );







>
>
>







97470
97471
97472
97473
97474
97475
97476
97477
97478
97479
97480
97481
97482
97483
97484
97485
97486
    case TK_COLUMN:
    case TK_AGG_FUNCTION:
    case TK_AGG_COLUMN:
      testcase( pExpr->op==TK_ID );
      testcase( pExpr->op==TK_COLUMN );
      testcase( pExpr->op==TK_AGG_FUNCTION );
      testcase( pExpr->op==TK_AGG_COLUMN );
      if( ExprHasProperty(pExpr, EP_FixedCol) && pWalker->eCode!=2 ){
        return WRC_Continue;
      }
      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
        return WRC_Continue;
      }
      /* Fall through */
    case TK_IF_NULL_ROW:
    case TK_REGISTER:
      testcase( pExpr->op==TK_REGISTER );
97463
97464
97465
97466
97467
97468
97469
97470
97471
97472
97473







97474
97475
97476
97477
97478
97479
97480
** a constant.
*/
SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
  return exprIsConst(p, 1, 0);
}

/*
** Walk an expression tree.  Return non-zero if the expression is constant
** that does no originate from the ON or USING clauses of a join.
** Return 0 if it involves variables or function calls or terms from
** an ON or USING clause.







*/
SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
  return exprIsConst(p, 2, 0);
}

/*
** Walk an expression tree.  Return non-zero if the expression is constant







|
|
|
|
>
>
>
>
>
>
>







97528
97529
97530
97531
97532
97533
97534
97535
97536
97537
97538
97539
97540
97541
97542
97543
97544
97545
97546
97547
97548
97549
97550
97551
97552
** a constant.
*/
SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
  return exprIsConst(p, 1, 0);
}

/*
** Walk an expression tree.  Return non-zero if
**
**   (1) the expression is constant, and
**   (2) the expression does originate in the ON or USING clause
**       of a LEFT JOIN, and
**   (3) the expression does not contain any EP_FixedCol TK_COLUMN
**       operands created by the constant propagation optimization.
**
** When this routine returns true, it indicates that the expression
** can be added to the pParse->pConstExpr list and evaluated once when
** the prepared statement starts up.  See sqlite3ExprCodeAtInit().
*/
SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
  return exprIsConst(p, 2, 0);
}

/*
** Walk an expression tree.  Return non-zero if the expression is constant
97496
97497
97498
97499
97500
97501
97502
97503
97504
97505
97506
97507
97508
97509
97510

  /* Check if pExpr is identical to any GROUP BY term. If so, consider
  ** it constant.  */
  for(i=0; i<pGroupBy->nExpr; i++){
    Expr *p = pGroupBy->a[i].pExpr;
    if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
      CollSeq *pColl = sqlite3ExprNNCollSeq(pWalker->pParse, p);
      if( sqlite3_stricmp("BINARY", pColl->zName)==0 ){
        return WRC_Prune;
      }
    }
  }

  /* Check if pExpr is a sub-select. If so, consider it variable. */
  if( ExprHasProperty(pExpr, EP_xIsSelect) ){







|







97568
97569
97570
97571
97572
97573
97574
97575
97576
97577
97578
97579
97580
97581
97582

  /* Check if pExpr is identical to any GROUP BY term. If so, consider
  ** it constant.  */
  for(i=0; i<pGroupBy->nExpr; i++){
    Expr *p = pGroupBy->a[i].pExpr;
    if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
      CollSeq *pColl = sqlite3ExprNNCollSeq(pWalker->pParse, p);
      if( sqlite3IsBinary(pColl) ){
        return WRC_Prune;
      }
    }
  }

  /* Check if pExpr is a sub-select. If so, consider it variable. */
  if( ExprHasProperty(pExpr, EP_xIsSelect) ){
97918
97919
97920
97921
97922
97923
97924
97925

97926
97927
97928
97929
97930
97931
97932
    if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){
      /* The "x IN (SELECT rowid FROM table)" case */
      int iAddr = sqlite3VdbeAddOp0(v, OP_Once);
      VdbeCoverage(v);

      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
      eType = IN_INDEX_ROWID;


      sqlite3VdbeJumpHere(v, iAddr);
    }else{
      Index *pIdx;                         /* Iterator variable */
      int affinity_ok = 1;
      int i;

      /* Check that the affinity that will be used to perform each 







|
>







97990
97991
97992
97993
97994
97995
97996
97997
97998
97999
98000
98001
98002
98003
98004
98005
    if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){
      /* The "x IN (SELECT rowid FROM table)" case */
      int iAddr = sqlite3VdbeAddOp0(v, OP_Once);
      VdbeCoverage(v);

      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
      eType = IN_INDEX_ROWID;
      ExplainQueryPlan((pParse, 0,
            "USING ROWID SEARCH ON TABLE %s FOR IN-OPERATOR",pTab->zName));
      sqlite3VdbeJumpHere(v, iAddr);
    }else{
      Index *pIdx;                         /* Iterator variable */
      int affinity_ok = 1;
      int i;

      /* Check that the affinity that will be used to perform each 
98177
98178
98179
98180
98181
98182
98183
98184
98185
98186
98187
98188
98189
98190
98191
  int rHasNullFlag,       /* Register that records whether NULLs exist in RHS */
  int isRowid             /* If true, LHS of IN operator is a rowid */
){
  int jmpIfDynamic = -1;                      /* One-time test address */
  int rReg = 0;                           /* Register storing resulting */
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( NEVER(v==0) ) return 0;
  sqlite3ExprCachePush(pParse);

  /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
  ** is encountered if any of the following is true:
  **
  **    *  The right-hand side is a correlated subquery
  **    *  The right-hand side is an expression list containing variables
  **    *  We are inside a trigger







<







98250
98251
98252
98253
98254
98255
98256

98257
98258
98259
98260
98261
98262
98263
  int rHasNullFlag,       /* Register that records whether NULLs exist in RHS */
  int isRowid             /* If true, LHS of IN operator is a rowid */
){
  int jmpIfDynamic = -1;                      /* One-time test address */
  int rReg = 0;                           /* Register storing resulting */
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( NEVER(v==0) ) return 0;


  /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
  ** is encountered if any of the following is true:
  **
  **    *  The right-hand side is a correlated subquery
  **    *  The right-hand side is an expression list containing variables
  **    *  We are inside a trigger
98313
98314
98315
98316
98317
98318
98319
98320
98321
98322
98323
98324
98325
98326
98327
            if( isRowid ){
              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
                                sqlite3VdbeCurrentAddr(v)+2);
              VdbeCoverage(v);
              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
            }else{
              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
              sqlite3ExprCacheAffinityChange(pParse, r3, 1);
              sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);
            }
          }
        }
        sqlite3ReleaseTempReg(pParse, r1);
        sqlite3ReleaseTempReg(pParse, r2);
      }







<







98385
98386
98387
98388
98389
98390
98391

98392
98393
98394
98395
98396
98397
98398
            if( isRowid ){
              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
                                sqlite3VdbeCurrentAddr(v)+2);
              VdbeCoverage(v);
              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
            }else{
              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);

              sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);
            }
          }
        }
        sqlite3ReleaseTempReg(pParse, r1);
        sqlite3ReleaseTempReg(pParse, r2);
      }
98394
98395
98396
98397
98398
98399
98400
98401
98402
98403
98404
98405
98406
98407
98408
  if( rHasNullFlag ){
    sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);
  }

  if( jmpIfDynamic>=0 ){
    sqlite3VdbeJumpHere(v, jmpIfDynamic);
  }
  sqlite3ExprCachePop(pParse);

  return rReg;
}
#endif /* SQLITE_OMIT_SUBQUERY */

#ifndef SQLITE_OMIT_SUBQUERY
/*







<







98465
98466
98467
98468
98469
98470
98471

98472
98473
98474
98475
98476
98477
98478
  if( rHasNullFlag ){
    sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);
  }

  if( jmpIfDynamic>=0 ){
    sqlite3VdbeJumpHere(v, jmpIfDynamic);
  }


  return rReg;
}
#endif /* SQLITE_OMIT_SUBQUERY */

#ifndef SQLITE_OMIT_SUBQUERY
/*
98513
98514
98515
98516
98517
98518
98519
98520
98521
98522
98523
98524
98525
98526
98527
  ** at r1.
  **
  ** sqlite3FindInIndex() might have reordered the fields of the LHS vector
  ** so that the fields are in the same order as an existing index.   The
  ** aiMap[] array contains a mapping from the original LHS field order to
  ** the field order that matches the RHS index.
  */
  sqlite3ExprCachePush(pParse);
  rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
  for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
  if( i==nVector ){
    /* LHS fields are not reordered */
    rLhs = rLhsOrig;
  }else{
    /* Need to reorder the LHS fields according to aiMap */







<







98583
98584
98585
98586
98587
98588
98589

98590
98591
98592
98593
98594
98595
98596
  ** at r1.
  **
  ** sqlite3FindInIndex() might have reordered the fields of the LHS vector
  ** so that the fields are in the same order as an existing index.   The
  ** aiMap[] array contains a mapping from the original LHS field order to
  ** the field order that matches the RHS index.
  */

  rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
  for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
  if( i==nVector ){
    /* LHS fields are not reordered */
    rLhs = rLhsOrig;
  }else{
    /* Need to reorder the LHS fields according to aiMap */
98672
98673
98674
98675
98676
98677
98678
98679
98680
98681
98682
98683
98684
98685
98686
  }

  /* Jumps here in order to return true. */
  sqlite3VdbeJumpHere(v, addrTruthOp);

sqlite3ExprCodeIN_finished:
  if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);
  sqlite3ExprCachePop(pParse);
  VdbeComment((v, "end IN expr"));
sqlite3ExprCodeIN_oom_error:
  sqlite3DbFree(pParse->db, aiMap);
  sqlite3DbFree(pParse->db, zAff);
}
#endif /* SQLITE_OMIT_SUBQUERY */








<







98741
98742
98743
98744
98745
98746
98747

98748
98749
98750
98751
98752
98753
98754
  }

  /* Jumps here in order to return true. */
  sqlite3VdbeJumpHere(v, addrTruthOp);

sqlite3ExprCodeIN_finished:
  if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);

  VdbeComment((v, "end IN expr"));
sqlite3ExprCodeIN_oom_error:
  sqlite3DbFree(pParse->db, aiMap);
  sqlite3DbFree(pParse->db, zAff);
}
#endif /* SQLITE_OMIT_SUBQUERY */

98740
98741
98742
98743
98744
98745
98746
98747
98748
98749
98750
98751
98752
98753
98754
98755
98756
98757
98758
98759
98760
98761
98762
98763
98764
98765
98766
98767
98768
98769
98770
98771
98772
98773
98774
98775
98776
98777
98778
98779
98780
98781
98782
98783
98784
98785
98786
98787
98788
98789
98790
98791
98792
98793
98794
98795
98796
98797
98798
98799
98800
98801
98802
98803
98804
98805
98806
98807
98808
98809
98810
98811
98812
98813
98814
98815
98816
98817
98818
98819
98820
98821
98822
98823
98824
98825
98826
98827
98828
98829
98830
98831
98832
98833
98834
98835
98836
98837
98838
98839
98840
98841
98842
98843
98844
98845
98846
98847
98848
98849
98850
98851
98852
98853
98854
98855
98856
98857
98858
98859
98860
98861
98862
98863
98864
98865
98866
98867
98868
98869
98870
98871
98872
98873
98874
98875
98876
98877
98878
98879
98880
98881
98882
98883
98884
98885
98886
98887
98888
98889
98890
98891
98892
98893
98894
98895
98896
98897
98898
98899
    }else{
      if( negFlag ){ value = c==3 ? SMALLEST_INT64 : -value; }
      sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, P4_INT64);
    }
  }
}

/*
** Erase column-cache entry number i
*/
static void cacheEntryClear(Parse *pParse, int i){
  if( pParse->aColCache[i].tempReg ){
    if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){
      pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;
    }
  }
  pParse->nColCache--;
  if( i<pParse->nColCache ){
    pParse->aColCache[i] = pParse->aColCache[pParse->nColCache];
  }
}


/*
** Record in the column cache that a particular column from a
** particular table is stored in a particular register.
*/
SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){
  int i;
  int minLru;
  int idxLru;
  struct yColCache *p;

  /* Unless an error has occurred, register numbers are always positive. */
  assert( iReg>0 || pParse->nErr || pParse->db->mallocFailed );
  assert( iCol>=-1 && iCol<32768 );  /* Finite column numbers */

  /* The SQLITE_ColumnCache flag disables the column cache.  This is used
  ** for testing only - to verify that SQLite always gets the same answer
  ** with and without the column cache.
  */
  if( OptimizationDisabled(pParse->db, SQLITE_ColumnCache) ) return;

  /* First replace any existing entry.
  **
  ** Actually, the way the column cache is currently used, we are guaranteed
  ** that the object will never already be in cache.  Verify this guarantee.
  */
#ifndef NDEBUG
  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
    assert( p->iTable!=iTab || p->iColumn!=iCol );
  }
#endif

#ifdef SQLITE_DEBUG_COLUMNCACHE
  /* Add a SetTabCol opcode for run-time verification that the column
  ** cache is working correctly.
  */
  sqlite3VdbeAddOp3(pParse->pVdbe, OP_SetTabCol, iTab, iCol, iReg);
#endif

  /* If the cache is already full, delete the least recently used entry */
  if( pParse->nColCache>=SQLITE_N_COLCACHE ){
    minLru = 0x7fffffff;
    idxLru = -1;
    for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
      if( p->lru<minLru ){
        idxLru = i;
        minLru = p->lru;
      }
    }
    p = &pParse->aColCache[idxLru];
  }else{
    p = &pParse->aColCache[pParse->nColCache++];
  }

  /* Add the new entry to the end of the cache */
  p->iLevel = pParse->iCacheLevel;
  p->iTable = iTab;
  p->iColumn = iCol;
  p->iReg = iReg;
  p->tempReg = 0;
  p->lru = pParse->iCacheCnt++;
}

/*
** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.
** Purge the range of registers from the column cache.
*/
SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){
  int i = 0;
  while( i<pParse->nColCache ){
    struct yColCache *p = &pParse->aColCache[i];
    if( p->iReg >= iReg && p->iReg < iReg+nReg ){
      cacheEntryClear(pParse, i);
    }else{
      i++;
    }
  }
}

/*
** Remember the current column cache context.  Any new entries added
** added to the column cache after this call are removed when the
** corresponding pop occurs.
*/
SQLITE_PRIVATE void sqlite3ExprCachePush(Parse *pParse){
  pParse->iCacheLevel++;
#ifdef SQLITE_DEBUG
  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
    printf("PUSH to %d\n", pParse->iCacheLevel);
  }
#endif
}

/*
** Remove from the column cache any entries that were added since the
** the previous sqlite3ExprCachePush operation.  In other words, restore
** the cache to the state it was in prior the most recent Push.
*/
SQLITE_PRIVATE void sqlite3ExprCachePop(Parse *pParse){
  int i = 0;
  assert( pParse->iCacheLevel>=1 );
  pParse->iCacheLevel--;
#ifdef SQLITE_DEBUG
  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
    printf("POP  to %d\n", pParse->iCacheLevel);
  }
#endif
  while( i<pParse->nColCache ){
    if( pParse->aColCache[i].iLevel>pParse->iCacheLevel ){
      cacheEntryClear(pParse, i);
    }else{
      i++;
    }
  }
}

/*
** When a cached column is reused, make sure that its register is
** no longer available as a temp register.  ticket #3879:  that same
** register might be in the cache in multiple places, so be sure to
** get them all.
*/
static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){
  int i;
  struct yColCache *p;
  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
    if( p->iReg==iReg ){
      p->tempReg = 0;
    }
  }
}

/* Generate code that will load into register regOut a value that is
** appropriate for the iIdxCol-th column of index pIdx.
*/
SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(
  Parse *pParse,  /* The parsing context */
  Index *pIdx,    /* The index whose column is to be loaded */







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







98808
98809
98810
98811
98812
98813
98814


















































































































































98815
98816
98817
98818
98819
98820
98821
    }else{
      if( negFlag ){ value = c==3 ? SMALLEST_INT64 : -value; }
      sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, P4_INT64);
    }
  }
}




















































































































































/* Generate code that will load into register regOut a value that is
** appropriate for the iIdxCol-th column of index pIdx.
*/
SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(
  Parse *pParse,  /* The parsing context */
  Index *pIdx,    /* The index whose column is to be loaded */
98941
98942
98943
98944
98945
98946
98947
98948
98949
98950
98951
98952
98953
98954
98955
98956
98957
98958
98959
98960
98961
98962
98963
98964
98965
98966
98967
98968
98969
98970
98971
98972
98973
98974
98975
98976
98977
98978
98979
98980
98981
98982
98983
98984
98985
98986
98987
98988
98989
98990
98991
98992
98993
98994
98995
98996
98997
98998
98999
99000
99001
99002
99003
99004
99005
99006
99007
99008
99009
99010
99011
99012
99013
99014
99015
99016
99017
99018
99019
99020
99021
99022
99023
99024
99025
99026
99027
99028
99029
99030
99031
99032
99033
99034
99035
99036
99037
99038
99039
99040
99041
99042
99043
99044
99045
99046
99047
99048
99049
99050
99051
99052
99053
99054
99055
99056
99057
99058
99059
99060
99061
99062
99063
99064
99065
  if( iCol>=0 ){
    sqlite3ColumnDefault(v, pTab, iCol, regOut);
  }
}

/*
** Generate code that will extract the iColumn-th column from
** table pTab and store the column value in a register. 
**
** An effort is made to store the column value in register iReg.  This
** is not garanteeed for GetColumn() - the result can be stored in
** any register.  But the result is guaranteed to land in register iReg
** for GetColumnToReg().
**
** There must be an open cursor to pTab in iTable when this routine
** is called.  If iColumn<0 then code is generated that extracts the rowid.
*/
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
  Parse *pParse,   /* Parsing and code generating context */
  Table *pTab,     /* Description of the table we are reading from */
  int iColumn,     /* Index of the table column */
  int iTable,      /* The cursor pointing to the table */
  int iReg,        /* Store results here */
  u8 p5            /* P5 value for OP_Column + FLAGS */
){
  Vdbe *v = pParse->pVdbe;
  int i;
  struct yColCache *p;

  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
    if( p->iTable==iTable && p->iColumn==iColumn ){
      p->lru = pParse->iCacheCnt++;
      sqlite3ExprCachePinRegister(pParse, p->iReg);
#ifdef SQLITE_DEBUG_COLUMNCACHE
      sqlite3VdbeAddOp3(v, OP_VerifyTabCol, iTable, iColumn, p->iReg);
#endif
      return p->iReg;
    }
  }  
  assert( v!=0 );
  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
  if( p5 ){
    sqlite3VdbeChangeP5(v, p5);
  }else{   
    sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
  }
  return iReg;
}
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(
  Parse *pParse,   /* Parsing and code generating context */
  Table *pTab,     /* Description of the table we are reading from */
  int iColumn,     /* Index of the table column */
  int iTable,      /* The cursor pointing to the table */
  int iReg         /* Store results here */
){
  int r1 = sqlite3ExprCodeGetColumn(pParse, pTab, iColumn, iTable, iReg, 0);
  if( r1!=iReg ) sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, r1, iReg);
}


/*
** Clear all column cache entries.
*/
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
  int i;

#ifdef SQLITE_DEBUG
  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
    printf("CLEAR\n");
  }
#endif
  for(i=0; i<pParse->nColCache; i++){
    if( pParse->aColCache[i].tempReg
     && pParse->nTempReg<ArraySize(pParse->aTempReg)
    ){
       pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;
    }
  }
  pParse->nColCache = 0;
}

/*
** Record the fact that an affinity change has occurred on iCount
** registers starting with iStart.
*/
SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
  sqlite3ExprCacheRemove(pParse, iStart, iCount);
}

/*
** Generate code to move content from registers iFrom...iFrom+nReg-1
** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.
*/
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){
  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );
  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);
  sqlite3ExprCacheRemove(pParse, iFrom, nReg);
}

#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
/*
** Return true if any register in the range iFrom..iTo (inclusive)
** is used as part of the column cache.
**
** This routine is used within assert() and testcase() macros only
** and does not appear in a normal build.
*/
static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
  int i;
  struct yColCache *p;
  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
    int r = p->iReg;
    if( r>=iFrom && r<=iTo ) return 1;    /*NO_TEST*/
  }
  return 0;
}
#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */


/*
** Convert a scalar expression node to a TK_REGISTER referencing
** register iReg.  The caller must ensure that iReg already contains
** the correct value for the expression.
*/
static void exprToRegister(Expr *p, int iReg){







|
<
<
<
<
<













<
<
<
<
<
<
<
<
<
<
<
<
<




<
<



<
<
<
<
<
<
<
<
<
|
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

|




<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







98863
98864
98865
98866
98867
98868
98869
98870





98871
98872
98873
98874
98875
98876
98877
98878
98879
98880
98881
98882
98883













98884
98885
98886
98887


98888
98889
98890









98891


98892





























98893
98894
98895
98896
98897
98898

98899




















98900
98901
98902
98903
98904
98905
98906
  if( iCol>=0 ){
    sqlite3ColumnDefault(v, pTab, iCol, regOut);
  }
}

/*
** Generate code that will extract the iColumn-th column from
** table pTab and store the column value in register iReg. 





**
** There must be an open cursor to pTab in iTable when this routine
** is called.  If iColumn<0 then code is generated that extracts the rowid.
*/
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
  Parse *pParse,   /* Parsing and code generating context */
  Table *pTab,     /* Description of the table we are reading from */
  int iColumn,     /* Index of the table column */
  int iTable,      /* The cursor pointing to the table */
  int iReg,        /* Store results here */
  u8 p5            /* P5 value for OP_Column + FLAGS */
){
  Vdbe *v = pParse->pVdbe;













  assert( v!=0 );
  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
  if( p5 ){
    sqlite3VdbeChangeP5(v, p5);


  }
  return iReg;
}












/*





























** Generate code to move content from registers iFrom...iFrom+nReg-1
** over to iTo..iTo+nReg-1.
*/
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){
  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );
  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);

}





















/*
** Convert a scalar expression node to a TK_REGISTER referencing
** register iReg.  The caller must ensure that iReg already contains
** the correct value for the expression.
*/
static void exprToRegister(Expr *p, int iReg){
99150
99151
99152
99153
99154
99155
99156






















99157
99158
99159
99160
99161
99162
99163
                              pCol->iSorterColumn, target);
        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;






















      if( iTab<0 ){
        if( pParse->iSelfTab<0 ){
          /* Generating CHECK constraints or inserting into partial index */
          return pExpr->iColumn - pParse->iSelfTab;
        }else{
          /* Coding an expression that is part of an index where column names
          ** in the index refer to the table to which the index belongs */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







98991
98992
98993
98994
98995
98996
98997
98998
98999
99000
99001
99002
99003
99004
99005
99006
99007
99008
99009
99010
99011
99012
99013
99014
99015
99016
99017
99018
99019
99020
99021
99022
99023
99024
99025
99026
                              pCol->iSorterColumn, target);
        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;
      if( ExprHasProperty(pExpr, EP_FixedCol) ){
        /* This COLUMN expression is really a constant due to WHERE clause
        ** constraints, and that constant is coded by the pExpr->pLeft
        ** expresssion.  However, make sure the constant has the correct
        ** datatype by applying the Affinity of the table column to the
        ** constant.
        */
        int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
        int aff = sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
        if( aff!=SQLITE_AFF_BLOB ){
          static const char zAff[] = "B\000C\000D\000E";
          assert( SQLITE_AFF_BLOB=='A' );
          assert( SQLITE_AFF_TEXT=='B' );
          if( iReg!=target ){
            sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);
            iReg = target;
          }
          sqlite3VdbeAddOp4(v, OP_Affinity, iReg, 1, 0,
                            &zAff[(aff-'B')*2], P4_STATIC);
        }
        return iReg;
      }
      if( iTab<0 ){
        if( pParse->iSelfTab<0 ){
          /* Generating CHECK constraints or inserting into partial index */
          return pExpr->iColumn - pParse->iSelfTab;
        }else{
          /* Coding an expression that is part of an index where column names
          ** in the index refer to the table to which the index belongs */
99230
99231
99232
99233
99234
99235
99236
99237
99238
99239
99240
99241
99242
99243
99244
99245
      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
      if( inReg!=target ){
        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
        inReg = target;
      }
      sqlite3VdbeAddOp2(v, OP_Cast, target,
                        sqlite3AffinityType(pExpr->u.zToken, 0));
      testcase( usedAsColumnCache(pParse, inReg, inReg) );
      sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
      return inReg;
    }
#endif /* SQLITE_OMIT_CAST */
    case TK_IS:
    case TK_ISNOT:
      op = (op==TK_IS) ? TK_EQ : TK_NE;
      p5 = SQLITE_NULLEQ;







<
<







99093
99094
99095
99096
99097
99098
99099


99100
99101
99102
99103
99104
99105
99106
      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
      if( inReg!=target ){
        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
        inReg = target;
      }
      sqlite3VdbeAddOp2(v, OP_Cast, target,
                        sqlite3AffinityType(pExpr->u.zToken, 0));


      return inReg;
    }
#endif /* SQLITE_OMIT_CAST */
    case TK_IS:
    case TK_ISNOT:
      op = (op==TK_IS) ? TK_EQ : TK_NE;
      p5 = SQLITE_NULLEQ;
99417
99418
99419
99420
99421
99422
99423
99424
99425
99426
99427
99428
99429
99430
99431
99432
99433
99434
      if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
        int endCoalesce = sqlite3VdbeMakeLabel(v);
        assert( nFarg>=2 );
        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
        for(i=1; i<nFarg; i++){
          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
          VdbeCoverage(v);
          sqlite3ExprCacheRemove(pParse, target, 1);
          sqlite3ExprCachePush(pParse);
          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
          sqlite3ExprCachePop(pParse);
        }
        sqlite3VdbeResolveLabel(v, endCoalesce);
        break;
      }

      /* The UNLIKELY() function is a no-op.  The result is the value
      ** of the first argument.







<
<

<







99278
99279
99280
99281
99282
99283
99284


99285

99286
99287
99288
99289
99290
99291
99292
      if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
        int endCoalesce = sqlite3VdbeMakeLabel(v);
        assert( nFarg>=2 );
        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
        for(i=1; i<nFarg; i++){
          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
          VdbeCoverage(v);


          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);

        }
        sqlite3VdbeResolveLabel(v, endCoalesce);
        break;
      }

      /* The UNLIKELY() function is a no-op.  The result is the value
      ** of the first argument.
99486
99487
99488
99489
99490
99491
99492
99493
99494
99495
99496
99497
99498
99499
99500
99501
99502
99503
            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
            testcase( pDef->funcFlags & OPFLAG_LENGTHARG );
            pFarg->a[0].pExpr->op2 = 
                  pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);
          }
        }

        sqlite3ExprCachePush(pParse);     /* Ticket 2ea2425d34be */
        sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,
                                SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);
        sqlite3ExprCachePop(pParse);      /* Ticket 2ea2425d34be */
      }else{
        r1 = 0;
      }
#ifndef SQLITE_OMIT_VIRTUALTABLE
      /* Possibly overload the function if the first argument is
      ** a virtual table column.
      **







<


<







99344
99345
99346
99347
99348
99349
99350

99351
99352

99353
99354
99355
99356
99357
99358
99359
            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
            testcase( pDef->funcFlags & OPFLAG_LENGTHARG );
            pFarg->a[0].pExpr->op2 = 
                  pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);
          }
        }


        sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,
                                SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);

      }else{
        r1 = 0;
      }
#ifndef SQLITE_OMIT_VIRTUALTABLE
      /* Possibly overload the function if the first argument is
      ** a virtual table column.
      **
99662
99663
99664
99665
99666
99667
99668
99669
99670
99671
99672
99673
99674
99675
99676
99677
99678
      sqlite3ErrorMsg(pParse, "row value misused");
      break;
    }

    case TK_IF_NULL_ROW: {
      int addrINR;
      addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
      sqlite3ExprCachePush(pParse);
      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
      sqlite3ExprCachePop(pParse);
      sqlite3VdbeJumpHere(v, addrINR);
      sqlite3VdbeChangeP3(v, addrINR, inReg);
      break;
    }

    /*
    ** Form A:







<

<







99518
99519
99520
99521
99522
99523
99524

99525

99526
99527
99528
99529
99530
99531
99532
      sqlite3ErrorMsg(pParse, "row value misused");
      break;
    }

    case TK_IF_NULL_ROW: {
      int addrINR;
      addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);

      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);

      sqlite3VdbeJumpHere(v, addrINR);
      sqlite3VdbeChangeP3(v, addrINR, inReg);
      break;
    }

    /*
    ** Form A:
99701
99702
99703
99704
99705
99706
99707
99708
99709
99710
99711
99712
99713
99714
99715
      int nExpr;                        /* 2x number of WHEN terms */
      int i;                            /* Loop counter */
      ExprList *pEList;                 /* List of WHEN terms */
      struct ExprList_item *aListelem;  /* Array of WHEN terms */
      Expr opCompare;                   /* The X==Ei expression */
      Expr *pX;                         /* The X expression */
      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */
      VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )

      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
      assert(pExpr->x.pList->nExpr > 0);
      pEList = pExpr->x.pList;
      aListelem = pEList->a;
      nExpr = pEList->nExpr;
      endLabel = sqlite3VdbeMakeLabel(v);







<







99555
99556
99557
99558
99559
99560
99561

99562
99563
99564
99565
99566
99567
99568
      int nExpr;                        /* 2x number of WHEN terms */
      int i;                            /* Loop counter */
      ExprList *pEList;                 /* List of WHEN terms */
      struct ExprList_item *aListelem;  /* Array of WHEN terms */
      Expr opCompare;                   /* The X==Ei expression */
      Expr *pX;                         /* The X expression */
      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */


      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
      assert(pExpr->x.pList->nExpr > 0);
      pEList = pExpr->x.pList;
      aListelem = pEList->a;
      nExpr = pEList->nExpr;
      endLabel = sqlite3VdbeMakeLabel(v);
99725
99726
99727
99728
99729
99730
99731
99732
99733
99734
99735
99736
99737
99738
99739
99740
99741
99742
99743
99744
99745
99746
99747
99748
99749
99750
99751
99752
99753
99754
99755
99756
99757
99758
99759
99760
99761
99762
99763
        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
        ** The value in regFree1 might get SCopy-ed into the file result.
        ** So make sure that the regFree1 register is not reused for other
        ** purposes and possibly overwritten.  */
        regFree1 = 0;
      }
      for(i=0; i<nExpr-1; i=i+2){
        sqlite3ExprCachePush(pParse);
        if( pX ){
          assert( pTest!=0 );
          opCompare.pRight = aListelem[i].pExpr;
        }else{
          pTest = aListelem[i].pExpr;
        }
        nextCase = sqlite3VdbeMakeLabel(v);
        testcase( pTest->op==TK_COLUMN );
        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
        sqlite3VdbeGoto(v, endLabel);
        sqlite3ExprCachePop(pParse);
        sqlite3VdbeResolveLabel(v, nextCase);
      }
      if( (nExpr&1)!=0 ){
        sqlite3ExprCachePush(pParse);
        sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
        sqlite3ExprCachePop(pParse);
      }else{
        sqlite3VdbeAddOp2(v, OP_Null, 0, target);
      }
      assert( pParse->db->mallocFailed || pParse->nErr>0 
           || pParse->iCacheLevel==iCacheLevel );
      sqlite3VdbeResolveLabel(v, endLabel);
      break;
    }
#ifndef SQLITE_OMIT_TRIGGER
    case TK_RAISE: {
      assert( pExpr->affinity==OE_Rollback 
           || pExpr->affinity==OE_Abort







<












<



<

<



<
<







99578
99579
99580
99581
99582
99583
99584

99585
99586
99587
99588
99589
99590
99591
99592
99593
99594
99595
99596

99597
99598
99599

99600

99601
99602
99603


99604
99605
99606
99607
99608
99609
99610
        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
        ** The value in regFree1 might get SCopy-ed into the file result.
        ** So make sure that the regFree1 register is not reused for other
        ** purposes and possibly overwritten.  */
        regFree1 = 0;
      }
      for(i=0; i<nExpr-1; i=i+2){

        if( pX ){
          assert( pTest!=0 );
          opCompare.pRight = aListelem[i].pExpr;
        }else{
          pTest = aListelem[i].pExpr;
        }
        nextCase = sqlite3VdbeMakeLabel(v);
        testcase( pTest->op==TK_COLUMN );
        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
        sqlite3VdbeGoto(v, endLabel);

        sqlite3VdbeResolveLabel(v, nextCase);
      }
      if( (nExpr&1)!=0 ){

        sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);

      }else{
        sqlite3VdbeAddOp2(v, OP_Null, 0, target);
      }


      sqlite3VdbeResolveLabel(v, endLabel);
      break;
    }
#ifndef SQLITE_OMIT_TRIGGER
    case TK_RAISE: {
      assert( pExpr->affinity==OE_Rollback 
           || pExpr->affinity==OE_Abort
99899
99900
99901
99902
99903
99904
99905
99906
99907
99908
99909
99910
99911
99912
99913
/*
** Generate code that will evaluate expression pExpr and store the
** results in register target.  The results are guaranteed to appear
** in register target.  If the expression is constant, then this routine
** might choose to code the expression at initialization time.
*/
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
  if( pParse->okConstFactor && sqlite3ExprIsConstant(pExpr) ){
    sqlite3ExprCodeAtInit(pParse, pExpr, target);
  }else{
    sqlite3ExprCode(pParse, pExpr, target);
  }
}

/*







|







99746
99747
99748
99749
99750
99751
99752
99753
99754
99755
99756
99757
99758
99759
99760
/*
** Generate code that will evaluate expression pExpr and store the
** results in register target.  The results are guaranteed to appear
** in register target.  If the expression is constant, then this routine
** might choose to code the expression at initialization time.
*/
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
  if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){
    sqlite3ExprCodeAtInit(pParse, pExpr, target);
  }else{
    sqlite3ExprCode(pParse, pExpr, target);
  }
}

/*
99981
99982
99983
99984
99985
99986
99987
99988


99989
99990
99991
99992
99993
99994
99995
    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){
      if( flags & SQLITE_ECEL_OMITREF ){
        i--;
        n--;
      }else{
        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
      }
    }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){


      sqlite3ExprCodeAtInit(pParse, pExpr, target+i);
    }else{
      int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
      if( inReg!=target+i ){
        VdbeOp *pOp;
        if( copyOp==OP_Copy
         && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy







|
>
>







99828
99829
99830
99831
99832
99833
99834
99835
99836
99837
99838
99839
99840
99841
99842
99843
99844
    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){
      if( flags & SQLITE_ECEL_OMITREF ){
        i--;
        n--;
      }else{
        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
      }
    }else if( (flags & SQLITE_ECEL_FACTOR)!=0
           && sqlite3ExprIsConstantNotJoin(pExpr)
    ){
      sqlite3ExprCodeAtInit(pParse, pExpr, target+i);
    }else{
      int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
      if( inReg!=target+i ){
        VdbeOp *pOp;
        if( copyOp==OP_Copy
         && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy
100107
100108
100109
100110
100111
100112
100113
100114
100115
100116
100117
100118
100119
100120
100121
100122
100123
100124
100125
100126
100127
100128
100129
100130
100131
100132
  if( NEVER(pExpr==0) ) return;  /* No way this can happen */
  op = pExpr->op;
  switch( op ){
    case TK_AND: {
      int d2 = sqlite3VdbeMakeLabel(v);
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
      sqlite3ExprCachePush(pParse);
      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3VdbeResolveLabel(v, d2);
      sqlite3ExprCachePop(pParse);
      break;
    }
    case TK_OR: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
      sqlite3ExprCachePush(pParse);
      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3ExprCachePop(pParse);
      break;
    }
    case TK_NOT: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
      break;
    }







<


<





<

<







99956
99957
99958
99959
99960
99961
99962

99963
99964

99965
99966
99967
99968
99969

99970

99971
99972
99973
99974
99975
99976
99977
  if( NEVER(pExpr==0) ) return;  /* No way this can happen */
  op = pExpr->op;
  switch( op ){
    case TK_AND: {
      int d2 = sqlite3VdbeMakeLabel(v);
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);

      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3VdbeResolveLabel(v, d2);

      break;
    }
    case TK_OR: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);

      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);

      break;
    }
    case TK_NOT: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
      break;
    }
100277
100278
100279
100280
100281
100282
100283
100284
100285
100286
100287
100288
100289
100290
100291
100292
100293
100294
100295
100296
100297
100298
100299
100300
100301
100302
100303
  assert( pExpr->op!=TK_GT || op==OP_Le );
  assert( pExpr->op!=TK_GE || op==OP_Lt );

  switch( pExpr->op ){
    case TK_AND: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
      sqlite3ExprCachePush(pParse);
      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3ExprCachePop(pParse);
      break;
    }
    case TK_OR: {
      int d2 = sqlite3VdbeMakeLabel(v);
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
      sqlite3ExprCachePush(pParse);
      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3VdbeResolveLabel(v, d2);
      sqlite3ExprCachePop(pParse);
      break;
    }
    case TK_NOT: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
      break;
    }







<

<






<


<







100122
100123
100124
100125
100126
100127
100128

100129

100130
100131
100132
100133
100134
100135

100136
100137

100138
100139
100140
100141
100142
100143
100144
  assert( pExpr->op!=TK_GT || op==OP_Le );
  assert( pExpr->op!=TK_GE || op==OP_Lt );

  switch( pExpr->op ){
    case TK_AND: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);

      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);

      break;
    }
    case TK_OR: {
      int d2 = sqlite3VdbeMakeLabel(v);
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);

      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
      sqlite3VdbeResolveLabel(v, d2);

      break;
    }
    case TK_NOT: {
      testcase( jumpIfNull==0 );
      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
      break;
    }
100511
100512
100513
100514
100515
100516
100517

100518
100519
100520
100521
100522
100523
100524
100525
    }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
      return 2;
    }
  }
  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
    if( combinedFlags & EP_xIsSelect ) return 2;

    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    assert( (combinedFlags & EP_Reduced)==0 );
    if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->iTable!=pB->iTable 
       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;







>
|







100352
100353
100354
100355
100356
100357
100358
100359
100360
100361
100362
100363
100364
100365
100366
100367
    }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
      return 2;
    }
  }
  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
    if( combinedFlags & EP_xIsSelect ) return 2;
    if( (combinedFlags & EP_FixedCol)==0
     && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    assert( (combinedFlags & EP_Reduced)==0 );
    if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->iTable!=pB->iTable 
       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
101056
101057
101058
101059
101060
101061
101062
101063
101064
101065
101066
101067
101068
101069
101070
101071
101072
101073
101074
101075
101076
101077
101078
101079
101080
101081
101082
101083
101084
101085
101086
101087
101088
101089
101090
101091
101092
101093
101094
101095
101096
101097
101098
101099
101100
101101
101102
101103
101104
101105
101106
101107
101108
101109
101110
101111
101112
  }
  return pParse->aTempReg[--pParse->nTempReg];
}

/*
** Deallocate a register, making available for reuse for some other
** purpose.
**
** If a register is currently being used by the column cache, then
** the deallocation is deferred until the column cache line that uses
** the register becomes stale.
*/
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){
    int i;
    struct yColCache *p;
    for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){
      if( p->iReg==iReg ){
        p->tempReg = 1;
        return;
      }
    }
    pParse->aTempReg[pParse->nTempReg++] = iReg;
  }
}

/*
** Allocate or deallocate a block of nReg consecutive registers.
*/
SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
  int i, n;
  if( nReg==1 ) return sqlite3GetTempReg(pParse);
  i = pParse->iRangeReg;
  n = pParse->nRangeReg;
  if( nReg<=n ){
    assert( !usedAsColumnCache(pParse, i, i+n-1) );
    pParse->iRangeReg += nReg;
    pParse->nRangeReg -= nReg;
  }else{
    i = pParse->nMem+1;
    pParse->nMem += nReg;
  }
  return i;
}
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
  if( nReg==1 ){
    sqlite3ReleaseTempReg(pParse, iReg);
    return;
  }
  sqlite3ExprCacheRemove(pParse, iReg, nReg);
  if( nReg>pParse->nRangeReg ){
    pParse->nRangeReg = nReg;
    pParse->iRangeReg = iReg;
  }
}

/*







<
<
<
<



<
<
<
<
<
<
<
<













<













<







100898
100899
100900
100901
100902
100903
100904




100905
100906
100907








100908
100909
100910
100911
100912
100913
100914
100915
100916
100917
100918
100919
100920

100921
100922
100923
100924
100925
100926
100927
100928
100929
100930
100931
100932
100933

100934
100935
100936
100937
100938
100939
100940
  }
  return pParse->aTempReg[--pParse->nTempReg];
}

/*
** Deallocate a register, making available for reuse for some other
** purpose.




*/
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){








    pParse->aTempReg[pParse->nTempReg++] = iReg;
  }
}

/*
** Allocate or deallocate a block of nReg consecutive registers.
*/
SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
  int i, n;
  if( nReg==1 ) return sqlite3GetTempReg(pParse);
  i = pParse->iRangeReg;
  n = pParse->nRangeReg;
  if( nReg<=n ){

    pParse->iRangeReg += nReg;
    pParse->nRangeReg -= nReg;
  }else{
    i = pParse->nMem+1;
    pParse->nMem += nReg;
  }
  return i;
}
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
  if( nReg==1 ){
    sqlite3ReleaseTempReg(pParse, iReg);
    return;
  }

  if( nReg>pParse->nRangeReg ){
    pParse->nRangeReg = nReg;
    pParse->iRangeReg = iReg;
  }
}

/*
105018
105019
105020
105021
105022
105023
105024
105025
105026
105027
105028
105029
105030
105031
105032
    }
  }


  /* Get the VDBE program ready for execution
  */
  if( v && pParse->nErr==0 && !db->mallocFailed ){
    assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */
    /* A minimum of one cursor is required if autoincrement is used
    *  See ticket [a696379c1f08866] */
    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
    sqlite3VdbeMakeReady(v, pParse);
    pParse->rc = SQLITE_DONE;
  }else{
    pParse->rc = SQLITE_ERROR;







<







104846
104847
104848
104849
104850
104851
104852

104853
104854
104855
104856
104857
104858
104859
    }
  }


  /* Get the VDBE program ready for execution
  */
  if( v && pParse->nErr==0 && !db->mallocFailed ){

    /* A minimum of one cursor is required if autoincrement is used
    *  See ticket [a696379c1f08866] */
    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
    sqlite3VdbeMakeReady(v, pParse);
    pParse->rc = SQLITE_DONE;
  }else{
    pParse->rc = SQLITE_ERROR;
107455
107456
107457
107458
107459
107460
107461

107462
107463

107464
107465
107466
107467
107468
107469
107470

  /* Generate code to remove the table from the master table
  ** on disk.
  */
  v = sqlite3GetVdbe(pParse);
  if( v ){
    sqlite3BeginWriteOperation(pParse, 1, iDb);

    sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName);
    sqlite3FkDropTable(pParse, pName, pTab);

    sqlite3CodeDropTable(pParse, pTab, iDb, isView);
  }

exit_drop_table:
  sqlite3SrcListDelete(db, pName);
}








>
|
|
>







107282
107283
107284
107285
107286
107287
107288
107289
107290
107291
107292
107293
107294
107295
107296
107297
107298
107299

  /* Generate code to remove the table from the master table
  ** on disk.
  */
  v = sqlite3GetVdbe(pParse);
  if( v ){
    sqlite3BeginWriteOperation(pParse, 1, iDb);
    if( !isView ){
      sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName);
      sqlite3FkDropTable(pParse, pName, pTab);
    }
    sqlite3CodeDropTable(pParse, pTab, iDb, isView);
  }

exit_drop_table:
  sqlite3SrcListDelete(db, pName);
}

110277
110278
110279
110280
110281
110282
110283
110284
110285
110286
110287
110288
110289
110290
110291
110292
110293
      for(i=0; i<nPk; i++){
        assert( pPk->aiColumn[i]>=0 );
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,
                                        pPk->aiColumn[i], iPk+i);
      }
      iKey = iPk;
    }else{
      iKey = pParse->nMem + 1;
      iKey = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iTabCur, iKey, 0);
      if( iKey>pParse->nMem ) pParse->nMem = iKey;
    }
  
    if( eOnePass!=ONEPASS_OFF ){
      /* For ONEPASS, no need to store the rowid/primary-key. There is only
      ** one, so just keep it in its register(s) and fall through to the
      ** delete code.  */
      nKey = nPk; /* OP_Found will use an unpacked key */







|
|
<







110106
110107
110108
110109
110110
110111
110112
110113
110114

110115
110116
110117
110118
110119
110120
110121
      for(i=0; i<nPk; i++){
        assert( pPk->aiColumn[i]>=0 );
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,
                                        pPk->aiColumn[i], iPk+i);
      }
      iKey = iPk;
    }else{
      iKey = ++pParse->nMem;
      sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, -1, iKey);

    }
  
    if( eOnePass!=ONEPASS_OFF ){
      /* For ONEPASS, no need to store the rowid/primary-key. There is only
      ** one, so just keep it in its register(s) and fall through to the
      ** delete code.  */
      nKey = nPk; /* OP_Found will use an unpacked key */
110712
110713
110714
110715
110716
110717
110718
110719
110720
110721
110722
110723
110724
110725
110726
  int regBase;
  int nCol;

  if( piPartIdxLabel ){
    if( pIdx->pPartIdxWhere ){
      *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
      pParse->iSelfTab = iDataCur + 1;
      sqlite3ExprCachePush(pParse);
      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, 
                            SQLITE_JUMPIFNULL);
      pParse->iSelfTab = 0;
    }else{
      *piPartIdxLabel = 0;
    }
  }







<







110540
110541
110542
110543
110544
110545
110546

110547
110548
110549
110550
110551
110552
110553
  int regBase;
  int nCol;

  if( piPartIdxLabel ){
    if( pIdx->pPartIdxWhere ){
      *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
      pParse->iSelfTab = iDataCur + 1;

      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, 
                            SQLITE_JUMPIFNULL);
      pParse->iSelfTab = 0;
    }else{
      *piPartIdxLabel = 0;
    }
  }
110759
110760
110761
110762
110763
110764
110765
110766
110767
110768
110769
110770
110771
110772
110773
** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label
** because it was a partial index, then this routine should be called to
** resolve that label.
*/
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){
  if( iLabel ){
    sqlite3VdbeResolveLabel(pParse->pVdbe, iLabel);
    sqlite3ExprCachePop(pParse);
  }
}

/************** End of delete.c **********************************************/
/************** Begin file func.c ********************************************/
/*
** 2002 February 23







<







110586
110587
110588
110589
110590
110591
110592

110593
110594
110595
110596
110597
110598
110599
** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label
** because it was a partial index, then this routine should be called to
** resolve that label.
*/
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){
  if( iLabel ){
    sqlite3VdbeResolveLabel(pParse->pVdbe, iLabel);

  }
}

/************** End of delete.c **********************************************/
/************** Begin file func.c ********************************************/
/*
** 2002 February 23
113498
113499
113500
113501
113502
113503
113504
113505
113506
113507
113508
113509

113510
113511
113512
113513
113514
113515
113516
**
** then the equivalent of "DELETE FROM <tbl>" is executed before dropping
** the table from the database. Triggers are disabled while running this
** DELETE, but foreign key actions are not.
*/
SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
  sqlite3 *db = pParse->db;
  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){
    int iSkip = 0;
    Vdbe *v = sqlite3GetVdbe(pParse);

    assert( v );                  /* VDBE has already been allocated */

    if( sqlite3FkReferences(pTab)==0 ){
      /* Search for a deferred foreign key constraint for which this table
      ** is the child table. If one cannot be found, return without 
      ** generating any VDBE code. If one can be found, then jump over
      ** the entire DELETE if there are no outstanding deferred constraints
      ** when this statement is run.  */
      FKey *p;







|




>







113324
113325
113326
113327
113328
113329
113330
113331
113332
113333
113334
113335
113336
113337
113338
113339
113340
113341
113342
113343
**
** then the equivalent of "DELETE FROM <tbl>" is executed before dropping
** the table from the database. Triggers are disabled while running this
** DELETE, but foreign key actions are not.
*/
SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
  sqlite3 *db = pParse->db;
  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) ){
    int iSkip = 0;
    Vdbe *v = sqlite3GetVdbe(pParse);

    assert( v );                  /* VDBE has already been allocated */
    assert( pTab->pSelect==0 );   /* Not a view */
    if( sqlite3FkReferences(pTab)==0 ){
      /* Search for a deferred foreign key constraint for which this table
      ** is the child table. If one cannot be found, return without 
      ** generating any VDBE code. If one can be found, then jump over
      ** the entire DELETE if there are no outstanding deferred constraints
      ** when this statement is run.  */
      FKey *p;
115397
115398
115399
115400
115401
115402
115403
115404
115405
115406
115407
115408
115409
115410
115411
115412
115413
115414
115415
115416
115417
115418
115419
115420
115421
115422
115423
115424
115425
115426
115427
115428
115429
115430
115431
115432
115433
115434
115435
115436
115437
115438
115439
115440
115441
115442
115443
115444
115445
115446
115447
115448
  testcase( w.eCode==0 );
  testcase( w.eCode==CKCNSTRNT_COLUMN );
  testcase( w.eCode==CKCNSTRNT_ROWID );
  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
  return !w.eCode;
}

/*
** An instance of the ConstraintAddr object remembers the byte-code addresses
** for sections of the constraint checks that deal with uniqueness constraints
** on the rowid and on the upsert constraint.
**
** This information is passed into checkReorderConstraintChecks() to insert
** some OP_Goto operations so that the rowid and upsert constraints occur
** in the correct order relative to other constraints.
*/
typedef struct ConstraintAddr ConstraintAddr;
struct ConstraintAddr {
  int ipkTop;          /* Subroutine for rowid constraint check */
  int upsertTop;       /* Label for upsert constraint check subroutine */
  int upsertTop2;      /* Copy of upsertTop not cleared by the call */
  int upsertBtm;       /* upsert constraint returns to this label */
  int ipkBtm;          /* Return opcode rowid constraint check */
};

/*
** Generate any OP_Goto operations needed to cause constraints to be
** run that haven't already been run.
*/
static void reorderConstraintChecks(Vdbe *v, ConstraintAddr *p){
  if( p->upsertTop ){
    testcase( sqlite3VdbeLabelHasBeenResolved(v, p->upsertTop) );
    sqlite3VdbeGoto(v, p->upsertTop);
    VdbeComment((v, "call upsert subroutine"));
    sqlite3VdbeResolveLabel(v, p->upsertBtm);
    p->upsertTop = 0;
  }
  if( p->ipkTop ){
    sqlite3VdbeGoto(v, p->ipkTop);
    VdbeComment((v, "call rowid unique-check subroutine"));
    sqlite3VdbeJumpHere(v, p->ipkBtm);
    p->ipkTop = 0;
  }
}

/*
** Generate code to do constraint checks prior to an INSERT or an UPDATE
** on table pTab.
**
** The regNewData parameter is the first register in a range that contains
** the data to be inserted or the data after the update.  There will be
** pTab->nCol+1 registers in this range.  The first register (the one







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







115224
115225
115226
115227
115228
115229
115230






































115231
115232
115233
115234
115235
115236
115237
  testcase( w.eCode==0 );
  testcase( w.eCode==CKCNSTRNT_COLUMN );
  testcase( w.eCode==CKCNSTRNT_ROWID );
  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
  return !w.eCode;
}







































/*
** Generate code to do constraint checks prior to an INSERT or an UPDATE
** on table pTab.
**
** The regNewData parameter is the first register in a range that contains
** the data to be inserted or the data after the update.  There will be
** pTab->nCol+1 registers in this range.  The first register (the one
115544
115545
115546
115547
115548
115549
115550
115551
115552
115553
115554
115555



115556
115557
115558
115559
115560
115561
115562
115563
115564
115565
115566
115567
115568
115569
115570
  int i;               /* loop counter */
  int ix;              /* Index loop counter */
  int nCol;            /* Number of columns */
  int onError;         /* Conflict resolution strategy */
  int addr1;           /* Address of jump instruction */
  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
  ConstraintAddr sAddr;/* Address information for constraint reordering */
  Index *pUpIdx = 0;   /* Index to which to apply the upsert */
  u8 isUpdate;         /* True if this is an UPDATE operation */
  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
  int upsertBypass = 0;  /* Address of Goto to bypass upsert subroutine */




  isUpdate = regOldData!=0;
  db = pParse->db;
  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  nCol = pTab->nCol;
  memset(&sAddr, 0, sizeof(sAddr));
  
  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
  ** normal rowid tables.  nPkField is the number of key fields in the 
  ** pPk index or 1 for a rowid table.  In other words, nPkField is the
  ** number of fields in the true primary key of the table. */
  if( HasRowid(pTab) ){
    pPk = 0;







<




>
>
>







<







115333
115334
115335
115336
115337
115338
115339

115340
115341
115342
115343
115344
115345
115346
115347
115348
115349
115350
115351
115352
115353

115354
115355
115356
115357
115358
115359
115360
  int i;               /* loop counter */
  int ix;              /* Index loop counter */
  int nCol;            /* Number of columns */
  int onError;         /* Conflict resolution strategy */
  int addr1;           /* Address of jump instruction */
  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */

  Index *pUpIdx = 0;   /* Index to which to apply the upsert */
  u8 isUpdate;         /* True if this is an UPDATE operation */
  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
  int upsertBypass = 0;  /* Address of Goto to bypass upsert subroutine */
  int upsertJump = 0;    /* Address of Goto that jumps into upsert subroutine */
  int ipkTop = 0;        /* Top of the IPK uniqueness check */
  int ipkBottom = 0;     /* OP_Goto at the end of the IPK uniqueness check */

  isUpdate = regOldData!=0;
  db = pParse->db;
  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  nCol = pTab->nCol;

  
  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
  ** normal rowid tables.  nPkField is the number of key fields in the 
  ** pPk index or 1 for a rowid table.  In other words, nPkField is the
  ** number of fields in the true primary key of the table. */
  if( HasRowid(pTab) ){
    pPk = 0;
115660
115661
115662
115663
115664
115665
115666
115667
115668
115669
115670
115671
115672
115673
115674
115675





115676
115677
115678
115679
115680
115681
115682
115683
115684
115685
115686
115687
115688
115689
115690
115691
115692
115693
115694
115695
115696
115697
115698
115699
115700

115701
115702
115703
115704
115705
115706
115707
    pParse->iSelfTab = 0;
  }
#endif /* !defined(SQLITE_OMIT_CHECK) */

  /* UNIQUE and PRIMARY KEY constraints should be handled in the following
  ** order:
  **
  **   (1)  OE_Abort, OE_Fail, OE_Rollback, OE_Ignore
  **   (2)  OE_Update
  **   (3)  OE_Replace
  **
  ** OE_Fail and OE_Ignore must happen before any changes are made.
  ** OE_Update guarantees that only a single row will change, so it
  ** must happen before OE_Replace.  Technically, OE_Abort and OE_Rollback
  ** could happen in any order, but they are grouped up front for
  ** convenience.





  **
  ** Constraint checking code is generated in this order:
  **   (A)  The rowid constraint
  **   (B)  Unique index constraints that do not have OE_Replace as their
  **        default conflict resolution strategy
  **   (C)  Unique index that do use OE_Replace by default.
  **
  ** The ordering of (2) and (3) is accomplished by making sure the linked
  ** list of indexes attached to a table puts all OE_Replace indexes last
  ** in the list.  See sqlite3CreateIndex() for where that happens.
  */

  if( pUpsert ){
    if( pUpsert->pUpsertTarget==0 ){
      /* An ON CONFLICT DO NOTHING clause, without a constraint-target.
      ** Make all unique constraint resolution be OE_Ignore */
      assert( pUpsert->pUpsertSet==0 );
      overrideError = OE_Ignore;
      pUpsert = 0;
    }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
      /* If the constraint-target is on some column other than
      ** then ROWID, then we might need to move the UPSERT around
      ** so that it occurs in the correct order. */
      sAddr.upsertTop = sAddr.upsertTop2 = sqlite3VdbeMakeLabel(v);
      sAddr.upsertBtm = sqlite3VdbeMakeLabel(v);

    }
  }

  /* If rowid is changing, make sure the new rowid does not previously
  ** exist in the table.
  */
  if( pkChng && pPk==0 ){







|
|







>
>
>
>
>




















|
<
|
<
|
>







115450
115451
115452
115453
115454
115455
115456
115457
115458
115459
115460
115461
115462
115463
115464
115465
115466
115467
115468
115469
115470
115471
115472
115473
115474
115475
115476
115477
115478
115479
115480
115481
115482
115483
115484
115485
115486
115487
115488
115489
115490
115491

115492

115493
115494
115495
115496
115497
115498
115499
115500
115501
    pParse->iSelfTab = 0;
  }
#endif /* !defined(SQLITE_OMIT_CHECK) */

  /* UNIQUE and PRIMARY KEY constraints should be handled in the following
  ** order:
  **
  **   (1)  OE_Update
  **   (2)  OE_Abort, OE_Fail, OE_Rollback, OE_Ignore
  **   (3)  OE_Replace
  **
  ** OE_Fail and OE_Ignore must happen before any changes are made.
  ** OE_Update guarantees that only a single row will change, so it
  ** must happen before OE_Replace.  Technically, OE_Abort and OE_Rollback
  ** could happen in any order, but they are grouped up front for
  ** convenience.
  **
  ** 2018-08-14: Ticket https://www.sqlite.org/src/info/908f001483982c43
  ** The order of constraints used to have OE_Update as (2) and OE_Abort
  ** and so forth as (1). But apparently PostgreSQL checks the OE_Update
  ** constraint before any others, so it had to be moved.
  **
  ** Constraint checking code is generated in this order:
  **   (A)  The rowid constraint
  **   (B)  Unique index constraints that do not have OE_Replace as their
  **        default conflict resolution strategy
  **   (C)  Unique index that do use OE_Replace by default.
  **
  ** The ordering of (2) and (3) is accomplished by making sure the linked
  ** list of indexes attached to a table puts all OE_Replace indexes last
  ** in the list.  See sqlite3CreateIndex() for where that happens.
  */

  if( pUpsert ){
    if( pUpsert->pUpsertTarget==0 ){
      /* An ON CONFLICT DO NOTHING clause, without a constraint-target.
      ** Make all unique constraint resolution be OE_Ignore */
      assert( pUpsert->pUpsertSet==0 );
      overrideError = OE_Ignore;
      pUpsert = 0;
    }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
      /* If the constraint-target uniqueness check must be run first.

      ** Jump to that uniqueness check now */

      upsertJump = sqlite3VdbeAddOp0(v, OP_Goto);
      VdbeComment((v, "UPSERT constraint goes first"));
    }
  }

  /* If rowid is changing, make sure the new rowid does not previously
  ** exist in the table.
  */
  if( pkChng && pPk==0 ){
115725
115726
115727
115728
115729
115730
115731
115732
115733
115734
115735
115736
115737
115738
115739
115740
115741

115742
115743
115744
115745
115746
115747
115748
115749
115750
115751
115752
115753
115754
115755
115756
115757
115758
115759
115760
115761
115762
115763
115764
115765
115766
    }

    /* If the response to a rowid conflict is REPLACE but the response
    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
    ** to defer the running of the rowid conflict checking until after
    ** the UNIQUE constraints have run.
    */
    assert( OE_Update>OE_Replace );
    assert( OE_Ignore<OE_Replace );
    assert( OE_Fail<OE_Replace );
    assert( OE_Abort<OE_Replace );
    assert( OE_Rollback<OE_Replace );
    if( onError>=OE_Replace
     && (pUpsert || onError!=overrideError)
     && pTab->pIndex
    ){
      sAddr.ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;

    }

    if( isUpdate ){
      /* pkChng!=0 does not mean that the rowid has changed, only that
      ** it might have changed.  Skip the conflict logic below if the rowid
      ** is unchanged. */
      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
      VdbeCoverage(v);
    }

    /* Check to see if the new rowid already exists in the table.  Skip
    ** the following conflict logic if it does not. */
    VdbeNoopComment((v, "uniqueness check for ROWID"));
    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
    VdbeCoverage(v);
    sqlite3ExprCachePush(pParse);

    switch( onError ){
      default: {
        onError = OE_Abort;
        /* Fall thru into the next case */
      }
      case OE_Rollback:







<
<
<
<
<
|
|
|

|
>

















<







115519
115520
115521
115522
115523
115524
115525





115526
115527
115528
115529
115530
115531
115532
115533
115534
115535
115536
115537
115538
115539
115540
115541
115542
115543
115544
115545
115546
115547
115548

115549
115550
115551
115552
115553
115554
115555
    }

    /* If the response to a rowid conflict is REPLACE but the response
    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
    ** to defer the running of the rowid conflict checking until after
    ** the UNIQUE constraints have run.
    */





    if( onError==OE_Replace      /* IPK rule is REPLACE */
     && onError!=overrideError   /* Rules for other contraints are different */
     && pTab->pIndex             /* There exist other constraints */
    ){
      ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
      VdbeComment((v, "defer IPK REPLACE until last"));
    }

    if( isUpdate ){
      /* pkChng!=0 does not mean that the rowid has changed, only that
      ** it might have changed.  Skip the conflict logic below if the rowid
      ** is unchanged. */
      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
      VdbeCoverage(v);
    }

    /* Check to see if the new rowid already exists in the table.  Skip
    ** the following conflict logic if it does not. */
    VdbeNoopComment((v, "uniqueness check for ROWID"));
    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
    VdbeCoverage(v);


    switch( onError ){
      default: {
        onError = OE_Abort;
        /* Fall thru into the next case */
      }
      case OE_Rollback:
115829
115830
115831
115832
115833
115834
115835
115836
115837
115838
115839
115840
115841
115842
115843
115844
115845
115846
115847
115848
115849
115850
115851
115852
115853
115854
115855
115856
115857
115858
115859
115860
115861
115862
115863
115864
115865
115866
115867
115868




115869
115870
115871
115872
115873
115874
115875
#endif
      case OE_Ignore: {
        testcase( onError==OE_Ignore );
        sqlite3VdbeGoto(v, ignoreDest);
        break;
      }
    }
    sqlite3ExprCachePop(pParse);
    sqlite3VdbeResolveLabel(v, addrRowidOk);
    if( sAddr.ipkTop ){
      sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
      sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
    }
  }

  /* Test all UNIQUE constraints by creating entries for each UNIQUE
  ** index and making sure that duplicate entries do not already exist.
  ** Compute the revised record entries for indices as we go.
  **
  ** This loop also handles the case of the PRIMARY KEY index for a
  ** WITHOUT ROWID table.
  */
  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
    int regIdx;          /* Range of registers hold conent for pIdx */
    int regR;            /* Range of registers holding conflicting PK */
    int iThisCur;        /* Cursor for this UNIQUE index */
    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */

    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */
    if( bAffinityDone==0 ){
      sqlite3TableAffinity(v, pTab, regNewData+1);
      bAffinityDone = 1;
    }
    if( pUpIdx==pIdx ){
      addrUniqueOk = sAddr.upsertBtm;
      upsertBypass = sqlite3VdbeGoto(v, 0);
      VdbeComment((v, "Skip upsert subroutine"));
      sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
    }else{
      addrUniqueOk = sqlite3VdbeMakeLabel(v);




    }
    VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
    iThisCur = iIdxCur+ix;


    /* Skip partial indices for which the WHERE clause is not true */
    if( pIdx->pPartIdxWhere ){







<

|
|
|

















<
<
<
<

|


|


>
>
>
>







115618
115619
115620
115621
115622
115623
115624

115625
115626
115627
115628
115629
115630
115631
115632
115633
115634
115635
115636
115637
115638
115639
115640
115641
115642
115643
115644
115645




115646
115647
115648
115649
115650
115651
115652
115653
115654
115655
115656
115657
115658
115659
115660
115661
115662
115663
#endif
      case OE_Ignore: {
        testcase( onError==OE_Ignore );
        sqlite3VdbeGoto(v, ignoreDest);
        break;
      }
    }

    sqlite3VdbeResolveLabel(v, addrRowidOk);
    if( ipkTop ){
      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);
      sqlite3VdbeJumpHere(v, ipkTop-1);
    }
  }

  /* Test all UNIQUE constraints by creating entries for each UNIQUE
  ** index and making sure that duplicate entries do not already exist.
  ** Compute the revised record entries for indices as we go.
  **
  ** This loop also handles the case of the PRIMARY KEY index for a
  ** WITHOUT ROWID table.
  */
  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
    int regIdx;          /* Range of registers hold conent for pIdx */
    int regR;            /* Range of registers holding conflicting PK */
    int iThisCur;        /* Cursor for this UNIQUE index */
    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */

    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */




    if( pUpIdx==pIdx ){
      addrUniqueOk = upsertJump+1;
      upsertBypass = sqlite3VdbeGoto(v, 0);
      VdbeComment((v, "Skip upsert subroutine"));
      sqlite3VdbeJumpHere(v, upsertJump);
    }else{
      addrUniqueOk = sqlite3VdbeMakeLabel(v);
    }
    if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
      sqlite3TableAffinity(v, pTab, regNewData+1);
      bAffinityDone = 1;
    }
    VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
    iThisCur = iIdxCur+ix;


    /* Skip partial indices for which the WHERE clause is not true */
    if( pIdx->pPartIdxWhere ){
115934
115935
115936
115937
115938
115939
115940
115941
115942
115943
115944
115945
115946
115947
115948
115949
115950
115951
115952
115953
115954
115955
115956
115957
115958
115959
115960
115961
115962
115963
115964
115965
115966
115967
115968
115969
115970
115971
115972
115973
115974
115975
115976
115977
      if( pUpsert->pUpsertSet==0 ){
        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
      }else{
        onError = OE_Update;  /* DO UPDATE */
      }
    }

    /* Invoke subroutines to handle IPK replace and upsert prior to running
    ** the first REPLACE constraint check. */
    if( onError==OE_Replace ){
      testcase( sAddr.ipkTop );
      testcase( sAddr.upsertTop
             && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
      reorderConstraintChecks(v, &sAddr);
    }

    /* Collision detection may be omitted if all of the following are true:
    **   (1) The conflict resolution algorithm is REPLACE
    **   (2) The table is a WITHOUT ROWID table
    **   (3) There are no secondary indexes on the table
    **   (4) No delete triggers need to be fired if there is a conflict
    **   (5) No FK constraint counters need to be updated if a conflict occurs.
    */ 
    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */
     && pPk==pIdx                                   /* Condition 2 */
     && onError==OE_Replace                         /* Condition 1 */
     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */
          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
     && ( 0==(db->flags&SQLITE_ForeignKeys) ||      /* Condition 5 */
         (0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))
    ){
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
      continue;
    }

    /* Check to see if the new index entry will be unique */
    sqlite3ExprCachePush(pParse);
    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);

    /* Generate code to handle collisions */
    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
    if( isUpdate || onError==OE_Replace ){







<
<
<
<
<
<
<
<
<




















<







115722
115723
115724
115725
115726
115727
115728









115729
115730
115731
115732
115733
115734
115735
115736
115737
115738
115739
115740
115741
115742
115743
115744
115745
115746
115747
115748

115749
115750
115751
115752
115753
115754
115755
      if( pUpsert->pUpsertSet==0 ){
        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
      }else{
        onError = OE_Update;  /* DO UPDATE */
      }
    }










    /* Collision detection may be omitted if all of the following are true:
    **   (1) The conflict resolution algorithm is REPLACE
    **   (2) The table is a WITHOUT ROWID table
    **   (3) There are no secondary indexes on the table
    **   (4) No delete triggers need to be fired if there is a conflict
    **   (5) No FK constraint counters need to be updated if a conflict occurs.
    */ 
    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */
     && pPk==pIdx                                   /* Condition 2 */
     && onError==OE_Replace                         /* Condition 1 */
     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */
          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
     && ( 0==(db->flags&SQLITE_ForeignKeys) ||      /* Condition 5 */
         (0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))
    ){
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
      continue;
    }

    /* Check to see if the new index entry will be unique */

    sqlite3VdbeVerifyAbortable(v, onError);
    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);

    /* Generate code to handle collisions */
    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
    if( isUpdate || onError==OE_Replace ){
116065
116066
116067
116068
116069
116070
116071

116072
116073
116074
116075
116076
116077
116078
116079

116080
116081
116082

116083
116084

116085
116086
116087
116088
116089
116090
116091
            regR, nPkField, 0, OE_Replace,
            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
        seenReplace = 1;
        break;
      }
    }
    if( pUpIdx==pIdx ){

      sqlite3VdbeJumpHere(v, upsertBypass);
    }else{
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
    }
    sqlite3ExprCachePop(pParse);
    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);

  }

  testcase( sAddr.ipkTop!=0 );
  testcase( sAddr.upsertTop
         && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );

  reorderConstraintChecks(v, &sAddr);
  

  *pbMayReplace = seenReplace;
  VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
}

#ifdef SQLITE_ENABLE_NULL_TRIM
/*
** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)







>




<

|
|
>
|
<
|
>
|
|
>







115843
115844
115845
115846
115847
115848
115849
115850
115851
115852
115853
115854

115855
115856
115857
115858
115859

115860
115861
115862
115863
115864
115865
115866
115867
115868
115869
115870
115871
            regR, nPkField, 0, OE_Replace,
            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
        seenReplace = 1;
        break;
      }
    }
    if( pUpIdx==pIdx ){
      sqlite3VdbeGoto(v, upsertJump+1);
      sqlite3VdbeJumpHere(v, upsertBypass);
    }else{
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
    }

    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
  }

  /* If the IPK constraint is a REPLACE, run it last */
  if( ipkTop ){

    sqlite3VdbeGoto(v, ipkTop+1);
    VdbeComment((v, "Do IPK REPLACE"));
    sqlite3VdbeJumpHere(v, ipkBottom);
  }

  *pbMayReplace = seenReplace;
  VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
}

#ifdef SQLITE_ENABLE_NULL_TRIM
/*
** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)
116173
116174
116175
116176
116177
116178
116179
116180
116181
116182
116183
116184
116185
116186
116187
  if( !HasRowid(pTab) ) return;
  regData = regNewData + 1;
  regRec = sqlite3GetTempReg(pParse);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
  sqlite3SetMakeRecordP5(v, pTab);
  if( !bAffinityDone ){
    sqlite3TableAffinity(v, pTab, 0);
    sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);
  }
  if( pParse->nested ){
    pik_flags = 0;
  }else{
    pik_flags = OPFLAG_NCHANGE;
    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);
  }







<







115953
115954
115955
115956
115957
115958
115959

115960
115961
115962
115963
115964
115965
115966
  if( !HasRowid(pTab) ) return;
  regData = regNewData + 1;
  regRec = sqlite3GetTempReg(pParse);
  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);
  sqlite3SetMakeRecordP5(v, pTab);
  if( !bAffinityDone ){
    sqlite3TableAffinity(v, pTab, 0);

  }
  if( pParse->nested ){
    pik_flags = 0;
  }else{
    pik_flags = OPFLAG_NCHANGE;
    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);
  }
120460
120461
120462
120463
120464
120465
120466
120467
120468
120469
120470
120471
120472
120473
120474
        Index *pPrior = 0;
        int loopTop;
        int iDataCur, iIdxCur;
        int r1 = -1;

        if( pTab->tnum<1 ) continue;  /* Skip VIEWs or VIRTUAL TABLEs */
        pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
        sqlite3ExprCacheClear(pParse);
        sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
                                   1, 0, &iDataCur, &iIdxCur);
        /* reg[7] counts the number of entries in the table.
        ** reg[8+i] counts the number of entries in the i-th index 
        */
        sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){







<







120239
120240
120241
120242
120243
120244
120245

120246
120247
120248
120249
120250
120251
120252
        Index *pPrior = 0;
        int loopTop;
        int iDataCur, iIdxCur;
        int r1 = -1;

        if( pTab->tnum<1 ) continue;  /* Skip VIEWs or VIRTUAL TABLEs */
        pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);

        sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
                                   1, 0, &iDataCur, &iIdxCur);
        /* reg[7] counts the number of entries in the table.
        ** reg[8+i] counts the number of entries in the i-th index 
        */
        sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
120503
120504
120505
120506
120507
120508
120509
120510
120511
120512
120513
120514
120515
120516
120517
120518
120519
120520
120521
120522
120523
120524
120525
120526
120527
120528
120529
120530
          ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
          if( db->mallocFailed==0 ){
            int addrCkFault = sqlite3VdbeMakeLabel(v);
            int addrCkOk = sqlite3VdbeMakeLabel(v);
            char *zErr;
            int k;
            pParse->iSelfTab = iDataCur + 1;
            sqlite3ExprCachePush(pParse);
            for(k=pCheck->nExpr-1; k>0; k--){
              sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
            }
            sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, 
                SQLITE_JUMPIFNULL);
            sqlite3VdbeResolveLabel(v, addrCkFault);
            pParse->iSelfTab = 0;
            zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
                pTab->zName);
            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
            integrityCheckResultRow(v);
            sqlite3VdbeResolveLabel(v, addrCkOk);
            sqlite3ExprCachePop(pParse);
          }
          sqlite3ExprListDelete(db, pCheck);
        }
        if( !isQuick ){ /* Omit the remaining tests for quick_check */
          /* Validate index entries for the current row */
          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
            int jmp2, jmp3, jmp4, jmp5;







<












<







120281
120282
120283
120284
120285
120286
120287

120288
120289
120290
120291
120292
120293
120294
120295
120296
120297
120298
120299

120300
120301
120302
120303
120304
120305
120306
          ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
          if( db->mallocFailed==0 ){
            int addrCkFault = sqlite3VdbeMakeLabel(v);
            int addrCkOk = sqlite3VdbeMakeLabel(v);
            char *zErr;
            int k;
            pParse->iSelfTab = iDataCur + 1;

            for(k=pCheck->nExpr-1; k>0; k--){
              sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
            }
            sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, 
                SQLITE_JUMPIFNULL);
            sqlite3VdbeResolveLabel(v, addrCkFault);
            pParse->iSelfTab = 0;
            zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
                pTab->zName);
            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
            integrityCheckResultRow(v);
            sqlite3VdbeResolveLabel(v, addrCkOk);

          }
          sqlite3ExprListDelete(db, pCheck);
        }
        if( !isQuick ){ /* Omit the remaining tests for quick_check */
          /* Validate index entries for the current row */
          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
            int jmp2, jmp3, jmp4, jmp5;
123461
123462
123463
123464
123465
123466
123467
123468
123469
123470
123471
123472
123473
123474
123475
        pushOntoSorter(
            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);
      }else{
        int r1 = sqlite3GetTempReg(pParse);
        assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );
        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, 
            r1, pDest->zAffSdst, nResultCol);
        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);
        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);
        sqlite3ReleaseTempReg(pParse, r1);
      }
      break;
    }

    /* If any row exist in the result set, record that fact and abort.







<







123237
123238
123239
123240
123241
123242
123243

123244
123245
123246
123247
123248
123249
123250
        pushOntoSorter(
            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);
      }else{
        int r1 = sqlite3GetTempReg(pParse);
        assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );
        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, 
            r1, pDest->zAffSdst, nResultCol);

        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);
        sqlite3ReleaseTempReg(pParse, r1);
      }
      break;
    }

    /* If any row exist in the result set, record that fact and abort.
123505
123506
123507
123508
123509
123510
123511
123512
123513
123514
123515
123516
123517
123518
123519
      if( pSort ){
        pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol,
                       nPrefixReg);
      }else if( eDest==SRT_Coroutine ){
        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
      }else{
        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);
        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);
      }
      break;
    }

#ifndef SQLITE_OMIT_CTE
    /* Write the results into a priority queue that is order according to
    ** pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an







<







123280
123281
123282
123283
123284
123285
123286

123287
123288
123289
123290
123291
123292
123293
      if( pSort ){
        pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol,
                       nPrefixReg);
      }else if( eDest==SRT_Coroutine ){
        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
      }else{
        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);

      }
      break;
    }

#ifndef SQLITE_OMIT_CTE
    /* Write the results into a priority queue that is order according to
    ** pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an
123862
123863
123864
123865
123866
123867
123868
123869
123870
123871
123872
123873
123874
123875
123876
123877
123878
123879
123880
123881
123882
123883
123884
123885
123886
123887
123888
123889
123890
123891
      break;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case SRT_Set: {
      assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );
      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,
                        pDest->zAffSdst, nColumn);
      sqlite3ExprCacheAffinityChange(pParse, regRow, nColumn);
      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, regRowid, regRow, nColumn);
      break;
    }
    case SRT_Mem: {
      /* The LIMIT clause will terminate the loop for us */
      break;
    }
#endif
    default: {
      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); 
      testcase( eDest==SRT_Output );
      testcase( eDest==SRT_Coroutine );
      if( eDest==SRT_Output ){
        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);
        sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn);
      }else{
        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
      }
      break;
    }
  }
  if( regRowid ){







<














<







123636
123637
123638
123639
123640
123641
123642

123643
123644
123645
123646
123647
123648
123649
123650
123651
123652
123653
123654
123655
123656

123657
123658
123659
123660
123661
123662
123663
      break;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case SRT_Set: {
      assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );
      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,
                        pDest->zAffSdst, nColumn);

      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, regRowid, regRow, nColumn);
      break;
    }
    case SRT_Mem: {
      /* The LIMIT clause will terminate the loop for us */
      break;
    }
#endif
    default: {
      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); 
      testcase( eDest==SRT_Output );
      testcase( eDest==SRT_Coroutine );
      if( eDest==SRT_Output ){
        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);

      }else{
        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
      }
      break;
    }
  }
  if( regRowid ){
124478
124479
124480
124481
124482
124483
124484
124485
124486
124487
124488
124489
124490
124491
124492

  /* 
  ** "LIMIT -1" always shows all rows.  There is some
  ** controversy about what the correct behavior should be.
  ** The current implementation interprets "LIMIT 0" to mean
  ** no rows.
  */
  sqlite3ExprCacheClear(pParse);
  if( pLimit ){
    assert( pLimit->op==TK_LIMIT );
    assert( pLimit->pLeft!=0 );
    p->iLimit = iLimit = ++pParse->nMem;
    v = sqlite3GetVdbe(pParse);
    assert( v!=0 );
    if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){







<







124250
124251
124252
124253
124254
124255
124256

124257
124258
124259
124260
124261
124262
124263

  /* 
  ** "LIMIT -1" always shows all rows.  There is some
  ** controversy about what the correct behavior should be.
  ** The current implementation interprets "LIMIT 0" to mean
  ** no rows.
  */

  if( pLimit ){
    assert( pLimit->op==TK_LIMIT );
    assert( pLimit->pLeft!=0 );
    p->iLimit = iLimit = ++pParse->nMem;
    v = sqlite3GetVdbe(pParse);
    assert( v!=0 );
    if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){
125264
125265
125266
125267
125268
125269
125270
125271
125272
125273
125274
125275
125276
125277
125278
    */
    case SRT_Set: {
      int r1;
      testcase( pIn->nSdst>1 );
      r1 = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, 
          r1, pDest->zAffSdst, pIn->nSdst);
      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1,
                           pIn->iSdst, pIn->nSdst);
      sqlite3ReleaseTempReg(pParse, r1);
      break;
    }

    /* If this is a scalar select that is part of an expression, then







<







125035
125036
125037
125038
125039
125040
125041

125042
125043
125044
125045
125046
125047
125048
    */
    case SRT_Set: {
      int r1;
      testcase( pIn->nSdst>1 );
      r1 = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, 
          r1, pDest->zAffSdst, pIn->nSdst);

      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1,
                           pIn->iSdst, pIn->nSdst);
      sqlite3ReleaseTempReg(pParse, r1);
      break;
    }

    /* If this is a scalar select that is part of an expression, then
125307
125308
125309
125310
125311
125312
125313
125314
125315
125316
125317
125318
125319
125320
125321
    ** For SRT_Output, results are stored in a sequence of registers.  
    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to
    ** return the next row of result.
    */
    default: {
      assert( pDest->eDest==SRT_Output );
      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);
      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
      break;
    }
  }

  /* Jump to the end of the loop if the LIMIT is reached.
  */
  if( p->iLimit ){







<







125077
125078
125079
125080
125081
125082
125083

125084
125085
125086
125087
125088
125089
125090
    ** For SRT_Output, results are stored in a sequence of registers.  
    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to
    ** return the next row of result.
    */
    default: {
      assert( pDest->eDest==SRT_Output );
      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);

      break;
    }
  }

  /* Jump to the end of the loop if the LIMIT is reached.
  */
  if( p->iLimit ){
125762
125763
125764
125765
125766
125767
125768
125769
125770
125771
125772
125773
125774
125775
125776
    if( pExpr->iColumn<0 ){
      pExpr->op = TK_NULL;
    }else{
      Expr *pNew;
      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;
      Expr ifNullRow;
      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );
      assert( pExpr->pLeft==0 && pExpr->pRight==0 );
      if( sqlite3ExprIsVector(pCopy) ){
        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);
      }else{
        sqlite3 *db = pSubst->pParse->db;
        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){
          memset(&ifNullRow, 0, sizeof(ifNullRow));
          ifNullRow.op = TK_IF_NULL_ROW;







|







125531
125532
125533
125534
125535
125536
125537
125538
125539
125540
125541
125542
125543
125544
125545
    if( pExpr->iColumn<0 ){
      pExpr->op = TK_NULL;
    }else{
      Expr *pNew;
      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;
      Expr ifNullRow;
      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );
      assert( pExpr->pRight==0 );
      if( sqlite3ExprIsVector(pCopy) ){
        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);
      }else{
        sqlite3 *db = pSubst->pParse->db;
        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){
          memset(&ifNullRow, 0, sizeof(ifNullRow));
          ifNullRow.op = TK_IF_NULL_ROW;
126386
126387
126388
126389
126390
126391
126392











126393






















































































































































126394
126395
126396
126397
126398
126399
126400
  }
#endif

  return 1;
}
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */




































































































































































#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
/*
** Make copies of relevant WHERE clause terms of the outer query into
** the WHERE clause of subquery.  Example:
**
**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10;







>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







126155
126156
126157
126158
126159
126160
126161
126162
126163
126164
126165
126166
126167
126168
126169
126170
126171
126172
126173
126174
126175
126176
126177
126178
126179
126180
126181
126182
126183
126184
126185
126186
126187
126188
126189
126190
126191
126192
126193
126194
126195
126196
126197
126198
126199
126200
126201
126202
126203
126204
126205
126206
126207
126208
126209
126210
126211
126212
126213
126214
126215
126216
126217
126218
126219
126220
126221
126222
126223
126224
126225
126226
126227
126228
126229
126230
126231
126232
126233
126234
126235
126236
126237
126238
126239
126240
126241
126242
126243
126244
126245
126246
126247
126248
126249
126250
126251
126252
126253
126254
126255
126256
126257
126258
126259
126260
126261
126262
126263
126264
126265
126266
126267
126268
126269
126270
126271
126272
126273
126274
126275
126276
126277
126278
126279
126280
126281
126282
126283
126284
126285
126286
126287
126288
126289
126290
126291
126292
126293
126294
126295
126296
126297
126298
126299
126300
126301
126302
126303
126304
126305
126306
126307
126308
126309
126310
126311
126312
126313
126314
126315
126316
126317
126318
126319
126320
126321
126322
126323
126324
126325
126326
126327
126328
126329
126330
  }
#endif

  return 1;
}
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */

/*
** A structure to keep track of all of the column values that fixed to
** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
*/
typedef struct WhereConst WhereConst;
struct WhereConst {
  Parse *pParse;   /* Parsing context */
  int nConst;      /* Number for COLUMN=CONSTANT terms */
  int nChng;       /* Number of times a constant is propagated */
  Expr **apExpr;   /* [i*2] is COLUMN and [i*2+1] is VALUE */
};

/*
** Add a new entry to the pConst object
*/
static void constInsert(
  WhereConst *pConst,
  Expr *pColumn,
  Expr *pValue
){

  pConst->nConst++;
  pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
                         pConst->nConst*2*sizeof(Expr*));
  if( pConst->apExpr==0 ){
    pConst->nConst = 0;
  }else{
    if( ExprHasProperty(pValue, EP_FixedCol) ) pValue = pValue->pLeft;
    pConst->apExpr[pConst->nConst*2-2] = pColumn;
    pConst->apExpr[pConst->nConst*2-1] = pValue;
  }
}

/*
** Find all terms of COLUMN=VALUE or VALUE=COLUMN in pExpr where VALUE
** is a constant expression and where the term must be true because it
** is part of the AND-connected terms of the expression.  For each term
** found, add it to the pConst structure.
*/
static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
  Expr *pRight, *pLeft;
  if( pExpr==0 ) return;
  if( ExprHasProperty(pExpr, EP_FromJoin) ) return;
  if( pExpr->op==TK_AND ){
    findConstInWhere(pConst, pExpr->pRight);
    findConstInWhere(pConst, pExpr->pLeft);
    return;
  }
  if( pExpr->op!=TK_EQ ) return;
  pRight = pExpr->pRight;
  pLeft = pExpr->pLeft;
  assert( pRight!=0 );
  assert( pLeft!=0 );
  if( pRight->op==TK_COLUMN
   && !ExprHasProperty(pRight, EP_FixedCol)
   && sqlite3ExprIsConstant(pLeft)
   && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
  ){
    constInsert(pConst, pRight, pLeft);
  }else
  if( pLeft->op==TK_COLUMN
   && !ExprHasProperty(pLeft, EP_FixedCol)
   && sqlite3ExprIsConstant(pRight)
   && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
  ){
    constInsert(pConst, pLeft, pRight);
  }
}

/*
** This is a Walker expression callback.  pExpr is a candidate expression
** to be replaced by a value.  If pExpr is equivalent to one of the
** columns named in pWalker->u.pConst, then overwrite it with its
** corresponding value.
*/
static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){
  int i;
  WhereConst *pConst;
  if( pExpr->op!=TK_COLUMN ) return WRC_Continue;
  if( ExprHasProperty(pExpr, EP_FixedCol) ) return WRC_Continue;
  pConst = pWalker->u.pConst;
  for(i=0; i<pConst->nConst; i++){
    Expr *pColumn = pConst->apExpr[i*2];
    if( pColumn==pExpr ) continue;
    if( pColumn->iTable!=pExpr->iTable ) continue;
    if( pColumn->iColumn!=pExpr->iColumn ) continue;
    /* A match is found.  Add the EP_FixedCol property */
    pConst->nChng++;
    ExprClearProperty(pExpr, EP_Leaf);
    ExprSetProperty(pExpr, EP_FixedCol);
    assert( pExpr->pLeft==0 );
    pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);
    break;
  }
  return WRC_Prune;
}

/*
** The WHERE-clause constant propagation optimization.
**
** If the WHERE clause contains terms of the form COLUMN=CONSTANT or
** CONSTANT=COLUMN that must be tree (in other words, if the terms top-level
** AND-connected terms that are not part of a ON clause from a LEFT JOIN)
** then throughout the query replace all other occurrences of COLUMN
** with CONSTANT within the WHERE clause.
**
** For example, the query:
**
**      SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=t1.a AND t3.c=t2.b
**
** Is transformed into
**
**      SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=39 AND t3.c=39
**
** Return true if any transformations where made and false if not.
**
** Implementation note:  Constant propagation is tricky due to affinity
** and collating sequence interactions.  Consider this example:
**
**    CREATE TABLE t1(a INT,b TEXT);
**    INSERT INTO t1 VALUES(123,'0123');
**    SELECT * FROM t1 WHERE a=123 AND b=a;
**    SELECT * FROM t1 WHERE a=123 AND b=123;
**
** The two SELECT statements above should return different answers.  b=a
** is alway true because the comparison uses numeric affinity, but b=123
** is false because it uses text affinity and '0123' is not the same as '123'.
** To work around this, the expression tree is not actually changed from
** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol
** and the "123" value is hung off of the pLeft pointer.  Code generator
** routines know to generate the constant "123" instead of looking up the
** column value.  Also, to avoid collation problems, this optimization is
** only attempted if the "a=123" term uses the default BINARY collation.
*/
static int propagateConstants(
  Parse *pParse,   /* The parsing context */
  Select *p        /* The query in which to propagate constants */
){
  WhereConst x;
  Walker w;
  int nChng = 0;
  x.pParse = pParse;
  do{
    x.nConst = 0;
    x.nChng = 0;
    x.apExpr = 0;
    findConstInWhere(&x, p->pWhere);
    if( x.nConst ){
      memset(&w, 0, sizeof(w));
      w.pParse = pParse;
      w.xExprCallback = propagateConstantExprRewrite;
      w.xSelectCallback = sqlite3SelectWalkNoop;
      w.xSelectCallback2 = 0;
      w.walkerDepth = 0;
      w.u.pConst = &x;
      sqlite3WalkExpr(&w, p->pWhere);
      sqlite3DbFree(x.pParse->db, x.apExpr);
      nChng += x.nChng;
    }
  }while( x.nChng );  
  return nChng;
}

#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
/*
** Make copies of relevant WHERE clause terms of the outer query into
** the WHERE clause of subquery.  Example:
**
**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10;
127487
127488
127489
127490
127491
127492
127493
127494
127495
127496
127497
127498
127499
127500
127501
127502
127503
127504
127505
127506
127507
127508
127509
127510
127511
127512
127513
127514
127515
127516
127517
127518
127519
127520
127521
127522
127523
127524
127525
127526
127527
127528
127529
127530
      }
      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
    }
    sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);
    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
    sqlite3VdbeChangeP5(v, (u8)nArg);
    sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
    if( addrNext ){
      sqlite3VdbeResolveLabel(v, addrNext);
      sqlite3ExprCacheClear(pParse);
    }
  }

  /* Before populating the accumulator registers, clear the column cache.
  ** Otherwise, if any of the required column values are already present 
  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value
  ** to pC->iMem. But by the time the value is used, the original register
  ** may have been used, invalidating the underlying buffer holding the
  ** text or blob value. See ticket [883034dcb5].
  **
  ** Another solution would be to change the OP_SCopy used to copy cached
  ** values to an OP_Copy.
  */
  if( regHit==0 && pAggInfo->nAccumulator ){
    regHit = regAcc;
  }
  if( regHit ){
    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
  }
  sqlite3ExprCacheClear(pParse);
  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
  }
  pAggInfo->directMode = 0;
  sqlite3ExprCacheClear(pParse);
  if( addrHitTest ){
    sqlite3VdbeJumpHere(v, addrHitTest);
  }
}

/*
** Add a single OP_Explain instruction to the VDBE to explain a simple







<



<


<
<
<
<
<
<
<
<
<
<
<






<




<







127417
127418
127419
127420
127421
127422
127423

127424
127425
127426

127427
127428











127429
127430
127431
127432
127433
127434

127435
127436
127437
127438

127439
127440
127441
127442
127443
127444
127445
      }
      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);
    }
    sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);
    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
    sqlite3VdbeChangeP5(v, (u8)nArg);

    sqlite3ReleaseTempRange(pParse, regAgg, nArg);
    if( addrNext ){
      sqlite3VdbeResolveLabel(v, addrNext);

    }
  }











  if( regHit==0 && pAggInfo->nAccumulator ){
    regHit = regAcc;
  }
  if( regHit ){
    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);
  }

  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
  }
  pAggInfo->directMode = 0;

  if( addrHitTest ){
    sqlite3VdbeJumpHere(v, addrHitTest);
  }
}

/*
** Add a single OP_Explain instruction to the VDBE to explain a simple
127646
127647
127648
127649
127650
127651
127652

127653
127654
127655
127656
127657
127658
127659
** Into this:
**
**    SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)
**
** The transformation only works if all of the following are true:
**
**   *  The subquery is a UNION ALL of two or more terms

**   *  There is no WHERE or GROUP BY or HAVING clauses on the subqueries
**   *  The outer query is a simple count(*)
**
** Return TRUE if the optimization is undertaken.
*/
static int countOfViewOptimization(Parse *pParse, Select *p){
  Select *pSub, *pPrior;







>







127561
127562
127563
127564
127565
127566
127567
127568
127569
127570
127571
127572
127573
127574
127575
** Into this:
**
**    SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)
**
** The transformation only works if all of the following are true:
**
**   *  The subquery is a UNION ALL of two or more terms
**   *  The subquery does not have a LIMIT clause
**   *  There is no WHERE or GROUP BY or HAVING clauses on the subqueries
**   *  The outer query is a simple count(*)
**
** Return TRUE if the optimization is undertaken.
*/
static int countOfViewOptimization(Parse *pParse, Select *p){
  Select *pSub, *pPrior;
127669
127670
127671
127672
127673
127674
127675

127676
127677
127678
127679
127680
127681
127682
  if( p->pSrc->nSrc!=1 ) return 0;                  /* One table in FROM  */
  pSub = p->pSrc->a[0].pSelect;
  if( pSub==0 ) return 0;                           /* The FROM is a subquery */
  if( pSub->pPrior==0 ) return 0;                   /* Must be a compound ry */
  do{
    if( pSub->op!=TK_ALL && pSub->pPrior ) return 0;  /* Must be UNION ALL */
    if( pSub->pWhere ) return 0;                      /* No WHERE clause */

    if( pSub->selFlags & SF_Aggregate ) return 0;     /* Not an aggregate */
    pSub = pSub->pPrior;                              /* Repeat over compound */
  }while( pSub );

  /* If we reach this point then it is OK to perform the transformation */

  db = pParse->db;







>







127585
127586
127587
127588
127589
127590
127591
127592
127593
127594
127595
127596
127597
127598
127599
  if( p->pSrc->nSrc!=1 ) return 0;                  /* One table in FROM  */
  pSub = p->pSrc->a[0].pSelect;
  if( pSub==0 ) return 0;                           /* The FROM is a subquery */
  if( pSub->pPrior==0 ) return 0;                   /* Must be a compound ry */
  do{
    if( pSub->op!=TK_ALL && pSub->pPrior ) return 0;  /* Must be UNION ALL */
    if( pSub->pWhere ) return 0;                      /* No WHERE clause */
    if( pSub->pLimit ) return 0;                      /* No LIMIT clause */
    if( pSub->selFlags & SF_Aggregate ) return 0;     /* Not an aggregate */
    pSub = pSub->pPrior;                              /* Repeat over compound */
  }while( pSub );

  /* If we reach this point then it is OK to perform the transformation */

  db = pParse->db;
127910
127911
127912
127913
127914
127915
127916





























127917
127918
127919
127920
127921
127922
127923
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif
    if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
    return rc;
  }
#endif






























  /* For each term in the FROM clause, do two things:
  ** (1) Authorized unreferenced tables
  ** (2) Generate code for all sub-queries
  */
  for(i=0; i<pTabList->nSrc; i++){
    struct SrcList_item *pItem = &pTabList->a[i];







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







127827
127828
127829
127830
127831
127832
127833
127834
127835
127836
127837
127838
127839
127840
127841
127842
127843
127844
127845
127846
127847
127848
127849
127850
127851
127852
127853
127854
127855
127856
127857
127858
127859
127860
127861
127862
127863
127864
127865
127866
127867
127868
127869
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif
    if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
    return rc;
  }
#endif

  /* Do the WHERE-clause constant propagation optimization if this is
  ** a join.  No need to speed time on this operation for non-join queries
  ** as the equivalent optimization will be handled by query planner in
  ** sqlite3WhereBegin().
  */
  if( pTabList->nSrc>1
   && OptimizationEnabled(db, SQLITE_PropagateConst)
   && propagateConstants(pParse, p)
  ){
#if SELECTTRACE_ENABLED
    if( sqlite3SelectTrace & 0x100 ){
      SELECTTRACE(0x100,pParse,p,("After constant propagation:\n"));
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif
  }else{
    SELECTTRACE(0x100,pParse,p,("Constant propagation not helpful\n"));
  }

#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
  if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)
   && countOfViewOptimization(pParse, p)
  ){
    if( db->mallocFailed ) goto select_end;
    pEList = p->pEList;
    pTabList = p->pSrc;
  }
#endif

  /* For each term in the FROM clause, do two things:
  ** (1) Authorized unreferenced tables
  ** (2) Generate code for all sub-queries
  */
  for(i=0; i<pTabList->nSrc; i++){
    struct SrcList_item *pItem = &pTabList->a[i];
127984
127985
127986
127987
127988
127989
127990
127991

127992
127993
127994
127995
127996
127997
127998
    */
    if( OptimizationEnabled(db, SQLITE_PushDown)
     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
                           (pItem->fg.jointype & JT_OUTER)!=0)
    ){
#if SELECTTRACE_ENABLED
      if( sqlite3SelectTrace & 0x100 ){
        SELECTTRACE(0x100,pParse,p,("After WHERE-clause push-down:\n"));

        sqlite3TreeViewSelect(0, p, 0);
      }
#endif
    }else{
      SELECTTRACE(0x100,pParse,p,("Push-down not possible\n"));
    }








|
>







127930
127931
127932
127933
127934
127935
127936
127937
127938
127939
127940
127941
127942
127943
127944
127945
    */
    if( OptimizationEnabled(db, SQLITE_PushDown)
     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
                           (pItem->fg.jointype & JT_OUTER)!=0)
    ){
#if SELECTTRACE_ENABLED
      if( sqlite3SelectTrace & 0x100 ){
        SELECTTRACE(0x100,pParse,p,
            ("After WHERE-clause push-down into subquery %d:\n", pSub->selId));
        sqlite3TreeViewSelect(0, p, 0);
      }
#endif
    }else{
      SELECTTRACE(0x100,pParse,p,("Push-down not possible\n"));
    }

128086
128087
128088
128089
128090
128091
128092
128093
128094
128095
128096
128097
128098
128099
128100
128101
128102
128103
128104
128105
128106
128107
128108
128109
  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;

#if SELECTTRACE_ENABLED
  if( sqlite3SelectTrace & 0x400 ){
    SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n"));
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif

#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
  if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)
   && countOfViewOptimization(pParse, p)
  ){
    if( db->mallocFailed ) goto select_end;
    pEList = p->pEList;
    pTabList = p->pSrc;
  }
#endif

  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and 
  ** if the select-list is the same as the ORDER BY list, then this query
  ** can be rewritten as a GROUP BY. In other words, this:
  **
  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz







<
<
<
<
<
<
<
<
<
<







128033
128034
128035
128036
128037
128038
128039










128040
128041
128042
128043
128044
128045
128046
  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;

#if SELECTTRACE_ENABLED
  if( sqlite3SelectTrace & 0x400 ){
    SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n"));
    sqlite3TreeViewSelect(0, p, 0);
  }










#endif

  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and 
  ** if the select-list is the same as the ORDER BY list, then this query
  ** can be rewritten as a GROUP BY. In other words, this:
  **
  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz
128447
128448
128449
128450
128451
128452
128453
128454
128455
128456
128457
128458
128459
128460
128461
128462
128463
128464
128465
128466
128467
128468
128469
128470
128471
128472
128473
128474
128475
128476
128477
128478
128479
128480
128481
128482
128483
128484
128485
128486
        for(i=0; i<sAggInfo.nColumn; i++){
          if( sAggInfo.aCol[i].iSorterColumn>=j ){
            nCol++;
            j++;
          }
        }
        regBase = sqlite3GetTempRange(pParse, nCol);
        sqlite3ExprCacheClear(pParse);
        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0);
        j = nGroupBy;
        for(i=0; i<sAggInfo.nColumn; i++){
          struct AggInfo_col *pCol = &sAggInfo.aCol[i];
          if( pCol->iSorterColumn>=j ){
            int r1 = j + regBase;
            sqlite3ExprCodeGetColumnToReg(pParse, 
                               pCol->pTab, pCol->iColumn, pCol->iTable, r1);
            j++;
          }
        }
        regRecord = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);
        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);
        sqlite3ReleaseTempReg(pParse, regRecord);
        sqlite3ReleaseTempRange(pParse, regBase, nCol);
        sqlite3WhereEnd(pWInfo);
        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;
        sortOut = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);
        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);
        VdbeComment((v, "GROUP BY sort")); VdbeCoverage(v);
        sAggInfo.useSortingIdx = 1;
        sqlite3ExprCacheClear(pParse);

      }

      /* If the index or temporary table used by the GROUP BY sort
      ** will naturally deliver rows in the order required by the ORDER BY
      ** clause, cancel the ephemeral table open coded earlier.
      **
      ** This is an optimization - the correct answer should result regardless.







<






|
|















<
<







128384
128385
128386
128387
128388
128389
128390

128391
128392
128393
128394
128395
128396
128397
128398
128399
128400
128401
128402
128403
128404
128405
128406
128407
128408
128409
128410
128411
128412
128413


128414
128415
128416
128417
128418
128419
128420
        for(i=0; i<sAggInfo.nColumn; i++){
          if( sAggInfo.aCol[i].iSorterColumn>=j ){
            nCol++;
            j++;
          }
        }
        regBase = sqlite3GetTempRange(pParse, nCol);

        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0);
        j = nGroupBy;
        for(i=0; i<sAggInfo.nColumn; i++){
          struct AggInfo_col *pCol = &sAggInfo.aCol[i];
          if( pCol->iSorterColumn>=j ){
            int r1 = j + regBase;
            sqlite3ExprCodeGetColumnOfTable(v,
                               pCol->pTab, pCol->iTable, pCol->iColumn, r1);
            j++;
          }
        }
        regRecord = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);
        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);
        sqlite3ReleaseTempReg(pParse, regRecord);
        sqlite3ReleaseTempRange(pParse, regBase, nCol);
        sqlite3WhereEnd(pWInfo);
        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;
        sortOut = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);
        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);
        VdbeComment((v, "GROUP BY sort")); VdbeCoverage(v);
        sAggInfo.useSortingIdx = 1;


      }

      /* If the index or temporary table used by the GROUP BY sort
      ** will naturally deliver rows in the order required by the ORDER BY
      ** clause, cancel the ephemeral table open coded earlier.
      **
      ** This is an optimization - the correct answer should result regardless.
128495
128496
128497
128498
128499
128500
128501
128502
128503
128504
128505
128506
128507
128508
128509

      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...
      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)
      ** Then compare the current GROUP BY terms against the GROUP BY terms
      ** from the previous row currently stored in a0, a1, a2...
      */
      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);
      sqlite3ExprCacheClear(pParse);
      if( groupBySort ){
        sqlite3VdbeAddOp3(v, OP_SorterData, sAggInfo.sortingIdx,
                          sortOut, sortPTab);
      }
      for(j=0; j<pGroupBy->nExpr; j++){
        if( groupBySort ){
          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);







<







128429
128430
128431
128432
128433
128434
128435

128436
128437
128438
128439
128440
128441
128442

      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...
      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)
      ** Then compare the current GROUP BY terms against the GROUP BY terms
      ** from the previous row currently stored in a0, a1, a2...
      */
      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);

      if( groupBySort ){
        sqlite3VdbeAddOp3(v, OP_SorterData, sAggInfo.sortingIdx,
                          sortOut, sortPTab);
      }
      for(j=0; j<pGroupBy->nExpr; j++){
        if( groupBySort ){
          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);
130712
130713
130714
130715
130716
130717
130718
130719
130720
130721
130722
130723
130724
130725
130726
130727
130728
130729
130730
130731
130732
        /* This branch loads the value of a column that will not be changed 
        ** into a register. This is done if there are no BEFORE triggers, or
        ** if there are one or more BEFORE triggers that use this value via
        ** a new.* reference in a trigger program.
        */
        testcase( i==31 );
        testcase( i==32 );
        sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i);
        if( tmask & TRIGGER_BEFORE ){
          /* This value will be recomputed in After-BEFORE-trigger-reload-loop
          ** below, so make sure that it is not cached and reused.
          ** Ticket d85fffd6ffe856092ed8daefa811b1e399706b28. */
          sqlite3ExprCacheRemove(pParse, regNew+i, 1);
        }
      }else{
        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
      }
    }
  }

  /* Fire any BEFORE UPDATE triggers. This happens before constraints are







|
<
<
<
<
<
<







130645
130646
130647
130648
130649
130650
130651
130652






130653
130654
130655
130656
130657
130658
130659
        /* This branch loads the value of a column that will not be changed 
        ** into a register. This is done if there are no BEFORE triggers, or
        ** if there are one or more BEFORE triggers that use this value via
        ** a new.* reference in a trigger program.
        */
        testcase( i==31 );
        testcase( i==32 );
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);






      }else{
        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
      }
    }
  }

  /* Fire any BEFORE UPDATE triggers. This happens before constraints are
133846
133847
133848
133849
133850
133851
133852
133853
133854
133855
133856
133857
133858
133859
133860
  while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){
    n--;
  }

  /* Code the OP_Affinity opcode if there is anything left to do. */
  if( n>0 ){
    sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);
    sqlite3ExprCacheAffinityChange(pParse, base, n);
  }
}

/*
** Expression pRight, which is the RHS of a comparison operation, is 
** either a vector of n elements or, if n==1, a scalar expression.
** Before the comparison operation, affinity zAff is to be applied







<







133773
133774
133775
133776
133777
133778
133779

133780
133781
133782
133783
133784
133785
133786
  while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){
    n--;
  }

  /* Code the OP_Affinity opcode if there is anything left to do. */
  if( n>0 ){
    sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);

  }
}

/*
** Expression pRight, which is the RHS of a comparison operation, is 
** either a vector of n elements or, if n==1, a scalar expression.
** Before the comparison operation, affinity zAff is to be applied
134382
134383
134384
134385
134386
134387
134388
134389
134390
134391
134392
134393
134394
134395
134396
** by pCCurHint.iTabCur, and an index is being used (which we will
** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
** an access of the index rather than the original table.
*/
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
  int rc = WRC_Continue;
  struct CCurHint *pHint = pWalker->u.pCCurHint;
  if( pExpr->op==TK_COLUMN ){
    if( pExpr->iTable!=pHint->iTabCur ){
      Vdbe *v = pWalker->pParse->pVdbe;
      int reg = ++pWalker->pParse->nMem;   /* Register for column value */
      sqlite3ExprCodeGetColumnOfTable(
          v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
      );
      pExpr->op = TK_REGISTER;







|







134308
134309
134310
134311
134312
134313
134314
134315
134316
134317
134318
134319
134320
134321
134322
** by pCCurHint.iTabCur, and an index is being used (which we will
** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
** an access of the index rather than the original table.
*/
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
  int rc = WRC_Continue;
  struct CCurHint *pHint = pWalker->u.pCCurHint;
  if( pExpr->op==TK_COLUMN && !ExprHasProperty(pExpr, EP_FixedCol) ){
    if( pExpr->iTable!=pHint->iTabCur ){
      Vdbe *v = pWalker->pParse->pVdbe;
      int reg = ++pWalker->pParse->nMem;   /* Register for column value */
      sqlite3ExprCodeGetColumnOfTable(
          v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg
      );
      pExpr->op = TK_REGISTER;
134755
134756
134757
134758
134759
134760
134761
134762
134763
134764
134765
134766
134767
134768
134769
    **          to access the data.
    */
    int iReg;   /* P3 Value for OP_VFilter */
    int addrNotFound;
    int nConstraint = pLoop->nLTerm;
    int iIn;    /* Counter for IN constraints */

    sqlite3ExprCachePush(pParse);
    iReg = sqlite3GetTempRange(pParse, nConstraint+2);
    addrNotFound = pLevel->addrBrk;
    for(j=0; j<nConstraint; j++){
      int iTarget = iReg+j+2;
      pTerm = pLoop->aLTerm[j];
      if( NEVER(pTerm==0) ) continue;
      if( pTerm->eOperator & WO_IN ){







<







134681
134682
134683
134684
134685
134686
134687

134688
134689
134690
134691
134692
134693
134694
    **          to access the data.
    */
    int iReg;   /* P3 Value for OP_VFilter */
    int addrNotFound;
    int nConstraint = pLoop->nLTerm;
    int iIn;    /* Counter for IN constraints */


    iReg = sqlite3GetTempRange(pParse, nConstraint+2);
    addrNotFound = pLevel->addrBrk;
    for(j=0; j<nConstraint; j++){
      int iTarget = iReg+j+2;
      pTerm = pLoop->aLTerm[j];
      if( NEVER(pTerm==0) ) continue;
      if( pTerm->eOperator & WO_IN ){
134828
134829
134830
134831
134832
134833
134834
134835
134836
134837
134838
134839
134840
134841
134842
    /* These registers need to be preserved in case there is an IN operator
    ** loop.  So we could deallocate the registers here (and potentially
    ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0.  But it seems
    ** simpler and safer to simply not reuse the registers.
    **
    **    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
    */
    sqlite3ExprCachePop(pParse);
  }else
#endif /* SQLITE_OMIT_VIRTUALTABLE */

  if( (pLoop->wsFlags & WHERE_IPK)!=0
   && (pLoop->wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_EQ))!=0
  ){
    /* Case 2:  We can directly reference a single row using an







<







134753
134754
134755
134756
134757
134758
134759

134760
134761
134762
134763
134764
134765
134766
    /* These registers need to be preserved in case there is an IN operator
    ** loop.  So we could deallocate the registers here (and potentially
    ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0.  But it seems
    ** simpler and safer to simply not reuse the registers.
    **
    **    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
    */

  }else
#endif /* SQLITE_OMIT_VIRTUALTABLE */

  if( (pLoop->wsFlags & WHERE_IPK)!=0
   && (pLoop->wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_EQ))!=0
  ){
    /* Case 2:  We can directly reference a single row using an
134852
134853
134854
134855
134856
134857
134858
134859
134860
134861
134862
134863
134864
134865
134866
134867
134868
    testcase( pTerm->wtFlags & TERM_VIRTUAL );
    iReleaseReg = ++pParse->nMem;
    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
    if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
    addrNxt = pLevel->addrNxt;
    sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
    VdbeCoverage(v);
    sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
    sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
    VdbeComment((v, "pk"));
    pLevel->op = OP_Noop;
  }else if( (pLoop->wsFlags & WHERE_IPK)!=0
         && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0
  ){
    /* Case 3:  We have an inequality comparison against the ROWID field.
    */
    int testOp = OP_Noop;







<
<
<







134776
134777
134778
134779
134780
134781
134782



134783
134784
134785
134786
134787
134788
134789
    testcase( pTerm->wtFlags & TERM_VIRTUAL );
    iReleaseReg = ++pParse->nMem;
    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
    if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
    addrNxt = pLevel->addrNxt;
    sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
    VdbeCoverage(v);



    pLevel->op = OP_Noop;
  }else if( (pLoop->wsFlags & WHERE_IPK)!=0
         && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0
  ){
    /* Case 3:  We have an inequality comparison against the ROWID field.
    */
    int testOp = OP_Noop;
134924
134925
134926
134927
134928
134929
134930
134931
134932
134933
134934
134935
134936
134937
134938
      }
      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
      VdbeComment((v, "pk"));
      VdbeCoverageIf(v, pX->op==TK_GT);
      VdbeCoverageIf(v, pX->op==TK_LE);
      VdbeCoverageIf(v, pX->op==TK_LT);
      VdbeCoverageIf(v, pX->op==TK_GE);
      sqlite3ExprCacheAffinityChange(pParse, r1, 1);
      sqlite3ReleaseTempReg(pParse, rTemp);
    }else{
      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
      VdbeCoverageIf(v, bRev==0);
      VdbeCoverageIf(v, bRev!=0);
    }
    if( pEnd ){







<







134845
134846
134847
134848
134849
134850
134851

134852
134853
134854
134855
134856
134857
134858
      }
      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
      VdbeComment((v, "pk"));
      VdbeCoverageIf(v, pX->op==TK_GT);
      VdbeCoverageIf(v, pX->op==TK_LE);
      VdbeCoverageIf(v, pX->op==TK_LT);
      VdbeCoverageIf(v, pX->op==TK_GE);

      sqlite3ReleaseTempReg(pParse, rTemp);
    }else{
      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
      VdbeCoverageIf(v, bRev==0);
      VdbeCoverageIf(v, bRev!=0);
    }
    if( pEnd ){
134959
134960
134961
134962
134963
134964
134965
134966
134967
134968
134969
134970
134971
134972
134973
    pLevel->op = bRev ? OP_Prev : OP_Next;
    pLevel->p1 = iCur;
    pLevel->p2 = start;
    assert( pLevel->p5==0 );
    if( testOp!=OP_Noop ){
      iRowidReg = ++pParse->nMem;
      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);
      sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);
      VdbeCoverageIf(v, testOp==OP_Le);
      VdbeCoverageIf(v, testOp==OP_Lt);
      VdbeCoverageIf(v, testOp==OP_Ge);
      VdbeCoverageIf(v, testOp==OP_Gt);
      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);
    }







<







134879
134880
134881
134882
134883
134884
134885

134886
134887
134888
134889
134890
134891
134892
    pLevel->op = bRev ? OP_Prev : OP_Next;
    pLevel->p1 = iCur;
    pLevel->p2 = start;
    assert( pLevel->p5==0 );
    if( testOp!=OP_Noop ){
      iRowidReg = ++pParse->nMem;
      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);

      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);
      VdbeCoverageIf(v, testOp==OP_Le);
      VdbeCoverageIf(v, testOp==OP_Lt);
      VdbeCoverageIf(v, testOp==OP_Ge);
      VdbeCoverageIf(v, testOp==OP_Gt);
      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);
    }
135185
135186
135187
135188
135189
135190
135191
135192
135193
135194
135195
135196
135197
135198
135199

    /* Load the value for the inequality constraint at the end of the
    ** range (if any).
    */
    nConstraint = nEq;
    if( pRangeEnd ){
      Expr *pRight = pRangeEnd->pExpr->pRight;
      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
      codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
      whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
      if( (pRangeEnd->wtFlags & TERM_VNULL)==0
       && sqlite3ExprCanBeNull(pRight)
      ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
        VdbeCoverage(v);







<







135104
135105
135106
135107
135108
135109
135110

135111
135112
135113
135114
135115
135116
135117

    /* Load the value for the inequality constraint at the end of the
    ** range (if any).
    */
    nConstraint = nEq;
    if( pRangeEnd ){
      Expr *pRight = pRangeEnd->pExpr->pRight;

      codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
      whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
      if( (pRangeEnd->wtFlags & TERM_VNULL)==0
       && sqlite3ExprCanBeNull(pRight)
      ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
        VdbeCoverage(v);
135210
135211
135212
135213
135214
135215
135216
135217
135218
135219
135220
135221
135222
135223
135224
      if( sqlite3ExprIsVector(pRight)==0 ){
        disableTerm(pLevel, pRangeEnd);
      }else{
        endEq = 1;
      }
    }else if( bStopAtNull ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
      endEq = 0;
      nConstraint++;
    }
    sqlite3DbFree(db, zStartAff);
    sqlite3DbFree(db, zEndAff);

    /* Top of the loop body */







<







135128
135129
135130
135131
135132
135133
135134

135135
135136
135137
135138
135139
135140
135141
      if( sqlite3ExprIsVector(pRight)==0 ){
        disableTerm(pLevel, pRangeEnd);
      }else{
        endEq = 1;
      }
    }else if( bStopAtNull ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);

      endEq = 0;
      nConstraint++;
    }
    sqlite3DbFree(db, zStartAff);
    sqlite3DbFree(db, zEndAff);

    /* Top of the loop body */
135244
135245
135246
135247
135248
135249
135250
135251
135252
135253
135254
135255
135256
135257
135258
    }else if( HasRowid(pIdx->pTable) ){
      if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (
          (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) 
       && (pWInfo->eOnePass==ONEPASS_SINGLE)
      )){
        iRowidReg = ++pParse->nMem;
        sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);
        sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
        sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);
        VdbeCoverage(v);
      }else{
        codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);
      }
    }else if( iCur!=iIdxCur ){
      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);







<







135161
135162
135163
135164
135165
135166
135167

135168
135169
135170
135171
135172
135173
135174
    }else if( HasRowid(pIdx->pTable) ){
      if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (
          (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) 
       && (pWInfo->eOnePass==ONEPASS_SINGLE)
      )){
        iRowidReg = ++pParse->nMem;
        sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);

        sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);
        VdbeCoverage(v);
      }else{
        codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);
      }
    }else if( iCur!=iIdxCur ){
      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
135479
135480
135481
135482
135483
135484
135485
135486
135487
135488
135489
135490
135491
135492
135493
135494
135495
135496

135497
135498
135499
135500
135501
135502
135503
135504
135505
135506
135507
135508
135509

          /* This is the sub-WHERE clause body.  First skip over
          ** duplicate rows from prior sub-WHERE clauses, and record the
          ** rowid (or PRIMARY KEY) for the current row so that the same
          ** row will be skipped in subsequent sub-WHERE clauses.
          */
          if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
            int r;
            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
            if( HasRowid(pTab) ){
              r = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, regRowid, 0);
              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,
                                           r,iSet);
              VdbeCoverage(v);
            }else{
              Index *pPk = sqlite3PrimaryKeyIndex(pTab);
              int nPk = pPk->nKeyCol;
              int iPk;


              /* Read the PK into an array of temp registers. */
              r = sqlite3GetTempRange(pParse, nPk);
              for(iPk=0; iPk<nPk; iPk++){
                int iCol = pPk->aiColumn[iPk];
                sqlite3ExprCodeGetColumnToReg(pParse, pTab, iCol, iCur, r+iPk);
              }

              /* Check if the temp table already contains this key. If so,
              ** the row has already been included in the result set and
              ** can be ignored (by jumping past the Gosub below). Otherwise,
              ** insert the key into the temp table and proceed with processing
              ** the row.







<


|

|





>





|







135395
135396
135397
135398
135399
135400
135401

135402
135403
135404
135405
135406
135407
135408
135409
135410
135411
135412
135413
135414
135415
135416
135417
135418
135419
135420
135421
135422
135423
135424
135425

          /* This is the sub-WHERE clause body.  First skip over
          ** duplicate rows from prior sub-WHERE clauses, and record the
          ** rowid (or PRIMARY KEY) for the current row so that the same
          ** row will be skipped in subsequent sub-WHERE clauses.
          */
          if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){

            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
            if( HasRowid(pTab) ){
              sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, -1, regRowid);
              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,
                                          regRowid, iSet);
              VdbeCoverage(v);
            }else{
              Index *pPk = sqlite3PrimaryKeyIndex(pTab);
              int nPk = pPk->nKeyCol;
              int iPk;
              int r;

              /* Read the PK into an array of temp registers. */
              r = sqlite3GetTempRange(pParse, nPk);
              for(iPk=0; iPk<nPk; iPk++){
                int iCol = pPk->aiColumn[iPk];
                sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, r+iPk);
              }

              /* Check if the temp table already contains this key. If so,
              ** the row has already been included in the result set and
              ** can be ignored (by jumping past the Gosub below). Otherwise,
              ** insert the key into the temp table and proceed with processing
              ** the row.
135728
135729
135730
135731
135732
135733
135734
135735
135736
135737
135738
135739
135740
135741
135742
  /* For a LEFT OUTER JOIN, generate code that will record the fact that
  ** at least one row of the right table has matched the left table.  
  */
  if( pLevel->iLeftJoin ){
    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
    VdbeComment((v, "record LEFT JOIN hit"));
    sqlite3ExprCacheClear(pParse);
    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
      testcase( pTerm->wtFlags & TERM_VIRTUAL );
      testcase( pTerm->wtFlags & TERM_CODED );
      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
        assert( pWInfo->untestedTerms );
        continue;







<







135644
135645
135646
135647
135648
135649
135650

135651
135652
135653
135654
135655
135656
135657
  /* For a LEFT OUTER JOIN, generate code that will record the fact that
  ** at least one row of the right table has matched the left table.  
  */
  if( pLevel->iLeftJoin ){
    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
    VdbeComment((v, "record LEFT JOIN hit"));

    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
      testcase( pTerm->wtFlags & TERM_VIRTUAL );
      testcase( pTerm->wtFlags & TERM_CODED );
      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
        assert( pWInfo->untestedTerms );
        continue;
135944
135945
135946
135947
135948
135949
135950
135951
135952
135953
135954
135955
135956
135957
135958
135959
135960
135961
135962
135963
135964
135965
135966
135967
135968
135969
static int isLikeOrGlob(
  Parse *pParse,    /* Parsing and code generating context */
  Expr *pExpr,      /* Test this expression */
  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */
  int *pisComplete, /* True if the only wildcard is % in the last character */
  int *pnoCase      /* True if uppercase is equivalent to lowercase */
){
  const u8 *z = 0;         /* String on RHS of LIKE operator */
  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */
  ExprList *pList;           /* List of operands to the LIKE operator */
  int c;                     /* One character in z[] */
  int cnt;                   /* Number of non-wildcard prefix characters */
  char wc[4];                /* Wildcard characters */
  sqlite3 *db = pParse->db;  /* Database connection */
  sqlite3_value *pVal = 0;
  int op;                    /* Opcode of pRight */
  int rc;                    /* Result code to return */

  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){
    return 0;
  }
#ifdef SQLITE_EBCDIC
  if( *pnoCase ) return 0;
#endif
  pList = pExpr->x.pList;
  pLeft = pList->a[1].pExpr;







|


|

|





|







135859
135860
135861
135862
135863
135864
135865
135866
135867
135868
135869
135870
135871
135872
135873
135874
135875
135876
135877
135878
135879
135880
135881
135882
135883
135884
static int isLikeOrGlob(
  Parse *pParse,    /* Parsing and code generating context */
  Expr *pExpr,      /* Test this expression */
  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */
  int *pisComplete, /* True if the only wildcard is % in the last character */
  int *pnoCase      /* True if uppercase is equivalent to lowercase */
){
  const u8 *z = 0;           /* String on RHS of LIKE operator */
  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */
  ExprList *pList;           /* List of operands to the LIKE operator */
  u8 c;                      /* One character in z[] */
  int cnt;                   /* Number of non-wildcard prefix characters */
  u8 wc[4];                  /* Wildcard characters */
  sqlite3 *db = pParse->db;  /* Database connection */
  sqlite3_value *pVal = 0;
  int op;                    /* Opcode of pRight */
  int rc;                    /* Result code to return */

  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, (char*)wc) ){
    return 0;
  }
#ifdef SQLITE_EBCDIC
  if( *pnoCase ) return 0;
#endif
  pList = pExpr->x.pList;
  pLeft = pList->a[1].pExpr;
136609
136610
136611
136612
136613
136614
136615
136616
136617
136618
136619
136620
136621
136622
136623
  aff2 = sqlite3ExprAffinity(pExpr->pRight);
  if( aff1!=aff2
   && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
  ){
    return 0;
  }
  pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
  if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
  return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
}

/*
** Recursively walk the expressions of a SELECT statement and generate
** a bitmask indicating which tables are used in that expression
** tree.







|







136524
136525
136526
136527
136528
136529
136530
136531
136532
136533
136534
136535
136536
136537
136538
  aff2 = sqlite3ExprAffinity(pExpr->pRight);
  if( aff1!=aff2
   && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
  ){
    return 0;
  }
  pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
  if( sqlite3IsBinary(pColl) ) return 1;
  return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
}

/*
** Recursively walk the expressions of a SELECT statement and generate
** a bitmask indicating which tables are used in that expression
** tree.
136950
136951
136952
136953
136954
136955
136956
136957
136958
136959
136960
136961
136962
136963
136964
        ** LIKE on all candidate expressions by clearing the isComplete flag
        */
        if( c=='A'-1 ) isComplete = 0;
        c = sqlite3UpperToLower[c];
      }
      *pC = c + 1;
    }
    zCollSeqName = noCase ? "NOCASE" : "BINARY";
    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
    pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
           sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
           pStr1);
    transferJoinMarkings(pNewExpr1, pExpr);
    idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
    testcase( idxNew1==0 );







|







136865
136866
136867
136868
136869
136870
136871
136872
136873
136874
136875
136876
136877
136878
136879
        ** LIKE on all candidate expressions by clearing the isComplete flag
        */
        if( c=='A'-1 ) isComplete = 0;
        c = sqlite3UpperToLower[c];
      }
      *pC = c + 1;
    }
    zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
    pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
           sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
           pStr1);
    transferJoinMarkings(pNewExpr1, pExpr);
    idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
    testcase( idxNew1==0 );
137200
137201
137202
137203
137204
137205
137206
137207
137208
137209
137210
137211
137212
137213
137214
/*
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
  Bitmask mask;
  if( p->op==TK_COLUMN ){
    return sqlite3WhereGetMask(pMaskSet, p->iTable);
  }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
    assert( p->op!=TK_IF_NULL_ROW );
    return 0;
  }
  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
  if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);







|







137115
137116
137117
137118
137119
137120
137121
137122
137123
137124
137125
137126
137127
137128
137129
/*
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
  Bitmask mask;
  if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
    return sqlite3WhereGetMask(pMaskSet, p->iTable);
  }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
    assert( p->op!=TK_IF_NULL_ROW );
    return 0;
  }
  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
  if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
138098
138099
138100
138101
138102
138103
138104
138105
138106
138107
138108
138109
138110
138111
138112
  assert( pLevel->iIdxCur>=0 );
  pLevel->iIdxCur = pParse->nTab++;
  sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
  sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
  VdbeComment((v, "for %s", pTable->zName));

  /* Fill the automatic index with content */
  sqlite3ExprCachePush(pParse);
  pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
  if( pTabItem->fg.viaCoroutine ){
    int regYield = pTabItem->regReturn;
    addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
    addrTop =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);
    VdbeCoverage(v);







<







138013
138014
138015
138016
138017
138018
138019

138020
138021
138022
138023
138024
138025
138026
  assert( pLevel->iIdxCur>=0 );
  pLevel->iIdxCur = pParse->nTab++;
  sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
  sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
  VdbeComment((v, "for %s", pTable->zName));

  /* Fill the automatic index with content */

  pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
  if( pTabItem->fg.viaCoroutine ){
    int regYield = pTabItem->regReturn;
    addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
    addrTop =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);
    VdbeCoverage(v);
138135
138136
138137
138138
138139
138140
138141
138142
138143
138144
138145
138146
138147
138148
138149
    pTabItem->fg.viaCoroutine = 0;
  }else{
    sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
  }
  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
  sqlite3VdbeJumpHere(v, addrTop);
  sqlite3ReleaseTempReg(pParse, regRecord);
  sqlite3ExprCachePop(pParse);
  
  /* Jump here when skipping the initialization */
  sqlite3VdbeJumpHere(v, addrInit);

end_auto_index_create:
  sqlite3ExprDelete(pParse->db, pPartial);
}







<







138049
138050
138051
138052
138053
138054
138055

138056
138057
138058
138059
138060
138061
138062
    pTabItem->fg.viaCoroutine = 0;
  }else{
    sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
  }
  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
  sqlite3VdbeJumpHere(v, addrTop);
  sqlite3ReleaseTempReg(pParse, regRecord);

  
  /* Jump here when skipping the initialization */
  sqlite3VdbeJumpHere(v, addrInit);

end_auto_index_create:
  sqlite3ExprDelete(pParse->db, pPartial);
}
140501
140502
140503
140504
140505
140506
140507
140508
140509
140510
140511
140512
140513
140514
140515
  if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
    CollSeq *pC = 0;
    int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
    Expr *pX = pHidden->pWC->a[iTerm].pExpr;
    if( pX->pLeft ){
      pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);
    }
    zRet = (pC ? pC->zName : "BINARY");
  }
  return zRet;
}

/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab.  That table is guaranteed to be a virtual table.







|







140414
140415
140416
140417
140418
140419
140420
140421
140422
140423
140424
140425
140426
140427
140428
  if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
    CollSeq *pC = 0;
    int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
    Expr *pX = pHidden->pWC->a[iTerm].pExpr;
    if( pX->pLeft ){
      pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);
    }
    zRet = (pC ? pC->zName : sqlite3StrBINARY);
  }
  return zRet;
}

/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab.  That table is guaranteed to be a virtual table.
141352
141353
141354
141355
141356
141357
141358




141359
141360
141361
141362
141363
141364
141365
141366
        }
        if( isOrdered>=0 && isOrdered<nOrderBy ){
          if( aSortCost[isOrdered]==0 ){
            aSortCost[isOrdered] = whereSortingCost(
                pWInfo, nRowEst, nOrderBy, isOrdered
            );
          }




          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);

          WHERETRACE(0x002,
              ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, 
               rUnsorted, rCost));
        }else{
          rCost = rUnsorted;







>
>
>
>
|







141265
141266
141267
141268
141269
141270
141271
141272
141273
141274
141275
141276
141277
141278
141279
141280
141281
141282
141283
        }
        if( isOrdered>=0 && isOrdered<nOrderBy ){
          if( aSortCost[isOrdered]==0 ){
            aSortCost[isOrdered] = whereSortingCost(
                pWInfo, nRowEst, nOrderBy, isOrdered
            );
          }
          /* TUNING:  Add a small extra penalty (5) to sorting as an
          ** extra encouragment to the query planner to select a plan
          ** where the rows emerge in the correct order without any sorting
          ** required. */
          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 5;

          WHERETRACE(0x002,
              ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, 
               rUnsorted, rCost));
        }else{
          rCost = rUnsorted;
142369
142370
142371
142372
142373
142374
142375
142376
142377
142378
142379
142380
142381
142382
142383
  WhereLoop *pLoop;
  SrcList *pTabList = pWInfo->pTabList;
  sqlite3 *db = pParse->db;

  /* Generate loop termination code.
  */
  VdbeModuleComment((v, "End WHERE-core"));
  sqlite3ExprCacheClear(pParse);
  for(i=pWInfo->nLevel-1; i>=0; i--){
    int addr;
    pLevel = &pWInfo->a[i];
    pLoop = pLevel->pWLoop;
    if( pLevel->op!=OP_Noop ){
#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
      int addrSeek = 0;







<







142286
142287
142288
142289
142290
142291
142292

142293
142294
142295
142296
142297
142298
142299
  WhereLoop *pLoop;
  SrcList *pTabList = pWInfo->pTabList;
  sqlite3 *db = pParse->db;

  /* Generate loop termination code.
  */
  VdbeModuleComment((v, "End WHERE-core"));

  for(i=pWInfo->nLevel-1; i>=0; i--){
    int addr;
    pLevel = &pWInfo->a[i];
    pLoop = pLevel->pWLoop;
    if( pLevel->op!=OP_Noop ){
#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
      int addrSeek = 0;
143534
143535
143536
143537
143538
143539
143540



143541
143542
143543
143544
143545
143546
143547
143548
}

/*
** Attach window object pWin to expression p.
*/
SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
  if( p ){



    if( pWin ){
      p->pWin = pWin;
      pWin->pOwner = p;
      if( p->flags & EP_Distinct ){
        sqlite3ErrorMsg(pParse,
           "DISTINCT is not supported for window functions");
      }
    }







>
>
>
|







143450
143451
143452
143453
143454
143455
143456
143457
143458
143459
143460
143461
143462
143463
143464
143465
143466
143467
}

/*
** Attach window object pWin to expression p.
*/
SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
  if( p ){
    /* This routine is only called for the parser.  If pWin was not
    ** allocated due to an OOM, then the parser would fail before ever
    ** invoking this routine */
    if( ALWAYS(pWin) ){
      p->pWin = pWin;
      pWin->pOwner = p;
      if( p->flags & EP_Distinct ){
        sqlite3ErrorMsg(pParse,
           "DISTINCT is not supported for window functions");
      }
    }
145093
145094
145095
145096
145097
145098
145099
145100
145101
145102
145103
145104
145105
145106
145107
145108
145109
145110
145111
145112
145113
145114
145115
145116
145117
#define sqlite3ParserARG_STORE
#define sqlite3ParserCTX_SDECL Parse *pParse;
#define sqlite3ParserCTX_PDECL ,Parse *pParse
#define sqlite3ParserCTX_PARAM ,pParse
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
#define YYNSTATE             516
#define YYNRULE              365
#define YYNTOKEN             155
#define YY_MAX_SHIFT         515
#define YY_MIN_SHIFTREDUCE   750
#define YY_MAX_SHIFTREDUCE   1114
#define YY_ERROR_ACTION      1115
#define YY_ACCEPT_ACTION     1116
#define YY_NO_ACTION         1117
#define YY_MIN_REDUCE        1118
#define YY_MAX_REDUCE        1482
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section







|
|

|
|
|
|
|
|
|
|







145012
145013
145014
145015
145016
145017
145018
145019
145020
145021
145022
145023
145024
145025
145026
145027
145028
145029
145030
145031
145032
145033
145034
145035
145036
#define sqlite3ParserARG_STORE
#define sqlite3ParserCTX_SDECL Parse *pParse;
#define sqlite3ParserCTX_PDECL ,Parse *pParse
#define sqlite3ParserCTX_PARAM ,pParse
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
#define YYNSTATE             518
#define YYNRULE              366
#define YYNTOKEN             155
#define YY_MAX_SHIFT         517
#define YY_MIN_SHIFTREDUCE   752
#define YY_MAX_SHIFTREDUCE   1117
#define YY_ERROR_ACTION      1118
#define YY_ACCEPT_ACTION     1119
#define YY_NO_ACTION         1120
#define YY_MIN_REDUCE        1121
#define YY_MAX_REDUCE        1486
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
145172
145173
145174
145175
145176
145177
145178
145179
145180
145181
145182
145183
145184
145185
145186
145187
145188
145189
145190
145191
145192
145193
145194
145195
145196
145197
145198
145199
145200
145201
145202
145203
145204
145205
145206
145207
145208
145209
145210
145211
145212
145213
145214
145215
145216
145217
145218
145219
145220
145221
145222
145223
145224
145225
145226
145227
145228
145229
145230
145231
145232
145233
145234
145235
145236
145237
145238
145239
145240
145241
145242
145243
145244
145245
145246
145247
145248
145249
145250
145251
145252
145253
145254
145255
145256
145257
145258
145259
145260
145261
145262
145263
145264
145265
145266
145267
145268
145269
145270
145271
145272
145273
145274
145275
145276
145277
145278
145279
145280
145281
145282
145283
145284
145285
145286
145287
145288
145289
145290
145291
145292
145293
145294
145295
145296
145297
145298
145299
145300
145301
145302
145303
145304
145305
145306
145307
145308
145309
145310
145311
145312
145313
145314
145315
145316
145317
145318
145319
145320
145321
145322
145323
145324
145325
145326
145327
145328
145329
145330
145331
145332
145333
145334
145335
145336
145337
145338
145339
145340
145341
145342
145343
145344
145345
145346
145347
145348
145349
145350
145351
145352
145353
145354
145355
145356
145357
145358
145359
145360
145361
145362
145363
145364
145365
145366
145367
145368
145369
145370
145371
145372
145373
145374
145375
145376
145377
145378
145379
145380
145381
145382
145383
145384
145385
145386
145387
145388
145389
145390
145391
145392
145393
145394
145395
145396
145397
145398
145399
145400
145401
145402
145403
145404
145405
145406
145407
145408
145409
145410
145411
145412
145413
145414
145415
145416
145417
145418
145419
145420
145421
145422
145423
145424
145425
145426
145427
145428
145429
145430
145431
145432
145433
145434
145435
145436
145437
145438
145439
145440
145441
145442
145443
145444
145445
145446
145447
145448
145449
145450
145451
145452
145453
145454
145455
145456
145457
145458
145459
145460
145461
145462
145463
145464
145465
145466
145467
145468
145469
145470
145471
145472
145473
145474
145475
145476
145477
145478
145479
145480
145481
145482
145483
145484
145485
145486
145487
145488
145489
145490
145491
145492
145493
145494
145495
145496
145497
145498
145499
145500
145501
145502
145503
145504
145505
145506
145507
145508
145509
145510
145511
145512
145513
145514
145515
145516
145517
145518
145519
145520
145521
145522
145523
145524
145525
145526
145527
145528
145529
145530
145531
145532
145533
145534
145535
145536
145537
145538
145539
145540
145541
145542
145543
145544
145545
145546
145547
145548
145549
145550
145551
145552
145553
145554
145555
145556
145557
145558
145559
145560
145561
145562
145563
145564
145565
145566
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (2009)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   510,  423,  364,  105,  102,  196,   14,  244, 1116,    1,
 /*    10 */     1,  515,    2, 1120,  510,  361, 1247,  362,  271,  366,
 /*    20 */   127,   37,   37, 1378,  105,  102,  196, 1197,  178,  472,
 /*    30 */  1246,  880, 1184, 1163,  423,   37,   37, 1189, 1189,  881,
 /*    40 */   353, 1184,  425,  112,  113,  103, 1092, 1092,  944,  947,
 /*    50 */   937,  937,  110,  110,  111,  111,  111,  111,  278,  249,
 /*    60 */   249,  249,  249,  105,  102,  196,  510,  105,  102,  196,
 /*    70 */  1071,  254,  507,  177,  507, 1187, 1187,  491,  415,  225,
 /*    80 */   193,  105,  102,  196,  510,  205,  906,   65,   65,  318,
 /*    90 */   249,  249,  109,  109,  109,  109,  108,  108,  107,  107,
 /*   100 */   107,  106,  396,  507,  258,   15,   15,  394,  393,  249,
 /*   110 */   249, 1413,  366, 1408,  400, 1096, 1071, 1072, 1073,  377,
 /*   120 */  1098,  178,  507,  493,  492, 1411, 1407,  396, 1097,  292,
 /*   130 */   411,  280,  366,  365,  134,  152,  112,  113,  103, 1092,
 /*   140 */  1092,  944,  947,  937,  937,  110,  110,  111,  111,  111,
 /*   150 */   111, 1450, 1099,  262, 1099,  262,  112,  113,  103, 1092,
 /*   160 */  1092,  944,  947,  937,  937,  110,  110,  111,  111,  111,
 /*   170 */   111,  107,  107,  107,  106,  396, 1049,  486, 1047,  509,
 /*   180 */    73,  270,  500,  416,  293,  109,  109,  109,  109,  108,
 /*   190 */   108,  107,  107,  107,  106,  396,  366,  111,  111,  111,
 /*   200 */   111,  104,  330,   89,  486,  109,  109,  109,  109,  108,
 /*   210 */   108,  107,  107,  107,  106,  396,  111,  111,  111,  111,
 /*   220 */   112,  113,  103, 1092, 1092,  944,  947,  937,  937,  110,
 /*   230 */   110,  111,  111,  111,  111,  109,  109,  109,  109,  108,
 /*   240 */   108,  107,  107,  107,  106,  396,  114,  108,  108,  107,
 /*   250 */   107,  107,  106,  396,  109,  109,  109,  109,  108,  108,
 /*   260 */   107,  107,  107,  106,  396,  394,  393,  106,  396,  109,
 /*   270 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  396,
 /*   280 */   217,  487, 1400,  453,  450,  449,  510, 1278,  423,  366,
 /*   290 */   503,  503,  503,  448,   74, 1071,  109,  109,  109,  109,
 /*   300 */   108,  108,  107,  107,  107,  106,  396,   37,   37, 1401,
 /*   310 */  1099,  440, 1099,  112,  113,  103, 1092, 1092,  944,  947,
 /*   320 */   937,  937,  110,  110,  111,  111,  111,  111, 1426,  515,
 /*   330 */     2, 1120,  934,  934,  945,  948,  271, 1071,  127,  477,
 /*   340 */   924, 1071, 1072, 1073,  217, 1197,  906,  453,  450,  449,
 /*   350 */   388,  167,  510, 1377,  152,  379,  917,  448,  259,  510,
 /*   360 */   916,  285,  109,  109,  109,  109,  108,  108,  107,  107,
 /*   370 */   107,  106,  396,   15,   15,  429,  846,  249,  249,  224,
 /*   380 */    15,   15,  366, 1071, 1072, 1073,  307,  382, 1071,  292,
 /*   390 */   507,  916,  916,  918,  384,   27,  938, 1411,  484,  408,
 /*   400 */   270,  500,  508,  205,  836,  836,  112,  113,  103, 1092,
 /*   410 */  1092,  944,  947,  937,  937,  110,  110,  111,  111,  111,
 /*   420 */   111, 1430,  282, 1120,  284, 1071,   28,  510,  271,  318,
 /*   430 */   127, 1422,  400,  385, 1071, 1072, 1073, 1197,  159,  235,
 /*   440 */   252,  317,  456,  312,  455,  222,  784,  375,   65,   65,
 /*   450 */   332,  310,  194,  243,  243,  109,  109,  109,  109,  108,
 /*   460 */   108,  107,  107,  107,  106,  396,  507,  257,  510,  249,
 /*   470 */   249, 1071, 1072, 1073,  136,  366,  335,  924,  440,  788,
 /*   480 */   270,  500,  507, 1446,  493,  473,  319, 1071,  429,   65,
 /*   490 */    65, 1158,  784,  917,  283,  205,  510,  916,  440,  112,
 /*   500 */   113,  103, 1092, 1092,  944,  947,  937,  937,  110,  110,
 /*   510 */   111,  111,  111,  111,  279, 1027, 1476,   15,   15, 1476,
 /*   520 */   403,  510,  383, 1071,  400,  493, 1404, 1386,  916,  916,
 /*   530 */   918,  261,  463, 1071, 1072, 1073,  173, 1421,  510, 1071,
 /*   540 */  1343,  510,   45,   45,  168,  990,  990,  437,  109,  109,
 /*   550 */   109,  109,  108,  108,  107,  107,  107,  106,  396,   63,
 /*   560 */    63,  510,   15,   15,  249,  249,  375,  510,  366, 1071,
 /*   570 */  1072, 1073,  781,    5,  401,  355,  488,  507,  464,    3,
 /*   580 */   291, 1071,   65,   65, 1025, 1071, 1072, 1073,   65,   65,
 /*   590 */   350, 1112,  112,  113,  103, 1092, 1092,  944,  947,  937,
 /*   600 */   937,  110,  110,  111,  111,  111,  111,  249,  249,  510,
 /*   610 */  1071, 1042,  867,  395,  395,  395, 1071,  336,  493,  490,
 /*   620 */   507, 1041, 1006,  318,  493,  505,  178, 1071, 1072, 1073,
 /*   630 */    65,   65, 1071,  255,  344,  421,  273, 1007,  358,  290,
 /*   640 */    88,  109,  109,  109,  109,  108,  108,  107,  107,  107,
 /*   650 */   106,  396, 1008,  510,  375, 1071, 1071, 1072, 1073, 1113,
 /*   660 */   510,  366, 1071, 1072, 1073, 1056,  493,  462,  133, 1478,
 /*   670 */   351,  249,  249,  822,   65,   65,  152,  440, 1071, 1072,
 /*   680 */  1073,   65,   65,  823,  507,  112,  113,  103, 1092, 1092,
 /*   690 */   944,  947,  937,  937,  110,  110,  111,  111,  111,  111,
 /*   700 */   274, 1071, 1072, 1073,  407,  866,  471, 1219, 1027, 1477,
 /*   710 */   478,  767, 1477,  406, 1195, 1347, 1138,  392,  465, 1196,
 /*   720 */   987,  256,  270,  500,  987,  445, 1075,   18,   18,  793,
 /*   730 */   406,  405, 1347, 1349,  109,  109,  109,  109,  108,  108,
 /*   740 */   107,  107,  107,  106,  396,  510,  249,  249,  249,  249,
 /*   750 */   249,  249,  221,  510,  366,  251,  435,  246,  925,  507,
 /*   760 */   865,  507,  468,  507,  318,  429,   49,   49,  494,    9,
 /*   770 */   414,  228,  802, 1075,   50,   50,  277, 1025,  112,  113,
 /*   780 */   103, 1092, 1092,  944,  947,  937,  937,  110,  110,  111,
 /*   790 */   111,  111,  111, 1006,  249,  249,  510,  406, 1345, 1347,
 /*   800 */   249,  249,  967,  454, 1141,  372, 1090,  507, 1007,  135,
 /*   810 */   371,  803,  440,  507,  220,  219,  218,   17,   17, 1423,
 /*   820 */   460,  510,  440, 1008,  510, 1232,  310,  109,  109,  109,
 /*   830 */   109,  108,  108,  107,  107,  107,  106,  396,  510, 1336,
 /*   840 */   510,  195,   39,   39,  497,   51,   51,  366,  510,  485,
 /*   850 */  1278,  911,    6, 1090, 1192,  985,  386,  260,  221,   52,
 /*   860 */    52,   53,   53, 1439,  298,  510,  865,  366,  510,   54,
 /*   870 */    54,  112,  113,  103, 1092, 1092,  944,  947,  937,  937,
 /*   880 */   110,  110,  111,  111,  111,  111,   55,   55,  865,   40,
 /*   890 */    40,  112,  113,  103, 1092, 1092,  944,  947,  937,  937,
 /*   900 */   110,  110,  111,  111,  111,  111,  250,  250,  755,  756,
 /*   910 */   757,  510,   95,  510,   93,  510,  371,  510,  380,  507,
 /*   920 */   109,  109,  109,  109,  108,  108,  107,  107,  107,  106,
 /*   930 */   396,  510,   41,   41,   43,   43,   44,   44,   56,   56,
 /*   940 */   109,  109,  109,  109,  108,  108,  107,  107,  107,  106,
 /*   950 */   396,  510,   57,   57,  510, 1231,  510,  370,  510,  410,
 /*   960 */   510,  416,  293,  510, 1291,  510, 1290,  510,  190,  195,
 /*   970 */   510,  319,   58,   58, 1391,   16,   16,   59,   59,  118,
 /*   980 */   118,   60,   60,  458,   46,   46,   61,   61,   62,   62,
 /*   990 */   510,   47,   47, 1201,  865,   91,  510,  474,  510,  461,
 /*  1000 */   510,  461,  510,  228,  510,  507,  510,  390,  510,  841,
 /*  1010 */   510,   64,   64, 1449,  840,  366,  811,  140,  140,  141,
 /*  1020 */   141,   69,   69,   48,   48,  119,  119,   66,   66,  120,
 /*  1030 */   120,  121,  121,  510,  434,  366,  510,  431, 1090,  112,
 /*  1040 */   113,  103, 1092, 1092,  944,  947,  937,  937,  110,  110,
 /*  1050 */   111,  111,  111,  111,  117,  117,  510,  139,  139,  112,
 /*  1060 */   113,  103, 1092, 1092,  944,  947,  937,  937,  110,  110,
 /*  1070 */   111,  111,  111,  111,  305,  427,  116,  138,  138,  510,
 /*  1080 */    86,  510,  131,  475,  510, 1090,  350, 1026,  109,  109,
 /*  1090 */   109,  109,  108,  108,  107,  107,  107,  106,  396,  510,
 /*  1100 */   125,  125,  124,  124,  510,  122,  122,  510,  109,  109,
 /*  1110 */   109,  109,  108,  108,  107,  107,  107,  106,  396,  777,
 /*  1120 */   123,  123,  502,  372,  510,   68,   68,  510,   70,   70,
 /*  1130 */  1089,  510,  286,   14, 1278,  300, 1278,  303,  270,  500,
 /*  1140 */   373,  153,  841,   94,  202,   67,   67,  840,   38,   38,
 /*  1150 */   189,  188,   42,   42, 1278, 1113,  248,  193,  269,  880,
 /*  1160 */   132,  428,   33,  366,  418, 1366,  777,  881,  182,  363,
 /*  1170 */  1022,  289,  908,  352,   88,  227,  422,  424,  294,  227,
 /*  1180 */   227,   88,  446,  366,   19,  223,  903,  112,  113,  103,
 /*  1190 */  1092, 1092,  944,  947,  937,  937,  110,  110,  111,  111,
 /*  1200 */   111,  111,  381,  308,  436,  430,   88,  112,  101,  103,
 /*  1210 */  1092, 1092,  944,  947,  937,  937,  110,  110,  111,  111,
 /*  1220 */   111,  111,  391,  417,  791,  801,  800,  808,  809,  970,
 /*  1230 */   874,  974,  223,  227,  920,  185,  109,  109,  109,  109,
 /*  1240 */   108,  108,  107,  107,  107,  106,  396,  984,  838,  984,
 /*  1250 */   204,   96,  983, 1365,  983,  432,  109,  109,  109,  109,
 /*  1260 */   108,  108,  107,  107,  107,  106,  396,  316,  295,  775,
 /*  1270 */  1228,  791,  130,  299, 1167,  302,  366,  315,  974, 1166,
 /*  1280 */   304,  920,  306,  496, 1180, 1164, 1165,  311,  320,  321,
 /*  1290 */  1240,  267, 1277, 1215, 1226,  495,  366, 1283, 1147, 1140,
 /*  1300 */  1129,  113,  103, 1092, 1092,  944,  947,  937,  937,  110,
 /*  1310 */   110,  111,  111,  111,  111, 1128,  441,  241,  183, 1130,
 /*  1320 */  1212, 1433,  103, 1092, 1092,  944,  947,  937,  937,  110,
 /*  1330 */   110,  111,  111,  111,  111,  349,  323,  325,  327,  288,
 /*  1340 */   426,  191,  187,   99,  501,  409,    4,  499,  314,  109,
 /*  1350 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  396,
 /*  1360 */   504,   13, 1163, 1262,  451, 1340,  281,  329, 1339,  109,
 /*  1370 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  396,
 /*  1380 */  1270,  357, 1436,  397,  230,  342, 1107,  186, 1385, 1383,
 /*  1390 */  1104,  374,  420,   99,  501,  498,    4,  165,   30,   72,
 /*  1400 */    75,  155, 1267,  149,  157,  152,   86, 1259,  412,  160,
 /*  1410 */   504,  413,  161,  162,  924,  163,  444,  207,  356,   31,
 /*  1420 */    97,   97,    8,  354, 1273,  419, 1334,   98,  169,  397,
 /*  1430 */   512,  511,  433,  397,  916,  211,   80,  242, 1354,  439,
 /*  1440 */   297,  213,  174,  301,  442,  498, 1131,  214,  215,  359,
 /*  1450 */   457,  270,  500,  387,  360, 1183,  482, 1182, 1174,  793,
 /*  1460 */  1181,  481,  476, 1154,  924,  916,  916,  918,  919,   25,
 /*  1470 */    97,   97, 1155,  313, 1173, 1153,  265,   98, 1448,  397,
 /*  1480 */   512,  511,  467,  389,  916,  266,  470, 1223,   99,  501,
 /*  1490 */    85,    4, 1224,  229,  480,  489,  332,  331,  322,  181,
 /*  1500 */  1402,   11, 1320,  334,   92,  504,  115,  129,  337,   99,
 /*  1510 */   501,  324,    4, 1222, 1221,  916,  916,  918,  919,   25,
 /*  1520 */  1425, 1060,  399,  326,  328,  253,  504, 1205,  397,  338,
 /*  1530 */   348,  348,  347,  238,  345,   87,  339,  764,  479,  340,
 /*  1540 */   498,  268,  236,  341, 1137,   29, 1066,  237,  513,  397,
 /*  1550 */   198,  482,  276,  240,  514,  239,  483, 1126, 1121,  924,
 /*  1560 */   275,  498,  154,  142, 1370,   97,   97,  368,  369,  143,
 /*  1570 */  1371,  751,   98,  144,  397,  512,  511,  398,  184,  916,
 /*  1580 */   924,  272, 1369, 1368,  128,  197,   97,   97,  845, 1151,
 /*  1590 */   200, 1150,  263,   98,   71,  397,  512,  511,  201, 1148,
 /*  1600 */   916,  146,  402,  126,  982,  980,  900,  156,  199,  203,
 /*  1610 */   916,  916,  918,  919,   25,  145,  158,  825,  996,  206,
 /*  1620 */   287,   99,  501,  164,    4,  147,  376,  904,  378,   76,
 /*  1630 */   166,  916,  916,  918,  919,   25,   77,   78,  504,   79,
 /*  1640 */   148,  999,  367,  208,  209,  995,  137,  270,  500,   20,
 /*  1650 */   210,  296,  227, 1101,  438,  212,  988,  170,  171,   32,
 /*  1660 */   766,  397,  443,  315,  216,  447,  452,  172,   81,   21,
 /*  1670 */   404,  309,   22,  498,   82,  264,  150,  804,  179,   83,
 /*  1680 */   459,  151,  180,  950,  482, 1030,   34,   84, 1031,  481,
 /*  1690 */   466,   35,  924,  192,  469,  245,  247,  873,   97,   97,
 /*  1700 */   175,  226,   96,  868, 1044,   98, 1048,  397,  512,  511,
 /*  1710 */  1060,  399,  916,   23,  253,   10, 1046, 1035,    7,  348,
 /*  1720 */   348,  347,  238,  345,  333,  176,  764,   88,  965,   24,
 /*  1730 */   951,   99,  501,  949,    4,  954,  953, 1005, 1004,  198,
 /*  1740 */   232,  276,  231,  916,  916,  918,  919,   25,  504,  275,
 /*  1750 */    26,   36,  506,  921,  776,  100,  835,  839,   12,  233,
 /*  1760 */   234,   90,  501,  343,    4,  346, 1441, 1440, 1061, 1117,
 /*  1770 */  1117,  397, 1117, 1117, 1117, 1117, 1117, 1117,  504,  200,
 /*  1780 */  1117, 1117, 1117,  498, 1117, 1117, 1117,  201, 1117, 1117,
 /*  1790 */   146, 1117, 1117, 1117, 1117, 1117, 1117,  199, 1117, 1117,
 /*  1800 */  1117,  397,  924, 1117, 1117, 1117, 1117, 1117,   97,   97,
 /*  1810 */  1117, 1117, 1117,  498, 1117,   98, 1117,  397,  512,  511,
 /*  1820 */  1117, 1117,  916, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1830 */  1117,  367,  924, 1117, 1117, 1117,  270,  500,   97,   97,
 /*  1840 */  1117, 1117, 1117, 1117, 1117,   98, 1117,  397,  512,  511,
 /*  1850 */  1117, 1117,  916,  916,  916,  918,  919,   25, 1117,  404,
 /*  1860 */  1117, 1117, 1117,  253, 1117, 1117, 1117, 1117,  348,  348,
 /*  1870 */   347,  238,  345, 1117, 1117,  764, 1117, 1117, 1117, 1117,
 /*  1880 */  1117, 1117, 1117,  916,  916,  918,  919,   25,  198, 1117,
 /*  1890 */   276, 1117, 1117, 1117, 1117, 1117, 1117, 1117,  275, 1117,
 /*  1900 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1910 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1920 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,  200, 1117,
 /*  1930 */  1117, 1117, 1117, 1117, 1117, 1117,  201, 1117, 1117,  146,
 /*  1940 */  1117, 1117, 1117, 1117, 1117, 1117,  199, 1117, 1117, 1117,
 /*  1950 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1960 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1970 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  1980 */   367, 1117, 1117, 1117, 1117,  270,  500, 1117, 1117, 1117,
 /*  1990 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,
 /*  2000 */  1117, 1117, 1117, 1117, 1117, 1117, 1117, 1117,  404,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   163,  163,  184,  238,  239,  240,  182,  182,  155,  156,
 /*    10 */   157,  158,  159,  160,  163,  184,  187,  184,  165,   19,
 /*    20 */   167,  184,  185,  258,  238,  239,  240,  174,  163,  174,
 /*    30 */   187,   31,  191,  192,  163,  184,  185,  202,  203,   39,
 /*    40 */   175,  200,  163,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  174,  206,
 /*    60 */   207,  206,  207,  238,  239,  240,  163,  238,  239,  240,
 /*    70 */    59,  233,  219,  249,  219,  202,  203,  174,  254,  224,
 /*    80 */   225,  238,  239,  240,  163,  232,   73,  184,  185,  163,
 /*    90 */   206,  207,   92,   93,   94,   95,   96,   97,   98,   99,
 /*   100 */   100,  101,  102,  219,  233,  184,  185,   96,   97,  206,
 /*   110 */   207,  274,   19,  276,  261,  104,  105,  106,  107,  198,
 /*   120 */   109,  163,  219,  220,  221,  274,  275,  102,  117,  116,
 /*   130 */   117,  118,   19,  175,  208,   81,   43,   44,   45,   46,
 /*   140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   150 */    57,  197,  141,  195,  143,  197,   43,   44,   45,   46,
 /*   160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   170 */    57,   98,   99,  100,  101,  102,   83,  163,   85,  163,
 /*   180 */    67,  127,  128,  117,  118,   92,   93,   94,   95,   96,
 /*   190 */    97,   98,   99,  100,  101,  102,   19,   54,   55,   56,
 /*   200 */    57,   58,  163,   26,  163,   92,   93,   94,   95,   96,
 /*   210 */    97,   98,   99,  100,  101,  102,   54,   55,   56,   57,
 /*   220 */    43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*   230 */    53,   54,   55,   56,   57,   92,   93,   94,   95,   96,
 /*   240 */    97,   98,   99,  100,  101,  102,   69,   96,   97,   98,
 /*   250 */    99,  100,  101,  102,   92,   93,   94,   95,   96,   97,
 /*   260 */    98,   99,  100,  101,  102,   96,   97,  101,  102,   92,
 /*   270 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*   280 */   108,  267,  268,  111,  112,  113,  163,  163,  163,   19,
 /*   290 */   179,  180,  181,  121,   24,   59,   92,   93,   94,   95,
 /*   300 */    96,   97,   98,   99,  100,  101,  102,  184,  185,  268,
 /*   310 */   141,  163,  143,   43,   44,   45,   46,   47,   48,   49,
 /*   320 */    50,   51,   52,   53,   54,   55,   56,   57,  157,  158,
 /*   330 */   159,  160,   46,   47,   48,   49,  165,   59,  167,  163,
 /*   340 */    90,  105,  106,  107,  108,  174,   73,  111,  112,  113,
 /*   350 */    19,   22,  163,  205,   81,  231,  106,  121,  233,  163,
 /*   360 */   110,   16,   92,   93,   94,   95,   96,   97,   98,   99,
 /*   370 */   100,  101,  102,  184,  185,  163,   98,  206,  207,   26,
 /*   380 */   184,  185,   19,  105,  106,  107,   23,  198,   59,  116,
 /*   390 */   219,  141,  142,  143,  198,   22,  110,  274,  275,  234,
 /*   400 */   127,  128,  123,  232,  125,  126,   43,   44,   45,   46,
 /*   410 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   420 */    57,  158,   77,  160,   79,   59,   53,  163,  165,  163,
 /*   430 */   167,  163,  261,  102,  105,  106,  107,  174,   72,  108,
 /*   440 */   109,  110,  111,  112,  113,  114,   59,  163,  184,  185,
 /*   450 */    22,  120,  163,  206,  207,   92,   93,   94,   95,   96,
 /*   460 */    97,   98,   99,  100,  101,  102,  219,  255,  163,  206,
 /*   470 */   207,  105,  106,  107,  208,   19,  163,   90,  163,   23,
 /*   480 */   127,  128,  219,  183,  220,  221,  163,   59,  163,  184,
 /*   490 */   185,  191,  105,  106,  149,  232,  163,  110,  163,   43,
 /*   500 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   510 */    54,   55,   56,   57,  230,   22,   23,  184,  185,   26,
 /*   520 */   205,  163,  199,   59,  261,  220,  221,  163,  141,  142,
 /*   530 */   143,  198,  174,  105,  106,  107,   72,  269,  163,   59,
 /*   540 */   205,  163,  184,  185,   22,  116,  117,  118,   92,   93,
 /*   550 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  184,
 /*   560 */   185,  163,  184,  185,  206,  207,  163,  163,   19,  105,
 /*   570 */   106,  107,   23,   22,  259,  174,  198,  219,  220,   22,
 /*   580 */   255,   59,  184,  185,   91,  105,  106,  107,  184,  185,
 /*   590 */    22,   23,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   600 */    51,   52,   53,   54,   55,   56,   57,  206,  207,  163,
 /*   610 */    59,   76,  132,  179,  180,  181,   59,  242,  220,  221,
 /*   620 */   219,   86,   12,  163,  220,  221,  163,  105,  106,  107,
 /*   630 */   184,  185,   59,  230,  171,  234,  163,   27,  175,  174,
 /*   640 */    26,   92,   93,   94,   95,   96,   97,   98,   99,  100,
 /*   650 */   101,  102,   42,  163,  163,   59,  105,  106,  107,   91,
 /*   660 */   163,   19,  105,  106,  107,   23,  220,  221,  208,  264,
 /*   670 */   265,  206,  207,   63,  184,  185,   81,  163,  105,  106,
 /*   680 */   107,  184,  185,   73,  219,   43,   44,   45,   46,   47,
 /*   690 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   700 */   163,  105,  106,  107,  109,  132,  163,  226,   22,   23,
 /*   710 */   220,   21,   26,  163,  174,  163,  174,  220,  174,  205,
 /*   720 */    29,  230,  127,  128,   33,   19,   59,  184,  185,  115,
 /*   730 */   180,  181,  180,  181,   92,   93,   94,   95,   96,   97,
 /*   740 */    98,   99,  100,  101,  102,  163,  206,  207,  206,  207,
 /*   750 */   206,  207,   46,  163,   19,   22,   65,   23,   23,  219,
 /*   760 */    26,  219,  174,  219,  163,  163,  184,  185,  174,   22,
 /*   770 */    80,   24,   35,  106,  184,  185,  163,   91,   43,   44,
 /*   780 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
 /*   790 */    55,   56,   57,   12,  206,  207,  163,  247,  163,  247,
 /*   800 */   206,  207,  112,   66,  177,  178,   59,  219,   27,  208,
 /*   810 */   104,   74,  163,  219,  116,  117,  118,  184,  185,  153,
 /*   820 */   154,  163,  163,   42,  163,  163,  120,   92,   93,   94,
 /*   830 */    95,   96,   97,   98,   99,  100,  101,  102,  163,  149,
 /*   840 */   163,  107,  184,  185,   63,  184,  185,   19,  163,  270,
 /*   850 */   163,   23,  273,  106,  205,   11,  119,  255,   46,  184,
 /*   860 */   185,  184,  185,  130,  205,  163,  132,   19,  163,  184,
 /*   870 */   185,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   880 */    52,   53,   54,   55,   56,   57,  184,  185,   26,  184,
 /*   890 */   185,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   900 */    52,   53,   54,   55,   56,   57,  206,  207,    7,    8,
 /*   910 */     9,  163,  146,  163,  148,  163,  104,  163,  231,  219,
 /*   920 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,
 /*   930 */   102,  163,  184,  185,  184,  185,  184,  185,  184,  185,
 /*   940 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,
 /*   950 */   102,  163,  184,  185,  163,  163,  163,  168,  163,  163,
 /*   960 */   163,  117,  118,  163,  237,  163,  237,  163,   26,  107,
 /*   970 */   163,  163,  184,  185,  163,  184,  185,  184,  185,  184,
 /*   980 */   185,  184,  185,   98,  184,  185,  184,  185,  184,  185,
 /*   990 */   163,  184,  185,  207,  132,  147,  163,   19,  163,  272,
 /*  1000 */   163,  272,  163,   24,  163,  219,  163,  199,  163,  124,
 /*  1010 */   163,  184,  185,   23,  129,   19,   26,  184,  185,  184,
 /*  1020 */   185,  184,  185,  184,  185,  184,  185,  184,  185,  184,
 /*  1030 */   185,  184,  185,  163,  245,   19,  163,  248,   59,   43,
 /*  1040 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1050 */    54,   55,   56,   57,  184,  185,  163,  184,  185,   43,
 /*  1060 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1070 */    54,   55,   56,   57,   16,   19,   22,  184,  185,  163,
 /*  1080 */   138,  163,   22,  105,  163,  106,   22,   23,   92,   93,
 /*  1090 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  163,
 /*  1100 */   184,  185,  184,  185,  163,  184,  185,  163,   92,   93,
 /*  1110 */    94,   95,   96,   97,   98,   99,  100,  101,  102,   59,
 /*  1120 */   184,  185,  177,  178,  163,  184,  185,  163,  184,  185,
 /*  1130 */    26,  163,  163,  182,  163,   77,  163,   79,  127,  128,
 /*  1140 */   262,  263,  124,  147,   24,  184,  185,  129,  184,  185,
 /*  1150 */    96,   97,  184,  185,  163,   91,  224,  225,  211,   31,
 /*  1160 */    22,  105,   24,   19,  118,  163,  106,   39,   24,  222,
 /*  1170 */    23,   23,   23,   26,   26,   26,   23,   23,   23,   26,
 /*  1180 */    26,   26,   23,   19,   22,   26,  140,   43,   44,   45,
 /*  1190 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*  1200 */    56,   57,  231,   23,  231,  254,   26,   43,   44,   45,
 /*  1210 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*  1220 */    56,   57,  231,   61,   59,  109,  110,    7,    8,   23,
 /*  1230 */    23,   59,   26,   26,   59,  131,   92,   93,   94,   95,
 /*  1240 */    96,   97,   98,   99,  100,  101,  102,  141,   23,  143,
 /*  1250 */   130,   26,  141,  163,  143,  163,   92,   93,   94,   95,
 /*  1260 */    96,   97,   98,   99,  100,  101,  102,  110,  163,   23,
 /*  1270 */   163,  106,   26,  163,  193,  163,   19,  120,  106,  193,
 /*  1280 */   163,  106,  163,  203,  163,  163,  193,  163,  163,  163,
 /*  1290 */   163,  223,  163,  163,  163,  163,   19,  163,  163,  163,
 /*  1300 */   163,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1310 */    53,   54,   55,   56,   57,  163,  251,  250,  209,  163,
 /*  1320 */   223,  163,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1330 */    53,   54,   55,   56,   57,  161,  223,  223,  223,  256,
 /*  1340 */   256,  196,  182,   19,   20,  227,   22,  244,  187,   92,
 /*  1350 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*  1360 */    36,  210,  192,  213,  188,  187,  227,  227,  187,   92,
 /*  1370 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*  1380 */   213,  213,  166,   59,  130,  212,   60,  210,  170,  170,
 /*  1390 */    38,  170,  104,   19,   20,   71,   22,   22,  235,  257,
 /*  1400 */   257,  260,  236,   43,  201,   81,  138,  213,   18,  204,
 /*  1410 */    36,  170,  204,  204,   90,  204,   18,  169,  236,  235,
 /*  1420 */    96,   97,   48,  213,  201,  213,  213,  103,  201,  105,
 /*  1430 */   106,  107,  170,   59,  110,  169,  146,  170,  253,   62,
 /*  1440 */   252,  169,   22,  170,  189,   71,  170,  169,  169,  189,
 /*  1450 */   104,  127,  128,   64,  189,  186,   82,  186,  194,  115,
 /*  1460 */   186,   87,  133,  188,   90,  141,  142,  143,  144,  145,
 /*  1470 */    96,   97,  186,  186,  194,  186,  246,  103,  186,  105,
 /*  1480 */   106,  107,  189,  102,  110,  246,  189,  229,   19,   20,
 /*  1490 */   104,   22,  229,  170,   84,  134,   22,  271,  228,  217,
 /*  1500 */   269,   22,  241,  170,  146,   36,  137,  152,  217,   19,
 /*  1510 */    20,  228,   22,  229,  229,  141,  142,  143,  144,  145,
 /*  1520 */     0,    1,    2,  228,  228,    5,   36,  218,   59,  216,
 /*  1530 */    10,   11,   12,   13,   14,  136,  215,   17,  135,  214,
 /*  1540 */    71,  243,   25,  213,  173,   26,   13,  164,  172,   59,
 /*  1550 */    30,   82,   32,    6,  162,  164,   87,  162,  162,   90,
 /*  1560 */    40,   71,  263,  176,  182,   96,   97,  266,  266,  176,
 /*  1570 */   182,    4,  103,  176,  105,  106,  107,    3,   22,  110,
 /*  1580 */    90,  151,  182,  182,  190,   15,   96,   97,   98,  182,
 /*  1590 */    70,  182,  190,  103,  182,  105,  106,  107,   78,  182,
 /*  1600 */   110,   81,   89,   16,   23,   23,  128,  139,   88,   24,
 /*  1610 */   141,  142,  143,  144,  145,  119,  131,   20,    1,  133,
 /*  1620 */    16,   19,   20,  131,   22,  119,   61,  140,   37,   53,
 /*  1630 */   139,  141,  142,  143,  144,  145,   53,   53,   36,   53,
 /*  1640 */   119,  105,  122,   34,  130,    1,    5,  127,  128,   22,
 /*  1650 */   104,  149,   26,   75,   41,  130,   68,   68,  104,   24,
 /*  1660 */    20,   59,   19,  120,  114,   67,   67,   22,   22,   22,
 /*  1670 */   150,   23,   22,   71,   22,   67,   37,   28,   23,  138,
 /*  1680 */    22,  153,   23,   23,   82,   23,   22,   26,   23,   87,
 /*  1690 */    24,   22,   90,  130,   24,   23,   23,  105,   96,   97,
 /*  1700 */    22,   34,   26,  132,   85,  103,   75,  105,  106,  107,
 /*  1710 */     1,    2,  110,   34,    5,   34,   83,   23,   44,   10,
 /*  1720 */    11,   12,   13,   14,   24,   26,   17,   26,   23,   34,
 /*  1730 */    23,   19,   20,   23,   22,   11,   23,   23,   23,   30,
 /*  1740 */    22,   32,   26,  141,  142,  143,  144,  145,   36,   40,
 /*  1750 */    22,   22,   26,   23,   23,   22,  124,   23,   22,  130,
 /*  1760 */   130,   19,   20,   23,   22,   15,  130,  130,    1,  277,
 /*  1770 */   277,   59,  277,  277,  277,  277,  277,  277,   36,   70,
 /*  1780 */   277,  277,  277,   71,  277,  277,  277,   78,  277,  277,
 /*  1790 */    81,  277,  277,  277,  277,  277,  277,   88,  277,  277,
 /*  1800 */   277,   59,   90,  277,  277,  277,  277,  277,   96,   97,
 /*  1810 */   277,  277,  277,   71,  277,  103,  277,  105,  106,  107,
 /*  1820 */   277,  277,  110,  277,  277,  277,  277,  277,  277,  277,
 /*  1830 */   277,  122,   90,  277,  277,  277,  127,  128,   96,   97,
 /*  1840 */   277,  277,  277,  277,  277,  103,  277,  105,  106,  107,







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|

|

|
|







|

|
|
|
|

|

|

|
|
|
|

|
|
|
|
|
|
|
|

|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|

|
|
|
|

|

|
|
|
|
|
|
|
|
|

|

|
|


|
|
|
|
|
|
|
|

|

|
|
|
|
|
|
|
|

|
|
|
|

|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







145091
145092
145093
145094
145095
145096
145097
145098
145099
145100
145101
145102
145103
145104
145105
145106
145107
145108
145109
145110
145111
145112
145113
145114
145115
145116
145117
145118
145119
145120
145121
145122
145123
145124
145125
145126
145127
145128
145129
145130
145131
145132
145133
145134
145135
145136
145137
145138
145139
145140
145141
145142
145143
145144
145145
145146
145147
145148
145149
145150
145151
145152
145153
145154
145155
145156
145157
145158
145159
145160
145161
145162
145163
145164
145165
145166
145167
145168
145169
145170
145171
145172
145173
145174
145175
145176
145177
145178
145179
145180
145181
145182
145183
145184
145185
145186
145187
145188
145189
145190
145191
145192
145193
145194
145195
145196
145197
145198
145199
145200
145201
145202
145203
145204
145205
145206
145207
145208
145209
145210
145211
145212
145213
145214
145215
145216
145217
145218
145219
145220
145221
145222
145223
145224
145225
145226
145227
145228
145229
145230
145231
145232
145233
145234
145235
145236
145237
145238
145239
145240
145241
145242
145243
145244
145245
145246
145247
145248
145249
145250
145251
145252
145253
145254
145255
145256
145257
145258
145259
145260
145261
145262
145263
145264
145265
145266
145267
145268
145269
145270
145271
145272
145273
145274
145275
145276
145277
145278
145279
145280
145281
145282
145283
145284
145285
145286
145287
145288
145289
145290
145291
145292
145293
145294
145295
145296
145297
145298
145299
145300
145301
145302
145303
145304
145305
145306
145307
145308
145309
145310
145311
145312
145313
145314
145315
145316
145317
145318
145319
145320
145321
145322
145323
145324
145325
145326
145327
145328
145329
145330
145331
145332
145333
145334
145335
145336
145337
145338
145339
145340
145341
145342
145343
145344
145345
145346
145347
145348
145349
145350
145351
145352
145353
145354
145355
145356
145357
145358
145359
145360
145361
145362
145363
145364
145365
145366
145367
145368
145369
145370
145371
145372
145373
145374
145375
145376
145377
145378
145379
145380
145381
145382
145383
145384
145385
145386
145387
145388
145389
145390
145391
145392
145393
145394
145395
145396
145397
145398
145399
145400
145401
145402
145403
145404
145405
145406
145407
145408
145409
145410
145411
145412
145413
145414
145415
145416
145417
145418
145419
145420
145421
145422
145423
145424
145425
145426
145427
145428
145429
145430
145431
145432
145433
145434
145435
145436
145437
145438
145439
145440
145441
145442
145443
145444
145445
145446
145447
145448
145449
145450
145451
145452
145453
145454
145455
145456
145457
145458
145459
145460
145461
145462
145463
145464
145465
145466
145467
145468
145469
145470
145471
145472
145473
145474
145475
145476
145477
145478
145479
145480
145481
145482
145483
145484
145485
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (2009)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */   365,  105,  102,  197,  105,  102,  197,  512, 1119,    1,
 /*    10 */     1,  517,    2, 1123,  512, 1187, 1166, 1450,  272,  367,
 /*    20 */   127, 1384, 1192, 1192, 1187, 1161,  178, 1200,   64,   64,
 /*    30 */   474,  883,  319,  425,  345,   37,   37,  804,  359,  884,
 /*    40 */   506,  506,  506,  112,  113,  103, 1095, 1095,  949,  952,
 /*    50 */   942,  942,  110,  110,  111,  111,  111,  111,  362,  250,
 /*    60 */   250,  512,  250,  250,  494,  512,  306,  512,  456,  512,
 /*    70 */  1074,  488,  509,  475,    6,  509,  805,  134,  495,  226,
 /*    80 */   194,  425,   37,   37,  512,  206,   64,   64,   64,   64,
 /*    90 */    13,   13,  109,  109,  109,  109,  108,  108,  107,  107,
 /*   100 */   107,  106,  398,  255,  378,   13,   13,  395,  394,  425,
 /*   110 */   250,  250,  367,  473,  402, 1099, 1074, 1075, 1076,  383,
 /*   120 */  1101,  387,  494,  509,  494, 1417, 1413,  301, 1100,  304,
 /*   130 */  1251,  493,  367,  496,   16,   16,  112,  113,  103, 1095,
 /*   140 */  1095,  949,  952,  942,  942,  110,  110,  111,  111,  111,
 /*   150 */   111,  259, 1102,  492, 1102,  398,  112,  113,  103, 1095,
 /*   160 */  1095,  949,  952,  942,  942,  110,  110,  111,  111,  111,
 /*   170 */   111,  129, 1419,  340, 1414,  336, 1054,  489, 1052,  260,
 /*   180 */    73,  105,  102,  197,  990,  109,  109,  109,  109,  108,
 /*   190 */   108,  107,  107,  107,  106,  398,  367,  111,  111,  111,
 /*   200 */   111,  104,  489,   89, 1426,  109,  109,  109,  109,  108,
 /*   210 */   108,  107,  107,  107,  106,  398,  111,  111,  111,  111,
 /*   220 */   112,  113,  103, 1095, 1095,  949,  952,  942,  942,  110,
 /*   230 */   110,  111,  111,  111,  111,  109,  109,  109,  109,  108,
 /*   240 */   108,  107,  107,  107,  106,  398,  114,  108,  108,  107,
 /*   250 */   107,  107,  106,  398,  109,  109,  109,  109,  108,  108,
 /*   260 */   107,  107,  107,  106,  398,  152,  396,  396,  396,  109,
 /*   270 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  398,
 /*   280 */   178,  490, 1406,  431, 1032, 1480, 1074,  512, 1480,  367,
 /*   290 */   418,  294,  354,  409,   74, 1074,  109,  109,  109,  109,
 /*   300 */   108,  108,  107,  107,  107,  106,  398, 1407,   37,   37,
 /*   310 */  1425,  271,  503,  112,  113,  103, 1095, 1095,  949,  952,
 /*   320 */   942,  942,  110,  110,  111,  111,  111,  111, 1430,  517,
 /*   330 */     2, 1123, 1074, 1075, 1076,  427,  272, 1074,  127,  363,
 /*   340 */   929, 1074, 1075, 1076,  218, 1200,  909,  455,  452,  451,
 /*   350 */   389,  167,  512, 1030,  152,  442,  920,  450,  152,  870,
 /*   360 */   919,  286,  109,  109,  109,  109,  108,  108,  107,  107,
 /*   370 */   107,  106,  398,   13,   13,  258,  849,  250,  250,  225,
 /*   380 */   106,  398,  367, 1074, 1075, 1076,  308,  385, 1074,  293,
 /*   390 */   509,  919,  919,  921,  229,  320, 1250, 1383, 1417,  487,
 /*   400 */   271,  503,   12,  206,  271,  503,  112,  113,  103, 1095,
 /*   410 */  1095,  949,  952,  942,  942,  110,  110,  111,  111,  111,
 /*   420 */   111, 1434,  283, 1123,  285, 1074, 1092,  245,  272, 1093,
 /*   430 */   127,  384,  402,  386, 1074, 1075, 1076, 1200,  159,  236,
 /*   440 */   253,  318,  458,  313,  457,  223,  786,  105,  102,  197,
 /*   450 */   510,  311,  838,  838,  442,  109,  109,  109,  109,  108,
 /*   460 */   108,  107,  107,  107,  106,  398,  512,  511,  512,  250,
 /*   470 */   250, 1074, 1075, 1076,  432,  367, 1093,  929, 1454,  790,
 /*   480 */   271,  503,  509,  105,  102,  197,  333,   63,   63,   64,
 /*   490 */    64,   27,  786,  920,  284,  206, 1349,  919,  512,  112,
 /*   500 */   113,  103, 1095, 1095,  949,  952,  942,  942,  110,  110,
 /*   510 */   111,  111,  111,  111,  107,  107,  107,  106,  398,   49,
 /*   520 */    49,  512,   28, 1074,  402,  494,  418,  294,  919,  919,
 /*   530 */   921,  186,  465, 1074,  464,  995,  995,  439,  512, 1074,
 /*   540 */   331,  512,   45,   45, 1078,  339,  173,  168,  109,  109,
 /*   550 */   109,  109,  108,  108,  107,  107,  107,  106,  398,   13,
 /*   560 */    13,  203,   13,   13,  250,  250, 1190, 1190,  367, 1074,
 /*   570 */  1075, 1076,  783,  262,    5,  356,  491,  509,  466, 1074,
 /*   580 */  1075, 1076,  395,  394, 1074, 1074, 1075, 1076,    3,  279,
 /*   590 */  1074, 1078,  112,  113,  103, 1095, 1095,  949,  952,  942,
 /*   600 */   942,  110,  110,  111,  111,  111,  111,  250,  250, 1011,
 /*   610 */   218, 1074,  869,  455,  452,  451,  939,  939,  950,  953,
 /*   620 */   509,  250,  250,  450, 1012, 1074,  442, 1102, 1204, 1102,
 /*   630 */  1074, 1075, 1076,  512,  509,  423, 1074, 1075, 1076, 1013,
 /*   640 */   509,  109,  109,  109,  109,  108,  108,  107,  107,  107,
 /*   650 */   106,  398, 1047,  512,   50,   50,  512, 1074, 1075, 1076,
 /*   660 */   824,  367, 1046,  376,  408, 1059, 1353,  205,  405,  769,
 /*   670 */   825, 1074, 1075, 1076,   64,   64,  319,   64,   64, 1297,
 /*   680 */   943,  408,  407, 1353, 1355,  112,  113,  103, 1095, 1095,
 /*   690 */   949,  952,  942,  942,  110,  110,  111,  111,  111,  111,
 /*   700 */   291,  479,  512, 1032, 1481,  512,  431, 1481,  351, 1115,
 /*   710 */   480,  992,  909,  482,  463,  992,  132,  178,   33,  447,
 /*   720 */  1198,  136,  403,   64,   64,  476,   64,   64,  416,  366,
 /*   730 */   280, 1141,  250,  250,  109,  109,  109,  109,  108,  108,
 /*   740 */   107,  107,  107,  106,  398,  509,  222,  437,  408,  263,
 /*   750 */  1353,  263,  250,  250,  367,  293,  413,  281,  930,  393,
 /*   760 */   972,  467,  397,  250,  250,  509,    9,  470,  229,  497,
 /*   770 */   351, 1031, 1030, 1482,  352,  371,  509, 1116,  112,  113,
 /*   780 */   103, 1095, 1095,  949,  952,  942,  942,  110,  110,  111,
 /*   790 */   111,  111,  111,  250,  250, 1011,  512, 1342,  292,  250,
 /*   800 */   250,  250,  250, 1093,  372,  247,  509,  442,  868,  319,
 /*   810 */  1012,  477,  509,  195,  509,  431,  270,   15,   15,  512,
 /*   820 */   311,  512,   95,  512,   93, 1013,  364,  109,  109,  109,
 /*   830 */   109,  108,  108,  107,  107,  107,  106,  398,  512, 1116,
 /*   840 */    39,   39,   51,   51,   52,   52,  500,  367,  512, 1199,
 /*   850 */  1093,  914,  436,  338,  133,  433,  221,  220,  219,   53,
 /*   860 */    53,  319, 1392,  757,  758,  759,  512,  367,   88,   54,
 /*   870 */    54,  112,  113,  103, 1095, 1095,  949,  952,  942,  942,
 /*   880 */   110,  110,  111,  111,  111,  111,  274,   55,   55,  196,
 /*   890 */   512,  112,  113,  103, 1095, 1095,  949,  952,  942,  942,
 /*   900 */   110,  110,  111,  111,  111,  111,  135,  261, 1144,  373,
 /*   910 */   512,   40,   40,  512,  868,  512,  989,  512,  989,  116,
 /*   920 */   109,  109,  109,  109,  108,  108,  107,  107,  107,  106,
 /*   930 */   398,   41,   41,  512,   43,   43,   44,   44,   56,   56,
 /*   940 */   109,  109,  109,  109,  108,  108,  107,  107,  107,  106,
 /*   950 */   398,  512,  376,  512,   57,   57,  512,  795,  512,  376,
 /*   960 */   512,  442,  793,  512,  320,  512,  275,  512, 1453,  512,
 /*   970 */  1282,  813,   58,   58,   14,   14,  512,   59,   59,  118,
 /*   980 */   118,   60,   60,  512,   46,   46,   61,   61,   62,   62,
 /*   990 */    47,   47,  512,  190,  189,   91,  512,  140,  140,  512,
 /*  1000 */   391,  512,  844, 1195,  141,  141,  512,  843,  512,  793,
 /*  1010 */   512,  410,  512,   69,   69,  367,  278,   48,   48,  256,
 /*  1020 */    65,   65,  119,  119,  244,  244,  257,   66,   66,  120,
 /*  1030 */   120,  121,  121,  117,  117,  367,  512,  509,  380,  112,
 /*  1040 */   113,  103, 1095, 1095,  949,  952,  942,  942,  110,  110,
 /*  1050 */   111,  111,  111,  111,  512,  868,  512,  139,  139,  112,
 /*  1060 */   113,  103, 1095, 1095,  949,  952,  942,  942,  110,  110,
 /*  1070 */   111,  111,  111,  111, 1282,  138,  138,  125,  125,  512,
 /*  1080 */    12,  512, 1351, 1282,  512,  442,  131, 1282,  109,  109,
 /*  1090 */   109,  109,  108,  108,  107,  107,  107,  106,  398,  512,
 /*  1100 */   124,  124,  122,  122,  512,  123,  123,  512,  109,  109,
 /*  1110 */   109,  109,  108,  108,  107,  107,  107,  106,  398,  512,
 /*  1120 */    68,   68,  460,  779,  512,   70,   70,  299,   67,   67,
 /*  1130 */  1027,  251,  251,  353, 1282,  191,  196, 1427,  462, 1296,
 /*  1140 */    38,   38,  381,   94,  509,   42,   42,  177,  844,  271,
 /*  1150 */   503,  382,  417,  843,  420,  438,  505,  373,  374,  153,
 /*  1160 */   252,  868,  429,  367,  222,  249,  194,  883,  182,  290,
 /*  1170 */   779,  988,   88,  988,  463,  884,  906,  911,  424,  426,
 /*  1180 */   228,  228,  228,  367,   17,  803,  802,  112,  113,  103,
 /*  1190 */  1095, 1095,  949,  952,  942,  942,  110,  110,  111,  111,
 /*  1200 */   111,  111,  392,  295,  810,  811,   88,  112,  101,  103,
 /*  1210 */  1095, 1095,  949,  952,  942,  942,  110,  110,  111,  111,
 /*  1220 */   111,  111,  372,  419,  448,  309,  979,  224,   88,  975,
 /*  1230 */   877,  841,  224,  228,  100,  923,  109,  109,  109,  109,
 /*  1240 */   108,  108,  107,  107,  107,  106,  398,   86,  430,  777,
 /*  1250 */   842, 1236,  130,  100, 1235,  412,  109,  109,  109,  109,
 /*  1260 */   108,  108,  107,  107,  107,  106,  398,  317, 1443, 1397,
 /*  1270 */  1170,  287, 1169,  979, 1372, 1371,  367,  316,  434,  296,
 /*  1280 */  1232, 1223,  923,  300,  303,  305,  307, 1183, 1168, 1167,
 /*  1290 */   312,  321,  322, 1244, 1281, 1219,  367,  268, 1230,  499,
 /*  1300 */   498,  113,  103, 1095, 1095,  949,  952,  942,  942,  110,
 /*  1310 */   110,  111,  111,  111,  111, 1287, 1150,  443,  242,  184,
 /*  1320 */  1216, 1143,  103, 1095, 1095,  949,  952,  942,  942,  110,
 /*  1330 */   110,  111,  111,  111,  111, 1132, 1131, 1133, 1437,  350,
 /*  1340 */   411,  324,  188,   98,  504,  289,    4,  326,  315,  109,
 /*  1350 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  398,
 /*  1360 */   507,  328, 1266, 1274,  358,  453,  282,  192, 1346,  109,
 /*  1370 */   109,  109,  109,  108,  108,  107,  107,  107,  106,  398,
 /*  1380 */    11, 1166, 1345,  399, 1440,  330,  502, 1110,  231,  428,
 /*  1390 */  1391,  343,  187,   98,  504,  501,    4, 1107, 1389,  375,
 /*  1400 */   422,  155,   72,  165,   75,  152,  149,   86,  414, 1263,
 /*  1410 */   507,  157,  415,  160,  929,  161,  162,  163,  446, 1271,
 /*  1420 */    96,   96,    8,   30,  208, 1277,  357,   97,  355,  399,
 /*  1430 */   514,  513,  421,  399,  919,   31,  169,  435, 1340,  212,
 /*  1440 */    80,  441,  243,  214, 1360,  501,  298,  174,  444,  302,
 /*  1450 */   215,  271,  503, 1134,  216,  360,  485,  459,  388, 1186,
 /*  1460 */   361,  484, 1185,  795,  929,  919,  919,  921,  922,   24,
 /*  1470 */    96,   96, 1184, 1158, 1177,  314, 1157,   97, 1176,  399,
 /*  1480 */   514,  513,  469, 1156,  919, 1452,  390,  266,   98,  504,
 /*  1490 */   267,    4,  472,  478,  483,   85, 1227,  333,  230,  492,
 /*  1500 */  1408,  332,  323,  115,   10,  507, 1228,  181,  335,   98,
 /*  1510 */   504,  337,    4,   92,   87,  919,  919,  921,  922,   24,
 /*  1520 */  1429, 1063,  401, 1226,  481,  254,  507,  325,  399,  327,
 /*  1530 */   349,  349,  348,  239,  346, 1225,  329,  766, 1209, 1326,
 /*  1540 */   501,  183, 1208,  341,  269,  342,  237, 1069, 1140,  399,
 /*  1550 */   199,  485,  277,   29,  515,  241,  486,  238,  516,  929,
 /*  1560 */   276,  501,  240, 1129, 1124,   96,   96, 1376,  142,  154,
 /*  1570 */   369,  370,   97,  143,  399,  514,  513, 1377,  128,  919,
 /*  1580 */   929, 1375,  144,  753,  400, 1374,   96,   96,  848, 1154,
 /*  1590 */   201, 1153,  185,   97,  264,  399,  514,  513,  202,   71,
 /*  1600 */   919,  146, 1151,  273,  198,  404,  126,  987,  200,  985,
 /*  1610 */   919,  919,  921,  922,   24,  903,  156,  145,  204,  158,
 /*  1620 */   827,   98,  504,  288,    4,  207, 1001,  164,  147,  907,
 /*  1630 */   377,  919,  919,  921,  922,   24,  379,  148,  507,  166,
 /*  1640 */    76,   77,  368, 1004,   78,   79,  209,  271,  503,  210,
 /*  1650 */  1000,  137,   18,  297,  211,  228,  440, 1104,  213,  171,
 /*  1660 */    32,  399,  768,  993,  170,  316,  445,  217,  449,  806,
 /*  1670 */   406,  310,  172,  501,   81,   19,   20,  454,   82,   83,
 /*  1680 */   265,  150,  179,  461,  485,  151,  180,  955,   84,  484,
 /*  1690 */  1035,   34,  929,   35,  468, 1036,  193,  471,   96,   96,
 /*  1700 */   246,  248,  876,  175,  871,   97,  100,  399,  514,  513,
 /*  1710 */  1063,  401,  919,  227,  254, 1053,   21,   22, 1049,  349,
 /*  1720 */   349,  348,  239,  346, 1040,  176,  766,  334, 1051,    7,
 /*  1730 */    88,   98,  504,  970,    4,  233,   23,  956,  954,  199,
 /*  1740 */   958,  277, 1010,  919,  919,  921,  922,   24,  507,  276,
 /*  1750 */   232, 1009,  959,   25,   36,  508,  924,  778,   99,   26,
 /*  1760 */   347,   90,  504,  837,    4,  234,  344,  235, 1445, 1064,
 /*  1770 */  1120,  399, 1120, 1444, 1120, 1120, 1120, 1120,  507,  201,
 /*  1780 */  1120, 1120, 1120,  501, 1120, 1120, 1120,  202, 1120, 1120,
 /*  1790 */   146, 1120, 1120, 1120, 1120, 1120, 1120,  200, 1120, 1120,
 /*  1800 */  1120,  399,  929, 1120, 1120, 1120, 1120, 1120,   96,   96,
 /*  1810 */  1120, 1120, 1120,  501, 1120,   97, 1120,  399,  514,  513,
 /*  1820 */  1120, 1120,  919, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1830 */  1120,  368,  929, 1120, 1120, 1120,  271,  503,   96,   96,
 /*  1840 */  1120, 1120, 1120, 1120, 1120,   97, 1120,  399,  514,  513,
 /*  1850 */  1120, 1120,  919,  919,  919,  921,  922,   24, 1120,  406,
 /*  1860 */  1120, 1120, 1120,  254, 1120, 1120, 1120, 1120,  349,  349,
 /*  1870 */   348,  239,  346, 1120, 1120,  766, 1120, 1120, 1120, 1120,
 /*  1880 */  1120, 1120, 1120,  919,  919,  921,  922,   24,  199, 1120,
 /*  1890 */   277, 1120, 1120, 1120, 1120, 1120, 1120, 1120,  276, 1120,
 /*  1900 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1910 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1920 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,  201, 1120,
 /*  1930 */  1120, 1120, 1120, 1120, 1120, 1120,  202, 1120, 1120,  146,
 /*  1940 */  1120, 1120, 1120, 1120, 1120, 1120,  200, 1120, 1120, 1120,
 /*  1950 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1960 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1970 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  1980 */   368, 1120, 1120, 1120, 1120,  271,  503, 1120, 1120, 1120,
 /*  1990 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
 /*  2000 */  1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,  406,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   184,  238,  239,  240,  238,  239,  240,  163,  155,  156,
 /*    10 */   157,  158,  159,  160,  163,  191,  192,  183,  165,   19,
 /*    20 */   167,  258,  202,  203,  200,  191,  163,  174,  184,  185,
 /*    30 */   174,   31,  163,  163,  171,  184,  185,   35,  175,   39,
 /*    40 */   179,  180,  181,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  184,  206,
 /*    60 */   207,  163,  206,  207,  220,  163,   16,  163,   66,  163,
 /*    70 */    59,  270,  219,  229,  273,  219,   74,  208,  174,  223,
 /*    80 */   224,  163,  184,  185,  163,  232,  184,  185,  184,  185,
 /*    90 */   184,  185,   92,   93,   94,   95,   96,   97,   98,   99,
 /*   100 */   100,  101,  102,  233,  198,  184,  185,   96,   97,  163,
 /*   110 */   206,  207,   19,  163,  261,  104,  105,  106,  107,  198,
 /*   120 */   109,  119,  220,  219,  220,  274,  275,   77,  117,   79,
 /*   130 */   187,  229,   19,  229,  184,  185,   43,   44,   45,   46,
 /*   140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   150 */    57,  233,  141,  134,  143,  102,   43,   44,   45,   46,
 /*   160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   170 */    57,  152,  274,  216,  276,  218,   83,  163,   85,  233,
 /*   180 */    67,  238,  239,  240,   11,   92,   93,   94,   95,   96,
 /*   190 */    97,   98,   99,  100,  101,  102,   19,   54,   55,   56,
 /*   200 */    57,   58,  163,   26,  163,   92,   93,   94,   95,   96,
 /*   210 */    97,   98,   99,  100,  101,  102,   54,   55,   56,   57,
 /*   220 */    43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*   230 */    53,   54,   55,   56,   57,   92,   93,   94,   95,   96,
 /*   240 */    97,   98,   99,  100,  101,  102,   69,   96,   97,   98,
 /*   250 */    99,  100,  101,  102,   92,   93,   94,   95,   96,   97,
 /*   260 */    98,   99,  100,  101,  102,   81,  179,  180,  181,   92,
 /*   270 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*   280 */   163,  267,  268,  163,   22,   23,   59,  163,   26,   19,
 /*   290 */   117,  118,  175,  109,   24,   59,   92,   93,   94,   95,
 /*   300 */    96,   97,   98,   99,  100,  101,  102,  268,  184,  185,
 /*   310 */   269,  127,  128,   43,   44,   45,   46,   47,   48,   49,
 /*   320 */    50,   51,   52,   53,   54,   55,   56,   57,  157,  158,
 /*   330 */   159,  160,  105,  106,  107,  163,  165,   59,  167,  184,
 /*   340 */    90,  105,  106,  107,  108,  174,   73,  111,  112,  113,
 /*   350 */    19,   22,  163,   91,   81,  163,  106,  121,   81,  132,
 /*   360 */   110,   16,   92,   93,   94,   95,   96,   97,   98,   99,
 /*   370 */   100,  101,  102,  184,  185,  255,   98,  206,  207,   26,
 /*   380 */   101,  102,   19,  105,  106,  107,   23,  198,   59,  116,
 /*   390 */   219,  141,  142,  143,   24,  163,  187,  205,  274,  275,
 /*   400 */   127,  128,  182,  232,  127,  128,   43,   44,   45,   46,
 /*   410 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   420 */    57,  158,   77,  160,   79,   59,   26,  182,  165,   59,
 /*   430 */   167,  199,  261,  102,  105,  106,  107,  174,   72,  108,
 /*   440 */   109,  110,  111,  112,  113,  114,   59,  238,  239,  240,
 /*   450 */   123,  120,  125,  126,  163,   92,   93,   94,   95,   96,
 /*   460 */    97,   98,   99,  100,  101,  102,  163,  163,  163,  206,
 /*   470 */   207,  105,  106,  107,  254,   19,  106,   90,  197,   23,
 /*   480 */   127,  128,  219,  238,  239,  240,   22,  184,  185,  184,
 /*   490 */   185,   22,  105,  106,  149,  232,  205,  110,  163,   43,
 /*   500 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   510 */    54,   55,   56,   57,   98,   99,  100,  101,  102,  184,
 /*   520 */   185,  163,   53,   59,  261,  220,  117,  118,  141,  142,
 /*   530 */   143,  131,  174,   59,  229,  116,  117,  118,  163,   59,
 /*   540 */   163,  163,  184,  185,   59,  242,   72,   22,   92,   93,
 /*   550 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  184,
 /*   560 */   185,   24,  184,  185,  206,  207,  202,  203,   19,  105,
 /*   570 */   106,  107,   23,  198,   22,  174,  198,  219,  220,  105,
 /*   580 */   106,  107,   96,   97,   59,  105,  106,  107,   22,  174,
 /*   590 */    59,  106,   43,   44,   45,   46,   47,   48,   49,   50,
 /*   600 */    51,   52,   53,   54,   55,   56,   57,  206,  207,   12,
 /*   610 */   108,   59,  132,  111,  112,  113,   46,   47,   48,   49,
 /*   620 */   219,  206,  207,  121,   27,   59,  163,  141,  207,  143,
 /*   630 */   105,  106,  107,  163,  219,  234,  105,  106,  107,   42,
 /*   640 */   219,   92,   93,   94,   95,   96,   97,   98,   99,  100,
 /*   650 */   101,  102,   76,  163,  184,  185,  163,  105,  106,  107,
 /*   660 */    63,   19,   86,  163,  163,   23,  163,  130,  205,   21,
 /*   670 */    73,  105,  106,  107,  184,  185,  163,  184,  185,  237,
 /*   680 */   110,  180,  181,  180,  181,   43,   44,   45,   46,   47,
 /*   690 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   700 */   174,  163,  163,   22,   23,  163,  163,   26,   22,   23,
 /*   710 */   220,   29,   73,  220,  272,   33,   22,  163,   24,   19,
 /*   720 */   174,  208,  259,  184,  185,   19,  184,  185,   80,  175,
 /*   730 */   230,  174,  206,  207,   92,   93,   94,   95,   96,   97,
 /*   740 */    98,   99,  100,  101,  102,  219,   46,   65,  247,  195,
 /*   750 */   247,  197,  206,  207,   19,  116,  117,  118,   23,  220,
 /*   760 */   112,  174,  220,  206,  207,  219,   22,  174,   24,  174,
 /*   770 */    22,   23,   91,  264,  265,  168,  219,   91,   43,   44,
 /*   780 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
 /*   790 */    55,   56,   57,  206,  207,   12,  163,  149,  255,  206,
 /*   800 */   207,  206,  207,   59,  104,   23,  219,  163,   26,  163,
 /*   810 */    27,  105,  219,  163,  219,  163,  211,  184,  185,  163,
 /*   820 */   120,  163,  146,  163,  148,   42,  221,   92,   93,   94,
 /*   830 */    95,   96,   97,   98,   99,  100,  101,  102,  163,   91,
 /*   840 */   184,  185,  184,  185,  184,  185,   63,   19,  163,  205,
 /*   850 */   106,   23,  245,  163,  208,  248,  116,  117,  118,  184,
 /*   860 */   185,  163,  163,    7,    8,    9,  163,   19,   26,  184,
 /*   870 */   185,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   880 */    52,   53,   54,   55,   56,   57,  163,  184,  185,  107,
 /*   890 */   163,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   900 */    52,   53,   54,   55,   56,   57,  208,  255,  177,  178,
 /*   910 */   163,  184,  185,  163,  132,  163,  141,  163,  143,   22,
 /*   920 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,
 /*   930 */   102,  184,  185,  163,  184,  185,  184,  185,  184,  185,
 /*   940 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,
 /*   950 */   102,  163,  163,  163,  184,  185,  163,  115,  163,  163,
 /*   960 */   163,  163,   59,  163,  163,  163,  163,  163,   23,  163,
 /*   970 */   163,   26,  184,  185,  184,  185,  163,  184,  185,  184,
 /*   980 */   185,  184,  185,  163,  184,  185,  184,  185,  184,  185,
 /*   990 */   184,  185,  163,   96,   97,  147,  163,  184,  185,  163,
 /*  1000 */   199,  163,  124,  205,  184,  185,  163,  129,  163,  106,
 /*  1010 */   163,  234,  163,  184,  185,   19,  163,  184,  185,  230,
 /*  1020 */   184,  185,  184,  185,  206,  207,  230,  184,  185,  184,
 /*  1030 */   185,  184,  185,  184,  185,   19,  163,  219,  231,   43,
 /*  1040 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1050 */    54,   55,   56,   57,  163,   26,  163,  184,  185,   43,
 /*  1060 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*  1070 */    54,   55,   56,   57,  163,  184,  185,  184,  185,  163,
 /*  1080 */   182,  163,  163,  163,  163,  163,   22,  163,   92,   93,
 /*  1090 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  163,
 /*  1100 */   184,  185,  184,  185,  163,  184,  185,  163,   92,   93,
 /*  1110 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  163,
 /*  1120 */   184,  185,   98,   59,  163,  184,  185,  205,  184,  185,
 /*  1130 */    23,  206,  207,   26,  163,   26,  107,  153,  154,  237,
 /*  1140 */   184,  185,  231,  147,  219,  184,  185,  249,  124,  127,
 /*  1150 */   128,  231,  254,  129,  118,  231,  177,  178,  262,  263,
 /*  1160 */    22,  132,   19,   19,   46,  223,  224,   31,   24,   23,
 /*  1170 */   106,  141,   26,  143,  272,   39,  140,   23,   23,   23,
 /*  1180 */    26,   26,   26,   19,   22,  109,  110,   43,   44,   45,
 /*  1190 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*  1200 */    56,   57,  231,   23,    7,    8,   26,   43,   44,   45,
 /*  1210 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*  1220 */    56,   57,  104,   61,   23,   23,   59,   26,   26,   23,
 /*  1230 */    23,   23,   26,   26,   26,   59,   92,   93,   94,   95,
 /*  1240 */    96,   97,   98,   99,  100,  101,  102,  138,  105,   23,
 /*  1250 */    23,  163,   26,   26,  163,  163,   92,   93,   94,   95,
 /*  1260 */    96,   97,   98,   99,  100,  101,  102,  110,  130,  163,
 /*  1270 */   193,  163,  193,  106,  163,  163,   19,  120,  163,  163,
 /*  1280 */   163,  225,  106,  163,  163,  163,  163,  163,  193,  163,
 /*  1290 */   163,  163,  163,  163,  163,  163,   19,  222,  163,  203,
 /*  1300 */   163,   44,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1310 */    53,   54,   55,   56,   57,  163,  163,  251,  250,  209,
 /*  1320 */   222,  163,   45,   46,   47,   48,   49,   50,   51,   52,
 /*  1330 */    53,   54,   55,   56,   57,  163,  163,  163,  163,  161,
 /*  1340 */   226,  222,  182,   19,   20,  256,   22,  222,  187,   92,
 /*  1350 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*  1360 */    36,  222,  213,  213,  213,  188,  226,  196,  187,   92,
 /*  1370 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
 /*  1380 */   210,  192,  187,   59,  166,  226,  244,   60,  130,  256,
 /*  1390 */   170,  212,  210,   19,   20,   71,   22,   38,  170,  170,
 /*  1400 */   104,  260,  257,   22,  257,   81,   43,  138,   18,  213,
 /*  1410 */    36,  201,  170,  204,   90,  204,  204,  204,   18,  236,
 /*  1420 */    96,   97,   48,  235,  169,  201,  236,  103,  213,  105,
 /*  1430 */   106,  107,  213,   59,  110,  235,  201,  170,  213,  169,
 /*  1440 */   146,   62,  170,  169,  253,   71,  252,   22,  189,  170,
 /*  1450 */   169,  127,  128,  170,  169,  189,   82,  104,   64,  186,
 /*  1460 */   189,   87,  186,  115,   90,  141,  142,  143,  144,  145,
 /*  1470 */    96,   97,  186,  186,  194,  186,  188,  103,  194,  105,
 /*  1480 */   106,  107,  189,  186,  110,  186,  102,  246,   19,   20,
 /*  1490 */   246,   22,  189,  133,   84,  104,  228,   22,  170,  134,
 /*  1500 */   269,  271,  227,  137,   22,   36,  228,  216,  216,   19,
 /*  1510 */    20,  170,   22,  146,  136,  141,  142,  143,  144,  145,
 /*  1520 */     0,    1,    2,  228,  135,    5,   36,  227,   59,  227,
 /*  1530 */    10,   11,   12,   13,   14,  228,  227,   17,  217,  241,
 /*  1540 */    71,  215,  217,  214,  243,  213,   25,   13,  173,   59,
 /*  1550 */    30,   82,   32,   26,  172,    6,   87,  164,  162,   90,
 /*  1560 */    40,   71,  164,  162,  162,   96,   97,  182,  176,  263,
 /*  1570 */   266,  266,  103,  176,  105,  106,  107,  182,  190,  110,
 /*  1580 */    90,  182,  176,    4,    3,  182,   96,   97,   98,  182,
 /*  1590 */    70,  182,   22,  103,  190,  105,  106,  107,   78,  182,
 /*  1600 */   110,   81,  182,  151,   15,   89,   16,   23,   88,   23,
 /*  1610 */   141,  142,  143,  144,  145,  128,  139,  119,   24,  131,
 /*  1620 */    20,   19,   20,   16,   22,  133,    1,  131,  119,  140,
 /*  1630 */    61,  141,  142,  143,  144,  145,   37,  119,   36,  139,
 /*  1640 */    53,   53,  122,  105,   53,   53,   34,  127,  128,  130,
 /*  1650 */     1,    5,   22,  149,  104,   26,   41,   75,  130,  104,
 /*  1660 */    24,   59,   20,   68,   68,  120,   19,  114,   67,   28,
 /*  1670 */   150,   23,   22,   71,   22,   22,   22,   67,   22,  138,
 /*  1680 */    67,   37,   23,   22,   82,  153,   23,   23,   26,   87,
 /*  1690 */    23,   22,   90,   22,   24,   23,  130,   24,   96,   97,
 /*  1700 */    23,   23,  105,   22,  132,  103,   26,  105,  106,  107,
 /*  1710 */     1,    2,  110,   34,    5,   75,   34,   34,   85,   10,
 /*  1720 */    11,   12,   13,   14,   23,   26,   17,   24,   83,   44,
 /*  1730 */    26,   19,   20,   23,   22,   22,   34,   23,   23,   30,
 /*  1740 */    23,   32,   23,  141,  142,  143,  144,  145,   36,   40,
 /*  1750 */    26,   23,   11,   22,   22,   26,   23,   23,   22,   22,
 /*  1760 */    15,   19,   20,  124,   22,  130,   23,  130,  130,    1,
 /*  1770 */   277,   59,  277,  130,  277,  277,  277,  277,   36,   70,
 /*  1780 */   277,  277,  277,   71,  277,  277,  277,   78,  277,  277,
 /*  1790 */    81,  277,  277,  277,  277,  277,  277,   88,  277,  277,
 /*  1800 */   277,   59,   90,  277,  277,  277,  277,  277,   96,   97,
 /*  1810 */   277,  277,  277,   71,  277,  103,  277,  105,  106,  107,
 /*  1820 */   277,  277,  110,  277,  277,  277,  277,  277,  277,  277,
 /*  1830 */   277,  122,   90,  277,  277,  277,  127,  128,   96,   97,
 /*  1840 */   277,  277,  277,  277,  277,  103,  277,  105,  106,  107,
145578
145579
145580
145581
145582
145583
145584
145585
145586
145587
145588
145589
145590
145591
145592
145593
145594
145595
145596
145597
145598
145599
145600
145601
145602
145603
145604
145605
145606
145607
145608
145609
145610
145611
145612
145613
145614
145615
145616
145617
145618
145619
145620
145621
145622
145623
145624
145625
145626
145627
145628
145629
145630
145631
145632
145633
145634
145635
145636
145637
145638
145639
145640
145641
145642
145643
145644
145645
145646
145647
145648
145649
145650
145651
145652
145653
145654
145655
145656
145657
145658
145659
145660
145661
145662
145663
145664
145665
145666
145667
145668
145669
145670
145671
145672
145673
145674
145675
145676
145677
145678
145679
145680
145681
145682
145683
145684
145685
145686
145687
145688
145689
145690
145691
145692
145693
145694
145695
145696
145697
145698
145699
145700
145701
145702
145703
145704
145705
145706
145707
145708
145709
145710
145711
145712
145713
145714
145715
145716
145717
145718
145719
145720
145721
145722
145723
145724
145725
145726
145727
145728
145729
145730
145731
145732
145733
145734
145735
145736
145737
145738
145739
145740
145741
145742
145743
 /*  1960 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  1970 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  1980 */   122,  277,  277,  277,  277,  127,  128,  277,  277,  277,
 /*  1990 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  2000 */   277,  277,  277,  277,  277,  277,  277,  277,  150,  277,
 /*  2010 */   277,  277,  277,  277,  277,  277,  277,  277,  277,
};
#define YY_SHIFT_COUNT    (515)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (1858)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */  1709, 1520, 1858, 1324, 1324,   54, 1374, 1469, 1602, 1712,
 /*    10 */  1712, 1712, 1712, 1712,  273,    0,    0,  113, 1016, 1712,
 /*    20 */  1712, 1712, 1712, 1712, 1712, 1712, 1712,   11,   11,  236,
 /*    30 */   595,   54,   54,   54,   54,   54,   54,   93,  177,  270,
 /*    40 */   363,  456,  549,  642,  735,  828,  848,  996, 1144, 1016,
 /*    50 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    60 */  1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257, 1277,
 /*    70 */  1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*    80 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*    90 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*   100 */  1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712, 1712, 1712,
 /*   110 */  1712, 1712, 1712, 1712, 1712, 1712, 1712,  143,  162,  162,
 /*   120 */   162,  162,  162,  204,  151,   73,  596,  690,  706,  596,
 /*   130 */   169,  169,  596,  353,  353,  353,  353,   66,  166,   25,
 /*   140 */  2009, 2009,  331,  331,  331,  329,  366,  329,  329,  610,
 /*   150 */   610,  428,  464,  493,  686,  596,  596,  596,  596,  596,
 /*   160 */   596,  596,  596,  596,  596,  596,  596,  596,  596,  596,
 /*   170 */   596,  596,  596,  596,  596,  596,  596,  844,  667,  666,
 /*   180 */   666,  535,  667, 1011, 2009, 2009, 2009,  387,  250,  250,
 /*   190 */   522,  172,  278,  551,  480,  573,  557,  596,  596,  596,
 /*   200 */   596,  596,  596,  596,  596,   13,  596,  596,  596,  596,
 /*   210 */   596,  596,  596,  596,  596,  596,  596,  596,  737,  737,
 /*   220 */   737,  596,  596,  596,  596,  734,  596,  596,  596,  747,
 /*   230 */   596,  596,  781,  596,  596,  596,  596,  596,  596,  596,
 /*   240 */   596,  429,  691,  279,  979,  979,  979,  979,  862,  279,
 /*   250 */   279,  885, 1054,  901,  942,  978,  978, 1056,  942,  942,
 /*   260 */  1056,  614,  990,  812, 1128, 1128, 1128,  978,  766, 1104,
 /*   270 */  1018, 1138, 1326, 1254, 1254, 1352, 1352, 1254, 1288, 1375,
 /*   280 */  1360, 1268, 1390, 1390, 1390, 1390, 1254, 1398, 1268, 1268,
 /*   290 */  1288, 1375, 1360, 1360, 1268, 1254, 1398, 1290, 1377, 1254,
 /*   300 */  1398, 1420, 1254, 1398, 1254, 1398, 1420, 1346, 1346, 1346,
 /*   310 */  1389, 1420, 1346, 1344, 1346, 1389, 1346, 1346, 1420, 1381,
 /*   320 */  1381, 1420, 1329, 1386, 1329, 1386, 1329, 1386, 1329, 1386,
 /*   330 */  1254, 1361, 1410, 1474, 1479, 1254, 1358, 1369, 1361, 1355,
 /*   340 */  1399, 1403, 1268, 1517, 1519, 1533, 1533, 1547, 1547, 1547,
 /*   350 */  2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
 /*   360 */  2009, 2009, 2009, 2009, 2009, 2009,  286,  345,  568, 1064,
 /*   370 */  1058,  698, 1060, 1147,  373, 1120, 1046, 1148, 1162, 1149,
 /*   380 */  1153, 1154, 1155, 1159, 1180, 1165, 1116, 1220, 1157, 1172,
 /*   390 */  1206, 1207, 1225, 1106, 1111, 1246, 1175,  733, 1567, 1574,
 /*   400 */  1556, 1430, 1570, 1513, 1587, 1581, 1582, 1478, 1468, 1496,
 /*   410 */  1585, 1485, 1597, 1486, 1604, 1617, 1492, 1487, 1506, 1565,
 /*   420 */  1591, 1491, 1576, 1583, 1584, 1586, 1521, 1536, 1609, 1514,
 /*   430 */  1644, 1641, 1627, 1546, 1502, 1588, 1626, 1589, 1578, 1613,
 /*   440 */  1525, 1554, 1635, 1640, 1643, 1543, 1550, 1645, 1598, 1646,
 /*   450 */  1647, 1648, 1650, 1599, 1649, 1652, 1608, 1639, 1655, 1541,
 /*   460 */  1658, 1528, 1659, 1660, 1661, 1662, 1664, 1666, 1665, 1669,
 /*   470 */  1670, 1563, 1672, 1673, 1592, 1667, 1678, 1571, 1676, 1679,
 /*   480 */  1681, 1619, 1631, 1633, 1674, 1694, 1700, 1699, 1701, 1695,
 /*   490 */  1705, 1707, 1710, 1676, 1713, 1714, 1716, 1715, 1718, 1724,
 /*   500 */  1728, 1729, 1730, 1731, 1733, 1734, 1736, 1726, 1632, 1629,
 /*   510 */  1630, 1636, 1637, 1740, 1750, 1767,
};
#define YY_REDUCE_COUNT (365)
#define YY_REDUCE_MIN   (-235)
#define YY_REDUCE_MAX   (1417)
static const short yy_reduce_ofst[] = {
 /*     0 */  -147,  171,  263,  -97,  358, -145, -149, -163,  123,  264,
 /*    10 */   305,  398,  404,  446,  401, -171, -157, -235, -175,  -79,
 /*    20 */   189,  196,  333,  490,  378,  375,  497,  550,  552,  -42,
 /*    30 */  -116,  465,  540,  542,  544,  588,  594, -214, -214, -214,
 /*    40 */  -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
 /*    50 */  -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
 /*    60 */  -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
 /*    70 */  -214,  543,  582,  590,  633,  658,  661,  675,  677,  685,
 /*    80 */   702,  705,  748,  750,  752,  754,  768,  788,  791,  793,
 /*    90 */   795,  797,  800,  802,  804,  807,  827,  833,  835,  837,
 /*   100 */   839,  841,  843,  845,  847,  870,  873,  893,  916,  918,
 /*   110 */   921,  936,  941,  944,  961,  964,  968, -214, -214, -214,
 /*   120 */  -214, -214, -214, -214, -214, -214,  315,  789, -159,   14,
 /*   130 */   111,  434,  463,  247,  700,  247,  700, -176, -214, -214,
 /*   140 */  -214, -214,  300,  300,  300, -162,  -74, -129,  125, -165,
 /*   150 */  -127,  268,  266,  405,  405, -135,  284,  403,  491,  460,
 /*   160 */   148,  335,  514,  649,  212,  124,  325,  687,  971,  602,
 /*   170 */   973,  659,  323,  601,  808,  991,   41,  951,  627,  727,
 /*   180 */   729,  579,  945,  786,  878,  932,  947, -182, -169, -167,
 /*   190 */  -121,  -46,   16,   39,  176,  289,  313,  364,  473,  537,
 /*   200 */   613,  635,  662,  792,  796,  165,  811,  969, 1002, 1090,
 /*   210 */  1092, 1105, 1107, 1110, 1112, 1117, 1119, 1121, 1081, 1086,
 /*   220 */  1093, 1122, 1124, 1125, 1126,  481, 1127, 1129, 1130, 1068,
 /*   230 */  1131, 1132, 1080, 1134,   16, 1135, 1136, 1137, 1152, 1156,
 /*   240 */  1158, 1065, 1067, 1109, 1097, 1113, 1114, 1115,  481, 1109,
 /*   250 */  1109, 1151, 1160, 1174, 1150, 1118, 1139, 1083, 1167, 1168,
 /*   260 */  1084, 1176, 1145, 1170, 1161, 1178, 1181, 1140, 1103, 1173,
 /*   270 */  1177, 1216, 1141, 1218, 1219, 1142, 1143, 1221, 1166, 1163,
 /*   280 */  1203, 1194, 1205, 1208, 1209, 1211, 1241, 1248, 1210, 1212,
 /*   290 */  1182, 1184, 1223, 1227, 1213, 1262, 1266, 1185, 1188, 1267,
 /*   300 */  1272, 1255, 1273, 1278, 1276, 1279, 1260, 1269, 1271, 1274,
 /*   310 */  1264, 1265, 1286, 1275, 1287, 1280, 1289, 1292, 1293, 1230,
 /*   320 */  1239, 1297, 1258, 1270, 1263, 1283, 1284, 1295, 1285, 1296,
 /*   330 */  1323, 1282, 1226, 1231, 1261, 1333, 1298, 1309, 1291, 1313,
 /*   340 */  1321, 1325, 1330, 1371, 1376, 1383, 1391, 1392, 1395, 1396,
 /*   350 */  1301, 1302, 1299, 1387, 1382, 1388, 1400, 1401, 1393, 1394,
 /*   360 */  1402, 1407, 1409, 1412, 1417, 1397,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1482, 1482, 1482, 1329, 1115, 1220, 1115, 1115, 1115, 1329,
 /*    10 */  1329, 1329, 1329, 1329, 1115, 1250, 1250, 1380, 1146, 1115,
 /*    20 */  1115, 1115, 1115, 1115, 1115, 1328, 1115, 1115, 1115, 1115,
 /*    30 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1256, 1115,
 /*    40 */  1115, 1115, 1115, 1115, 1330, 1331, 1115, 1115, 1115, 1379,
 /*    50 */  1381, 1266, 1265, 1264, 1263, 1362, 1237, 1261, 1254, 1258,
 /*    60 */  1324, 1325, 1323, 1327, 1330, 1331, 1115, 1257, 1295, 1309,
 /*    70 */  1294, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*    80 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*    90 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   100 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   110 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1303, 1308, 1314,
 /*   120 */  1307, 1304, 1297, 1296, 1298, 1299, 1115, 1136, 1185, 1115,
 /*   130 */  1115, 1115, 1115, 1397, 1396, 1115, 1115, 1146, 1300, 1301,
 /*   140 */  1311, 1310, 1387, 1438, 1437, 1115, 1115, 1115, 1115, 1115,
 /*   150 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   160 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   170 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1146, 1142, 1420,
 /*   180 */  1420, 1406, 1142, 1115, 1392, 1220, 1211, 1115, 1115, 1115,
 /*   190 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1384, 1382,
 /*   200 */  1115, 1344, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   210 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   220 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1216,
 /*   230 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   240 */  1432, 1115, 1357, 1199, 1216, 1216, 1216, 1216, 1218, 1200,
 /*   250 */  1198, 1210, 1146, 1122, 1260, 1239, 1239, 1471, 1260, 1260,
 /*   260 */  1471, 1160, 1452, 1157, 1250, 1250, 1250, 1239, 1326, 1217,
 /*   270 */  1210, 1115, 1474, 1225, 1225, 1473, 1473, 1225, 1269, 1275,
 /*   280 */  1188, 1260, 1194, 1194, 1194, 1194, 1225, 1133, 1260, 1260,
 /*   290 */  1269, 1275, 1188, 1188, 1260, 1225, 1133, 1361, 1468, 1225,
 /*   300 */  1133, 1337, 1225, 1133, 1225, 1133, 1337, 1186, 1186, 1186,
 /*   310 */  1175, 1337, 1186, 1160, 1186, 1175, 1186, 1186, 1337, 1341,
 /*   320 */  1341, 1337, 1243, 1238, 1243, 1238, 1243, 1238, 1243, 1238,
 /*   330 */  1225, 1244, 1405, 1115, 1332, 1225, 1115, 1255, 1244, 1418,
 /*   340 */  1253, 1251, 1260, 1139, 1178, 1435, 1435, 1431, 1431, 1431,
 /*   350 */  1479, 1479, 1392, 1447, 1146, 1146, 1146, 1146, 1447, 1162,
 /*   360 */  1162, 1146, 1146, 1146, 1146, 1447, 1115, 1115, 1115, 1115,
 /*   370 */  1115, 1115, 1442, 1115, 1346, 1229, 1115, 1115, 1115, 1115,
 /*   380 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   390 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1280, 1115, 1118,
 /*   400 */  1389, 1115, 1115, 1388, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   410 */  1230, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   420 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1470,
 /*   430 */  1115, 1115, 1115, 1115, 1115, 1115, 1360, 1359, 1115, 1115,
 /*   440 */  1227, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   450 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   460 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   470 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1252, 1115,
 /*   480 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1419, 1245, 1115,
 /*   490 */  1115, 1115, 1115, 1461, 1115, 1115, 1115, 1115, 1115, 1115,
 /*   500 */  1115, 1115, 1115, 1115, 1115, 1115, 1115, 1456, 1202, 1282,
 /*   510 */  1115, 1281, 1285, 1115, 1127, 1115,
};
/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.  
** If a construct like the following:
** 
**      %fallback ID X Y Z.







|



|
|

|








|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







145497
145498
145499
145500
145501
145502
145503
145504
145505
145506
145507
145508
145509
145510
145511
145512
145513
145514
145515
145516
145517
145518
145519
145520
145521
145522
145523
145524
145525
145526
145527
145528
145529
145530
145531
145532
145533
145534
145535
145536
145537
145538
145539
145540
145541
145542
145543
145544
145545
145546
145547
145548
145549
145550
145551
145552
145553
145554
145555
145556
145557
145558
145559
145560
145561
145562
145563
145564
145565
145566
145567
145568
145569
145570
145571
145572
145573
145574
145575
145576
145577
145578
145579
145580
145581
145582
145583
145584
145585
145586
145587
145588
145589
145590
145591
145592
145593
145594
145595
145596
145597
145598
145599
145600
145601
145602
145603
145604
145605
145606
145607
145608
145609
145610
145611
145612
145613
145614
145615
145616
145617
145618
145619
145620
145621
145622
145623
145624
145625
145626
145627
145628
145629
145630
145631
145632
145633
145634
145635
145636
145637
145638
145639
145640
145641
145642
145643
145644
145645
145646
145647
145648
145649
145650
145651
145652
145653
145654
145655
145656
145657
145658
145659
145660
145661
145662
 /*  1960 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  1970 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  1980 */   122,  277,  277,  277,  277,  127,  128,  277,  277,  277,
 /*  1990 */   277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
 /*  2000 */   277,  277,  277,  277,  277,  277,  277,  277,  150,  277,
 /*  2010 */   277,  277,  277,  277,  277,  277,  277,  277,  277,
};
#define YY_SHIFT_COUNT    (517)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (1858)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */  1709, 1520, 1858, 1324, 1324,  277, 1374, 1469, 1602, 1712,
 /*    10 */  1712, 1712,  273,    0,    0,  113, 1016, 1712, 1712, 1712,
 /*    20 */  1712, 1712, 1712, 1712, 1712, 1712, 1712,   11,   11,  236,
 /*    30 */   184,  277,  277,  277,  277,  277,  277,   93,  177,  270,
 /*    40 */   363,  456,  549,  642,  735,  828,  848,  996, 1144, 1016,
 /*    50 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
 /*    60 */  1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257, 1277,
 /*    70 */  1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*    80 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*    90 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
 /*   100 */  1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712, 1712, 1712,
 /*   110 */  1712, 1712, 1712, 1712, 1712, 1712, 1712,  143,  162,  162,
 /*   120 */   162,  162,  162,  204,  151,  416,  531,  648,  700,  531,
 /*   130 */   486,  486,  531,  353,  353,  353,  353,  409,  279,   53,
 /*   140 */  2009, 2009,  331,  331,  331,  329,  366,  329,  329,  597,
 /*   150 */   597,  464,  474,  262,  681,  531,  531,  531,  531,  531,
 /*   160 */   531,  531,  531,  531,  531,  531,  531,  531,  531,  531,
 /*   170 */   531,  531,  531,  531,  531,  531,  531,  173,  485,  984,
 /*   180 */   984,  576,  485,   19, 1022, 2009, 2009, 2009,  387,  250,
 /*   190 */   250,  525,  502,  278,  552,  227,  480,  566,  531,  531,
 /*   200 */   531,  531,  531,  531,  531,  531,  639,  531,  531,  531,
 /*   210 */   531,  531,  531,  531,  531,  531,  531,  531,  531,    2,
 /*   220 */     2,    2,  531,  531,  531,  531,  782,  531,  531,  531,
 /*   230 */   744,  531,  531,  783,  531,  531,  531,  531,  531,  531,
 /*   240 */   531,  531,  419,  682,  327,  370,  370,  370,  370, 1029,
 /*   250 */   327,  327, 1024,  897,  856, 1109,  706,  706, 1143, 1109,
 /*   260 */  1109, 1143,  842,  945, 1118, 1136, 1136, 1136,  706,  676,
 /*   270 */   400,  878,  694, 1327, 1258, 1258, 1359, 1359, 1258, 1296,
 /*   280 */  1381, 1363, 1269, 1390, 1390, 1390, 1390, 1258, 1400, 1269,
 /*   290 */  1269, 1296, 1381, 1363, 1363, 1269, 1258, 1400, 1294, 1379,
 /*   300 */  1258, 1400, 1425, 1258, 1400, 1258, 1400, 1425, 1353, 1353,
 /*   310 */  1353, 1394, 1425, 1353, 1348, 1353, 1394, 1353, 1353, 1425,
 /*   320 */  1384, 1384, 1425, 1360, 1391, 1360, 1391, 1360, 1391, 1360,
 /*   330 */  1391, 1258, 1365, 1410, 1475, 1366, 1365, 1482, 1258, 1367,
 /*   340 */  1366, 1378, 1389, 1269, 1521, 1527, 1534, 1534, 1549, 1549,
 /*   350 */  1549, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
 /*   360 */  2009, 2009, 2009, 2009, 2009, 2009, 2009,  570,  345,  686,
 /*   370 */   748,   50,  740, 1064, 1107,  469,  537, 1036, 1146, 1162,
 /*   380 */  1154, 1155, 1156, 1180, 1201, 1202,  903, 1076, 1197, 1157,
 /*   390 */  1167, 1206, 1207, 1208,  775, 1030, 1226, 1227, 1176, 1138,
 /*   400 */  1579, 1581, 1570, 1452, 1589, 1516, 1590, 1584, 1586, 1487,
 /*   410 */  1477, 1498, 1594, 1488, 1600, 1492, 1607, 1625, 1496, 1489,
 /*   420 */  1509, 1569, 1599, 1500, 1587, 1588, 1591, 1592, 1518, 1538,
 /*   430 */  1612, 1519, 1649, 1646, 1630, 1550, 1504, 1595, 1629, 1596,
 /*   440 */  1582, 1615, 1528, 1555, 1636, 1642, 1647, 1545, 1553, 1650,
 /*   450 */  1601, 1652, 1653, 1648, 1654, 1610, 1641, 1656, 1613, 1644,
 /*   460 */  1659, 1541, 1661, 1532, 1663, 1664, 1662, 1667, 1669, 1670,
 /*   470 */  1672, 1671, 1673, 1566, 1677, 1678, 1597, 1679, 1681, 1572,
 /*   480 */  1680, 1682, 1680, 1683, 1633, 1640, 1645, 1685, 1701, 1703,
 /*   490 */  1699, 1704, 1702, 1710, 1680, 1714, 1715, 1717, 1719, 1724,
 /*   500 */  1728, 1713, 1741, 1731, 1732, 1733, 1734, 1736, 1737, 1729,
 /*   510 */  1639, 1635, 1637, 1638, 1643, 1743, 1745, 1768,
};
#define YY_REDUCE_COUNT (366)
#define YY_REDUCE_MIN   (-237)
#define YY_REDUCE_MAX   (1420)
static const short yy_reduce_ofst[] = {
 /*     0 */  -147,  171,  263,  -96,  358, -144, -149, -102,  124, -156,
 /*    10 */   -98,  305,  401,  -57,  209, -237,  245,  -94,  -79,  189,
 /*    20 */   375,  490,  493,  378,  303,  539,  542,  501,  503,  554,
 /*    30 */   415,  526,  546,  557,  587,  593,  595, -234, -234, -234,
 /*    40 */  -234, -234, -234, -234, -234, -234, -234, -234, -234, -234,
 /*    50 */  -234, -234, -234, -234, -234, -234, -234, -234, -234, -234,
 /*    60 */  -234, -234, -234, -234, -234, -234, -234, -234, -234, -234,
 /*    70 */  -234,  -50,  335,  470,  633,  656,  658,  660,  675,  685,
 /*    80 */   703,  727,  747,  750,  752,  754,  770,  788,  790,  793,
 /*    90 */   795,  797,  800,  802,  804,  806,  813,  820,  829,  833,
 /*   100 */   836,  838,  843,  845,  847,  849,  873,  891,  893,  916,
 /*   110 */   918,  921,  936,  941,  944,  956,  961, -234, -234, -234,
 /*   120 */  -234, -234, -234, -234, -234, -234,  463,  607, -176,   14,
 /*   130 */  -139,   87, -137,  818,  925,  818,  925,  898, -234, -234,
 /*   140 */  -234, -234, -166, -166, -166, -130, -131,  -82,  -54, -180,
 /*   150 */   364,   41,  513,  509,  509,  117,  500,  789,  796,  646,
 /*   160 */   192,  291,  644,  798,  120,  807,  543,  911,  920,  652,
 /*   170 */   924,  922,  232,  698,  801,  971,   39,  220,  731,  442,
 /*   180 */   902, -199,  979,  -43,  421,  896,  942,  605, -184, -126,
 /*   190 */   155,  172,  281,  304,  377,  538,  650,  690,  699,  723,
 /*   200 */   803,  853,  919, 1088, 1091, 1092,  777, 1106, 1108, 1111,
 /*   210 */  1112, 1115, 1116, 1117, 1120, 1121, 1122, 1123, 1124, 1077,
 /*   220 */  1079, 1095, 1126, 1127, 1128, 1129, 1056, 1130, 1131, 1132,
 /*   230 */  1075, 1135, 1137, 1096, 1152,  304, 1153, 1158, 1172, 1173,
 /*   240 */  1174, 1175, 1066, 1068, 1110, 1098, 1119, 1125, 1139, 1056,
 /*   250 */  1110, 1110, 1170, 1160, 1178, 1149, 1114, 1140, 1089, 1150,
 /*   260 */  1151, 1133, 1177, 1171, 1189, 1161, 1181, 1195, 1159, 1142,
 /*   270 */  1179, 1182, 1218, 1141, 1220, 1228, 1145, 1147, 1229, 1183,
 /*   280 */  1188, 1210, 1196, 1209, 1211, 1212, 1213, 1242, 1255, 1215,
 /*   290 */  1219, 1190, 1200, 1224, 1235, 1225, 1267, 1270, 1191, 1194,
 /*   300 */  1272, 1274, 1259, 1279, 1281, 1283, 1285, 1266, 1273, 1276,
 /*   310 */  1286, 1280, 1271, 1287, 1288, 1289, 1284, 1297, 1299, 1293,
 /*   320 */  1241, 1244, 1303, 1268, 1275, 1278, 1300, 1295, 1302, 1307,
 /*   330 */  1309, 1328, 1291, 1230, 1231, 1321, 1292, 1298, 1341, 1301,
 /*   340 */  1325, 1326, 1329, 1332, 1375, 1382, 1393, 1398, 1396, 1401,
 /*   350 */  1402, 1304, 1305, 1306, 1392, 1385, 1395, 1399, 1403, 1397,
 /*   360 */  1388, 1404, 1407, 1409, 1417, 1420, 1406,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1486, 1486, 1486, 1335, 1118, 1224, 1118, 1118, 1118, 1335,
 /*    10 */  1335, 1335, 1118, 1254, 1254, 1386, 1149, 1118, 1118, 1118,
 /*    20 */  1118, 1118, 1118, 1118, 1334, 1118, 1118, 1118, 1118, 1118,
 /*    30 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1260, 1118,
 /*    40 */  1118, 1118, 1118, 1118, 1336, 1337, 1118, 1118, 1118, 1385,
 /*    50 */  1387, 1270, 1269, 1268, 1267, 1368, 1241, 1265, 1258, 1262,
 /*    60 */  1330, 1331, 1329, 1333, 1337, 1336, 1118, 1261, 1301, 1315,
 /*    70 */  1300, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*    80 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*    90 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   100 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   110 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1309, 1314, 1320,
 /*   120 */  1313, 1310, 1303, 1302, 1304, 1305, 1118, 1139, 1188, 1118,
 /*   130 */  1118, 1118, 1118, 1403, 1402, 1118, 1118, 1149, 1306, 1307,
 /*   140 */  1317, 1316, 1393, 1442, 1441, 1118, 1118, 1118, 1118, 1118,
 /*   150 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   160 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   170 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1149, 1145, 1295,
 /*   180 */  1294, 1412, 1145, 1248, 1118, 1398, 1224, 1215, 1118, 1118,
 /*   190 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1390,
 /*   200 */  1388, 1118, 1350, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   210 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   220 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   230 */  1220, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   240 */  1118, 1436, 1118, 1363, 1202, 1220, 1220, 1220, 1220, 1222,
 /*   250 */  1203, 1201, 1214, 1149, 1125, 1264, 1243, 1243, 1475, 1264,
 /*   260 */  1264, 1475, 1163, 1456, 1160, 1254, 1254, 1254, 1243, 1332,
 /*   270 */  1221, 1214, 1118, 1478, 1229, 1229, 1477, 1477, 1229, 1273,
 /*   280 */  1279, 1191, 1264, 1197, 1197, 1197, 1197, 1229, 1136, 1264,
 /*   290 */  1264, 1273, 1279, 1191, 1191, 1264, 1229, 1136, 1367, 1472,
 /*   300 */  1229, 1136, 1343, 1229, 1136, 1229, 1136, 1343, 1189, 1189,
 /*   310 */  1189, 1178, 1343, 1189, 1163, 1189, 1178, 1189, 1189, 1343,
 /*   320 */  1347, 1347, 1343, 1247, 1242, 1247, 1242, 1247, 1242, 1247,
 /*   330 */  1242, 1229, 1248, 1411, 1118, 1259, 1248, 1338, 1229, 1118,
 /*   340 */  1259, 1257, 1255, 1264, 1142, 1181, 1439, 1439, 1435, 1435,
 /*   350 */  1435, 1483, 1483, 1398, 1451, 1149, 1149, 1149, 1149, 1451,
 /*   360 */  1165, 1165, 1149, 1149, 1149, 1149, 1451, 1118, 1118, 1118,
 /*   370 */  1118, 1118, 1118, 1446, 1118, 1352, 1233, 1118, 1118, 1118,
 /*   380 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   390 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1284,
 /*   400 */  1118, 1121, 1395, 1118, 1118, 1394, 1118, 1118, 1118, 1118,
 /*   410 */  1118, 1118, 1234, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   420 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   430 */  1118, 1474, 1118, 1118, 1118, 1118, 1118, 1118, 1366, 1365,
 /*   440 */  1118, 1118, 1231, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   450 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   460 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   470 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   480 */  1256, 1118, 1410, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
 /*   490 */  1424, 1249, 1118, 1118, 1465, 1118, 1118, 1118, 1118, 1118,
 /*   500 */  1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1460,
 /*   510 */  1205, 1286, 1118, 1285, 1289, 1118, 1130, 1118,
};
/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.  
** If a construct like the following:
** 
**      %fallback ID X Y Z.
146143
146144
146145
146146
146147
146148
146149
146150
146151
146152
146153
146154
146155
146156
146157
146158
146159
146160
146161
146162
146163
146164
146165
146166
146167
146168
146169
146170
146171
146172
146173
146174
146175
146176
146177
146178
  /*  209 */ "multiselect_op",
  /*  210 */ "distinct",
  /*  211 */ "selcollist",
  /*  212 */ "from",
  /*  213 */ "where_opt",
  /*  214 */ "groupby_opt",
  /*  215 */ "having_opt",
  /*  216 */ "windowdefn_opt",
  /*  217 */ "orderby_opt",
  /*  218 */ "limit_opt",
  /*  219 */ "values",
  /*  220 */ "nexprlist",
  /*  221 */ "exprlist",
  /*  222 */ "sclp",
  /*  223 */ "as",
  /*  224 */ "seltablist",
  /*  225 */ "stl_prefix",
  /*  226 */ "joinop",
  /*  227 */ "indexed_opt",
  /*  228 */ "on_opt",
  /*  229 */ "using_opt",
  /*  230 */ "xfullname",
  /*  231 */ "idlist",
  /*  232 */ "with",
  /*  233 */ "setlist",
  /*  234 */ "insert_cmd",
  /*  235 */ "idlist_opt",
  /*  236 */ "upsert",
  /*  237 */ "over_opt",
  /*  238 */ "likeop",
  /*  239 */ "between_op",
  /*  240 */ "in_op",
  /*  241 */ "paren_exprlist",
  /*  242 */ "case_operand",
  /*  243 */ "case_exprlist",
  /*  244 */ "case_else",







|
|
|


|
|
|
|
|
|
|
|
|







|







146062
146063
146064
146065
146066
146067
146068
146069
146070
146071
146072
146073
146074
146075
146076
146077
146078
146079
146080
146081
146082
146083
146084
146085
146086
146087
146088
146089
146090
146091
146092
146093
146094
146095
146096
146097
  /*  209 */ "multiselect_op",
  /*  210 */ "distinct",
  /*  211 */ "selcollist",
  /*  212 */ "from",
  /*  213 */ "where_opt",
  /*  214 */ "groupby_opt",
  /*  215 */ "having_opt",
  /*  216 */ "orderby_opt",
  /*  217 */ "limit_opt",
  /*  218 */ "window_clause",
  /*  219 */ "values",
  /*  220 */ "nexprlist",
  /*  221 */ "sclp",
  /*  222 */ "as",
  /*  223 */ "seltablist",
  /*  224 */ "stl_prefix",
  /*  225 */ "joinop",
  /*  226 */ "indexed_opt",
  /*  227 */ "on_opt",
  /*  228 */ "using_opt",
  /*  229 */ "exprlist",
  /*  230 */ "xfullname",
  /*  231 */ "idlist",
  /*  232 */ "with",
  /*  233 */ "setlist",
  /*  234 */ "insert_cmd",
  /*  235 */ "idlist_opt",
  /*  236 */ "upsert",
  /*  237 */ "over_clause",
  /*  238 */ "likeop",
  /*  239 */ "between_op",
  /*  240 */ "in_op",
  /*  241 */ "paren_exprlist",
  /*  242 */ "case_operand",
  /*  243 */ "case_exprlist",
  /*  244 */ "case_else",
146298
146299
146300
146301
146302
146303
146304
146305

146306
146307
146308
146309
146310
146311
146312
146313
146314
146315
146316
146317
146318

146319
146320
146321
146322
146323
146324
146325
146326
146327
146328
146329
146330
146331
146332
146333
146334
146335
146336

146337
146338
146339
146340
146341
146342
146343
146344
146345
146346
146347
146348
146349
146350
146351
146352
146353
146354
146355
146356
146357
146358

146359
146360
146361
146362
146363
146364
146365
146366
146367
146368
146369
146370
146371
146372
146373
146374
146375
146376
146377
146378
146379
146380
146381
146382
146383
146384
146385
146386

146387
146388
146389
146390
146391
146392
146393
146394
146395
146396
146397
146398
146399
146400
146401
146402
146403
146404
146405
146406
146407
146408
146409
146410
146411



146412
146413
146414
146415
146416
146417
146418
146419
146420
146421
146422
146423
146424
146425
146426
146427
146428
146429
146430
146431
146432
146433
146434
146435
146436
146437
146438
146439
146440
146441
146442
146443
146444
146445
146446
146447
146448
146449
146450
146451
146452
146453
146454
146455
146456
146457
146458
146459
146460
146461
146462
146463
146464
146465
146466
146467
146468
146469
146470
146471
146472
146473
146474
146475
146476
146477
146478
146479
146480
146481
146482
146483
146484
146485
146486
146487
146488
146489
146490
146491
146492
146493
146494
146495
146496
146497
146498
146499
146500
146501
146502
146503
146504
146505
146506
146507
146508
146509
146510
146511
146512
146513
146514
146515
146516
146517
146518
146519
146520
146521
146522
146523
146524
146525
146526
146527
146528
146529
146530
146531
146532
146533

146534
146535
146536
146537
146538
146539
146540
146541
146542
146543
146544
146545
146546
146547

146548
146549
146550
146551
146552
146553
146554
146555
146556
146557
146558
146559
146560
146561
146562
146563
146564
146565
146566

146567
146568
146569
146570
146571
146572
146573
146574
146575
146576
146577
146578
146579
146580
146581
146582
146583
146584
146585
146586
146587
146588
146589
 /*  80 */ "select ::= WITH wqlist selectnowith",
 /*  81 */ "select ::= WITH RECURSIVE wqlist selectnowith",
 /*  82 */ "select ::= selectnowith",
 /*  83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
 /*  84 */ "multiselect_op ::= UNION",
 /*  85 */ "multiselect_op ::= UNION ALL",
 /*  86 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /*  87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt",

 /*  88 */ "values ::= VALUES LP nexprlist RP",
 /*  89 */ "values ::= values COMMA LP exprlist RP",
 /*  90 */ "distinct ::= DISTINCT",
 /*  91 */ "distinct ::= ALL",
 /*  92 */ "distinct ::=",
 /*  93 */ "sclp ::=",
 /*  94 */ "selcollist ::= sclp scanpt expr scanpt as",
 /*  95 */ "selcollist ::= sclp scanpt STAR",
 /*  96 */ "selcollist ::= sclp scanpt nm DOT STAR",
 /*  97 */ "as ::= AS nm",
 /*  98 */ "as ::=",
 /*  99 */ "from ::=",
 /* 100 */ "from ::= FROM seltablist",

 /* 101 */ "stl_prefix ::= seltablist joinop",
 /* 102 */ "stl_prefix ::=",
 /* 103 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 104 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
 /* 105 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 106 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
 /* 107 */ "dbnm ::=",
 /* 108 */ "dbnm ::= DOT nm",
 /* 109 */ "fullname ::= nm",
 /* 110 */ "fullname ::= nm DOT nm",
 /* 111 */ "xfullname ::= nm",
 /* 112 */ "xfullname ::= nm DOT nm",
 /* 113 */ "xfullname ::= nm DOT nm AS nm",
 /* 114 */ "xfullname ::= nm AS nm",
 /* 115 */ "joinop ::= COMMA|JOIN",
 /* 116 */ "joinop ::= JOIN_KW JOIN",
 /* 117 */ "joinop ::= JOIN_KW nm JOIN",
 /* 118 */ "joinop ::= JOIN_KW nm nm JOIN",

 /* 119 */ "on_opt ::= ON expr",
 /* 120 */ "on_opt ::=",
 /* 121 */ "indexed_opt ::=",
 /* 122 */ "indexed_opt ::= INDEXED BY nm",
 /* 123 */ "indexed_opt ::= NOT INDEXED",
 /* 124 */ "using_opt ::= USING LP idlist RP",
 /* 125 */ "using_opt ::=",
 /* 126 */ "orderby_opt ::=",
 /* 127 */ "orderby_opt ::= ORDER BY sortlist",
 /* 128 */ "sortlist ::= sortlist COMMA expr sortorder",
 /* 129 */ "sortlist ::= expr sortorder",
 /* 130 */ "sortorder ::= ASC",
 /* 131 */ "sortorder ::= DESC",
 /* 132 */ "sortorder ::=",
 /* 133 */ "groupby_opt ::=",
 /* 134 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 135 */ "having_opt ::=",
 /* 136 */ "having_opt ::= HAVING expr",
 /* 137 */ "limit_opt ::=",
 /* 138 */ "limit_opt ::= LIMIT expr",
 /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 140 */ "limit_opt ::= LIMIT expr COMMA expr",

 /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
 /* 142 */ "where_opt ::=",
 /* 143 */ "where_opt ::= WHERE expr",
 /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
 /* 145 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
 /* 147 */ "setlist ::= nm EQ expr",
 /* 148 */ "setlist ::= LP idlist RP EQ expr",
 /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
 /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
 /* 151 */ "upsert ::=",
 /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
 /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
 /* 154 */ "upsert ::= ON CONFLICT DO NOTHING",
 /* 155 */ "insert_cmd ::= INSERT orconf",
 /* 156 */ "insert_cmd ::= REPLACE",
 /* 157 */ "idlist_opt ::=",
 /* 158 */ "idlist_opt ::= LP idlist RP",
 /* 159 */ "idlist ::= idlist COMMA nm",
 /* 160 */ "idlist ::= nm",
 /* 161 */ "expr ::= LP expr RP",
 /* 162 */ "expr ::= ID|INDEXED",
 /* 163 */ "expr ::= JOIN_KW",
 /* 164 */ "expr ::= nm DOT nm",
 /* 165 */ "expr ::= nm DOT nm DOT nm",
 /* 166 */ "term ::= NULL|FLOAT|BLOB",
 /* 167 */ "term ::= STRING",
 /* 168 */ "term ::= INTEGER",

 /* 169 */ "expr ::= VARIABLE",
 /* 170 */ "expr ::= expr COLLATE ID|STRING",
 /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_opt",
 /* 173 */ "expr ::= ID|INDEXED LP STAR RP over_opt",
 /* 174 */ "term ::= CTIME_KW",
 /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
 /* 176 */ "expr ::= expr AND expr",
 /* 177 */ "expr ::= expr OR expr",
 /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 179 */ "expr ::= expr EQ|NE expr",
 /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 181 */ "expr ::= expr PLUS|MINUS expr",
 /* 182 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 183 */ "expr ::= expr CONCAT expr",
 /* 184 */ "likeop ::= NOT LIKE_KW|MATCH",
 /* 185 */ "expr ::= expr likeop expr",
 /* 186 */ "expr ::= expr likeop expr ESCAPE expr",
 /* 187 */ "expr ::= expr ISNULL|NOTNULL",
 /* 188 */ "expr ::= expr NOT NULL",
 /* 189 */ "expr ::= expr IS expr",
 /* 190 */ "expr ::= expr IS NOT expr",
 /* 191 */ "expr ::= NOT expr",
 /* 192 */ "expr ::= BITNOT expr",
 /* 193 */ "expr ::= PLUS|MINUS expr",



 /* 194 */ "between_op ::= BETWEEN",
 /* 195 */ "between_op ::= NOT BETWEEN",
 /* 196 */ "expr ::= expr between_op expr AND expr",
 /* 197 */ "in_op ::= IN",
 /* 198 */ "in_op ::= NOT IN",
 /* 199 */ "expr ::= expr in_op LP exprlist RP",
 /* 200 */ "expr ::= LP select RP",
 /* 201 */ "expr ::= expr in_op LP select RP",
 /* 202 */ "expr ::= expr in_op nm dbnm paren_exprlist",
 /* 203 */ "expr ::= EXISTS LP select RP",
 /* 204 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 205 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 206 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 207 */ "case_else ::= ELSE expr",
 /* 208 */ "case_else ::=",
 /* 209 */ "case_operand ::= expr",
 /* 210 */ "case_operand ::=",
 /* 211 */ "exprlist ::=",
 /* 212 */ "nexprlist ::= nexprlist COMMA expr",
 /* 213 */ "nexprlist ::= expr",
 /* 214 */ "paren_exprlist ::=",
 /* 215 */ "paren_exprlist ::= LP exprlist RP",
 /* 216 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
 /* 217 */ "uniqueflag ::= UNIQUE",
 /* 218 */ "uniqueflag ::=",
 /* 219 */ "eidlist_opt ::=",
 /* 220 */ "eidlist_opt ::= LP eidlist RP",
 /* 221 */ "eidlist ::= eidlist COMMA nm collate sortorder",
 /* 222 */ "eidlist ::= nm collate sortorder",
 /* 223 */ "collate ::=",
 /* 224 */ "collate ::= COLLATE ID|STRING",
 /* 225 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 226 */ "cmd ::= VACUUM",
 /* 227 */ "cmd ::= VACUUM nm",
 /* 228 */ "cmd ::= PRAGMA nm dbnm",
 /* 229 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
 /* 230 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
 /* 231 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
 /* 232 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
 /* 233 */ "plus_num ::= PLUS INTEGER|FLOAT",
 /* 234 */ "minus_num ::= MINUS INTEGER|FLOAT",
 /* 235 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 236 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 237 */ "trigger_time ::= BEFORE|AFTER",
 /* 238 */ "trigger_time ::= INSTEAD OF",
 /* 239 */ "trigger_time ::=",
 /* 240 */ "trigger_event ::= DELETE|INSERT",
 /* 241 */ "trigger_event ::= UPDATE",
 /* 242 */ "trigger_event ::= UPDATE OF idlist",
 /* 243 */ "when_clause ::=",
 /* 244 */ "when_clause ::= WHEN expr",
 /* 245 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 246 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 247 */ "trnm ::= nm DOT nm",
 /* 248 */ "tridxby ::= INDEXED BY nm",
 /* 249 */ "tridxby ::= NOT INDEXED",
 /* 250 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
 /* 251 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
 /* 252 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
 /* 253 */ "trigger_cmd ::= scanpt select scanpt",
 /* 254 */ "expr ::= RAISE LP IGNORE RP",
 /* 255 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 256 */ "raisetype ::= ROLLBACK",
 /* 257 */ "raisetype ::= ABORT",
 /* 258 */ "raisetype ::= FAIL",
 /* 259 */ "cmd ::= DROP TRIGGER ifexists fullname",
 /* 260 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
 /* 261 */ "cmd ::= DETACH database_kw_opt expr",
 /* 262 */ "key_opt ::=",
 /* 263 */ "key_opt ::= KEY expr",
 /* 264 */ "cmd ::= REINDEX",
 /* 265 */ "cmd ::= REINDEX nm dbnm",
 /* 266 */ "cmd ::= ANALYZE",
 /* 267 */ "cmd ::= ANALYZE nm dbnm",
 /* 268 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
 /* 269 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
 /* 270 */ "add_column_fullname ::= fullname",
 /* 271 */ "cmd ::= create_vtab",
 /* 272 */ "cmd ::= create_vtab LP vtabarglist RP",
 /* 273 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
 /* 274 */ "vtabarg ::=",
 /* 275 */ "vtabargtoken ::= ANY",
 /* 276 */ "vtabargtoken ::= lp anylist RP",
 /* 277 */ "lp ::= LP",
 /* 278 */ "with ::= WITH wqlist",
 /* 279 */ "with ::= WITH RECURSIVE wqlist",
 /* 280 */ "wqlist ::= nm eidlist_opt AS LP select RP",
 /* 281 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
 /* 282 */ "windowdefn_list ::= windowdefn",
 /* 283 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
 /* 284 */ "windowdefn ::= nm AS window",
 /* 285 */ "window ::= LP part_opt orderby_opt frame_opt RP",
 /* 286 */ "part_opt ::= PARTITION BY exprlist",
 /* 287 */ "part_opt ::=",
 /* 288 */ "frame_opt ::=",
 /* 289 */ "frame_opt ::= range_or_rows frame_bound_s",
 /* 290 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
 /* 291 */ "range_or_rows ::= RANGE",
 /* 292 */ "range_or_rows ::= ROWS",
 /* 293 */ "frame_bound_s ::= frame_bound",
 /* 294 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
 /* 295 */ "frame_bound_e ::= frame_bound",
 /* 296 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
 /* 297 */ "frame_bound ::= expr PRECEDING",
 /* 298 */ "frame_bound ::= CURRENT ROW",
 /* 299 */ "frame_bound ::= expr FOLLOWING",
 /* 300 */ "windowdefn_opt ::=",
 /* 301 */ "windowdefn_opt ::= WINDOW windowdefn_list",
 /* 302 */ "over_opt ::=",
 /* 303 */ "over_opt ::= filter_opt OVER window",
 /* 304 */ "over_opt ::= filter_opt OVER nm",
 /* 305 */ "filter_opt ::=",
 /* 306 */ "filter_opt ::= FILTER LP WHERE expr RP",
 /* 307 */ "input ::= cmdlist",
 /* 308 */ "cmdlist ::= cmdlist ecmd",
 /* 309 */ "cmdlist ::= ecmd",
 /* 310 */ "ecmd ::= SEMI",
 /* 311 */ "ecmd ::= cmdx SEMI",
 /* 312 */ "ecmd ::= explain cmdx",
 /* 313 */ "trans_opt ::=",
 /* 314 */ "trans_opt ::= TRANSACTION",
 /* 315 */ "trans_opt ::= TRANSACTION nm",

 /* 316 */ "savepoint_opt ::= SAVEPOINT",
 /* 317 */ "savepoint_opt ::=",
 /* 318 */ "cmd ::= create_table create_table_args",
 /* 319 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 320 */ "columnlist ::= columnname carglist",
 /* 321 */ "nm ::= ID|INDEXED",
 /* 322 */ "nm ::= STRING",
 /* 323 */ "nm ::= JOIN_KW",
 /* 324 */ "typetoken ::= typename",
 /* 325 */ "typename ::= ID|STRING",
 /* 326 */ "signed ::= plus_num",
 /* 327 */ "signed ::= minus_num",
 /* 328 */ "carglist ::= carglist ccons",
 /* 329 */ "carglist ::=",

 /* 330 */ "ccons ::= NULL onconf",
 /* 331 */ "conslist_opt ::= COMMA conslist",
 /* 332 */ "conslist ::= conslist tconscomma tcons",
 /* 333 */ "conslist ::= tcons",
 /* 334 */ "tconscomma ::=",
 /* 335 */ "defer_subclause_opt ::= defer_subclause",
 /* 336 */ "resolvetype ::= raisetype",
 /* 337 */ "selectnowith ::= oneselect",
 /* 338 */ "oneselect ::= values",
 /* 339 */ "sclp ::= selcollist COMMA",
 /* 340 */ "as ::= ID|STRING",
 /* 341 */ "expr ::= term",
 /* 342 */ "likeop ::= LIKE_KW|MATCH",
 /* 343 */ "exprlist ::= nexprlist",
 /* 344 */ "nmnum ::= plus_num",
 /* 345 */ "nmnum ::= nm",
 /* 346 */ "nmnum ::= ON",
 /* 347 */ "nmnum ::= DELETE",
 /* 348 */ "nmnum ::= DEFAULT",

 /* 349 */ "plus_num ::= INTEGER|FLOAT",
 /* 350 */ "foreach_clause ::=",
 /* 351 */ "foreach_clause ::= FOR EACH ROW",
 /* 352 */ "trnm ::= nm",
 /* 353 */ "tridxby ::=",
 /* 354 */ "database_kw_opt ::= DATABASE",
 /* 355 */ "database_kw_opt ::=",
 /* 356 */ "kwcolumn_opt ::=",
 /* 357 */ "kwcolumn_opt ::= COLUMNKW",
 /* 358 */ "vtabarglist ::= vtabarg",
 /* 359 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 360 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 361 */ "anylist ::=",
 /* 362 */ "anylist ::= anylist LP anylist RP",
 /* 363 */ "anylist ::= anylist ANY",
 /* 364 */ "with ::=",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.  Return the number







|
>
|
|
<
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
<
|
|
|
|
|
|
|
<
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
<
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







146217
146218
146219
146220
146221
146222
146223
146224
146225
146226
146227

146228
146229
146230
146231
146232
146233
146234
146235
146236
146237
146238
146239
146240
146241
146242
146243
146244

146245
146246
146247
146248
146249
146250
146251
146252
146253
146254
146255
146256
146257
146258
146259
146260
146261
146262
146263
146264
146265
146266
146267

146268
146269
146270
146271
146272
146273
146274
146275
146276
146277
146278
146279
146280
146281
146282
146283
146284
146285
146286
146287
146288
146289
146290
146291
146292

146293
146294
146295
146296
146297
146298
146299
146300
146301
146302
146303
146304
146305
146306
146307
146308
146309
146310
146311

146312
146313
146314
146315
146316
146317
146318
146319
146320
146321
146322
146323
146324
146325
146326
146327
146328
146329
146330
146331
146332
146333
146334
146335
146336
146337
146338
146339
146340
146341
146342
146343
146344
146345
146346
146347
146348
146349
146350
146351
146352
146353
146354
146355
146356
146357
146358
146359
146360
146361
146362
146363
146364
146365
146366
146367
146368
146369
146370
146371
146372
146373
146374
146375
146376
146377
146378
146379
146380
146381
146382
146383
146384
146385
146386
146387
146388
146389
146390
146391
146392
146393
146394
146395
146396
146397
146398
146399
146400
146401
146402
146403
146404
146405
146406
146407
146408
146409
146410
146411
146412
146413
146414
146415
146416
146417
146418
146419
146420
146421
146422
146423
146424
146425
146426
146427
146428
146429
146430
146431
146432
146433
146434
146435
146436
146437
146438
146439

146440

146441
146442
146443
146444
146445
146446
146447

146448
146449
146450
146451
146452
146453
146454
146455
146456
146457
146458
146459
146460
146461
146462
146463
146464
146465

146466
146467
146468
146469
146470
146471
146472
146473
146474
146475
146476
146477
146478
146479
146480
146481

146482
146483
146484
146485
146486
146487
146488
146489
146490
146491
146492
146493
146494
146495
146496
146497
146498
146499
146500
146501
146502
146503
146504
146505
146506
146507
146508
146509
 /*  80 */ "select ::= WITH wqlist selectnowith",
 /*  81 */ "select ::= WITH RECURSIVE wqlist selectnowith",
 /*  82 */ "select ::= selectnowith",
 /*  83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
 /*  84 */ "multiselect_op ::= UNION",
 /*  85 */ "multiselect_op ::= UNION ALL",
 /*  86 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /*  87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
 /*  88 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
 /*  89 */ "values ::= VALUES LP nexprlist RP",
 /*  90 */ "values ::= values COMMA LP nexprlist RP",

 /*  91 */ "distinct ::= DISTINCT",
 /*  92 */ "distinct ::= ALL",
 /*  93 */ "distinct ::=",
 /*  94 */ "sclp ::=",
 /*  95 */ "selcollist ::= sclp scanpt expr scanpt as",
 /*  96 */ "selcollist ::= sclp scanpt STAR",
 /*  97 */ "selcollist ::= sclp scanpt nm DOT STAR",
 /*  98 */ "as ::= AS nm",
 /*  99 */ "as ::=",
 /* 100 */ "from ::=",
 /* 101 */ "from ::= FROM seltablist",
 /* 102 */ "stl_prefix ::= seltablist joinop",
 /* 103 */ "stl_prefix ::=",
 /* 104 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 105 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
 /* 106 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 107 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",

 /* 108 */ "dbnm ::=",
 /* 109 */ "dbnm ::= DOT nm",
 /* 110 */ "fullname ::= nm",
 /* 111 */ "fullname ::= nm DOT nm",
 /* 112 */ "xfullname ::= nm",
 /* 113 */ "xfullname ::= nm DOT nm",
 /* 114 */ "xfullname ::= nm DOT nm AS nm",
 /* 115 */ "xfullname ::= nm AS nm",
 /* 116 */ "joinop ::= COMMA|JOIN",
 /* 117 */ "joinop ::= JOIN_KW JOIN",
 /* 118 */ "joinop ::= JOIN_KW nm JOIN",
 /* 119 */ "joinop ::= JOIN_KW nm nm JOIN",
 /* 120 */ "on_opt ::= ON expr",
 /* 121 */ "on_opt ::=",
 /* 122 */ "indexed_opt ::=",
 /* 123 */ "indexed_opt ::= INDEXED BY nm",
 /* 124 */ "indexed_opt ::= NOT INDEXED",
 /* 125 */ "using_opt ::= USING LP idlist RP",
 /* 126 */ "using_opt ::=",
 /* 127 */ "orderby_opt ::=",
 /* 128 */ "orderby_opt ::= ORDER BY sortlist",
 /* 129 */ "sortlist ::= sortlist COMMA expr sortorder",
 /* 130 */ "sortlist ::= expr sortorder",

 /* 131 */ "sortorder ::= ASC",
 /* 132 */ "sortorder ::= DESC",
 /* 133 */ "sortorder ::=",
 /* 134 */ "groupby_opt ::=",
 /* 135 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 136 */ "having_opt ::=",
 /* 137 */ "having_opt ::= HAVING expr",
 /* 138 */ "limit_opt ::=",
 /* 139 */ "limit_opt ::= LIMIT expr",
 /* 140 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 141 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 142 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
 /* 143 */ "where_opt ::=",
 /* 144 */ "where_opt ::= WHERE expr",
 /* 145 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
 /* 146 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 147 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
 /* 148 */ "setlist ::= nm EQ expr",
 /* 149 */ "setlist ::= LP idlist RP EQ expr",
 /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
 /* 151 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
 /* 152 */ "upsert ::=",
 /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
 /* 154 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
 /* 155 */ "upsert ::= ON CONFLICT DO NOTHING",

 /* 156 */ "insert_cmd ::= INSERT orconf",
 /* 157 */ "insert_cmd ::= REPLACE",
 /* 158 */ "idlist_opt ::=",
 /* 159 */ "idlist_opt ::= LP idlist RP",
 /* 160 */ "idlist ::= idlist COMMA nm",
 /* 161 */ "idlist ::= nm",
 /* 162 */ "expr ::= LP expr RP",
 /* 163 */ "expr ::= ID|INDEXED",
 /* 164 */ "expr ::= JOIN_KW",
 /* 165 */ "expr ::= nm DOT nm",
 /* 166 */ "expr ::= nm DOT nm DOT nm",
 /* 167 */ "term ::= NULL|FLOAT|BLOB",
 /* 168 */ "term ::= STRING",
 /* 169 */ "term ::= INTEGER",
 /* 170 */ "expr ::= VARIABLE",
 /* 171 */ "expr ::= expr COLLATE ID|STRING",
 /* 172 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 173 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
 /* 174 */ "expr ::= ID|INDEXED LP STAR RP",

 /* 175 */ "expr ::= ID|INDEXED LP distinct exprlist RP over_clause",
 /* 176 */ "expr ::= ID|INDEXED LP STAR RP over_clause",
 /* 177 */ "term ::= CTIME_KW",
 /* 178 */ "expr ::= LP nexprlist COMMA expr RP",
 /* 179 */ "expr ::= expr AND expr",
 /* 180 */ "expr ::= expr OR expr",
 /* 181 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 182 */ "expr ::= expr EQ|NE expr",
 /* 183 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 184 */ "expr ::= expr PLUS|MINUS expr",
 /* 185 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 186 */ "expr ::= expr CONCAT expr",
 /* 187 */ "likeop ::= NOT LIKE_KW|MATCH",
 /* 188 */ "expr ::= expr likeop expr",
 /* 189 */ "expr ::= expr likeop expr ESCAPE expr",
 /* 190 */ "expr ::= expr ISNULL|NOTNULL",
 /* 191 */ "expr ::= expr NOT NULL",
 /* 192 */ "expr ::= expr IS expr",
 /* 193 */ "expr ::= expr IS NOT expr",
 /* 194 */ "expr ::= NOT expr",
 /* 195 */ "expr ::= BITNOT expr",
 /* 196 */ "expr ::= PLUS|MINUS expr",
 /* 197 */ "between_op ::= BETWEEN",
 /* 198 */ "between_op ::= NOT BETWEEN",
 /* 199 */ "expr ::= expr between_op expr AND expr",
 /* 200 */ "in_op ::= IN",
 /* 201 */ "in_op ::= NOT IN",
 /* 202 */ "expr ::= expr in_op LP exprlist RP",
 /* 203 */ "expr ::= LP select RP",
 /* 204 */ "expr ::= expr in_op LP select RP",
 /* 205 */ "expr ::= expr in_op nm dbnm paren_exprlist",
 /* 206 */ "expr ::= EXISTS LP select RP",
 /* 207 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 208 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 209 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 210 */ "case_else ::= ELSE expr",
 /* 211 */ "case_else ::=",
 /* 212 */ "case_operand ::= expr",
 /* 213 */ "case_operand ::=",
 /* 214 */ "exprlist ::=",
 /* 215 */ "nexprlist ::= nexprlist COMMA expr",
 /* 216 */ "nexprlist ::= expr",
 /* 217 */ "paren_exprlist ::=",
 /* 218 */ "paren_exprlist ::= LP exprlist RP",
 /* 219 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
 /* 220 */ "uniqueflag ::= UNIQUE",
 /* 221 */ "uniqueflag ::=",
 /* 222 */ "eidlist_opt ::=",
 /* 223 */ "eidlist_opt ::= LP eidlist RP",
 /* 224 */ "eidlist ::= eidlist COMMA nm collate sortorder",
 /* 225 */ "eidlist ::= nm collate sortorder",
 /* 226 */ "collate ::=",
 /* 227 */ "collate ::= COLLATE ID|STRING",
 /* 228 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 229 */ "cmd ::= VACUUM",
 /* 230 */ "cmd ::= VACUUM nm",
 /* 231 */ "cmd ::= PRAGMA nm dbnm",
 /* 232 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
 /* 233 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
 /* 234 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
 /* 235 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
 /* 236 */ "plus_num ::= PLUS INTEGER|FLOAT",
 /* 237 */ "minus_num ::= MINUS INTEGER|FLOAT",
 /* 238 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 239 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 240 */ "trigger_time ::= BEFORE|AFTER",
 /* 241 */ "trigger_time ::= INSTEAD OF",
 /* 242 */ "trigger_time ::=",
 /* 243 */ "trigger_event ::= DELETE|INSERT",
 /* 244 */ "trigger_event ::= UPDATE",
 /* 245 */ "trigger_event ::= UPDATE OF idlist",
 /* 246 */ "when_clause ::=",
 /* 247 */ "when_clause ::= WHEN expr",
 /* 248 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 249 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 250 */ "trnm ::= nm DOT nm",
 /* 251 */ "tridxby ::= INDEXED BY nm",
 /* 252 */ "tridxby ::= NOT INDEXED",
 /* 253 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
 /* 254 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
 /* 255 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
 /* 256 */ "trigger_cmd ::= scanpt select scanpt",
 /* 257 */ "expr ::= RAISE LP IGNORE RP",
 /* 258 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 259 */ "raisetype ::= ROLLBACK",
 /* 260 */ "raisetype ::= ABORT",
 /* 261 */ "raisetype ::= FAIL",
 /* 262 */ "cmd ::= DROP TRIGGER ifexists fullname",
 /* 263 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
 /* 264 */ "cmd ::= DETACH database_kw_opt expr",
 /* 265 */ "key_opt ::=",
 /* 266 */ "key_opt ::= KEY expr",
 /* 267 */ "cmd ::= REINDEX",
 /* 268 */ "cmd ::= REINDEX nm dbnm",
 /* 269 */ "cmd ::= ANALYZE",
 /* 270 */ "cmd ::= ANALYZE nm dbnm",
 /* 271 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
 /* 272 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
 /* 273 */ "add_column_fullname ::= fullname",
 /* 274 */ "cmd ::= create_vtab",
 /* 275 */ "cmd ::= create_vtab LP vtabarglist RP",
 /* 276 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
 /* 277 */ "vtabarg ::=",
 /* 278 */ "vtabargtoken ::= ANY",
 /* 279 */ "vtabargtoken ::= lp anylist RP",
 /* 280 */ "lp ::= LP",
 /* 281 */ "with ::= WITH wqlist",
 /* 282 */ "with ::= WITH RECURSIVE wqlist",
 /* 283 */ "wqlist ::= nm eidlist_opt AS LP select RP",
 /* 284 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
 /* 285 */ "windowdefn_list ::= windowdefn",
 /* 286 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
 /* 287 */ "windowdefn ::= nm AS window",
 /* 288 */ "window ::= LP part_opt orderby_opt frame_opt RP",
 /* 289 */ "part_opt ::= PARTITION BY nexprlist",
 /* 290 */ "part_opt ::=",
 /* 291 */ "frame_opt ::=",
 /* 292 */ "frame_opt ::= range_or_rows frame_bound_s",
 /* 293 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
 /* 294 */ "range_or_rows ::= RANGE",
 /* 295 */ "range_or_rows ::= ROWS",
 /* 296 */ "frame_bound_s ::= frame_bound",
 /* 297 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
 /* 298 */ "frame_bound_e ::= frame_bound",
 /* 299 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
 /* 300 */ "frame_bound ::= expr PRECEDING",
 /* 301 */ "frame_bound ::= CURRENT ROW",
 /* 302 */ "frame_bound ::= expr FOLLOWING",

 /* 303 */ "window_clause ::= WINDOW windowdefn_list",

 /* 304 */ "over_clause ::= filter_opt OVER window",
 /* 305 */ "over_clause ::= filter_opt OVER nm",
 /* 306 */ "filter_opt ::=",
 /* 307 */ "filter_opt ::= FILTER LP WHERE expr RP",
 /* 308 */ "input ::= cmdlist",
 /* 309 */ "cmdlist ::= cmdlist ecmd",
 /* 310 */ "cmdlist ::= ecmd",

 /* 311 */ "ecmd ::= SEMI",
 /* 312 */ "ecmd ::= cmdx SEMI",
 /* 313 */ "ecmd ::= explain cmdx",
 /* 314 */ "trans_opt ::=",
 /* 315 */ "trans_opt ::= TRANSACTION",
 /* 316 */ "trans_opt ::= TRANSACTION nm",
 /* 317 */ "savepoint_opt ::= SAVEPOINT",
 /* 318 */ "savepoint_opt ::=",
 /* 319 */ "cmd ::= create_table create_table_args",
 /* 320 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 321 */ "columnlist ::= columnname carglist",
 /* 322 */ "nm ::= ID|INDEXED",
 /* 323 */ "nm ::= STRING",
 /* 324 */ "nm ::= JOIN_KW",
 /* 325 */ "typetoken ::= typename",
 /* 326 */ "typename ::= ID|STRING",
 /* 327 */ "signed ::= plus_num",
 /* 328 */ "signed ::= minus_num",

 /* 329 */ "carglist ::= carglist ccons",
 /* 330 */ "carglist ::=",
 /* 331 */ "ccons ::= NULL onconf",
 /* 332 */ "conslist_opt ::= COMMA conslist",
 /* 333 */ "conslist ::= conslist tconscomma tcons",
 /* 334 */ "conslist ::= tcons",
 /* 335 */ "tconscomma ::=",
 /* 336 */ "defer_subclause_opt ::= defer_subclause",
 /* 337 */ "resolvetype ::= raisetype",
 /* 338 */ "selectnowith ::= oneselect",
 /* 339 */ "oneselect ::= values",
 /* 340 */ "sclp ::= selcollist COMMA",
 /* 341 */ "as ::= ID|STRING",
 /* 342 */ "expr ::= term",
 /* 343 */ "likeop ::= LIKE_KW|MATCH",
 /* 344 */ "exprlist ::= nexprlist",

 /* 345 */ "nmnum ::= plus_num",
 /* 346 */ "nmnum ::= nm",
 /* 347 */ "nmnum ::= ON",
 /* 348 */ "nmnum ::= DELETE",
 /* 349 */ "nmnum ::= DEFAULT",
 /* 350 */ "plus_num ::= INTEGER|FLOAT",
 /* 351 */ "foreach_clause ::=",
 /* 352 */ "foreach_clause ::= FOR EACH ROW",
 /* 353 */ "trnm ::= nm",
 /* 354 */ "tridxby ::=",
 /* 355 */ "database_kw_opt ::= DATABASE",
 /* 356 */ "database_kw_opt ::=",
 /* 357 */ "kwcolumn_opt ::=",
 /* 358 */ "kwcolumn_opt ::= COLUMNKW",
 /* 359 */ "vtabarglist ::= vtabarg",
 /* 360 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 361 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 362 */ "anylist ::=",
 /* 363 */ "anylist ::= anylist LP anylist RP",
 /* 364 */ "anylist ::= anylist ANY",
 /* 365 */ "with ::=",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.  Return the number
146713
146714
146715
146716
146717
146718
146719
146720
146721
146722
146723
146724
146725
146726
146727
146728
146729
146730
146731
146732
146733
146734
146735
146736
146737
146738
146739
146740
146741
146742
146743
146744
146745
146746
146747
146748
146749
146750
146751
146752
146753
146754
146755
146756
146757
146758
146759
146760
146761
146762
146763
146764
146765
146766
146767
146768
146769
146770
146771
146772
146773
146774
146775
146776
146777
146778
146779
146780
146781
sqlite3SelectDelete(pParse->db, (yypminor->yy489));
}
      break;
    case 184: /* term */
    case 185: /* expr */
    case 213: /* where_opt */
    case 215: /* having_opt */
    case 228: /* on_opt */
    case 242: /* case_operand */
    case 244: /* case_else */
    case 253: /* when_clause */
    case 258: /* key_opt */
    case 272: /* filter_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy18));
}
      break;
    case 189: /* eidlist_opt */
    case 198: /* sortlist */
    case 199: /* eidlist */
    case 211: /* selcollist */
    case 214: /* groupby_opt */
    case 217: /* orderby_opt */
    case 220: /* nexprlist */
    case 221: /* exprlist */
    case 222: /* sclp */
    case 233: /* setlist */
    case 241: /* paren_exprlist */
    case 243: /* case_exprlist */
    case 271: /* part_opt */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy420));
}
      break;
    case 205: /* fullname */
    case 212: /* from */
    case 224: /* seltablist */
    case 225: /* stl_prefix */
    case 230: /* xfullname */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy135));
}
      break;
    case 208: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy449));
}
      break;
    case 216: /* windowdefn_opt */
    case 267: /* windowdefn_list */
{
sqlite3WindowListDelete(pParse->db, (yypminor->yy327));
}
      break;
    case 229: /* using_opt */
    case 231: /* idlist */
    case 235: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy48));
}
      break;
    case 237: /* over_opt */
    case 268: /* windowdefn */
    case 269: /* window */
    case 270: /* frame_opt */
{
sqlite3WindowDelete(pParse->db, (yypminor->yy327));
}
      break;







|














|

|
|










|
|










|





|






|







146633
146634
146635
146636
146637
146638
146639
146640
146641
146642
146643
146644
146645
146646
146647
146648
146649
146650
146651
146652
146653
146654
146655
146656
146657
146658
146659
146660
146661
146662
146663
146664
146665
146666
146667
146668
146669
146670
146671
146672
146673
146674
146675
146676
146677
146678
146679
146680
146681
146682
146683
146684
146685
146686
146687
146688
146689
146690
146691
146692
146693
146694
146695
146696
146697
146698
146699
146700
146701
sqlite3SelectDelete(pParse->db, (yypminor->yy489));
}
      break;
    case 184: /* term */
    case 185: /* expr */
    case 213: /* where_opt */
    case 215: /* having_opt */
    case 227: /* on_opt */
    case 242: /* case_operand */
    case 244: /* case_else */
    case 253: /* when_clause */
    case 258: /* key_opt */
    case 272: /* filter_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy18));
}
      break;
    case 189: /* eidlist_opt */
    case 198: /* sortlist */
    case 199: /* eidlist */
    case 211: /* selcollist */
    case 214: /* groupby_opt */
    case 216: /* orderby_opt */
    case 220: /* nexprlist */
    case 221: /* sclp */
    case 229: /* exprlist */
    case 233: /* setlist */
    case 241: /* paren_exprlist */
    case 243: /* case_exprlist */
    case 271: /* part_opt */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy420));
}
      break;
    case 205: /* fullname */
    case 212: /* from */
    case 223: /* seltablist */
    case 224: /* stl_prefix */
    case 230: /* xfullname */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy135));
}
      break;
    case 208: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy449));
}
      break;
    case 218: /* window_clause */
    case 267: /* windowdefn_list */
{
sqlite3WindowListDelete(pParse->db, (yypminor->yy327));
}
      break;
    case 228: /* using_opt */
    case 231: /* idlist */
    case 235: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy48));
}
      break;
    case 237: /* over_clause */
    case 268: /* windowdefn */
    case 269: /* window */
    case 270: /* frame_opt */
{
sqlite3WindowDelete(pParse->db, (yypminor->yy327));
}
      break;
147176
147177
147178
147179
147180
147181
147182
147183

147184
147185
147186
147187
147188
147189
147190
147191
147192
147193
147194
147195
147196
147197
147198
147199
147200
147201
147202
147203
147204
147205
147206
147207
147208
147209
147210
147211
147212
147213
147214
147215
147216
147217

147218
147219
147220
147221
147222
147223
147224
147225
147226
147227
147228
147229
147230
147231
147232
147233
147234
147235
147236
147237
147238
147239
147240
147241
147242
147243
147244
147245
147246
147247
147248
147249
147250
147251
147252
147253
147254
147255
147256
147257
147258
147259
147260
147261
147262
147263
147264
147265
147266
147267
147268
147269
147270
147271
147272
147273
147274
147275
147276
147277
147278
147279
147280
147281



147282
147283
147284
147285
147286
147287
147288
147289
147290
147291
147292
147293
147294
147295
147296
147297
147298
147299
147300
147301
147302
147303
147304
147305
147306
147307
147308
147309
147310
147311
147312
147313
147314
147315
147316
147317
147318
147319
147320
147321
147322
147323
147324
147325
147326
147327
147328
147329
147330
147331
147332
147333
147334
147335
147336
147337
147338
147339
147340
147341
147342
147343
147344
147345
147346
147347
147348
147349
147350
147351
147352
147353
147354
147355
147356
147357
147358
147359
147360
147361
147362
147363
147364
147365
147366
147367
147368
147369
147370
147371
147372
147373
147374
147375
147376
147377
147378
147379
147380
147381
147382
147383
147384
147385
147386
147387
147388
147389
147390
147391
147392
147393
147394
147395
147396
147397
147398
147399
147400
147401
147402
147403
147404
147405
147406
147407
147408
147409
147410
147411
147412
147413
147414
147415
147416
147417
147418
147419
147420
147421
147422
147423
147424
147425
147426
147427
147428
147429
147430
147431
147432
147433
147434
147435
147436
147437
147438
147439
147440
147441
147442
147443
147444

147445
147446
147447
147448
147449
147450
147451
147452
147453
147454
147455
147456
147457
147458
147459
147460
147461
147462
147463
147464
147465
147466
147467
  {  174,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
  {  174,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
  {  174,   -1 }, /* (82) select ::= selectnowith */
  {  206,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
  {  209,   -1 }, /* (84) multiselect_op ::= UNION */
  {  209,   -2 }, /* (85) multiselect_op ::= UNION ALL */
  {  209,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
  {  207,  -10 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */

  {  219,   -4 }, /* (88) values ::= VALUES LP nexprlist RP */
  {  219,   -5 }, /* (89) values ::= values COMMA LP exprlist RP */
  {  210,   -1 }, /* (90) distinct ::= DISTINCT */
  {  210,   -1 }, /* (91) distinct ::= ALL */
  {  210,    0 }, /* (92) distinct ::= */
  {  222,    0 }, /* (93) sclp ::= */
  {  211,   -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
  {  211,   -3 }, /* (95) selcollist ::= sclp scanpt STAR */
  {  211,   -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
  {  223,   -2 }, /* (97) as ::= AS nm */
  {  223,    0 }, /* (98) as ::= */
  {  212,    0 }, /* (99) from ::= */
  {  212,   -2 }, /* (100) from ::= FROM seltablist */
  {  225,   -2 }, /* (101) stl_prefix ::= seltablist joinop */
  {  225,    0 }, /* (102) stl_prefix ::= */
  {  224,   -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
  {  224,   -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
  {  224,   -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
  {  224,   -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
  {  170,    0 }, /* (107) dbnm ::= */
  {  170,   -2 }, /* (108) dbnm ::= DOT nm */
  {  205,   -1 }, /* (109) fullname ::= nm */
  {  205,   -3 }, /* (110) fullname ::= nm DOT nm */
  {  230,   -1 }, /* (111) xfullname ::= nm */
  {  230,   -3 }, /* (112) xfullname ::= nm DOT nm */
  {  230,   -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
  {  230,   -3 }, /* (114) xfullname ::= nm AS nm */
  {  226,   -1 }, /* (115) joinop ::= COMMA|JOIN */
  {  226,   -2 }, /* (116) joinop ::= JOIN_KW JOIN */
  {  226,   -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
  {  226,   -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
  {  228,   -2 }, /* (119) on_opt ::= ON expr */
  {  228,    0 }, /* (120) on_opt ::= */
  {  227,    0 }, /* (121) indexed_opt ::= */

  {  227,   -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
  {  227,   -2 }, /* (123) indexed_opt ::= NOT INDEXED */
  {  229,   -4 }, /* (124) using_opt ::= USING LP idlist RP */
  {  229,    0 }, /* (125) using_opt ::= */
  {  217,    0 }, /* (126) orderby_opt ::= */
  {  217,   -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
  {  198,   -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
  {  198,   -2 }, /* (129) sortlist ::= expr sortorder */
  {  187,   -1 }, /* (130) sortorder ::= ASC */
  {  187,   -1 }, /* (131) sortorder ::= DESC */
  {  187,    0 }, /* (132) sortorder ::= */
  {  214,    0 }, /* (133) groupby_opt ::= */
  {  214,   -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
  {  215,    0 }, /* (135) having_opt ::= */
  {  215,   -2 }, /* (136) having_opt ::= HAVING expr */
  {  218,    0 }, /* (137) limit_opt ::= */
  {  218,   -2 }, /* (138) limit_opt ::= LIMIT expr */
  {  218,   -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
  {  218,   -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
  {  160,   -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
  {  213,    0 }, /* (142) where_opt ::= */
  {  213,   -2 }, /* (143) where_opt ::= WHERE expr */
  {  160,   -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
  {  233,   -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
  {  233,   -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
  {  233,   -3 }, /* (147) setlist ::= nm EQ expr */
  {  233,   -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
  {  160,   -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
  {  160,   -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
  {  236,    0 }, /* (151) upsert ::= */
  {  236,  -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
  {  236,   -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
  {  236,   -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
  {  234,   -2 }, /* (155) insert_cmd ::= INSERT orconf */
  {  234,   -1 }, /* (156) insert_cmd ::= REPLACE */
  {  235,    0 }, /* (157) idlist_opt ::= */
  {  235,   -3 }, /* (158) idlist_opt ::= LP idlist RP */
  {  231,   -3 }, /* (159) idlist ::= idlist COMMA nm */
  {  231,   -1 }, /* (160) idlist ::= nm */
  {  185,   -3 }, /* (161) expr ::= LP expr RP */
  {  185,   -1 }, /* (162) expr ::= ID|INDEXED */
  {  185,   -1 }, /* (163) expr ::= JOIN_KW */
  {  185,   -3 }, /* (164) expr ::= nm DOT nm */
  {  185,   -5 }, /* (165) expr ::= nm DOT nm DOT nm */
  {  184,   -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
  {  184,   -1 }, /* (167) term ::= STRING */
  {  184,   -1 }, /* (168) term ::= INTEGER */
  {  185,   -1 }, /* (169) expr ::= VARIABLE */
  {  185,   -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
  {  185,   -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
  {  185,   -6 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
  {  185,   -5 }, /* (173) expr ::= ID|INDEXED LP STAR RP over_opt */
  {  184,   -1 }, /* (174) term ::= CTIME_KW */
  {  185,   -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
  {  185,   -3 }, /* (176) expr ::= expr AND expr */
  {  185,   -3 }, /* (177) expr ::= expr OR expr */
  {  185,   -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
  {  185,   -3 }, /* (179) expr ::= expr EQ|NE expr */
  {  185,   -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
  {  185,   -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
  {  185,   -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
  {  185,   -3 }, /* (183) expr ::= expr CONCAT expr */
  {  238,   -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
  {  185,   -3 }, /* (185) expr ::= expr likeop expr */



  {  185,   -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
  {  185,   -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
  {  185,   -3 }, /* (188) expr ::= expr NOT NULL */
  {  185,   -3 }, /* (189) expr ::= expr IS expr */
  {  185,   -4 }, /* (190) expr ::= expr IS NOT expr */
  {  185,   -2 }, /* (191) expr ::= NOT expr */
  {  185,   -2 }, /* (192) expr ::= BITNOT expr */
  {  185,   -2 }, /* (193) expr ::= PLUS|MINUS expr */
  {  239,   -1 }, /* (194) between_op ::= BETWEEN */
  {  239,   -2 }, /* (195) between_op ::= NOT BETWEEN */
  {  185,   -5 }, /* (196) expr ::= expr between_op expr AND expr */
  {  240,   -1 }, /* (197) in_op ::= IN */
  {  240,   -2 }, /* (198) in_op ::= NOT IN */
  {  185,   -5 }, /* (199) expr ::= expr in_op LP exprlist RP */
  {  185,   -3 }, /* (200) expr ::= LP select RP */
  {  185,   -5 }, /* (201) expr ::= expr in_op LP select RP */
  {  185,   -5 }, /* (202) expr ::= expr in_op nm dbnm paren_exprlist */
  {  185,   -4 }, /* (203) expr ::= EXISTS LP select RP */
  {  185,   -5 }, /* (204) expr ::= CASE case_operand case_exprlist case_else END */
  {  243,   -5 }, /* (205) case_exprlist ::= case_exprlist WHEN expr THEN expr */
  {  243,   -4 }, /* (206) case_exprlist ::= WHEN expr THEN expr */
  {  244,   -2 }, /* (207) case_else ::= ELSE expr */
  {  244,    0 }, /* (208) case_else ::= */
  {  242,   -1 }, /* (209) case_operand ::= expr */
  {  242,    0 }, /* (210) case_operand ::= */
  {  221,    0 }, /* (211) exprlist ::= */
  {  220,   -3 }, /* (212) nexprlist ::= nexprlist COMMA expr */
  {  220,   -1 }, /* (213) nexprlist ::= expr */
  {  241,    0 }, /* (214) paren_exprlist ::= */
  {  241,   -3 }, /* (215) paren_exprlist ::= LP exprlist RP */
  {  160,  -12 }, /* (216) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
  {  245,   -1 }, /* (217) uniqueflag ::= UNIQUE */
  {  245,    0 }, /* (218) uniqueflag ::= */
  {  189,    0 }, /* (219) eidlist_opt ::= */
  {  189,   -3 }, /* (220) eidlist_opt ::= LP eidlist RP */
  {  199,   -5 }, /* (221) eidlist ::= eidlist COMMA nm collate sortorder */
  {  199,   -3 }, /* (222) eidlist ::= nm collate sortorder */
  {  246,    0 }, /* (223) collate ::= */
  {  246,   -2 }, /* (224) collate ::= COLLATE ID|STRING */
  {  160,   -4 }, /* (225) cmd ::= DROP INDEX ifexists fullname */
  {  160,   -1 }, /* (226) cmd ::= VACUUM */
  {  160,   -2 }, /* (227) cmd ::= VACUUM nm */
  {  160,   -3 }, /* (228) cmd ::= PRAGMA nm dbnm */
  {  160,   -5 }, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
  {  160,   -6 }, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
  {  160,   -5 }, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
  {  160,   -6 }, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
  {  180,   -2 }, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
  {  181,   -2 }, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
  {  160,   -5 }, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
  {  248,  -11 }, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
  {  250,   -1 }, /* (237) trigger_time ::= BEFORE|AFTER */
  {  250,   -2 }, /* (238) trigger_time ::= INSTEAD OF */
  {  250,    0 }, /* (239) trigger_time ::= */
  {  251,   -1 }, /* (240) trigger_event ::= DELETE|INSERT */
  {  251,   -1 }, /* (241) trigger_event ::= UPDATE */
  {  251,   -3 }, /* (242) trigger_event ::= UPDATE OF idlist */
  {  253,    0 }, /* (243) when_clause ::= */
  {  253,   -2 }, /* (244) when_clause ::= WHEN expr */
  {  249,   -3 }, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
  {  249,   -2 }, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
  {  255,   -3 }, /* (247) trnm ::= nm DOT nm */
  {  256,   -3 }, /* (248) tridxby ::= INDEXED BY nm */
  {  256,   -2 }, /* (249) tridxby ::= NOT INDEXED */
  {  254,   -8 }, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
  {  254,   -8 }, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
  {  254,   -6 }, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
  {  254,   -3 }, /* (253) trigger_cmd ::= scanpt select scanpt */
  {  185,   -4 }, /* (254) expr ::= RAISE LP IGNORE RP */
  {  185,   -6 }, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
  {  203,   -1 }, /* (256) raisetype ::= ROLLBACK */
  {  203,   -1 }, /* (257) raisetype ::= ABORT */
  {  203,   -1 }, /* (258) raisetype ::= FAIL */
  {  160,   -4 }, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
  {  160,   -6 }, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
  {  160,   -3 }, /* (261) cmd ::= DETACH database_kw_opt expr */
  {  258,    0 }, /* (262) key_opt ::= */
  {  258,   -2 }, /* (263) key_opt ::= KEY expr */
  {  160,   -1 }, /* (264) cmd ::= REINDEX */
  {  160,   -3 }, /* (265) cmd ::= REINDEX nm dbnm */
  {  160,   -1 }, /* (266) cmd ::= ANALYZE */
  {  160,   -3 }, /* (267) cmd ::= ANALYZE nm dbnm */
  {  160,   -6 }, /* (268) cmd ::= ALTER TABLE fullname RENAME TO nm */
  {  160,   -7 }, /* (269) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
  {  259,   -1 }, /* (270) add_column_fullname ::= fullname */
  {  160,   -1 }, /* (271) cmd ::= create_vtab */
  {  160,   -4 }, /* (272) cmd ::= create_vtab LP vtabarglist RP */
  {  261,   -8 }, /* (273) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
  {  263,    0 }, /* (274) vtabarg ::= */
  {  264,   -1 }, /* (275) vtabargtoken ::= ANY */
  {  264,   -3 }, /* (276) vtabargtoken ::= lp anylist RP */
  {  265,   -1 }, /* (277) lp ::= LP */
  {  232,   -2 }, /* (278) with ::= WITH wqlist */
  {  232,   -3 }, /* (279) with ::= WITH RECURSIVE wqlist */
  {  208,   -6 }, /* (280) wqlist ::= nm eidlist_opt AS LP select RP */
  {  208,   -8 }, /* (281) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
  {  267,   -1 }, /* (282) windowdefn_list ::= windowdefn */
  {  267,   -3 }, /* (283) windowdefn_list ::= windowdefn_list COMMA windowdefn */
  {  268,   -3 }, /* (284) windowdefn ::= nm AS window */
  {  269,   -5 }, /* (285) window ::= LP part_opt orderby_opt frame_opt RP */
  {  271,   -3 }, /* (286) part_opt ::= PARTITION BY exprlist */
  {  271,    0 }, /* (287) part_opt ::= */
  {  270,    0 }, /* (288) frame_opt ::= */
  {  270,   -2 }, /* (289) frame_opt ::= range_or_rows frame_bound_s */
  {  270,   -5 }, /* (290) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
  {  273,   -1 }, /* (291) range_or_rows ::= RANGE */
  {  273,   -1 }, /* (292) range_or_rows ::= ROWS */
  {  275,   -1 }, /* (293) frame_bound_s ::= frame_bound */
  {  275,   -2 }, /* (294) frame_bound_s ::= UNBOUNDED PRECEDING */
  {  276,   -1 }, /* (295) frame_bound_e ::= frame_bound */
  {  276,   -2 }, /* (296) frame_bound_e ::= UNBOUNDED FOLLOWING */
  {  274,   -2 }, /* (297) frame_bound ::= expr PRECEDING */
  {  274,   -2 }, /* (298) frame_bound ::= CURRENT ROW */
  {  274,   -2 }, /* (299) frame_bound ::= expr FOLLOWING */
  {  216,    0 }, /* (300) windowdefn_opt ::= */
  {  216,   -2 }, /* (301) windowdefn_opt ::= WINDOW windowdefn_list */
  {  237,    0 }, /* (302) over_opt ::= */
  {  237,   -3 }, /* (303) over_opt ::= filter_opt OVER window */
  {  237,   -3 }, /* (304) over_opt ::= filter_opt OVER nm */
  {  272,    0 }, /* (305) filter_opt ::= */
  {  272,   -5 }, /* (306) filter_opt ::= FILTER LP WHERE expr RP */
  {  155,   -1 }, /* (307) input ::= cmdlist */
  {  156,   -2 }, /* (308) cmdlist ::= cmdlist ecmd */
  {  156,   -1 }, /* (309) cmdlist ::= ecmd */
  {  157,   -1 }, /* (310) ecmd ::= SEMI */
  {  157,   -2 }, /* (311) ecmd ::= cmdx SEMI */
  {  157,   -2 }, /* (312) ecmd ::= explain cmdx */
  {  162,    0 }, /* (313) trans_opt ::= */
  {  162,   -1 }, /* (314) trans_opt ::= TRANSACTION */
  {  162,   -2 }, /* (315) trans_opt ::= TRANSACTION nm */
  {  164,   -1 }, /* (316) savepoint_opt ::= SAVEPOINT */
  {  164,    0 }, /* (317) savepoint_opt ::= */
  {  160,   -2 }, /* (318) cmd ::= create_table create_table_args */
  {  171,   -4 }, /* (319) columnlist ::= columnlist COMMA columnname carglist */
  {  171,   -2 }, /* (320) columnlist ::= columnname carglist */
  {  163,   -1 }, /* (321) nm ::= ID|INDEXED */
  {  163,   -1 }, /* (322) nm ::= STRING */
  {  163,   -1 }, /* (323) nm ::= JOIN_KW */
  {  177,   -1 }, /* (324) typetoken ::= typename */
  {  178,   -1 }, /* (325) typename ::= ID|STRING */
  {  179,   -1 }, /* (326) signed ::= plus_num */
  {  179,   -1 }, /* (327) signed ::= minus_num */
  {  176,   -2 }, /* (328) carglist ::= carglist ccons */
  {  176,    0 }, /* (329) carglist ::= */
  {  183,   -2 }, /* (330) ccons ::= NULL onconf */
  {  172,   -2 }, /* (331) conslist_opt ::= COMMA conslist */
  {  195,   -3 }, /* (332) conslist ::= conslist tconscomma tcons */
  {  195,   -1 }, /* (333) conslist ::= tcons */
  {  196,    0 }, /* (334) tconscomma ::= */
  {  200,   -1 }, /* (335) defer_subclause_opt ::= defer_subclause */
  {  202,   -1 }, /* (336) resolvetype ::= raisetype */
  {  206,   -1 }, /* (337) selectnowith ::= oneselect */
  {  207,   -1 }, /* (338) oneselect ::= values */
  {  222,   -2 }, /* (339) sclp ::= selcollist COMMA */
  {  223,   -1 }, /* (340) as ::= ID|STRING */
  {  185,   -1 }, /* (341) expr ::= term */
  {  238,   -1 }, /* (342) likeop ::= LIKE_KW|MATCH */
  {  221,   -1 }, /* (343) exprlist ::= nexprlist */
  {  247,   -1 }, /* (344) nmnum ::= plus_num */
  {  247,   -1 }, /* (345) nmnum ::= nm */
  {  247,   -1 }, /* (346) nmnum ::= ON */
  {  247,   -1 }, /* (347) nmnum ::= DELETE */
  {  247,   -1 }, /* (348) nmnum ::= DEFAULT */

  {  180,   -1 }, /* (349) plus_num ::= INTEGER|FLOAT */
  {  252,    0 }, /* (350) foreach_clause ::= */
  {  252,   -3 }, /* (351) foreach_clause ::= FOR EACH ROW */
  {  255,   -1 }, /* (352) trnm ::= nm */
  {  256,    0 }, /* (353) tridxby ::= */
  {  257,   -1 }, /* (354) database_kw_opt ::= DATABASE */
  {  257,    0 }, /* (355) database_kw_opt ::= */
  {  260,    0 }, /* (356) kwcolumn_opt ::= */
  {  260,   -1 }, /* (357) kwcolumn_opt ::= COLUMNKW */
  {  262,   -1 }, /* (358) vtabarglist ::= vtabarg */
  {  262,   -3 }, /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */
  {  263,   -2 }, /* (360) vtabarg ::= vtabarg vtabargtoken */
  {  266,    0 }, /* (361) anylist ::= */
  {  266,   -4 }, /* (362) anylist ::= anylist LP anylist RP */
  {  266,   -2 }, /* (363) anylist ::= anylist ANY */
  {  232,    0 }, /* (364) with ::= */
};

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

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.







|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







147096
147097
147098
147099
147100
147101
147102
147103
147104
147105
147106
147107
147108
147109
147110
147111
147112
147113
147114
147115
147116
147117
147118
147119
147120
147121
147122
147123
147124
147125
147126
147127
147128
147129
147130
147131
147132
147133
147134
147135

147136
147137
147138
147139
147140
147141
147142
147143
147144
147145
147146
147147
147148
147149
147150
147151
147152
147153
147154
147155
147156
147157
147158
147159
147160
147161
147162
147163
147164
147165
147166
147167
147168
147169
147170
147171
147172
147173
147174
147175
147176
147177
147178

147179
147180
147181
147182
147183
147184
147185
147186
147187
147188
147189
147190
147191
147192
147193
147194
147195
147196
147197
147198
147199
147200
147201
147202
147203
147204
147205
147206
147207
147208
147209
147210
147211
147212
147213
147214
147215
147216
147217
147218
147219
147220
147221
147222
147223
147224
147225
147226
147227
147228
147229
147230
147231
147232
147233
147234
147235
147236
147237
147238
147239
147240
147241
147242
147243
147244
147245
147246
147247
147248
147249
147250
147251
147252
147253
147254
147255
147256
147257
147258
147259
147260
147261
147262
147263
147264
147265
147266
147267
147268
147269
147270
147271
147272
147273
147274
147275
147276
147277
147278
147279
147280
147281
147282
147283
147284
147285
147286
147287
147288
147289
147290
147291
147292
147293
147294
147295
147296
147297
147298
147299
147300
147301
147302
147303
147304
147305
147306
147307
147308
147309
147310
147311
147312
147313
147314
147315
147316
147317
147318

147319

147320
147321
147322
147323
147324
147325
147326
147327
147328
147329
147330
147331
147332
147333
147334
147335
147336
147337
147338
147339
147340
147341
147342
147343
147344
147345
147346
147347
147348
147349
147350
147351
147352
147353
147354
147355
147356
147357
147358
147359
147360

147361
147362
147363
147364
147365
147366
147367
147368
147369
147370
147371
147372
147373
147374
147375
147376
147377
147378
147379
147380
147381
147382
147383
147384
147385
147386
147387
147388
  {  174,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
  {  174,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
  {  174,   -1 }, /* (82) select ::= selectnowith */
  {  206,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
  {  209,   -1 }, /* (84) multiselect_op ::= UNION */
  {  209,   -2 }, /* (85) multiselect_op ::= UNION ALL */
  {  209,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
  {  207,   -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
  {  207,  -10 }, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
  {  219,   -4 }, /* (89) values ::= VALUES LP nexprlist RP */
  {  219,   -5 }, /* (90) values ::= values COMMA LP nexprlist RP */
  {  210,   -1 }, /* (91) distinct ::= DISTINCT */
  {  210,   -1 }, /* (92) distinct ::= ALL */
  {  210,    0 }, /* (93) distinct ::= */
  {  221,    0 }, /* (94) sclp ::= */
  {  211,   -5 }, /* (95) selcollist ::= sclp scanpt expr scanpt as */
  {  211,   -3 }, /* (96) selcollist ::= sclp scanpt STAR */
  {  211,   -5 }, /* (97) selcollist ::= sclp scanpt nm DOT STAR */
  {  222,   -2 }, /* (98) as ::= AS nm */
  {  222,    0 }, /* (99) as ::= */
  {  212,    0 }, /* (100) from ::= */
  {  212,   -2 }, /* (101) from ::= FROM seltablist */
  {  224,   -2 }, /* (102) stl_prefix ::= seltablist joinop */
  {  224,    0 }, /* (103) stl_prefix ::= */
  {  223,   -7 }, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
  {  223,   -9 }, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
  {  223,   -7 }, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
  {  223,   -7 }, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
  {  170,    0 }, /* (108) dbnm ::= */
  {  170,   -2 }, /* (109) dbnm ::= DOT nm */
  {  205,   -1 }, /* (110) fullname ::= nm */
  {  205,   -3 }, /* (111) fullname ::= nm DOT nm */
  {  230,   -1 }, /* (112) xfullname ::= nm */
  {  230,   -3 }, /* (113) xfullname ::= nm DOT nm */
  {  230,   -5 }, /* (114) xfullname ::= nm DOT nm AS nm */
  {  230,   -3 }, /* (115) xfullname ::= nm AS nm */
  {  225,   -1 }, /* (116) joinop ::= COMMA|JOIN */
  {  225,   -2 }, /* (117) joinop ::= JOIN_KW JOIN */
  {  225,   -3 }, /* (118) joinop ::= JOIN_KW nm JOIN */
  {  225,   -4 }, /* (119) joinop ::= JOIN_KW nm nm JOIN */

  {  227,   -2 }, /* (120) on_opt ::= ON expr */
  {  227,    0 }, /* (121) on_opt ::= */
  {  226,    0 }, /* (122) indexed_opt ::= */
  {  226,   -3 }, /* (123) indexed_opt ::= INDEXED BY nm */
  {  226,   -2 }, /* (124) indexed_opt ::= NOT INDEXED */
  {  228,   -4 }, /* (125) using_opt ::= USING LP idlist RP */
  {  228,    0 }, /* (126) using_opt ::= */
  {  216,    0 }, /* (127) orderby_opt ::= */
  {  216,   -3 }, /* (128) orderby_opt ::= ORDER BY sortlist */
  {  198,   -4 }, /* (129) sortlist ::= sortlist COMMA expr sortorder */
  {  198,   -2 }, /* (130) sortlist ::= expr sortorder */
  {  187,   -1 }, /* (131) sortorder ::= ASC */
  {  187,   -1 }, /* (132) sortorder ::= DESC */
  {  187,    0 }, /* (133) sortorder ::= */
  {  214,    0 }, /* (134) groupby_opt ::= */
  {  214,   -3 }, /* (135) groupby_opt ::= GROUP BY nexprlist */
  {  215,    0 }, /* (136) having_opt ::= */
  {  215,   -2 }, /* (137) having_opt ::= HAVING expr */
  {  217,    0 }, /* (138) limit_opt ::= */
  {  217,   -2 }, /* (139) limit_opt ::= LIMIT expr */
  {  217,   -4 }, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
  {  217,   -4 }, /* (141) limit_opt ::= LIMIT expr COMMA expr */
  {  160,   -6 }, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
  {  213,    0 }, /* (143) where_opt ::= */
  {  213,   -2 }, /* (144) where_opt ::= WHERE expr */
  {  160,   -8 }, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
  {  233,   -5 }, /* (146) setlist ::= setlist COMMA nm EQ expr */
  {  233,   -7 }, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
  {  233,   -3 }, /* (148) setlist ::= nm EQ expr */
  {  233,   -5 }, /* (149) setlist ::= LP idlist RP EQ expr */
  {  160,   -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
  {  160,   -7 }, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
  {  236,    0 }, /* (152) upsert ::= */
  {  236,  -11 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
  {  236,   -8 }, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
  {  236,   -4 }, /* (155) upsert ::= ON CONFLICT DO NOTHING */
  {  234,   -2 }, /* (156) insert_cmd ::= INSERT orconf */
  {  234,   -1 }, /* (157) insert_cmd ::= REPLACE */
  {  235,    0 }, /* (158) idlist_opt ::= */
  {  235,   -3 }, /* (159) idlist_opt ::= LP idlist RP */
  {  231,   -3 }, /* (160) idlist ::= idlist COMMA nm */
  {  231,   -1 }, /* (161) idlist ::= nm */
  {  185,   -3 }, /* (162) expr ::= LP expr RP */

  {  185,   -1 }, /* (163) expr ::= ID|INDEXED */
  {  185,   -1 }, /* (164) expr ::= JOIN_KW */
  {  185,   -3 }, /* (165) expr ::= nm DOT nm */
  {  185,   -5 }, /* (166) expr ::= nm DOT nm DOT nm */
  {  184,   -1 }, /* (167) term ::= NULL|FLOAT|BLOB */
  {  184,   -1 }, /* (168) term ::= STRING */
  {  184,   -1 }, /* (169) term ::= INTEGER */
  {  185,   -1 }, /* (170) expr ::= VARIABLE */
  {  185,   -3 }, /* (171) expr ::= expr COLLATE ID|STRING */
  {  185,   -6 }, /* (172) expr ::= CAST LP expr AS typetoken RP */
  {  185,   -5 }, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */
  {  185,   -4 }, /* (174) expr ::= ID|INDEXED LP STAR RP */
  {  185,   -6 }, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
  {  185,   -5 }, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */
  {  184,   -1 }, /* (177) term ::= CTIME_KW */
  {  185,   -5 }, /* (178) expr ::= LP nexprlist COMMA expr RP */
  {  185,   -3 }, /* (179) expr ::= expr AND expr */
  {  185,   -3 }, /* (180) expr ::= expr OR expr */
  {  185,   -3 }, /* (181) expr ::= expr LT|GT|GE|LE expr */
  {  185,   -3 }, /* (182) expr ::= expr EQ|NE expr */
  {  185,   -3 }, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
  {  185,   -3 }, /* (184) expr ::= expr PLUS|MINUS expr */
  {  185,   -3 }, /* (185) expr ::= expr STAR|SLASH|REM expr */
  {  185,   -3 }, /* (186) expr ::= expr CONCAT expr */
  {  238,   -2 }, /* (187) likeop ::= NOT LIKE_KW|MATCH */
  {  185,   -3 }, /* (188) expr ::= expr likeop expr */
  {  185,   -5 }, /* (189) expr ::= expr likeop expr ESCAPE expr */
  {  185,   -2 }, /* (190) expr ::= expr ISNULL|NOTNULL */
  {  185,   -3 }, /* (191) expr ::= expr NOT NULL */
  {  185,   -3 }, /* (192) expr ::= expr IS expr */
  {  185,   -4 }, /* (193) expr ::= expr IS NOT expr */
  {  185,   -2 }, /* (194) expr ::= NOT expr */
  {  185,   -2 }, /* (195) expr ::= BITNOT expr */
  {  185,   -2 }, /* (196) expr ::= PLUS|MINUS expr */
  {  239,   -1 }, /* (197) between_op ::= BETWEEN */
  {  239,   -2 }, /* (198) between_op ::= NOT BETWEEN */
  {  185,   -5 }, /* (199) expr ::= expr between_op expr AND expr */
  {  240,   -1 }, /* (200) in_op ::= IN */
  {  240,   -2 }, /* (201) in_op ::= NOT IN */
  {  185,   -5 }, /* (202) expr ::= expr in_op LP exprlist RP */
  {  185,   -3 }, /* (203) expr ::= LP select RP */
  {  185,   -5 }, /* (204) expr ::= expr in_op LP select RP */
  {  185,   -5 }, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */
  {  185,   -4 }, /* (206) expr ::= EXISTS LP select RP */
  {  185,   -5 }, /* (207) expr ::= CASE case_operand case_exprlist case_else END */
  {  243,   -5 }, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */
  {  243,   -4 }, /* (209) case_exprlist ::= WHEN expr THEN expr */
  {  244,   -2 }, /* (210) case_else ::= ELSE expr */
  {  244,    0 }, /* (211) case_else ::= */
  {  242,   -1 }, /* (212) case_operand ::= expr */
  {  242,    0 }, /* (213) case_operand ::= */
  {  229,    0 }, /* (214) exprlist ::= */
  {  220,   -3 }, /* (215) nexprlist ::= nexprlist COMMA expr */
  {  220,   -1 }, /* (216) nexprlist ::= expr */
  {  241,    0 }, /* (217) paren_exprlist ::= */
  {  241,   -3 }, /* (218) paren_exprlist ::= LP exprlist RP */
  {  160,  -12 }, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
  {  245,   -1 }, /* (220) uniqueflag ::= UNIQUE */
  {  245,    0 }, /* (221) uniqueflag ::= */
  {  189,    0 }, /* (222) eidlist_opt ::= */
  {  189,   -3 }, /* (223) eidlist_opt ::= LP eidlist RP */
  {  199,   -5 }, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */
  {  199,   -3 }, /* (225) eidlist ::= nm collate sortorder */
  {  246,    0 }, /* (226) collate ::= */
  {  246,   -2 }, /* (227) collate ::= COLLATE ID|STRING */
  {  160,   -4 }, /* (228) cmd ::= DROP INDEX ifexists fullname */
  {  160,   -1 }, /* (229) cmd ::= VACUUM */
  {  160,   -2 }, /* (230) cmd ::= VACUUM nm */
  {  160,   -3 }, /* (231) cmd ::= PRAGMA nm dbnm */
  {  160,   -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ nmnum */
  {  160,   -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP nmnum RP */
  {  160,   -5 }, /* (234) cmd ::= PRAGMA nm dbnm EQ minus_num */
  {  160,   -6 }, /* (235) cmd ::= PRAGMA nm dbnm LP minus_num RP */
  {  180,   -2 }, /* (236) plus_num ::= PLUS INTEGER|FLOAT */
  {  181,   -2 }, /* (237) minus_num ::= MINUS INTEGER|FLOAT */
  {  160,   -5 }, /* (238) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
  {  248,  -11 }, /* (239) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
  {  250,   -1 }, /* (240) trigger_time ::= BEFORE|AFTER */
  {  250,   -2 }, /* (241) trigger_time ::= INSTEAD OF */
  {  250,    0 }, /* (242) trigger_time ::= */
  {  251,   -1 }, /* (243) trigger_event ::= DELETE|INSERT */
  {  251,   -1 }, /* (244) trigger_event ::= UPDATE */
  {  251,   -3 }, /* (245) trigger_event ::= UPDATE OF idlist */
  {  253,    0 }, /* (246) when_clause ::= */
  {  253,   -2 }, /* (247) when_clause ::= WHEN expr */
  {  249,   -3 }, /* (248) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
  {  249,   -2 }, /* (249) trigger_cmd_list ::= trigger_cmd SEMI */
  {  255,   -3 }, /* (250) trnm ::= nm DOT nm */
  {  256,   -3 }, /* (251) tridxby ::= INDEXED BY nm */
  {  256,   -2 }, /* (252) tridxby ::= NOT INDEXED */
  {  254,   -8 }, /* (253) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
  {  254,   -8 }, /* (254) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
  {  254,   -6 }, /* (255) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
  {  254,   -3 }, /* (256) trigger_cmd ::= scanpt select scanpt */
  {  185,   -4 }, /* (257) expr ::= RAISE LP IGNORE RP */
  {  185,   -6 }, /* (258) expr ::= RAISE LP raisetype COMMA nm RP */
  {  203,   -1 }, /* (259) raisetype ::= ROLLBACK */
  {  203,   -1 }, /* (260) raisetype ::= ABORT */
  {  203,   -1 }, /* (261) raisetype ::= FAIL */
  {  160,   -4 }, /* (262) cmd ::= DROP TRIGGER ifexists fullname */
  {  160,   -6 }, /* (263) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
  {  160,   -3 }, /* (264) cmd ::= DETACH database_kw_opt expr */
  {  258,    0 }, /* (265) key_opt ::= */
  {  258,   -2 }, /* (266) key_opt ::= KEY expr */
  {  160,   -1 }, /* (267) cmd ::= REINDEX */
  {  160,   -3 }, /* (268) cmd ::= REINDEX nm dbnm */
  {  160,   -1 }, /* (269) cmd ::= ANALYZE */
  {  160,   -3 }, /* (270) cmd ::= ANALYZE nm dbnm */
  {  160,   -6 }, /* (271) cmd ::= ALTER TABLE fullname RENAME TO nm */
  {  160,   -7 }, /* (272) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
  {  259,   -1 }, /* (273) add_column_fullname ::= fullname */
  {  160,   -1 }, /* (274) cmd ::= create_vtab */
  {  160,   -4 }, /* (275) cmd ::= create_vtab LP vtabarglist RP */
  {  261,   -8 }, /* (276) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
  {  263,    0 }, /* (277) vtabarg ::= */
  {  264,   -1 }, /* (278) vtabargtoken ::= ANY */
  {  264,   -3 }, /* (279) vtabargtoken ::= lp anylist RP */
  {  265,   -1 }, /* (280) lp ::= LP */
  {  232,   -2 }, /* (281) with ::= WITH wqlist */
  {  232,   -3 }, /* (282) with ::= WITH RECURSIVE wqlist */
  {  208,   -6 }, /* (283) wqlist ::= nm eidlist_opt AS LP select RP */
  {  208,   -8 }, /* (284) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
  {  267,   -1 }, /* (285) windowdefn_list ::= windowdefn */
  {  267,   -3 }, /* (286) windowdefn_list ::= windowdefn_list COMMA windowdefn */
  {  268,   -3 }, /* (287) windowdefn ::= nm AS window */
  {  269,   -5 }, /* (288) window ::= LP part_opt orderby_opt frame_opt RP */
  {  271,   -3 }, /* (289) part_opt ::= PARTITION BY nexprlist */
  {  271,    0 }, /* (290) part_opt ::= */
  {  270,    0 }, /* (291) frame_opt ::= */
  {  270,   -2 }, /* (292) frame_opt ::= range_or_rows frame_bound_s */
  {  270,   -5 }, /* (293) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
  {  273,   -1 }, /* (294) range_or_rows ::= RANGE */
  {  273,   -1 }, /* (295) range_or_rows ::= ROWS */
  {  275,   -1 }, /* (296) frame_bound_s ::= frame_bound */
  {  275,   -2 }, /* (297) frame_bound_s ::= UNBOUNDED PRECEDING */
  {  276,   -1 }, /* (298) frame_bound_e ::= frame_bound */
  {  276,   -2 }, /* (299) frame_bound_e ::= UNBOUNDED FOLLOWING */
  {  274,   -2 }, /* (300) frame_bound ::= expr PRECEDING */
  {  274,   -2 }, /* (301) frame_bound ::= CURRENT ROW */
  {  274,   -2 }, /* (302) frame_bound ::= expr FOLLOWING */

  {  218,   -2 }, /* (303) window_clause ::= WINDOW windowdefn_list */

  {  237,   -3 }, /* (304) over_clause ::= filter_opt OVER window */
  {  237,   -3 }, /* (305) over_clause ::= filter_opt OVER nm */
  {  272,    0 }, /* (306) filter_opt ::= */
  {  272,   -5 }, /* (307) filter_opt ::= FILTER LP WHERE expr RP */
  {  155,   -1 }, /* (308) input ::= cmdlist */
  {  156,   -2 }, /* (309) cmdlist ::= cmdlist ecmd */
  {  156,   -1 }, /* (310) cmdlist ::= ecmd */
  {  157,   -1 }, /* (311) ecmd ::= SEMI */
  {  157,   -2 }, /* (312) ecmd ::= cmdx SEMI */
  {  157,   -2 }, /* (313) ecmd ::= explain cmdx */
  {  162,    0 }, /* (314) trans_opt ::= */
  {  162,   -1 }, /* (315) trans_opt ::= TRANSACTION */
  {  162,   -2 }, /* (316) trans_opt ::= TRANSACTION nm */
  {  164,   -1 }, /* (317) savepoint_opt ::= SAVEPOINT */
  {  164,    0 }, /* (318) savepoint_opt ::= */
  {  160,   -2 }, /* (319) cmd ::= create_table create_table_args */
  {  171,   -4 }, /* (320) columnlist ::= columnlist COMMA columnname carglist */
  {  171,   -2 }, /* (321) columnlist ::= columnname carglist */
  {  163,   -1 }, /* (322) nm ::= ID|INDEXED */
  {  163,   -1 }, /* (323) nm ::= STRING */
  {  163,   -1 }, /* (324) nm ::= JOIN_KW */
  {  177,   -1 }, /* (325) typetoken ::= typename */
  {  178,   -1 }, /* (326) typename ::= ID|STRING */
  {  179,   -1 }, /* (327) signed ::= plus_num */
  {  179,   -1 }, /* (328) signed ::= minus_num */
  {  176,   -2 }, /* (329) carglist ::= carglist ccons */
  {  176,    0 }, /* (330) carglist ::= */
  {  183,   -2 }, /* (331) ccons ::= NULL onconf */
  {  172,   -2 }, /* (332) conslist_opt ::= COMMA conslist */
  {  195,   -3 }, /* (333) conslist ::= conslist tconscomma tcons */
  {  195,   -1 }, /* (334) conslist ::= tcons */
  {  196,    0 }, /* (335) tconscomma ::= */
  {  200,   -1 }, /* (336) defer_subclause_opt ::= defer_subclause */
  {  202,   -1 }, /* (337) resolvetype ::= raisetype */
  {  206,   -1 }, /* (338) selectnowith ::= oneselect */
  {  207,   -1 }, /* (339) oneselect ::= values */
  {  221,   -2 }, /* (340) sclp ::= selcollist COMMA */
  {  222,   -1 }, /* (341) as ::= ID|STRING */
  {  185,   -1 }, /* (342) expr ::= term */
  {  238,   -1 }, /* (343) likeop ::= LIKE_KW|MATCH */
  {  229,   -1 }, /* (344) exprlist ::= nexprlist */

  {  247,   -1 }, /* (345) nmnum ::= plus_num */
  {  247,   -1 }, /* (346) nmnum ::= nm */
  {  247,   -1 }, /* (347) nmnum ::= ON */
  {  247,   -1 }, /* (348) nmnum ::= DELETE */
  {  247,   -1 }, /* (349) nmnum ::= DEFAULT */
  {  180,   -1 }, /* (350) plus_num ::= INTEGER|FLOAT */
  {  252,    0 }, /* (351) foreach_clause ::= */
  {  252,   -3 }, /* (352) foreach_clause ::= FOR EACH ROW */
  {  255,   -1 }, /* (353) trnm ::= nm */
  {  256,    0 }, /* (354) tridxby ::= */
  {  257,   -1 }, /* (355) database_kw_opt ::= DATABASE */
  {  257,    0 }, /* (356) database_kw_opt ::= */
  {  260,    0 }, /* (357) kwcolumn_opt ::= */
  {  260,   -1 }, /* (358) kwcolumn_opt ::= COLUMNKW */
  {  262,   -1 }, /* (359) vtabarglist ::= vtabarg */
  {  262,   -3 }, /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */
  {  263,   -2 }, /* (361) vtabarg ::= vtabarg vtabargtoken */
  {  266,    0 }, /* (362) anylist ::= */
  {  266,   -4 }, /* (363) anylist ::= anylist LP anylist RP */
  {  266,   -2 }, /* (364) anylist ::= anylist ANY */
  {  232,    0 }, /* (365) with ::= */
};

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

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
147594
147595
147596
147597
147598
147599
147600
147601
147602
147603
147604
147605
147606
147607
147608
147609
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 21: /* table_options ::= */ yytestcase(yyruleno==21);
      case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
      case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
      case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
      case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
      case 92: /* distinct ::= */ yytestcase(yyruleno==92);
      case 223: /* collate ::= */ yytestcase(yyruleno==223);
{yymsp[1].minor.yy70 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy70 = 1;}
        break;
      case 17: /* temp ::= TEMP */
      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);







|
|







147515
147516
147517
147518
147519
147520
147521
147522
147523
147524
147525
147526
147527
147528
147529
147530
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 21: /* table_options ::= */ yytestcase(yyruleno==21);
      case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
      case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
      case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
      case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
      case 93: /* distinct ::= */ yytestcase(yyruleno==93);
      case 226: /* collate ::= */ yytestcase(yyruleno==226);
{yymsp[1].minor.yy70 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy70 = 1;}
        break;
      case 17: /* temp ::= TEMP */
      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
147631
147632
147633
147634
147635
147636
147637
147638
147639
147640
147641
147642
147643
147644
147645
}
        break;
      case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 24: /* typetoken ::= */
      case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
      case 98: /* as ::= */ yytestcase(yyruleno==98);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
        break;
      case 25: /* typetoken ::= typename LP signed RP */
{
  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;







|







147552
147553
147554
147555
147556
147557
147558
147559
147560
147561
147562
147563
147564
147565
147566
}
        break;
      case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 24: /* typetoken ::= */
      case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
      case 99: /* as ::= */ yytestcase(yyruleno==99);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
        break;
      case 25: /* typetoken ::= typename LP signed RP */
{
  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;
147742
147743
147744
147745
147746
147747
147748
147749
147750
147751
147752
147753
147754
147755
147756
147757
147758
147759
147760
147761
147762
147763
{ yymsp[-1].minor.yy70 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy70 = 0;}
        break;
      case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
      case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
{yymsp[-1].minor.yy70 = yymsp[0].minor.yy70;}
        break;
      case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
      case 195: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==195);
      case 198: /* in_op ::= NOT IN */ yytestcase(yyruleno==198);
      case 224: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==224);
{yymsp[-1].minor.yy70 = 1;}
        break;
      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy70 = 0;}
        break;
      case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}







|




|
|
|







147663
147664
147665
147666
147667
147668
147669
147670
147671
147672
147673
147674
147675
147676
147677
147678
147679
147680
147681
147682
147683
147684
{ yymsp[-1].minor.yy70 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy70 = 0;}
        break;
      case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
      case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156);
{yymsp[-1].minor.yy70 = yymsp[0].minor.yy70;}
        break;
      case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
      case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198);
      case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201);
      case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227);
{yymsp[-1].minor.yy70 = 1;}
        break;
      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy70 = 0;}
        break;
      case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
147785
147786
147787
147788
147789
147790
147791
147792
147793
147794
147795
147796
147797
147798
147799
      case 69: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
        break;
      case 72: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy70 = OE_Ignore;}
        break;
      case 73: /* resolvetype ::= REPLACE */
      case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
{yymsp[0].minor.yy70 = OE_Replace;}
        break;
      case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy135, 0, yymsp[-1].minor.yy70);
}
        break;







|







147706
147707
147708
147709
147710
147711
147712
147713
147714
147715
147716
147717
147718
147719
147720
      case 69: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;}
        break;
      case 72: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy70 = OE_Ignore;}
        break;
      case 73: /* resolvetype ::= REPLACE */
      case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157);
{yymsp[0].minor.yy70 = OE_Replace;}
        break;
      case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy135, 0, yymsp[-1].minor.yy70);
}
        break;
147874
147875
147876
147877
147878
147879
147880
147881
147882





147883
147884
147885
147886
147887
147888
147889
147890
147891
147892
147893
147894
147895
147896
147897
147898
147899
147900
147901
147902
147903
147904
147905
147906
147907
147908
147909
147910
147911
147912
147913
147914
147915
147916
147917
147918
147919
147920
147921
147922
147923
147924
147925
147926
147927
147928
147929
147930
147931
147932
147933
147934
147935
147936
147937
147938
147939
147940
147941
147942
147943
147944
147945
147946
147947
147948
147949
147950
147951
147952
147953
147954
147955
147956
147957
147958
147959
147960
147961
147962
147963
147964
147965
147966
147967
147968
147969
147970
147971
147972
147973
147974
147975
147976
147977
147978
147979
147980
147981
147982
147983
147984
147985
147986
147987
147988
147989
147990
147991
147992
147993
147994
      case 84: /* multiselect_op ::= UNION */
      case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
{yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 85: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy70 = TK_ALL;}
        break;
      case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt windowdefn_opt orderby_opt limit_opt */
{





  yymsp[-9].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy420,yymsp[-6].minor.yy135,yymsp[-5].minor.yy18,yymsp[-4].minor.yy420,yymsp[-3].minor.yy18,yymsp[-1].minor.yy420,yymsp[-8].minor.yy70,yymsp[0].minor.yy18);
#ifndef SQLITE_OMIT_WINDOWFUNC
  if( yymsp[-9].minor.yy489 ){
    yymsp[-9].minor.yy489->pWinDefn = yymsp[-2].minor.yy327;
  }else{
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy327);
  }
#endif /* SQLITE_OMIT_WINDOWFUNC */
}
        break;
      case 88: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values,0);
}
        break;
      case 89: /* values ::= values COMMA LP exprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy489;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values|SF_MultiValue,0);
  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
  if( pRight ){
    pRight->op = TK_ALL;
    pRight->pPrior = pLeft;
    yymsp[-4].minor.yy489 = pRight;
  }else{
    yymsp[-4].minor.yy489 = pLeft;
  }
}
        break;
      case 90: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy70 = SF_Distinct;}
        break;
      case 91: /* distinct ::= ALL */
{yymsp[0].minor.yy70 = SF_All;}
        break;
      case 93: /* sclp ::= */
      case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
      case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
      case 211: /* exprlist ::= */ yytestcase(yyruleno==211);
      case 214: /* paren_exprlist ::= */ yytestcase(yyruleno==214);
      case 219: /* eidlist_opt ::= */ yytestcase(yyruleno==219);
{yymsp[1].minor.yy420 = 0;}
        break;
      case 94: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy420,yymsp[-3].minor.yy392,yymsp[-1].minor.yy392);
}
        break;
      case 95: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy420, p);
}
        break;
      case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, pDot);
}
        break;
      case 97: /* as ::= AS nm */
      case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
      case 233: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==233);
      case 234: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 99: /* from ::= */
{yymsp[1].minor.yy135 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy135));}
        break;
      case 100: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy135 = yymsp[0].minor.yy135;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy135);
}
        break;
      case 101: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy135 && yymsp[-1].minor.yy135->nSrc>0) ) yymsp[-1].minor.yy135->a[yymsp[-1].minor.yy135->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy70;
}
        break;
      case 102: /* stl_prefix ::= */
{yymsp[1].minor.yy135 = 0;}
        break;
      case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-2].minor.yy0);
}
        break;
      case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
  yymsp[-8].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy135,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy135, yymsp[-4].minor.yy420);
}
        break;
      case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy489,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  }
        break;
      case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy135==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy18==0 && yymsp[0].minor.yy48==0 ){
      yymsp[-6].minor.yy135 = yymsp[-4].minor.yy135;
    }else if( yymsp[-4].minor.yy135->nSrc==1 ){
      yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
      if( yymsp[-6].minor.yy135 ){
        struct SrcList_item *pNew = &yymsp[-6].minor.yy135->a[yymsp[-6].minor.yy135->nSrc-1];







|

>
>
>
>
>

<





<


|




|













|


|


|
|
|
|
|
|


|






|





|







|
|
|
|


|


|





|




|


|





|





|




|







147795
147796
147797
147798
147799
147800
147801
147802
147803
147804
147805
147806
147807
147808
147809

147810
147811
147812
147813
147814

147815
147816
147817
147818
147819
147820
147821
147822
147823
147824
147825
147826
147827
147828
147829
147830
147831
147832
147833
147834
147835
147836
147837
147838
147839
147840
147841
147842
147843
147844
147845
147846
147847
147848
147849
147850
147851
147852
147853
147854
147855
147856
147857
147858
147859
147860
147861
147862
147863
147864
147865
147866
147867
147868
147869
147870
147871
147872
147873
147874
147875
147876
147877
147878
147879
147880
147881
147882
147883
147884
147885
147886
147887
147888
147889
147890
147891
147892
147893
147894
147895
147896
147897
147898
147899
147900
147901
147902
147903
147904
147905
147906
147907
147908
147909
147910
147911
147912
147913
147914
147915
147916
147917
147918
      case 84: /* multiselect_op ::= UNION */
      case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
{yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 85: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy70 = TK_ALL;}
        break;
      case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
  yymsp[-8].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy420,yymsp[-5].minor.yy135,yymsp[-4].minor.yy18,yymsp[-3].minor.yy420,yymsp[-2].minor.yy18,yymsp[-1].minor.yy420,yymsp[-7].minor.yy70,yymsp[0].minor.yy18);
}
        break;
      case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
{
  yymsp[-9].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy420,yymsp[-6].minor.yy135,yymsp[-5].minor.yy18,yymsp[-4].minor.yy420,yymsp[-3].minor.yy18,yymsp[-1].minor.yy420,yymsp[-8].minor.yy70,yymsp[0].minor.yy18);

  if( yymsp[-9].minor.yy489 ){
    yymsp[-9].minor.yy489->pWinDefn = yymsp[-2].minor.yy327;
  }else{
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy327);
  }

}
        break;
      case 89: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy489 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values,0);
}
        break;
      case 90: /* values ::= values COMMA LP nexprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy489;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy420,0,0,0,0,0,SF_Values|SF_MultiValue,0);
  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
  if( pRight ){
    pRight->op = TK_ALL;
    pRight->pPrior = pLeft;
    yymsp[-4].minor.yy489 = pRight;
  }else{
    yymsp[-4].minor.yy489 = pLeft;
  }
}
        break;
      case 91: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy70 = SF_Distinct;}
        break;
      case 92: /* distinct ::= ALL */
{yymsp[0].minor.yy70 = SF_All;}
        break;
      case 94: /* sclp ::= */
      case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127);
      case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134);
      case 214: /* exprlist ::= */ yytestcase(yyruleno==214);
      case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217);
      case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222);
{yymsp[1].minor.yy420 = 0;}
        break;
      case 95: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy420,yymsp[-3].minor.yy392,yymsp[-1].minor.yy392);
}
        break;
      case 96: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy420, p);
}
        break;
      case 97: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, pDot);
}
        break;
      case 98: /* as ::= AS nm */
      case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109);
      case 236: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==236);
      case 237: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==237);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 100: /* from ::= */
{yymsp[1].minor.yy135 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy135));}
        break;
      case 101: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy135 = yymsp[0].minor.yy135;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy135);
}
        break;
      case 102: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy135 && yymsp[-1].minor.yy135->nSrc>0) ) yymsp[-1].minor.yy135->a[yymsp[-1].minor.yy135->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy70;
}
        break;
      case 103: /* stl_prefix ::= */
{yymsp[1].minor.yy135 = 0;}
        break;
      case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-2].minor.yy0);
}
        break;
      case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
  yymsp[-8].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy135,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy135, yymsp[-4].minor.yy420);
}
        break;
      case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy489,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
  }
        break;
      case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy135==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy18==0 && yymsp[0].minor.yy48==0 ){
      yymsp[-6].minor.yy135 = yymsp[-4].minor.yy135;
    }else if( yymsp[-4].minor.yy135->nSrc==1 ){
      yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
      if( yymsp[-6].minor.yy135 ){
        struct SrcList_item *pNew = &yymsp[-6].minor.yy135->a[yymsp[-6].minor.yy135->nSrc-1];
148004
148005
148006
148007
148008
148009
148010
148011
148012
148013
148014
148015
148016
148017
148018
148019
148020
148021
148022
148023
148024
148025
148026
148027
148028
148029
148030
148031
148032
148033
148034
148035
148036
148037
148038
148039
148040
148041
148042
148043
148044
148045
148046
148047
148048
148049
148050
148051
148052
148053
148054
148055
148056
148057
148058
148059
148060
148061
148062
148063
148064
148065
148066
148067
148068
148069
148070
148071
148072
148073
148074
148075
148076
148077
148078
148079
148080
148081
148082
148083
148084
148085
148086
148087
148088
148089
148090
148091
148092
148093
148094
148095
148096
148097
148098
148099
148100
148101
148102
148103
148104
148105
148106
148107
148108
148109
148110
148111
148112
148113
148114
148115
148116
148117
148118
148119
148120
148121
148122
148123
148124
148125
148126
148127
148128
148129
148130
148131
148132
148133
148134
148135
148136
148137
148138
148139
148140
148141
148142
148143
148144
148145
148146
148147
148148
148149
148150
148151
148152
148153
148154
148155
148156
148157
148158
148159
148160
148161
148162
148163
148164
148165
148166
148167
148168
148169
148170
148171
148172
148173
148174
148175
148176
148177
148178
148179
148180
148181
148182
148183
148184
148185
148186
148187
148188
148189
148190
148191
148192
148193
148194
148195
148196
148197
148198
148199
148200
148201
148202
148203
148204
148205
148206
148207
148208
148209
148210
148211
148212
148213
148214
148215
148216
148217
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy135);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy135,0,0,0,0,SF_NestedFrom,0);
      yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
    }
  }
        break;
      case 107: /* dbnm ::= */
      case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 109: /* fullname ::= nm */
      case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
{yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 110: /* fullname ::= nm DOT nm */
      case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
{yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 113: /* xfullname ::= nm DOT nm AS nm */
{
   yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
   if( yymsp[-4].minor.yy135 ) yymsp[-4].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 114: /* xfullname ::= nm AS nm */
{  
   yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
   if( yymsp[-2].minor.yy135 ) yymsp[-2].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 115: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy70 = JT_INNER; }
        break;
      case 116: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 117: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 118: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 119: /* on_opt ::= ON expr */
      case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
      case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
      case 207: /* case_else ::= ELSE expr */ yytestcase(yyruleno==207);
{yymsp[-1].minor.yy18 = yymsp[0].minor.yy18;}
        break;
      case 120: /* on_opt ::= */
      case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
      case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
      case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
      case 208: /* case_else ::= */ yytestcase(yyruleno==208);
      case 210: /* case_operand ::= */ yytestcase(yyruleno==210);
{yymsp[1].minor.yy18 = 0;}
        break;
      case 122: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 123: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 124: /* using_opt ::= USING LP idlist RP */
{yymsp[-3].minor.yy48 = yymsp[-1].minor.yy48;}
        break;
      case 125: /* using_opt ::= */
      case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
{yymsp[1].minor.yy48 = 0;}
        break;
      case 127: /* orderby_opt ::= ORDER BY sortlist */
      case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
{yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
        break;
      case 128: /* sortlist ::= sortlist COMMA expr sortorder */
{
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420,yymsp[-1].minor.yy18);
  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy420,yymsp[0].minor.yy70);
}
        break;
      case 129: /* sortlist ::= expr sortorder */
{
  yymsp[-1].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy18); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy420,yymsp[0].minor.yy70);
}
        break;
      case 130: /* sortorder ::= ASC */
{yymsp[0].minor.yy70 = SQLITE_SO_ASC;}
        break;
      case 131: /* sortorder ::= DESC */
{yymsp[0].minor.yy70 = SQLITE_SO_DESC;}
        break;
      case 132: /* sortorder ::= */
{yymsp[1].minor.yy70 = SQLITE_SO_UNDEFINED;}
        break;
      case 138: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,0);}
        break;
      case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
        break;
      case 140: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
        break;
      case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
}
        break;
      case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
}
        break;
      case 145: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy420 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy420, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
}
        break;
      case 147: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy420 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy18);
  sqlite3ExprListSetName(pParse, yylhsminor.yy420, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy420 = yylhsminor.yy420;
        break;
      case 148: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
}
        break;
      case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy135, yymsp[-1].minor.yy489, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, yymsp[0].minor.yy340);
}
        break;
      case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy135, 0, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, 0);
}
        break;
      case 151: /* upsert ::= */
{ yymsp[1].minor.yy340 = 0; }
        break;
      case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
{ yymsp[-10].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy420,yymsp[-5].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);}
        break;
      case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
{ yymsp[-7].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy420,yymsp[-2].minor.yy18,0,0); }
        break;
      case 154: /* upsert ::= ON CONFLICT DO NOTHING */
{ yymsp[-3].minor.yy340 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
        break;
      case 158: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
        break;
      case 159: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
        break;
      case 160: /* idlist ::= nm */
{yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 161: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
        break;
      case 162: /* expr ::= ID|INDEXED */
      case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
{yymsp[0].minor.yy18=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 164: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy18 = yylhsminor.yy18;
        break;
      case 165: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy18 = yylhsminor.yy18;
        break;
      case 166: /* term ::= NULL|FLOAT|BLOB */
      case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
{yymsp[0].minor.yy18=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 168: /* term ::= INTEGER */
{
  yylhsminor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
  yymsp[0].minor.yy18 = yylhsminor.yy18;
        break;
      case 169: /* expr ::= VARIABLE */
{
  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
    u32 n = yymsp[0].minor.yy0.n;
    yymsp[0].minor.yy18 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy18, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression







|
|


|
|


|
|


|





|





|


|


|


|


|
|
|
|


|
|
|
|
|
|


|


|


|


|
|


|
|


|





|





|


|


|


|


|


|


|





|






|





|




|






|




|




|




|


|


|


|


|


|


|


|


|
|


|







|









|
|


|





|







147928
147929
147930
147931
147932
147933
147934
147935
147936
147937
147938
147939
147940
147941
147942
147943
147944
147945
147946
147947
147948
147949
147950
147951
147952
147953
147954
147955
147956
147957
147958
147959
147960
147961
147962
147963
147964
147965
147966
147967
147968
147969
147970
147971
147972
147973
147974
147975
147976
147977
147978
147979
147980
147981
147982
147983
147984
147985
147986
147987
147988
147989
147990
147991
147992
147993
147994
147995
147996
147997
147998
147999
148000
148001
148002
148003
148004
148005
148006
148007
148008
148009
148010
148011
148012
148013
148014
148015
148016
148017
148018
148019
148020
148021
148022
148023
148024
148025
148026
148027
148028
148029
148030
148031
148032
148033
148034
148035
148036
148037
148038
148039
148040
148041
148042
148043
148044
148045
148046
148047
148048
148049
148050
148051
148052
148053
148054
148055
148056
148057
148058
148059
148060
148061
148062
148063
148064
148065
148066
148067
148068
148069
148070
148071
148072
148073
148074
148075
148076
148077
148078
148079
148080
148081
148082
148083
148084
148085
148086
148087
148088
148089
148090
148091
148092
148093
148094
148095
148096
148097
148098
148099
148100
148101
148102
148103
148104
148105
148106
148107
148108
148109
148110
148111
148112
148113
148114
148115
148116
148117
148118
148119
148120
148121
148122
148123
148124
148125
148126
148127
148128
148129
148130
148131
148132
148133
148134
148135
148136
148137
148138
148139
148140
148141
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy135);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy135,0,0,0,0,SF_NestedFrom,0);
      yymsp[-6].minor.yy135 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy135,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy18,yymsp[0].minor.yy48);
    }
  }
        break;
      case 108: /* dbnm ::= */
      case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 110: /* fullname ::= nm */
      case 112: /* xfullname ::= nm */ yytestcase(yyruleno==112);
{yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 111: /* fullname ::= nm DOT nm */
      case 113: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==113);
{yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 114: /* xfullname ::= nm DOT nm AS nm */
{
   yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
   if( yymsp[-4].minor.yy135 ) yymsp[-4].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 115: /* xfullname ::= nm AS nm */
{  
   yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
   if( yymsp[-2].minor.yy135 ) yymsp[-2].minor.yy135->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 116: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy70 = JT_INNER; }
        break;
      case 117: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 118: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 119: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy70 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 120: /* on_opt ::= ON expr */
      case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137);
      case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144);
      case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210);
{yymsp[-1].minor.yy18 = yymsp[0].minor.yy18;}
        break;
      case 121: /* on_opt ::= */
      case 136: /* having_opt ::= */ yytestcase(yyruleno==136);
      case 138: /* limit_opt ::= */ yytestcase(yyruleno==138);
      case 143: /* where_opt ::= */ yytestcase(yyruleno==143);
      case 211: /* case_else ::= */ yytestcase(yyruleno==211);
      case 213: /* case_operand ::= */ yytestcase(yyruleno==213);
{yymsp[1].minor.yy18 = 0;}
        break;
      case 123: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 124: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 125: /* using_opt ::= USING LP idlist RP */
{yymsp[-3].minor.yy48 = yymsp[-1].minor.yy48;}
        break;
      case 126: /* using_opt ::= */
      case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158);
{yymsp[1].minor.yy48 = 0;}
        break;
      case 128: /* orderby_opt ::= ORDER BY sortlist */
      case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135);
{yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
        break;
      case 129: /* sortlist ::= sortlist COMMA expr sortorder */
{
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420,yymsp[-1].minor.yy18);
  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy420,yymsp[0].minor.yy70);
}
        break;
      case 130: /* sortlist ::= expr sortorder */
{
  yymsp[-1].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy18); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy420,yymsp[0].minor.yy70);
}
        break;
      case 131: /* sortorder ::= ASC */
{yymsp[0].minor.yy70 = SQLITE_SO_ASC;}
        break;
      case 132: /* sortorder ::= DESC */
{yymsp[0].minor.yy70 = SQLITE_SO_DESC;}
        break;
      case 133: /* sortorder ::= */
{yymsp[1].minor.yy70 = SQLITE_SO_UNDEFINED;}
        break;
      case 139: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,0);}
        break;
      case 140: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
        break;
      case 141: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
        break;
      case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
}
        break;
      case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
{
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
}
        break;
      case 146: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy420 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy420, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
}
        break;
      case 148: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy420 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy18);
  sqlite3ExprListSetName(pParse, yylhsminor.yy420, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy420 = yylhsminor.yy420;
        break;
      case 149: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy48, yymsp[0].minor.yy18);
}
        break;
      case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy135, yymsp[-1].minor.yy489, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, yymsp[0].minor.yy340);
}
        break;
      case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
  sqlite3Insert(pParse, yymsp[-3].minor.yy135, 0, yymsp[-2].minor.yy48, yymsp[-5].minor.yy70, 0);
}
        break;
      case 152: /* upsert ::= */
{ yymsp[1].minor.yy340 = 0; }
        break;
      case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
{ yymsp[-10].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy420,yymsp[-5].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);}
        break;
      case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
{ yymsp[-7].minor.yy340 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy420,yymsp[-2].minor.yy18,0,0); }
        break;
      case 155: /* upsert ::= ON CONFLICT DO NOTHING */
{ yymsp[-3].minor.yy340 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
        break;
      case 159: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
        break;
      case 160: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
        break;
      case 161: /* idlist ::= nm */
{yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 162: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
        break;
      case 163: /* expr ::= ID|INDEXED */
      case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164);
{yymsp[0].minor.yy18=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 165: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy18 = yylhsminor.yy18;
        break;
      case 166: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy18 = yylhsminor.yy18;
        break;
      case 167: /* term ::= NULL|FLOAT|BLOB */
      case 168: /* term ::= STRING */ yytestcase(yyruleno==168);
{yymsp[0].minor.yy18=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 169: /* term ::= INTEGER */
{
  yylhsminor.yy18 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
  yymsp[0].minor.yy18 = yylhsminor.yy18;
        break;
      case 170: /* expr ::= VARIABLE */
{
  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
    u32 n = yymsp[0].minor.yy0.n;
    yymsp[0].minor.yy18 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy18, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression
148225
148226
148227
148228
148229
148230
148231
148232
148233
148234
148235
148236
148237
148238
148239
148240
148241
148242
148243
148244
148245
148246
148247




148248
148249
148250
148251





148252
148253
148254
148255
148256
148257
148258
148259
148260
148261
148262
148263
148264
148265
148266
148267
148268
148269
148270
148271
148272
148273
148274
148275
148276
148277
148278
148279
148280
148281
148282
148283
148284
148285
148286
148287
148288
148289
148290
148291
148292
148293
148294
148295
148296
148297
148298
148299
148300
148301
148302
148303
148304
148305
148306
148307
148308
148309
148310
148311
148312
148313
148314
148315
148316
148317
148318
148319
148320
148321
148322
148323
148324
148325
148326
148327
148328
148329
148330
148331
148332
148333
148334
148335
148336
148337
148338
148339
148340
148341
148342
148343
148344
148345
148346
148347
148348
148349
148350
148351
148352
148353
148354
148355
148356
148357
148358
148359
148360
148361
148362
148363
148364
148365
148366
148367
148368
148369
148370
    }else{
      yymsp[0].minor.yy18 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy18 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy18->iTable);
    }
  }
}
        break;
      case 170: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy18 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy18, &yymsp[0].minor.yy0, 1);
}
        break;
      case 171: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy18, yymsp[-3].minor.yy18, 0);
}
        break;
      case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP over_opt */
{
  if( yymsp[-2].minor.yy420 && yymsp[-2].minor.yy420->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-5].minor.yy0);
  }




  yylhsminor.yy18 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy420, &yymsp[-5].minor.yy0);
  if( yymsp[-3].minor.yy70==SF_Distinct && yylhsminor.yy18 ){
    yylhsminor.yy18->flags |= EP_Distinct;
  }





  sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
}
  yymsp[-5].minor.yy18 = yylhsminor.yy18;
        break;
      case 173: /* expr ::= ID|INDEXED LP STAR RP over_opt */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0);
  sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
}
  yymsp[-4].minor.yy18 = yylhsminor.yy18;
        break;
      case 174: /* term ::= CTIME_KW */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy18 = yylhsminor.yy18;
        break;
      case 175: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy420, yymsp[-1].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 176: /* expr ::= expr AND expr */
      case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177);
      case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178);
      case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
      case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
      case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
      case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
      case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
{yymsp[-2].minor.yy18=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
        break;
      case 184: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
        break;
      case 185: /* expr ::= expr likeop expr */
{
  ExprList *pList;
  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
  yymsp[-1].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy18);
  yymsp[-2].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
  if( bNot ) yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy18, 0);
  if( yymsp[-2].minor.yy18 ) yymsp[-2].minor.yy18->flags |= EP_InfixFunc;
}
        break;
      case 186: /* expr ::= expr likeop expr ESCAPE expr */
{
  ExprList *pList;
  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
  yymsp[-3].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
  if( bNot ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ) yymsp[-4].minor.yy18->flags |= EP_InfixFunc;
}
        break;
      case 187: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy18,0);}
        break;
      case 188: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy18,0);}
        break;
      case 189: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-2].minor.yy18, TK_ISNULL);
}
        break;
      case 190: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy18,yymsp[0].minor.yy18);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-3].minor.yy18, TK_NOTNULL);
}
        break;
      case 191: /* expr ::= NOT expr */
      case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy18, 0);/*A-overwrites-B*/}
        break;
      case 193: /* expr ::= PLUS|MINUS expr */
{
  yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy18, 0);
  /*A-overwrites-B*/
}
        break;
      case 194: /* between_op ::= BETWEEN */
      case 197: /* in_op ::= IN */ yytestcase(yyruleno==197);
{yymsp[0].minor.yy70 = 0;}
        break;
      case 196: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
}
        break;
      case 199: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy420==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **







|




|





|

|
<
|
>
>
>
>
|
<
<
|
>
>
>
>
>




|

|




|

|



|










|
|
|
|
|
|
|
|


|


|






|




|







|




|


|


|





|





|
|


|





|
|


|












|







148149
148150
148151
148152
148153
148154
148155
148156
148157
148158
148159
148160
148161
148162
148163
148164
148165
148166
148167
148168
148169

148170
148171
148172
148173
148174
148175


148176
148177
148178
148179
148180
148181
148182
148183
148184
148185
148186
148187
148188
148189
148190
148191
148192
148193
148194
148195
148196
148197
148198
148199
148200
148201
148202
148203
148204
148205
148206
148207
148208
148209
148210
148211
148212
148213
148214
148215
148216
148217
148218
148219
148220
148221
148222
148223
148224
148225
148226
148227
148228
148229
148230
148231
148232
148233
148234
148235
148236
148237
148238
148239
148240
148241
148242
148243
148244
148245
148246
148247
148248
148249
148250
148251
148252
148253
148254
148255
148256
148257
148258
148259
148260
148261
148262
148263
148264
148265
148266
148267
148268
148269
148270
148271
148272
148273
148274
148275
148276
148277
148278
148279
148280
148281
148282
148283
148284
148285
148286
148287
148288
148289
148290
148291
148292
148293
148294
148295
148296
148297
148298
148299
148300
    }else{
      yymsp[0].minor.yy18 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy18 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy18->iTable);
    }
  }
}
        break;
      case 171: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy18 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy18, &yymsp[0].minor.yy0, 1);
}
        break;
      case 172: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy18, yymsp[-3].minor.yy18, 0);
}
        break;
      case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy420, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy70);

}
  yymsp[-4].minor.yy18 = yylhsminor.yy18;
        break;
      case 174: /* expr ::= ID|INDEXED LP STAR RP */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);


}
  yymsp[-3].minor.yy18 = yylhsminor.yy18;
        break;
      case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy420, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy70);
  sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
}
  yymsp[-5].minor.yy18 = yylhsminor.yy18;
        break;
      case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
  sqlite3WindowAttach(pParse, yylhsminor.yy18, yymsp[0].minor.yy327);
}
  yymsp[-4].minor.yy18 = yylhsminor.yy18;
        break;
      case 177: /* term ::= CTIME_KW */
{
  yylhsminor.yy18 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
  yymsp[0].minor.yy18 = yylhsminor.yy18;
        break;
      case 178: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy420, yymsp[-1].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 179: /* expr ::= expr AND expr */
      case 180: /* expr ::= expr OR expr */ yytestcase(yyruleno==180);
      case 181: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==181);
      case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182);
      case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183);
      case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184);
      case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185);
      case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186);
{yymsp[-2].minor.yy18=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
        break;
      case 187: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
        break;
      case 188: /* expr ::= expr likeop expr */
{
  ExprList *pList;
  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
  yymsp[-1].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy18);
  yymsp[-2].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
  if( bNot ) yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy18, 0);
  if( yymsp[-2].minor.yy18 ) yymsp[-2].minor.yy18->flags |= EP_InfixFunc;
}
        break;
      case 189: /* expr ::= expr likeop expr ESCAPE expr */
{
  ExprList *pList;
  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
  yymsp[-3].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
  if( bNot ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ) yymsp[-4].minor.yy18->flags |= EP_InfixFunc;
}
        break;
      case 190: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy18,0);}
        break;
      case 191: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy18,0);}
        break;
      case 192: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy18 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-2].minor.yy18, TK_ISNULL);
}
        break;
      case 193: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy18,yymsp[0].minor.yy18);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy18, yymsp[-3].minor.yy18, TK_NOTNULL);
}
        break;
      case 194: /* expr ::= NOT expr */
      case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195);
{yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy18, 0);/*A-overwrites-B*/}
        break;
      case 196: /* expr ::= PLUS|MINUS expr */
{
  yymsp[-1].minor.yy18 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy18, 0);
  /*A-overwrites-B*/
}
        break;
      case 197: /* between_op ::= BETWEEN */
      case 200: /* in_op ::= IN */ yytestcase(yyruleno==200);
{yymsp[0].minor.yy70 = 0;}
        break;
      case 199: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy18);
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
}
        break;
      case 202: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy420==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
148408
148409
148410
148411
148412
148413
148414
148415
148416
148417
148418
148419
148420
148421
148422
148423
148424
148425
148426
148427
148428
148429
148430
148431
148432
148433
148434
148435
148436
148437
148438
148439
148440
148441
148442
148443
148444
148445
148446
148447
148448
148449
148450
148451
148452
148453
148454
148455
148456
148457
148458
148459
148460
148461
148462
148463
148464
148465
148466
148467
148468
148469
148470
148471
148472
148473
148474
148475
148476
148477
148478
148479
148480
148481
148482
148483
148484
148485
148486
148487
148488
148489
148490
148491
148492
148493
148494
148495
148496
148497
148498
148499
148500
148501
148502
148503
148504
148505
148506
148507
148508
148509
148510
148511
148512
148513
148514
148515
148516
148517
148518
148519
148520
148521
148522
148523
148524
148525
148526
148527
148528
148529
148530
148531
148532
148533
148534
148535
148536
148537
148538
148539
148540
148541
148542
148543
148544
148545
148546
148547
148548
148549
148550
148551
148552
148553
148554
148555
148556
148557
148558
148559
148560
148561
148562
148563
148564
148565
148566
148567
148568
148569
148570
148571
148572
148573
148574
148575
148576
148577
148578
148579
148580
148581
148582
148583
148584
148585
148586
148587
148588
148589
148590
148591
148592
148593
148594
148595
148596
148597
148598
148599
148600
148601
148602
148603
148604
148605
148606
148607
148608
148609
148610
148611
148612
148613
148614
148615
148616
148617
148618
148619
148620
148621
148622
148623
148624
148625
148626
148627
148628
148629
148630
148631
148632
148633
148634
148635
148636
148637
148638
148639
148640
148641
148642
148643
148644
148645
148646
148647
148648
148649
148650
148651
148652
148653
148654
148655
148656
148657
148658
148659
148660
148661
148662
148663
148664
148665
148666
148667
148668
148669
148670
148671
148672
148673
148674
148675
148676
148677
148678
148679
148680
148681
148682
148683
148684
148685
148686
148687
148688
148689
148690
148691
148692
148693
148694
148695
148696
148697
148698
148699
148700
148701
148702
148703
148704
148705
148706
148707
148708
148709
148710
148711
148712
148713
148714
148715
148716
148717
148718
148719
148720
148721
148722
148723
148724
148725
148726
148727
148728
148729
148730
148731
148732
148733
148734
148735
148736
148737
148738
148739
148740
148741
148742
148743
148744
148745
148746
148747
148748
148749
148750
148751
148752
148753
148754
148755
148756
148757
148758
148759
148760
148761
148762
148763
148764
148765
148766
148767
148768
148769
148770
148771
148772
148773
148774
148775
148776
148777
148778
148779
148780
148781
148782
148783
148784
148785
148786
148787
148788
148789
148790
148791
148792
148793
148794
148795
148796
148797
148798
148799
148800
148801
148802
148803
148804
148805
148806
148807
148808
148809
148810
148811
148812
148813
148814
148815
148816
148817
148818
148819
148820
148821
148822
148823
148824
148825
148826
148827
148828
148829
148830
148831
148832
148833
148834
148835
148836
148837
148838
148839
148840
148841
148842
148843
148844
148845
148846
148847
148848
148849
148850
148851
148852
148853
148854
148855
148856
148857
148858
148859
148860
148861
148862
148863
148864
148865
148866
148867
148868
148869
148870
148871
148872
148873
148874
148875
148876
148877
148878
148879
148880
148881
148882
148883
148884
148885
148886
148887
148888
148889
148890
148891
148892
148893
148894
148895
      }else{
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
      }
      if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
    }
  }
        break;
      case 200: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy18, yymsp[-1].minor.yy489);
  }
        break;
      case 201: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, yymsp[-1].minor.yy489);
    if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  }
        break;
      case 202: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
    if( yymsp[0].minor.yy420 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy420);
    yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, pSelect);
    if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  }
        break;
      case 203: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy489);
  }
        break;
      case 204: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy18 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[-1].minor.yy18) : yymsp[-2].minor.yy420;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy420);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy18);
  }
}
        break;
      case 205: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
}
        break;
      case 206: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420, yymsp[0].minor.yy18);
}
        break;
      case 209: /* case_operand ::= expr */
{yymsp[0].minor.yy18 = yymsp[0].minor.yy18; /*A-overwrites-X*/}
        break;
      case 212: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[0].minor.yy18);}
        break;
      case 213: /* nexprlist ::= expr */
{yymsp[0].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy18); /*A-overwrites-Y*/}
        break;
      case 215: /* paren_exprlist ::= LP exprlist RP */
      case 220: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==220);
{yymsp[-2].minor.yy420 = yymsp[-1].minor.yy420;}
        break;
      case 216: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
}
        break;
      case 217: /* uniqueflag ::= UNIQUE */
      case 257: /* raisetype ::= ABORT */ yytestcase(yyruleno==257);
{yymsp[0].minor.yy70 = OE_Abort;}
        break;
      case 218: /* uniqueflag ::= */
{yymsp[1].minor.yy70 = OE_None;}
        break;
      case 221: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy420 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70);
}
        break;
      case 222: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy420 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70); /*A-overwrites-Y*/
}
        break;
      case 225: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy135, yymsp[-1].minor.yy70);}
        break;
      case 226: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
        break;
      case 227: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
        break;
      case 228: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 229: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;
      case 230: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
        break;
      case 231: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
        break;
      case 232: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 235: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
  Token all;
  all.z = yymsp[-3].minor.yy0.z;
  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy207, &all);
}
        break;
      case 236: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy70, yymsp[-4].minor.yy34.a, yymsp[-4].minor.yy34.b, yymsp[-2].minor.yy135, yymsp[0].minor.yy18, yymsp[-10].minor.yy70, yymsp[-8].minor.yy70);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 237: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 238: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy70 = TK_INSTEAD;}
        break;
      case 239: /* trigger_time ::= */
{ yymsp[1].minor.yy70 = TK_BEFORE; }
        break;
      case 240: /* trigger_event ::= DELETE|INSERT */
      case 241: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==241);
{yymsp[0].minor.yy34.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy34.b = 0;}
        break;
      case 242: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
        break;
      case 243: /* when_clause ::= */
      case 262: /* key_opt ::= */ yytestcase(yyruleno==262);
      case 305: /* filter_opt ::= */ yytestcase(yyruleno==305);
{ yymsp[1].minor.yy18 = 0; }
        break;
      case 244: /* when_clause ::= WHEN expr */
      case 263: /* key_opt ::= KEY expr */ yytestcase(yyruleno==263);
{ yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
        break;
      case 245: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy207!=0 );
  yymsp[-2].minor.yy207->pLast->pNext = yymsp[-1].minor.yy207;
  yymsp[-2].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
        break;
      case 246: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  assert( yymsp[-1].minor.yy207!=0 );
  yymsp[-1].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
        break;
      case 247: /* trnm ::= nm DOT nm */
{
  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
  sqlite3ErrorMsg(pParse, 
        "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
        "statements within triggers");
}
        break;
      case 248: /* tridxby ::= INDEXED BY nm */
{
  sqlite3ErrorMsg(pParse,
        "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 249: /* tridxby ::= NOT INDEXED */
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 250: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
  yymsp[-7].minor.yy207 = yylhsminor.yy207;
        break;
      case 251: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
   yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
}
  yymsp[-7].minor.yy207 = yylhsminor.yy207;
        break;
      case 252: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
  yymsp[-5].minor.yy207 = yylhsminor.yy207;
        break;
      case 253: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
  yymsp[-2].minor.yy207 = yylhsminor.yy207;
        break;
      case 254: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
  if( yymsp[-3].minor.yy18 ){
    yymsp[-3].minor.yy18->affinity = OE_Ignore;
  }
}
        break;
      case 255: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
  if( yymsp[-5].minor.yy18 ) {
    yymsp[-5].minor.yy18->affinity = (char)yymsp[-3].minor.yy70;
  }
}
        break;
      case 256: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy70 = OE_Rollback;}
        break;
      case 258: /* raisetype ::= FAIL */
{yymsp[0].minor.yy70 = OE_Fail;}
        break;
      case 259: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy135,yymsp[-1].minor.yy70);
}
        break;
      case 260: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy18, yymsp[-1].minor.yy18, yymsp[0].minor.yy18);
}
        break;
      case 261: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy18);
}
        break;
      case 264: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 265: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 266: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 267: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 268: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy135,&yymsp[0].minor.yy0);
}
        break;
      case 269: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
        break;
      case 270: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
}
        break;
      case 271: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 272: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 273: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
}
        break;
      case 274: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 275: /* vtabargtoken ::= ANY */
      case 276: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==276);
      case 277: /* lp ::= LP */ yytestcase(yyruleno==277);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;
      case 278: /* with ::= WITH wqlist */
      case 279: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==279);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
        break;
      case 280: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
  yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
}
        break;
      case 281: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
  yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
}
        break;
      case 282: /* windowdefn_list ::= windowdefn */
{ yylhsminor.yy327 = yymsp[0].minor.yy327; }
  yymsp[0].minor.yy327 = yylhsminor.yy327;
        break;
      case 283: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
  assert( yymsp[0].minor.yy327!=0 );
  yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
  yylhsminor.yy327 = yymsp[0].minor.yy327;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 284: /* windowdefn ::= nm AS window */
{
  if( ALWAYS(yymsp[0].minor.yy327) ){
    yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
  }
  yylhsminor.yy327 = yymsp[0].minor.yy327;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 285: /* window ::= LP part_opt orderby_opt frame_opt RP */
{
  yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
  if( ALWAYS(yymsp[-4].minor.yy327) ){
    yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
    yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
  }
}
        break;
      case 286: /* part_opt ::= PARTITION BY exprlist */
{ yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
        break;
      case 287: /* part_opt ::= */
{ yymsp[1].minor.yy420 = 0; }
        break;
      case 288: /* frame_opt ::= */
{ 
  yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
}
        break;
      case 289: /* frame_opt ::= range_or_rows frame_bound_s */
{ 
  yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
}
  yymsp[-1].minor.yy327 = yylhsminor.yy327;
        break;
      case 290: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
{ 
  yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
}
  yymsp[-4].minor.yy327 = yylhsminor.yy327;
        break;
      case 291: /* range_or_rows ::= RANGE */
{ yymsp[0].minor.yy70 = TK_RANGE; }
        break;
      case 292: /* range_or_rows ::= ROWS */
{ yymsp[0].minor.yy70 = TK_ROWS;  }
        break;
      case 293: /* frame_bound_s ::= frame_bound */
      case 295: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==295);
{ yylhsminor.yy119 = yymsp[0].minor.yy119; }
  yymsp[0].minor.yy119 = yylhsminor.yy119;
        break;
      case 294: /* frame_bound_s ::= UNBOUNDED PRECEDING */
      case 296: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==296);
{yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
        break;
      case 297: /* frame_bound ::= expr PRECEDING */
{ yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
  yymsp[-1].minor.yy119 = yylhsminor.yy119;
        break;
      case 298: /* frame_bound ::= CURRENT ROW */
{ yymsp[-1].minor.yy119.eType = TK_CURRENT  ; yymsp[-1].minor.yy119.pExpr = 0; }
        break;
      case 299: /* frame_bound ::= expr FOLLOWING */
{ yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
  yymsp[-1].minor.yy119 = yylhsminor.yy119;
        break;
      case 300: /* windowdefn_opt ::= */
      case 302: /* over_opt ::= */ yytestcase(yyruleno==302);
{ yymsp[1].minor.yy327 = 0; }
        break;
      case 301: /* windowdefn_opt ::= WINDOW windowdefn_list */
{ yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
        break;
      case 303: /* over_opt ::= filter_opt OVER window */
{
  yylhsminor.yy327 = yymsp[0].minor.yy327;
  assert( yylhsminor.yy327!=0 );
  yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 304: /* over_opt ::= filter_opt OVER nm */
{
  yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yylhsminor.yy327 ){
    yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
    yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
  }
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 306: /* filter_opt ::= FILTER LP WHERE expr RP */
{ yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
        break;
      default:
      /* (307) input ::= cmdlist */ yytestcase(yyruleno==307);
      /* (308) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==308);
      /* (309) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=309);
      /* (310) ecmd ::= SEMI */ yytestcase(yyruleno==310);
      /* (311) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==311);
      /* (312) ecmd ::= explain cmdx */ yytestcase(yyruleno==312);
      /* (313) trans_opt ::= */ yytestcase(yyruleno==313);
      /* (314) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==314);
      /* (315) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==315);
      /* (316) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==316);
      /* (317) savepoint_opt ::= */ yytestcase(yyruleno==317);
      /* (318) cmd ::= create_table create_table_args */ yytestcase(yyruleno==318);
      /* (319) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==319);
      /* (320) columnlist ::= columnname carglist */ yytestcase(yyruleno==320);
      /* (321) nm ::= ID|INDEXED */ yytestcase(yyruleno==321);
      /* (322) nm ::= STRING */ yytestcase(yyruleno==322);
      /* (323) nm ::= JOIN_KW */ yytestcase(yyruleno==323);
      /* (324) typetoken ::= typename */ yytestcase(yyruleno==324);
      /* (325) typename ::= ID|STRING */ yytestcase(yyruleno==325);
      /* (326) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=326);
      /* (327) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
      /* (328) carglist ::= carglist ccons */ yytestcase(yyruleno==328);
      /* (329) carglist ::= */ yytestcase(yyruleno==329);
      /* (330) ccons ::= NULL onconf */ yytestcase(yyruleno==330);
      /* (331) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==331);
      /* (332) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==332);
      /* (333) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=333);
      /* (334) tconscomma ::= */ yytestcase(yyruleno==334);
      /* (335) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=335);
      /* (336) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=336);
      /* (337) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=337);
      /* (338) oneselect ::= values */ yytestcase(yyruleno==338);
      /* (339) sclp ::= selcollist COMMA */ yytestcase(yyruleno==339);
      /* (340) as ::= ID|STRING */ yytestcase(yyruleno==340);
      /* (341) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=341);
      /* (342) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==342);
      /* (343) exprlist ::= nexprlist */ yytestcase(yyruleno==343);
      /* (344) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344);
      /* (345) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=345);
      /* (346) nmnum ::= ON */ yytestcase(yyruleno==346);
      /* (347) nmnum ::= DELETE */ yytestcase(yyruleno==347);
      /* (348) nmnum ::= DEFAULT */ yytestcase(yyruleno==348);
      /* (349) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==349);
      /* (350) foreach_clause ::= */ yytestcase(yyruleno==350);
      /* (351) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==351);
      /* (352) trnm ::= nm */ yytestcase(yyruleno==352);
      /* (353) tridxby ::= */ yytestcase(yyruleno==353);
      /* (354) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==354);
      /* (355) database_kw_opt ::= */ yytestcase(yyruleno==355);
      /* (356) kwcolumn_opt ::= */ yytestcase(yyruleno==356);
      /* (357) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==357);
      /* (358) vtabarglist ::= vtabarg */ yytestcase(yyruleno==358);
      /* (359) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==359);
      /* (360) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==360);
      /* (361) anylist ::= */ yytestcase(yyruleno==361);
      /* (362) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==362);
      /* (363) anylist ::= anylist ANY */ yytestcase(yyruleno==363);
      /* (364) with ::= */ yytestcase(yyruleno==364);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);







|





|






|









|






|











|





|





|


|


|


|
|


|






|
|


|


|




|




|


|


|


|


|


|


|


|


|







|





|


|


|


|
|


|


|
|
|


|
|


|






|





|







|






|






|



|





|



|



|







|







|


|


|




|




|




|


|


|


|


|




|





|





|


|


|




|


|
|
|


|
|


|




|




|



|







|








|








|


|


|




|





|





|


|


|
|



|
|


|



|


|



<
<
<
<
|


|







|











|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







148338
148339
148340
148341
148342
148343
148344
148345
148346
148347
148348
148349
148350
148351
148352
148353
148354
148355
148356
148357
148358
148359
148360
148361
148362
148363
148364
148365
148366
148367
148368
148369
148370
148371
148372
148373
148374
148375
148376
148377
148378
148379
148380
148381
148382
148383
148384
148385
148386
148387
148388
148389
148390
148391
148392
148393
148394
148395
148396
148397
148398
148399
148400
148401
148402
148403
148404
148405
148406
148407
148408
148409
148410
148411
148412
148413
148414
148415
148416
148417
148418
148419
148420
148421
148422
148423
148424
148425
148426
148427
148428
148429
148430
148431
148432
148433
148434
148435
148436
148437
148438
148439
148440
148441
148442
148443
148444
148445
148446
148447
148448
148449
148450
148451
148452
148453
148454
148455
148456
148457
148458
148459
148460
148461
148462
148463
148464
148465
148466
148467
148468
148469
148470
148471
148472
148473
148474
148475
148476
148477
148478
148479
148480
148481
148482
148483
148484
148485
148486
148487
148488
148489
148490
148491
148492
148493
148494
148495
148496
148497
148498
148499
148500
148501
148502
148503
148504
148505
148506
148507
148508
148509
148510
148511
148512
148513
148514
148515
148516
148517
148518
148519
148520
148521
148522
148523
148524
148525
148526
148527
148528
148529
148530
148531
148532
148533
148534
148535
148536
148537
148538
148539
148540
148541
148542
148543
148544
148545
148546
148547
148548
148549
148550
148551
148552
148553
148554
148555
148556
148557
148558
148559
148560
148561
148562
148563
148564
148565
148566
148567
148568
148569
148570
148571
148572
148573
148574
148575
148576
148577
148578
148579
148580
148581
148582
148583
148584
148585
148586
148587
148588
148589
148590
148591
148592
148593
148594
148595
148596
148597
148598
148599
148600
148601
148602
148603
148604
148605
148606
148607
148608
148609
148610
148611
148612
148613
148614
148615
148616
148617
148618
148619
148620
148621
148622
148623
148624
148625
148626
148627
148628
148629
148630
148631
148632
148633
148634
148635
148636
148637
148638
148639
148640
148641
148642
148643
148644
148645
148646
148647
148648
148649
148650
148651
148652
148653
148654
148655
148656
148657
148658
148659
148660
148661
148662
148663
148664
148665
148666
148667
148668
148669
148670
148671
148672
148673
148674
148675
148676
148677
148678
148679
148680
148681
148682
148683
148684
148685
148686
148687
148688
148689
148690
148691
148692
148693
148694
148695
148696
148697
148698
148699
148700
148701
148702
148703
148704
148705
148706
148707
148708
148709
148710
148711
148712
148713
148714
148715
148716
148717
148718
148719
148720
148721
148722
148723
148724
148725
148726
148727
148728
148729




148730
148731
148732
148733
148734
148735
148736
148737
148738
148739
148740
148741
148742
148743
148744
148745
148746
148747
148748
148749
148750
148751
148752
148753
148754
148755
148756
148757
148758
148759
148760
148761
148762
148763
148764
148765
148766
148767
148768
148769
148770
148771
148772
148773
148774
148775
148776
148777
148778
148779
148780
148781
148782
148783
148784
148785
148786
148787
148788
148789
148790
148791
148792
148793
148794
148795
148796
148797
148798
148799
148800
148801
148802
148803
148804
148805
148806
148807
148808
148809
148810
148811
148812
148813
148814
148815
148816
148817
148818
148819
148820
148821
      }else{
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy420);
      }
      if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
    }
  }
        break;
      case 203: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy18 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy18, yymsp[-1].minor.yy489);
  }
        break;
      case 204: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, yymsp[-1].minor.yy489);
    if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  }
        break;
      case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
    if( yymsp[0].minor.yy420 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy420);
    yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy18, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy18, pSelect);
    if( yymsp[-3].minor.yy70 ) yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy18, 0);
  }
        break;
      case 206: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy489);
  }
        break;
      case 207: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy18 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy18, 0);
  if( yymsp[-4].minor.yy18 ){
    yymsp[-4].minor.yy18->x.pList = yymsp[-1].minor.yy18 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[-1].minor.yy18) : yymsp[-2].minor.yy420;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy18);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy420);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy18);
  }
}
        break;
      case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[-2].minor.yy18);
  yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
}
        break;
      case 209: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy18);
  yymsp[-3].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy420, yymsp[0].minor.yy18);
}
        break;
      case 212: /* case_operand ::= expr */
{yymsp[0].minor.yy18 = yymsp[0].minor.yy18; /*A-overwrites-X*/}
        break;
      case 215: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy420 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy420,yymsp[0].minor.yy18);}
        break;
      case 216: /* nexprlist ::= expr */
{yymsp[0].minor.yy420 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy18); /*A-overwrites-Y*/}
        break;
      case 218: /* paren_exprlist ::= LP exprlist RP */
      case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223);
{yymsp[-2].minor.yy420 = yymsp[-1].minor.yy420;}
        break;
      case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
}
        break;
      case 220: /* uniqueflag ::= UNIQUE */
      case 260: /* raisetype ::= ABORT */ yytestcase(yyruleno==260);
{yymsp[0].minor.yy70 = OE_Abort;}
        break;
      case 221: /* uniqueflag ::= */
{yymsp[1].minor.yy70 = OE_None;}
        break;
      case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy420 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy420, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70);
}
        break;
      case 225: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy420 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy70, yymsp[0].minor.yy70); /*A-overwrites-Y*/
}
        break;
      case 228: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy135, yymsp[-1].minor.yy70);}
        break;
      case 229: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
        break;
      case 230: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
        break;
      case 231: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 232: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;
      case 233: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
        break;
      case 234: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
        break;
      case 235: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 238: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
  Token all;
  all.z = yymsp[-3].minor.yy0.z;
  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy207, &all);
}
        break;
      case 239: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy70, yymsp[-4].minor.yy34.a, yymsp[-4].minor.yy34.b, yymsp[-2].minor.yy135, yymsp[0].minor.yy18, yymsp[-10].minor.yy70, yymsp[-8].minor.yy70);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 240: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy70 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 241: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy70 = TK_INSTEAD;}
        break;
      case 242: /* trigger_time ::= */
{ yymsp[1].minor.yy70 = TK_BEFORE; }
        break;
      case 243: /* trigger_event ::= DELETE|INSERT */
      case 244: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==244);
{yymsp[0].minor.yy34.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy34.b = 0;}
        break;
      case 245: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
        break;
      case 246: /* when_clause ::= */
      case 265: /* key_opt ::= */ yytestcase(yyruleno==265);
      case 306: /* filter_opt ::= */ yytestcase(yyruleno==306);
{ yymsp[1].minor.yy18 = 0; }
        break;
      case 247: /* when_clause ::= WHEN expr */
      case 266: /* key_opt ::= KEY expr */ yytestcase(yyruleno==266);
{ yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
        break;
      case 248: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy207!=0 );
  yymsp[-2].minor.yy207->pLast->pNext = yymsp[-1].minor.yy207;
  yymsp[-2].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
        break;
      case 249: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  assert( yymsp[-1].minor.yy207!=0 );
  yymsp[-1].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
        break;
      case 250: /* trnm ::= nm DOT nm */
{
  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
  sqlite3ErrorMsg(pParse, 
        "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
        "statements within triggers");
}
        break;
      case 251: /* tridxby ::= INDEXED BY nm */
{
  sqlite3ErrorMsg(pParse,
        "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 252: /* tridxby ::= NOT INDEXED */
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 253: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
  yymsp[-7].minor.yy207 = yylhsminor.yy207;
        break;
      case 254: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
   yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
}
  yymsp[-7].minor.yy207 = yylhsminor.yy207;
        break;
      case 255: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
  yymsp[-5].minor.yy207 = yylhsminor.yy207;
        break;
      case 256: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
  yymsp[-2].minor.yy207 = yylhsminor.yy207;
        break;
      case 257: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy18 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
  if( yymsp[-3].minor.yy18 ){
    yymsp[-3].minor.yy18->affinity = OE_Ignore;
  }
}
        break;
      case 258: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy18 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
  if( yymsp[-5].minor.yy18 ) {
    yymsp[-5].minor.yy18->affinity = (char)yymsp[-3].minor.yy70;
  }
}
        break;
      case 259: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy70 = OE_Rollback;}
        break;
      case 261: /* raisetype ::= FAIL */
{yymsp[0].minor.yy70 = OE_Fail;}
        break;
      case 262: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy135,yymsp[-1].minor.yy70);
}
        break;
      case 263: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy18, yymsp[-1].minor.yy18, yymsp[0].minor.yy18);
}
        break;
      case 264: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy18);
}
        break;
      case 267: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 268: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 269: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 270: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 271: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy135,&yymsp[0].minor.yy0);
}
        break;
      case 272: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
        break;
      case 273: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
}
        break;
      case 274: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 275: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 276: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
}
        break;
      case 277: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 278: /* vtabargtoken ::= ANY */
      case 279: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==279);
      case 280: /* lp ::= LP */ yytestcase(yyruleno==280);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;
      case 281: /* with ::= WITH wqlist */
      case 282: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==282);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
        break;
      case 283: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
  yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
}
        break;
      case 284: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
  yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
}
        break;
      case 285: /* windowdefn_list ::= windowdefn */
{ yylhsminor.yy327 = yymsp[0].minor.yy327; }
  yymsp[0].minor.yy327 = yylhsminor.yy327;
        break;
      case 286: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
  assert( yymsp[0].minor.yy327!=0 );
  yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
  yylhsminor.yy327 = yymsp[0].minor.yy327;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 287: /* windowdefn ::= nm AS window */
{
  if( ALWAYS(yymsp[0].minor.yy327) ){
    yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
  }
  yylhsminor.yy327 = yymsp[0].minor.yy327;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 288: /* window ::= LP part_opt orderby_opt frame_opt RP */
{
  yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
  if( ALWAYS(yymsp[-4].minor.yy327) ){
    yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
    yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
  }
}
        break;
      case 289: /* part_opt ::= PARTITION BY nexprlist */
{ yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
        break;
      case 290: /* part_opt ::= */
{ yymsp[1].minor.yy420 = 0; }
        break;
      case 291: /* frame_opt ::= */
{ 
  yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
}
        break;
      case 292: /* frame_opt ::= range_or_rows frame_bound_s */
{ 
  yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
}
  yymsp[-1].minor.yy327 = yylhsminor.yy327;
        break;
      case 293: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
{ 
  yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
}
  yymsp[-4].minor.yy327 = yylhsminor.yy327;
        break;
      case 294: /* range_or_rows ::= RANGE */
{ yymsp[0].minor.yy70 = TK_RANGE; }
        break;
      case 295: /* range_or_rows ::= ROWS */
{ yymsp[0].minor.yy70 = TK_ROWS;  }
        break;
      case 296: /* frame_bound_s ::= frame_bound */
      case 298: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==298);
{ yylhsminor.yy119 = yymsp[0].minor.yy119; }
  yymsp[0].minor.yy119 = yylhsminor.yy119;
        break;
      case 297: /* frame_bound_s ::= UNBOUNDED PRECEDING */
      case 299: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==299);
{yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
        break;
      case 300: /* frame_bound ::= expr PRECEDING */
{ yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
  yymsp[-1].minor.yy119 = yylhsminor.yy119;
        break;
      case 301: /* frame_bound ::= CURRENT ROW */
{ yymsp[-1].minor.yy119.eType = TK_CURRENT  ; yymsp[-1].minor.yy119.pExpr = 0; }
        break;
      case 302: /* frame_bound ::= expr FOLLOWING */
{ yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
  yymsp[-1].minor.yy119 = yylhsminor.yy119;
        break;




      case 303: /* window_clause ::= WINDOW windowdefn_list */
{ yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
        break;
      case 304: /* over_clause ::= filter_opt OVER window */
{
  yylhsminor.yy327 = yymsp[0].minor.yy327;
  assert( yylhsminor.yy327!=0 );
  yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 305: /* over_clause ::= filter_opt OVER nm */
{
  yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  if( yylhsminor.yy327 ){
    yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
    yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
  }else{
    sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
  }
}
  yymsp[-2].minor.yy327 = yylhsminor.yy327;
        break;
      case 307: /* filter_opt ::= FILTER LP WHERE expr RP */
{ yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
        break;
      default:
      /* (308) input ::= cmdlist */ yytestcase(yyruleno==308);
      /* (309) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==309);
      /* (310) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=310);
      /* (311) ecmd ::= SEMI */ yytestcase(yyruleno==311);
      /* (312) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==312);
      /* (313) ecmd ::= explain cmdx */ yytestcase(yyruleno==313);
      /* (314) trans_opt ::= */ yytestcase(yyruleno==314);
      /* (315) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==315);
      /* (316) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==316);
      /* (317) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==317);
      /* (318) savepoint_opt ::= */ yytestcase(yyruleno==318);
      /* (319) cmd ::= create_table create_table_args */ yytestcase(yyruleno==319);
      /* (320) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==320);
      /* (321) columnlist ::= columnname carglist */ yytestcase(yyruleno==321);
      /* (322) nm ::= ID|INDEXED */ yytestcase(yyruleno==322);
      /* (323) nm ::= STRING */ yytestcase(yyruleno==323);
      /* (324) nm ::= JOIN_KW */ yytestcase(yyruleno==324);
      /* (325) typetoken ::= typename */ yytestcase(yyruleno==325);
      /* (326) typename ::= ID|STRING */ yytestcase(yyruleno==326);
      /* (327) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
      /* (328) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=328);
      /* (329) carglist ::= carglist ccons */ yytestcase(yyruleno==329);
      /* (330) carglist ::= */ yytestcase(yyruleno==330);
      /* (331) ccons ::= NULL onconf */ yytestcase(yyruleno==331);
      /* (332) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==332);
      /* (333) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==333);
      /* (334) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=334);
      /* (335) tconscomma ::= */ yytestcase(yyruleno==335);
      /* (336) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=336);
      /* (337) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=337);
      /* (338) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=338);
      /* (339) oneselect ::= values */ yytestcase(yyruleno==339);
      /* (340) sclp ::= selcollist COMMA */ yytestcase(yyruleno==340);
      /* (341) as ::= ID|STRING */ yytestcase(yyruleno==341);
      /* (342) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=342);
      /* (343) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==343);
      /* (344) exprlist ::= nexprlist */ yytestcase(yyruleno==344);
      /* (345) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=345);
      /* (346) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=346);
      /* (347) nmnum ::= ON */ yytestcase(yyruleno==347);
      /* (348) nmnum ::= DELETE */ yytestcase(yyruleno==348);
      /* (349) nmnum ::= DEFAULT */ yytestcase(yyruleno==349);
      /* (350) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==350);
      /* (351) foreach_clause ::= */ yytestcase(yyruleno==351);
      /* (352) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==352);
      /* (353) trnm ::= nm */ yytestcase(yyruleno==353);
      /* (354) tridxby ::= */ yytestcase(yyruleno==354);
      /* (355) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==355);
      /* (356) database_kw_opt ::= */ yytestcase(yyruleno==356);
      /* (357) kwcolumn_opt ::= */ yytestcase(yyruleno==357);
      /* (358) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==358);
      /* (359) vtabarglist ::= vtabarg */ yytestcase(yyruleno==359);
      /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==360);
      /* (361) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==361);
      /* (362) anylist ::= */ yytestcase(yyruleno==362);
      /* (363) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==363);
      /* (364) anylist ::= anylist ANY */ yytestcase(yyruleno==364);
      /* (365) with ::= */ yytestcase(yyruleno==365);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
151536
151537
151538
151539
151540
151541
151542









151543
151544
151545
151546
151547
151548
151549
      */
    }else{
      rc = nKey1 - nKey2;
    }
  }
  return rc;
}










/*
** Another built-in collating sequence: NOCASE. 
**
** This collating sequence is intended to be used for "case independent
** comparison". SQLite's knowledge of upper and lower case equivalents
** extends only to the 26 characters used in the English language.







>
>
>
>
>
>
>
>
>







151462
151463
151464
151465
151466
151467
151468
151469
151470
151471
151472
151473
151474
151475
151476
151477
151478
151479
151480
151481
151482
151483
151484
      */
    }else{
      rc = nKey1 - nKey2;
    }
  }
  return rc;
}

/*
** Return true if CollSeq is the default built-in BINARY.
*/
SQLITE_PRIVATE int sqlite3IsBinary(const CollSeq *p){
  assert( p==0 || p->xCmp!=binCollFunc || p->pUser!=0
            || strcmp(p->zName,"BINARY")==0 );
  return p==0 || (p->xCmp==binCollFunc && p->pUser==0);
}

/*
** Another built-in collating sequence: NOCASE. 
**
** This collating sequence is intended to be used for "case independent
** comparison". SQLite's knowledge of upper and lower case equivalents
** extends only to the 26 characters used in the English language.
151658
151659
151660
151661
151662
151663
151664
151665
151666
151667
151668
151669
151670
151671
151672
static void disconnectAllVtab(sqlite3 *db){
#ifndef SQLITE_OMIT_VIRTUALTABLE
  int i;
  HashElem *p;
  sqlite3BtreeEnterAll(db);
  for(i=0; i<db->nDb; i++){
    Schema *pSchema = db->aDb[i].pSchema;
    if( db->aDb[i].pSchema ){
      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){
        Table *pTab = (Table *)sqliteHashData(p);
        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);
      }
    }
  }
  for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){







|







151593
151594
151595
151596
151597
151598
151599
151600
151601
151602
151603
151604
151605
151606
151607
static void disconnectAllVtab(sqlite3 *db){
#ifndef SQLITE_OMIT_VIRTUALTABLE
  int i;
  HashElem *p;
  sqlite3BtreeEnterAll(db);
  for(i=0; i<db->nDb; i++){
    Schema *pSchema = db->aDb[i].pSchema;
    if( pSchema ){
      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){
        Table *pTab = (Table *)sqliteHashData(p);
        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);
      }
    }
  }
  for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){
154827
154828
154829
154830
154831
154832
154833



154834











154835

154836
154837
154838



154839
154840
154841
154842
154843
154844
154845
#endif
  sqlite3_mutex_enter(db->mutex);
  if( db->autoCommit==0 ){
    int iDb;
    iDb = sqlite3FindDbName(db, zDb);
    if( iDb==0 || iDb>1 ){
      Btree *pBt = db->aDb[iDb].pBt;



      if( 0==sqlite3BtreeIsInReadTrans(pBt) ){











        rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);

        if( rc==SQLITE_OK ){
          rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
          sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);



        }
      }
    }
  }

  sqlite3_mutex_leave(db->mutex);
#endif   /* SQLITE_OMIT_WAL */







>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
>


|
>
>
>







154762
154763
154764
154765
154766
154767
154768
154769
154770
154771
154772
154773
154774
154775
154776
154777
154778
154779
154780
154781
154782
154783
154784
154785
154786
154787
154788
154789
154790
154791
154792
154793
154794
154795
154796
154797
154798
#endif
  sqlite3_mutex_enter(db->mutex);
  if( db->autoCommit==0 ){
    int iDb;
    iDb = sqlite3FindDbName(db, zDb);
    if( iDb==0 || iDb>1 ){
      Btree *pBt = db->aDb[iDb].pBt;
      if( sqlite3BtreeIsInTrans(pBt)==0 ){
        Pager *pPager = sqlite3BtreePager(pBt);
        int bUnlock = 0;
        if( sqlite3BtreeIsInReadTrans(pBt) ){
          if( db->nVdbeActive==0 ){
            rc = sqlite3PagerSnapshotCheck(pPager, pSnapshot);
            if( rc==SQLITE_OK ){
              bUnlock = 1;
              rc = sqlite3BtreeCommit(pBt);
            }
          }
        }else{
          rc = SQLITE_OK;
        }
        if( rc==SQLITE_OK ){
          rc = sqlite3PagerSnapshotOpen(pPager, pSnapshot);
        }
        if( rc==SQLITE_OK ){
          rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
          sqlite3PagerSnapshotOpen(pPager, 0);
        }
        if( bUnlock ){
          sqlite3PagerSnapshotUnlock(pPager);
        }
      }
    }
  }

  sqlite3_mutex_leave(db->mutex);
#endif   /* SQLITE_OMIT_WAL */
207690
207691
207692
207693
207694
207695
207696
207697



207698
207699
207700
207701
207702
207703
207704
  int nChar
){
  int n = 0;
  int i;
  for(i=0; i<nChar; i++){
    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */
    if( (unsigned char)p[n++]>=0xc0 ){
      while( (p[n] & 0xc0)==0x80 ) n++;



    }
  }
  return n;
}

/*
** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of







|
>
>
>







207643
207644
207645
207646
207647
207648
207649
207650
207651
207652
207653
207654
207655
207656
207657
207658
207659
207660
  int nChar
){
  int n = 0;
  int i;
  for(i=0; i<nChar; i++){
    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */
    if( (unsigned char)p[n++]>=0xc0 ){
      while( (p[n] & 0xc0)==0x80 ){
        n++;
        if( n>=nByte ) break;
      }
    }
  }
  return n;
}

/*
** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of
211570
211571
211572
211573
211574
211575
211576
211577
211578
211579
211580
211581
211582
211583
211584
static void fts5SourceIdFunc(
  sqlite3_context *pCtx,          /* Function call context */
  int nArg,                       /* Number of args */
  sqlite3_value **apUnused        /* Function arguments */
){
  assert( nArg==0 );
  UNUSED_PARAM2(nArg, apUnused);
  sqlite3_result_text(pCtx, "fts5: 2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,







|







211526
211527
211528
211529
211530
211531
211532
211533
211534
211535
211536
211537
211538
211539
211540
static void fts5SourceIdFunc(
  sqlite3_context *pCtx,          /* Function call context */
  int nArg,                       /* Number of args */
  sqlite3_value **apUnused        /* Function arguments */
){
  assert( nArg==0 );
  UNUSED_PARAM2(nArg, apUnused);
  sqlite3_result_text(pCtx, "fts5: 2018-08-16 15:29:40 60045fbf52162f15f2e18a4e392e80fab19bdbce242728b5e62b0894eac49dfd", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,
216280
216281
216282
216283
216284
216285
216286
216287
216288
216289
216290
216291
216292
216293
#endif
  return rc;
}
#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/************** End of stmt.c ************************************************/
#if __LINE__!=216287
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID      "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cbalt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/************************** End of sqlite3.c ******************************/







|

|




216236
216237
216238
216239
216240
216241
216242
216243
216244
216245
216246
216247
216248
216249
#endif
  return rc;
}
#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/************** End of stmt.c ************************************************/
#if __LINE__!=216243
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID      "2018-08-16 16:24:24 456842924bb33c0af8af29402f06e5f25b6791f698a0d12a080258b20b0calt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/************************** End of sqlite3.c ******************************/
Changes to src/sqlite3.h.
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.25.0"
#define SQLITE_VERSION_NUMBER 3025000
#define SQLITE_SOURCE_ID      "2018-07-24 22:02:12 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros







|







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.25.0"
#define SQLITE_VERSION_NUMBER 3025000
#define SQLITE_SOURCE_ID      "2018-08-16 16:24:24 456842924bb33c0af8af29402f06e5f25b6791f698a0d12a080258b20b0cfb61"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
**
** The following must be true for this function to succeed. If any of
** the following statements are false when sqlite3_snapshot_get() is
** called, SQLITE_ERROR is returned. The final value of *P is undefined
** in this case. 
**
** <ul>
**   <li> The database handle must be in [autocommit mode].
**
**   <li> Schema S of [database connection] D must be a [WAL mode] database.
**
**   <li> There must not be a write transaction open on schema S of database
**        connection D.
**
**   <li> One or more transactions must have been written to the current wal







|







8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
**
** The following must be true for this function to succeed. If any of
** the following statements are false when sqlite3_snapshot_get() is
** called, SQLITE_ERROR is returned. The final value of *P is undefined
** in this case. 
**
** <ul>
**   <li> The database handle must not be in [autocommit mode].
**
**   <li> Schema S of [database connection] D must be a [WAL mode] database.
**
**   <li> There must not be a write transaction open on schema S of database
**        connection D.
**
**   <li> One or more transactions must have been written to the current wal
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048




9049

9050
9051
9052

9053








9054
9055
9056
9057
9058
9059
9060
  sqlite3_snapshot **ppSnapshot
);

/*
** CAPI3REF: Start a read transaction on an historical snapshot
** METHOD: sqlite3_snapshot
**
** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
** read transaction for schema S of
** [database connection] D such that the read transaction
** refers to historical [snapshot] P, rather than the most
** recent change to the database.
** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
** or an appropriate [error code] if it fails.
**
** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
** the first operation following the [BEGIN] that takes the schema S
** out of [autocommit mode].




** ^In other words, schema S must not currently be in

** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the
** database connection D must be out of [autocommit mode].
** ^A [snapshot] will fail to open if it has been overwritten by a

** [checkpoint].








** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
** database connection D does not know that the database file for
** schema S is in [WAL mode].  A database connection might not know
** that the database file is in [WAL mode] if there has been no prior
** I/O on that database connection, or if the database entered [WAL mode] 
** after the most recent I/O on the database connection.)^
** (Hint: Run "[PRAGMA application_id]" against a newly opened







|
|
|
|
<
|
|

|
<
|
>
>
>
>
|
>
|
<
|
>
|
>
>
>
>
>
>
>
>







9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041

9042
9043
9044
9045

9046
9047
9048
9049
9050
9051
9052
9053

9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
  sqlite3_snapshot **ppSnapshot
);

/*
** CAPI3REF: Start a read transaction on an historical snapshot
** METHOD: sqlite3_snapshot
**
** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read 
** transaction or upgrades an existing one for schema S of 
** [database connection] D such that the read transaction refers to 
** historical [snapshot] P, rather than the most recent change to the 

** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK 
** on success or an appropriate [error code] if it fails.
**
** ^In order to succeed, the database connection must not be in 

** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there
** is already a read transaction open on schema S, then the database handle
** must have no active statements (SELECT statements that have been passed
** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). 
** SQLITE_ERROR is returned if either of these conditions is violated, or
** if schema S does not exist, or if the snapshot object is invalid.
**
** ^A call to sqlite3_snapshot_open() will fail to open if the specified

** snapshot has been overwritten by a [checkpoint]. In this case 
** SQLITE_BUSY_SNAPSHOT is returned.
**
** If there is already a read transaction open when this function is 
** invoked, then the same read transaction remains open (on the same
** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
** is returned. If another error code - for example SQLITE_PROTOCOL or an
** SQLITE_IOERR error code - is returned, then the final state of the
** read transaction is undefined. If SQLITE_OK is returned, then the 
** read transaction is now open on database snapshot P.
**
** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
** database connection D does not know that the database file for
** schema S is in [WAL mode].  A database connection might not know
** that the database file is in [WAL mode] if there has been no prior
** I/O on that database connection, or if the database entered [WAL mode] 
** after the most recent I/O on the database connection.)^
** (Hint: Run "[PRAGMA application_id]" against a newly opened