mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Allow expressions like "<tbl>.rowid" to refer to implicit rowid columns of tables in nested FROM clauses.
FossilOrigin-Name: 59a1bbc69f5dbb33418fa4b383393fb13a46bc1e531577da8ad54ae2fad5a10e
This commit is contained in:
21
src/expr.c
21
src/expr.c
@@ -2694,6 +2694,27 @@ int sqlite3IsRowid(const char *z){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a pointer to a buffer containing a usable rowid alias for table
|
||||
** pTab. An alias is usable if there is not an explicit user-defined column
|
||||
** of the same name.
|
||||
*/
|
||||
const char *sqlite3RowidAlias(Table *pTab){
|
||||
const char *azOpt[] = {"_ROWID_", "ROWID", "OID"};
|
||||
int ii;
|
||||
assert( VisibleRowid(pTab) );
|
||||
for(ii=0; ii<ArraySize(azOpt); ii++){
|
||||
int iCol;
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break;
|
||||
}
|
||||
if( iCol==pTab->nCol ){
|
||||
return azOpt[ii];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** pX is the RHS of an IN operator. If pX is a SELECT statement
|
||||
** that can be simplified to a direct table access, then return
|
||||
|
Reference in New Issue
Block a user