mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Fix the sqlite3_table_column_metadata() routine so that it gives the correct
answer for the "rowid" column in a WITHOUT ROWID table. Enhance it so that it can be used to check for the existence of a table by setting the column name parameter to NULL. The routine is now included in the build by default, even without the SQLITE_ENABLE_COLUMN_METADATA compile-time option. FossilOrigin-Name: cf9be419a16156a9814e1378bb49b780de977343
This commit is contained in:
16
src/main.c
16
src/main.c
@@ -3188,11 +3188,8 @@ int sqlite3_table_column_metadata(
|
||||
}
|
||||
|
||||
/* Find the column for which info is requested */
|
||||
if( sqlite3IsRowid(zColumnName) ){
|
||||
iCol = pTab->iPKey;
|
||||
if( iCol>=0 ){
|
||||
pCol = &pTab->aCol[iCol];
|
||||
}
|
||||
if( zColumnName==0 ){
|
||||
/* Query for existance of table only */
|
||||
}else{
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
pCol = &pTab->aCol[iCol];
|
||||
@@ -3201,8 +3198,13 @@ int sqlite3_table_column_metadata(
|
||||
}
|
||||
}
|
||||
if( iCol==pTab->nCol ){
|
||||
pTab = 0;
|
||||
goto error_out;
|
||||
if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
|
||||
iCol = pTab->iPKey;
|
||||
pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
|
||||
}else{
|
||||
pTab = 0;
|
||||
goto error_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user