MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / idxAppendColDefn

Function idxAppendColDefn

modules/dasSQLITE/sqlite/shell.c:11043–11071  ·  view source on GitHub ↗

** This function appends an index column definition suitable for constraint ** pCons to the string passed as zIn and returns the result. */

Source from the content-addressed store, hash-verified

11041** pCons to the string passed as zIn and returns the result.
11042*/
11043static char *idxAppendColDefn(
11044 int *pRc, /* IN/OUT: Error code */
11045 char *zIn, /* Column defn accumulated so far */
11046 IdxTable *pTab, /* Table index will be created on */
11047 IdxConstraint *pCons
11048){
11049 char *zRet = zIn;
11050 IdxColumn *p = &pTab->aCol[pCons->iCol];
11051 if( zRet ) zRet = idxAppendText(pRc, zRet, ", ");
11052
11053 if( idxIdentifierRequiresQuotes(p->zName) ){
11054 zRet = idxAppendText(pRc, zRet, "%Q", p->zName);
11055 }else{
11056 zRet = idxAppendText(pRc, zRet, "%s", p->zName);
11057 }
11058
11059 if( sqlite3_stricmp(p->zColl, pCons->zColl) ){
11060 if( idxIdentifierRequiresQuotes(pCons->zColl) ){
11061 zRet = idxAppendText(pRc, zRet, " COLLATE %Q", pCons->zColl);
11062 }else{
11063 zRet = idxAppendText(pRc, zRet, " COLLATE %s", pCons->zColl);
11064 }
11065 }
11066
11067 if( pCons->bDesc ){
11068 zRet = idxAppendText(pRc, zRet, " DESC");
11069 }
11070 return zRet;
11071}
11072
11073/*
11074** Search database dbm for an index compatible with the one idxCreateFromCons()

Callers 1

idxCreateFromConsFunction · 0.85

Calls 2

idxAppendTextFunction · 0.85

Tested by

no test coverage detected