diff options
author | drh <drh@noemail.net> | 2015-08-25 19:20:04 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-08-25 19:20:04 +0000 |
commit | e91076981782e96e4c9acb79cff227f19a6425ae (patch) | |
tree | 78275b9e0c191c134306476159c4fe5c3eca3c89 /src/insert.c | |
parent | f8febc1b052ae908f1f95789bc1a630e9fd5666d (diff) | |
download | sqlite-e91076981782e96e4c9acb79cff227f19a6425ae.tar.gz sqlite-e91076981782e96e4c9acb79cff227f19a6425ae.zip |
Use the sqlite3IndexColumnAffinity() routine to quickly and correctly find the
affinity of an index column.
FossilOrigin-Name: 1ee089a72d789002a0a377347fc51e08ab32fb14
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/insert.c b/src/insert.c index 839599438..e94af0985 100644 --- a/src/insert.c +++ b/src/insert.c @@ -69,7 +69,7 @@ void sqlite3OpenTable( ** is managed along with the rest of the Index structure. It will be ** released when sqlite3DeleteIndex() is called. */ -const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){ +const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){ if( !pIdx->zColAff ){ /* The first time a column affinity string for a particular index is ** required, it is allocated and populated here. It is then stored as @@ -81,7 +81,6 @@ const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){ */ int n; Table *pTab = pIdx->pTable; - sqlite3 *db = sqlite3VdbeDb(v); pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1); if( !pIdx->zColAff ){ db->mallocFailed = 1; @@ -98,6 +97,16 @@ const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){ } /* +** Return the affinity for a single column of an index. +*/ +char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){ + if( !pIdx->zColAff ){ + if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB; + } + return pIdx->zColAff[iCol]; +} + +/* ** Compute the affinity string for table pTab, if it has not already been ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities. ** |