summaryrefslogtreecommitdiff
path: root/chromium/third_party/sqlite/src/tool
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/sqlite/src/tool')
-rw-r--r--chromium/third_party/sqlite/src/tool/lemon.c12
-rw-r--r--chromium/third_party/sqlite/src/tool/lempar.c101
-rw-r--r--chromium/third_party/sqlite/src/tool/mkkeywordhash.c32
-rw-r--r--chromium/third_party/sqlite/src/tool/sqldiff.c14
4 files changed, 90 insertions, 69 deletions
diff --git a/chromium/third_party/sqlite/src/tool/lemon.c b/chromium/third_party/sqlite/src/tool/lemon.c
index 54c8946a0df..06ba1be2bd6 100644
--- a/chromium/third_party/sqlite/src/tool/lemon.c
+++ b/chromium/third_party/sqlite/src/tool/lemon.c
@@ -401,7 +401,7 @@ struct lemon {
struct symbol *errsym; /* The error symbol */
struct symbol *wildcard; /* Token that matches anything */
char *name; /* Name of the generated parser */
- char *arg; /* Declaration of the 3th argument to parser */
+ char *arg; /* Declaration of the 3rd argument to parser */
char *ctx; /* Declaration of 2nd argument to constructor */
char *tokentype; /* Type of terminal symbols in the parser stack */
char *vartype; /* The default type of non-terminal symbols */
@@ -1027,7 +1027,7 @@ PRIVATE void buildshifts(struct lemon *lemp, struct state *stp)
struct symbol *bsp; /* Symbol following the dot in configuration "bcfp" */
struct state *newstp; /* A pointer to a successor state */
- /* Each configuration becomes complete after it contibutes to a successor
+ /* Each configuration becomes complete after it contributes to a successor
** state. Initially, all configurations are incomplete */
for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE;
@@ -1887,7 +1887,7 @@ static char *merge(
**
** Return Value:
** A pointer to the head of a sorted list containing the elements
-** orginally in list.
+** originally in list.
**
** Side effects:
** The "next" pointers for elements in list are changed.
@@ -3513,7 +3513,7 @@ void ReportOutput(struct lemon *lemp)
}
/* Search for the file "name" which is in the same directory as
-** the exacutable */
+** the executable */
PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
{
const char *pathlist;
@@ -3868,7 +3868,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
lhsdirect = 1;
}else if( rp->rhsalias[0]==0 ){
/* The left-most RHS symbol has no value. LHS direct is ok. But
- ** we have to call the distructor on the RHS symbol first. */
+ ** we have to call the destructor on the RHS symbol first. */
lhsdirect = 1;
if( has_destructor(rp->rhs[0],lemp) ){
append_str(0,0,0,0);
@@ -4849,7 +4849,7 @@ void ReportTable(
** yyRuleInfoNRhs[].
**
** Note: This code depends on the fact that rules are number
- ** sequentually beginning with 0.
+ ** sequentially beginning with 0.
*/
for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
fprintf(out," %4d, /* (%d) ", rp->lhs->index, i);
diff --git a/chromium/third_party/sqlite/src/tool/lempar.c b/chromium/third_party/sqlite/src/tool/lempar.c
index 71a51cf4487..35c3768bb9d 100644
--- a/chromium/third_party/sqlite/src/tool/lempar.c
+++ b/chromium/third_party/sqlite/src/tool/lempar.c
@@ -718,55 +718,6 @@ static YYACTIONTYPE yy_reduce(
(void)yyLookahead;
(void)yyLookaheadToken;
yymsp = yypParser->yytos;
- assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
-#ifndef NDEBUG
- if( yyTraceFILE ){
- yysize = yyRuleInfoNRhs[yyruleno];
- if( yysize ){
- fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
- yyTracePrompt,
- yyruleno, yyRuleName[yyruleno],
- yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
- yymsp[yysize].stateno);
- }else{
- fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
- yyTracePrompt, yyruleno, yyRuleName[yyruleno],
- yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
- }
- }
-#endif /* NDEBUG */
-
- /* Check that the stack is large enough to grow by a single entry
- ** if the RHS of the rule is empty. This ensures that there is room
- ** enough on the stack to push the LHS value */
- if( yyRuleInfoNRhs[yyruleno]==0 ){
-#ifdef YYTRACKMAXSTACKDEPTH
- if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
- yypParser->yyhwm++;
- assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
- }
-#endif
-#if YYSTACKDEPTH>0
- if( yypParser->yytos>=yypParser->yystackEnd ){
- yyStackOverflow(yypParser);
- /* The call to yyStackOverflow() above pops the stack until it is
- ** empty, causing the main parser loop to exit. So the return value
- ** is never used and does not matter. */
- return 0;
- }
-#else
- if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
- if( yyGrowStack(yypParser) ){
- yyStackOverflow(yypParser);
- /* The call to yyStackOverflow() above pops the stack until it is
- ** empty, causing the main parser loop to exit. So the return value
- ** is never used and does not matter. */
- return 0;
- }
- yymsp = yypParser->yytos;
- }
-#endif
- }
switch( yyruleno ){
/* Beginning here are the reduction cases. A typical example
@@ -925,12 +876,56 @@ void Parse(
}
#endif
- do{
+ while(1){ /* Exit by "break" */
+ assert( yypParser->yytos>=yypParser->yystack );
assert( yyact==yypParser->yytos->stateno );
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
if( yyact >= YY_MIN_REDUCE ){
- yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
- yyminor ParseCTX_PARAM);
+ unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
+ assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
+#ifndef NDEBUG
+ if( yyTraceFILE ){
+ int yysize = yyRuleInfoNRhs[yyruleno];
+ if( yysize ){
+ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
+ yyTracePrompt,
+ yyruleno, yyRuleName[yyruleno],
+ yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
+ yypParser->yytos[yysize].stateno);
+ }else{
+ fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
+ yyTracePrompt, yyruleno, yyRuleName[yyruleno],
+ yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
+ }
+ }
+#endif /* NDEBUG */
+
+ /* Check that the stack is large enough to grow by a single entry
+ ** if the RHS of the rule is empty. This ensures that there is room
+ ** enough on the stack to push the LHS value */
+ if( yyRuleInfoNRhs[yyruleno]==0 ){
+#ifdef YYTRACKMAXSTACKDEPTH
+ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
+ yypParser->yyhwm++;
+ assert( yypParser->yyhwm ==
+ (int)(yypParser->yytos - yypParser->yystack));
+ }
+#endif
+#if YYSTACKDEPTH>0
+ if( yypParser->yytos>=yypParser->yystackEnd ){
+ yyStackOverflow(yypParser);
+ break;
+ }
+#else
+ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
+ if( yyGrowStack(yypParser) ){
+ yyStackOverflow(yypParser);
+ break;
+ }
+ }
+#endif
+ }
+ yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM);
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
@@ -1043,7 +1038,7 @@ void Parse(
break;
#endif
}
- }while( yypParser->yytos>yypParser->yystack );
+ }
#ifndef NDEBUG
if( yyTraceFILE ){
yyStackEntry *i;
diff --git a/chromium/third_party/sqlite/src/tool/mkkeywordhash.c b/chromium/third_party/sqlite/src/tool/mkkeywordhash.c
index 83ec179ba08..bbb0ccf2932 100644
--- a/chromium/third_party/sqlite/src/tool/mkkeywordhash.c
+++ b/chromium/third_party/sqlite/src/tool/mkkeywordhash.c
@@ -155,10 +155,16 @@ struct Keyword {
# define WINDOWFUNC 0x00100000
#endif
#ifdef SQLITE_OMIT_GENERATED_COLUMNS
-# define GENCOL 0
+# define GENCOL 0
#else
-# define GENCOL 0x00200000
+# define GENCOL 0x00200000
#endif
+#ifdef SQLITE_OMIT_RETURNING
+# define RETURNING 0
+#else
+# define RETURNING 0x00400000
+#endif
+
/*
** These are the keywords
@@ -223,7 +229,7 @@ static Keyword aKeywordTable[] = {
{ "FOREIGN", "TK_FOREIGN", FKEY, 1 },
{ "FROM", "TK_FROM", ALWAYS, 10 },
{ "FULL", "TK_JOIN_KW", ALWAYS, 3 },
- { "GENERATED", "TK_GENERATED", GENCOL, 1 },
+ { "GENERATED", "TK_GENERATED", ALWAYS, 1 },
{ "GLOB", "TK_LIKE_KW", ALWAYS, 3 },
{ "GROUP", "TK_GROUP", ALWAYS, 5 },
{ "GROUPS", "TK_GROUPS", WINDOWFUNC, 2 },
@@ -249,6 +255,7 @@ static Keyword aKeywordTable[] = {
{ "LIKE", "TK_LIKE_KW", ALWAYS, 5 },
{ "LIMIT", "TK_LIMIT", ALWAYS, 3 },
{ "MATCH", "TK_MATCH", ALWAYS, 2 },
+ { "MATERIALIZED", "TK_MATERIALIZED", CTE, 12 },
{ "NATURAL", "TK_JOIN_KW", ALWAYS, 3 },
{ "NO", "TK_NO", FKEY|WINDOWFUNC, 2 },
{ "NOT", "TK_NOT", ALWAYS, 10 },
@@ -280,6 +287,7 @@ static Keyword aKeywordTable[] = {
{ "RENAME", "TK_RENAME", ALTER, 1 },
{ "REPLACE", "TK_REPLACE", CONFLICT, 10 },
{ "RESTRICT", "TK_RESTRICT", FKEY, 1 },
+ { "RETURNING", "TK_RETURNING", RETURNING, 10 },
{ "RIGHT", "TK_JOIN_KW", ALWAYS, 0 },
{ "ROLLBACK", "TK_ROLLBACK", ALWAYS, 1 },
{ "ROW", "TK_ROW", TRIGGER, 1 },
@@ -381,6 +389,14 @@ static void reorder(int *pFrom){
reorder(&aKeywordTable[i].iNext);
}
+/* Parameter to the hash function
+*/
+#define HASH_OP ^
+#define HASH_CC '^'
+#define HASH_C0 4
+#define HASH_C1 3
+#define HASH_C2 1
+
/*
** This routine does the work. The generated code is printed on standard
** output.
@@ -411,8 +427,9 @@ int main(int argc, char **argv){
assert( p->len<sizeof(p->zOrigName) );
memcpy(p->zOrigName, p->zName, p->len+1);
totalLen += p->len;
- p->hash = (charMap(p->zName[0])*4) ^
- (charMap(p->zName[p->len-1])*3) ^ (p->len*1);
+ p->hash = (charMap(p->zName[0])*HASH_C0) HASH_OP
+ (charMap(p->zName[p->len-1])*HASH_C1) HASH_OP
+ (p->len*HASH_C2);
p->id = i+1;
}
@@ -648,8 +665,9 @@ int main(int argc, char **argv){
printf(" int i, j;\n");
printf(" const char *zKW;\n");
printf(" if( n>=2 ){\n");
- printf(" i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
- bestSize);
+ printf(" i = ((charMap(z[0])*%d) %c", HASH_C0, HASH_CC);
+ printf(" (charMap(z[n-1])*%d) %c", HASH_C1, HASH_CC);
+ printf(" n*%d) %% %d;\n", HASH_C2, bestSize);
printf(" for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){\n");
printf(" if( aKWLen[i]!=n ) continue;\n");
printf(" zKW = &zKWText[aKWOffset[i]];\n");
diff --git a/chromium/third_party/sqlite/src/tool/sqldiff.c b/chromium/third_party/sqlite/src/tool/sqldiff.c
index 123d5b49b78..9844cbadf0f 100644
--- a/chromium/third_party/sqlite/src/tool/sqldiff.c
+++ b/chromium/third_party/sqlite/src/tool/sqldiff.c
@@ -1713,19 +1713,27 @@ end_changeset_one_table:
}
/*
+** Return true if the ascii character passed as the only argument is a
+** whitespace character. Otherwise return false.
+*/
+static int is_whitespace(char x){
+ return (x==' ' || x=='\t' || x=='\n' || x=='\r');
+}
+
+/*
** Extract the next SQL keyword or quoted string from buffer zIn and copy it
** (or a prefix of it if it will not fit) into buffer zBuf, size nBuf bytes.
** Return a pointer to the character within zIn immediately following
** the token or quoted string just extracted.
*/
-const char *gobble_token(const char *zIn, char *zBuf, int nBuf){
+static const char *gobble_token(const char *zIn, char *zBuf, int nBuf){
const char *p = zIn;
char *pOut = zBuf;
char *pEnd = &pOut[nBuf-1];
char q = 0; /* quote character, if any */
if( p==0 ) return 0;
- while( *p==' ' ) p++;
+ while( is_whitespace(*p) ) p++;
switch( *p ){
case '"': q = '"'; break;
case '\'': q = '\''; break;
@@ -1744,7 +1752,7 @@ const char *gobble_token(const char *zIn, char *zBuf, int nBuf){
p++;
}
}else{
- while( *p && *p!=' ' && *p!='(' ){
+ while( *p && !is_whitespace(*p) && *p!='(' ){
if( pOut<pEnd ) *pOut++ = *p;
p++;
}