mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Report an error if a USING or ON clause is specified following a from-list element that is not to the right of a join operator. Fix for #3846. (CVS 6832)
FossilOrigin-Name: 29b48972b65a17dab343b063a620cf8d456a923c
This commit is contained in:
29
src/build.c
29
src/build.c
@@ -22,7 +22,7 @@
|
||||
** COMMIT
|
||||
** ROLLBACK
|
||||
**
|
||||
** $Id: build.c,v 1.555 2009/07/01 14:56:40 danielk1977 Exp $
|
||||
** $Id: build.c,v 1.556 2009/07/01 16:12:08 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -3208,12 +3208,15 @@ SrcList *sqlite3SrcListAppendFromTerm(
|
||||
){
|
||||
struct SrcList_item *pItem;
|
||||
sqlite3 *db = pParse->db;
|
||||
if( !p && (pOn || pUsing) ){
|
||||
sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s",
|
||||
(pOn ? "ON" : "USING")
|
||||
);
|
||||
goto append_from_error;
|
||||
}
|
||||
p = sqlite3SrcListAppend(db, p, pTable, pDatabase);
|
||||
if( p==0 || NEVER(p->nSrc==0) ){
|
||||
sqlite3ExprDelete(db, pOn);
|
||||
sqlite3IdListDelete(db, pUsing);
|
||||
sqlite3SelectDelete(db, pSubquery);
|
||||
return p;
|
||||
goto append_from_error;
|
||||
}
|
||||
pItem = &p->a[p->nSrc-1];
|
||||
assert( pAlias!=0 );
|
||||
@@ -3221,14 +3224,16 @@ SrcList *sqlite3SrcListAppendFromTerm(
|
||||
pItem->zAlias = sqlite3NameFromToken(db, pAlias);
|
||||
}
|
||||
pItem->pSelect = pSubquery;
|
||||
if( p->nSrc>1 ){
|
||||
pItem->pOn = pOn;
|
||||
pItem->pUsing = pUsing;
|
||||
}else{
|
||||
sqlite3ExprDelete(db, pOn);
|
||||
sqlite3IdListDelete(db, pUsing);
|
||||
}
|
||||
pItem->pOn = pOn;
|
||||
pItem->pUsing = pUsing;
|
||||
return p;
|
||||
|
||||
append_from_error:
|
||||
assert( p==0 );
|
||||
sqlite3ExprDelete(db, pOn);
|
||||
sqlite3IdListDelete(db, pUsing);
|
||||
sqlite3SelectDelete(db, pSubquery);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user