MCPcopy Create free account
hub / github.com/audacity/audacity / dbdataColumn

Function dbdataColumn

lib-src/sqlite/shell.c:11079–11132  ·  view source on GitHub ↗

** Return a column for the sqlite_dbdata or sqlite_dbptr table. */

Source from the content-addressed store, hash-verified

11077** Return a column for the sqlite_dbdata or sqlite_dbptr table.
11078*/
11079static int dbdataColumn(
11080 sqlite3_vtab_cursor *pCursor,
11081 sqlite3_context *ctx,
11082 int i
11083){
11084 DbdataCursor *pCsr = (DbdataCursor*)pCursor;
11085 DbdataTable *pTab = (DbdataTable*)pCursor->pVtab;
11086 if( pTab->bPtr ){
11087 switch( i ){
11088 case DBPTR_COLUMN_PGNO:
11089 sqlite3_result_int64(ctx, pCsr->iPgno);
11090 break;
11091 case DBPTR_COLUMN_CHILD: {
11092 int iOff = pCsr->iPgno==1 ? 100 : 0;
11093 if( pCsr->iCell<0 ){
11094 iOff += 8;
11095 }else{
11096 iOff += 12 + pCsr->iCell*2;
11097 if( iOff>pCsr->nPage ) return SQLITE_OK;
11098 iOff = get_uint16(&pCsr->aPage[iOff]);
11099 }
11100 if( iOff<=pCsr->nPage ){
11101 sqlite3_result_int64(ctx, get_uint32(&pCsr->aPage[iOff]));
11102 }
11103 break;
11104 }
11105 }
11106 }else{
11107 switch( i ){
11108 case DBDATA_COLUMN_PGNO:
11109 sqlite3_result_int64(ctx, pCsr->iPgno);
11110 break;
11111 case DBDATA_COLUMN_CELL:
11112 sqlite3_result_int(ctx, pCsr->iCell);
11113 break;
11114 case DBDATA_COLUMN_FIELD:
11115 sqlite3_result_int(ctx, pCsr->iField);
11116 break;
11117 case DBDATA_COLUMN_VALUE: {
11118 if( pCsr->iField<0 ){
11119 sqlite3_result_int64(ctx, pCsr->iIntkey);
11120 }else{
11121 sqlite3_int64 iType;
11122 dbdataGetVarint(pCsr->pHdrPtr, &iType);
11123 dbdataValue(
11124 ctx, iType, pCsr->pPtr, &pCsr->pRec[pCsr->nRec] - pCsr->pPtr
11125 );
11126 }
11127 break;
11128 }
11129 }
11130 }
11131 return SQLITE_OK;
11132}
11133
11134/*
11135** Return the rowid for an sqlite_dbdata or sqlite_dptr table.

Callers

nothing calls this directly

Calls 4

get_uint16Function · 0.85
get_uint32Function · 0.85
dbdataGetVarintFunction · 0.85
dbdataValueFunction · 0.85

Tested by

no test coverage detected