/ Check-in [620d19c3]
Login

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

Overview
Comment:Fix a faulty assert() in sqlite3SelectNew().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 620d19c3b462f5c4763ebd26513321431f21dd72
User & Date: drh 2015-04-17 15:16:58
Context
2015-04-17
15:58
Ensure that semantic SQL errors are always reported back up to the syntax parser. Also: Improve the defense against invalid PRAGMA synchronous settings. check-in: 7aeade9a user: drh tags: trunk
15:16
Fix a faulty assert() in sqlite3SelectNew(). check-in: 620d19c3 user: drh tags: trunk
14:30
Add the tool/fuzzershell.c utility program. check-in: db8d9af4 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  Expr *pLimit,         /* LIMIT value.  NULL means not used */
  Expr *pOffset         /* OFFSET value.  NULL means no offset */
){
  Select *pNew;
  Select standin;
  sqlite3 *db = pParse->db;
  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
  assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */
  if( pNew==0 ){
    assert( db->mallocFailed );
    pNew = &standin;
    memset(pNew, 0, sizeof(*pNew));
  }
  if( pEList==0 ){
    pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ALL,0));
................................................................................
  pNew->pGroupBy = pGroupBy;
  pNew->pHaving = pHaving;
  pNew->pOrderBy = pOrderBy;
  pNew->selFlags = selFlags;
  pNew->op = TK_SELECT;
  pNew->pLimit = pLimit;
  pNew->pOffset = pOffset;
  assert( pOffset==0 || pLimit!=0 );
  pNew->addrOpenEphm[0] = -1;
  pNew->addrOpenEphm[1] = -1;
  if( db->mallocFailed ) {
    clearSelect(db, pNew, pNew!=&standin);
    pNew = 0;
  }else{
    assert( pNew->pSrc!=0 || pParse->nErr>0 );







<







 







|







107
108
109
110
111
112
113

114
115
116
117
118
119
120
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  Expr *pLimit,         /* LIMIT value.  NULL means not used */
  Expr *pOffset         /* OFFSET value.  NULL means no offset */
){
  Select *pNew;
  Select standin;
  sqlite3 *db = pParse->db;
  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );

  if( pNew==0 ){
    assert( db->mallocFailed );
    pNew = &standin;
    memset(pNew, 0, sizeof(*pNew));
  }
  if( pEList==0 ){
    pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ALL,0));
................................................................................
  pNew->pGroupBy = pGroupBy;
  pNew->pHaving = pHaving;
  pNew->pOrderBy = pOrderBy;
  pNew->selFlags = selFlags;
  pNew->op = TK_SELECT;
  pNew->pLimit = pLimit;
  pNew->pOffset = pOffset;
  assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 );
  pNew->addrOpenEphm[0] = -1;
  pNew->addrOpenEphm[1] = -1;
  if( db->mallocFailed ) {
    clearSelect(db, pNew, pNew!=&standin);
    pNew = 0;
  }else{
    assert( pNew->pSrc!=0 || pParse->nErr>0 );

Changes to test/select1.test.

1071
1072
1073
1074
1075
1076
1077
1078





1079
}

# Crash bug reported on the mailing list on 2012-02-23
#
do_test select1-16.1 {
  catchsql {SELECT 1 FROM (SELECT *)}
} {1 {no tables specified}}
  





finish_test







|
>
>
>
>
>

1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
}

# Crash bug reported on the mailing list on 2012-02-23
#
do_test select1-16.1 {
  catchsql {SELECT 1 FROM (SELECT *)}
} {1 {no tables specified}}

# 2015-04-17:  assertion fix.
do_catchsql_test select1-16.2 {
  SELECT 1 FROM sqlite_master LIMIT 1,#1;
} {1 {near "#1": syntax error}}
  
finish_test