SHOW:
|
|
- or go back to the newest paste.
| 1 | case OP_CustomResultRow: | |
| 2 | {
| |
| 3 | ||
| 4 | . | |
| 5 | . | |
| 6 | . | |
| 7 | copied from op_resultrow | |
| 8 | . | |
| 9 | . | |
| 10 | . | |
| 11 | . | |
| 12 | ||
| 13 | custom_pResultSet = (Mem*) malloc(sizeof (Mem) * (custom_numElements)); | |
| 14 | ||
| 15 | for(i = 0;i < custom_numElements;i++) | |
| 16 | {
| |
| 17 | sqlite3VdbeMemInit(&custom_pResultSet[i], p->db, MEM_Null); | |
| 18 | } | |
| 19 | ||
| 20 | custom_pResultSet[0].z = zColumnSelector; | |
| 21 | custom_pResultSet[0].flags = MEM_Str; | |
| 22 | custom_pResultSet[0].n = strlen(zColumnSelector); | |
| 23 | custom_pResultSet[0].zMalloc = zColumnSelector; | |
| 24 | custom_pResultSet[0].enc = SQLITE_UTF8; | |
| 25 | ||
| 26 | k = 1; | |
| 27 | ||
| 28 | for (i = 0, j = 0; i < p->custom_iNumTables; i++) | |
| 29 | {
| |
| 30 | if (p->custom_pAllRows[i] == 1) | |
| 31 | {
| |
| 32 | l = 0; | |
| 33 | while (l < p->custom_piColumnCount[i]) | |
| 34 | {
| |
| 35 | custom_pResultSet[k++] = aMem[pOp->p1 + j]; // copy every column into the result set | |
| 36 | l++; | |
| 37 | j++; | |
| 38 | } | |
| 39 | } | |
| 40 | else | |
| 41 | {
| |
| 42 | j += p->custom_piPriKey[i]; | |
| 43 | custom_pResultSet[k++] = aMem[pOp->p1 + j]; // copy only primary key into the result set | |
| 44 | j += p->custom_piColumnCount[i]; | |
| 45 | j -= p->custom_piPriKey[i]; | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| 49 | ||
| 50 | pMem = p->pResultSet = custom_pResultSet; | |
| 51 | ||
| 52 | for (i = 0; i < custom_numElements ; i++) | |
| 53 | {
| |
| 54 | char zBuf[200]; | |
| 55 | assert(memIsValid(&pMem[i])); | |
| 56 | Deephemeralize(&pMem[i]); | |
| 57 | assert((pMem[i].flags & MEM_Ephem) == 0 | |
| 58 | || (pMem[i].flags & (MEM_Str | MEM_Blob)) == 0); | |
| 59 | ||
| 60 | sqlite3VdbeMemNulTerminate(&pMem[i]); | |
| 61 | REGISTER_TRACE(pOp->p1 + i, &pMem[i]); | |
| 62 | } | |
| 63 | ||
| 64 | if (db->mallocFailed) goto no_mem; | |
| 65 | ||
| 66 | p->pc = pc + 1; | |
| 67 | rc = SQLITE_ROW; | |
| 68 | goto vdbe_return; | |
| 69 | } |