Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected out of memory error for valid query #32

Open
vitaliyb1 opened this issue Sep 21, 2016 · 0 comments
Open

Unexpected out of memory error for valid query #32

vitaliyb1 opened this issue Sep 21, 2016 · 0 comments

Comments

@vitaliyb1
Copy link

vitaliyb1 commented Sep 21, 2016

Priority:Critical

Hi Marios,

For perfectly valid query

select c3.* from parent c1, child c2, grandchild c3 where c1.rownum=5 and c2.base=c1.child_id and c3.base=c2.child_id

I receive an error:

Error in preparation of query: error no 7
Extended error code 7. Extended error message: out of memory
Extended error message: out of memory

I hacked best_index (see vitaliyb tag below) to stop getting that error for this and some other queries:

int best_index_vtable(sqlite3_vtab pVtab,
sqlite3_index_info *pInfo) {
picoQLTable *st=(picoQLTable *)pVtab;
int re;
st->toOpen = 1;
re = toOpen(pVtab);
if (re)
return re;
/
No constraint no setting up. _/
if (pInfo->nConstraint > 0) {
int nCol;
int nidxLen = pInfo->nConstraint_7 + 1;
int i, j = 0, counter = 0, score = 0;
char nidxStr = (char)malloc( nidxLen );
memset(nidxStr, 0, sizeof(nidxStr));
assert(pInfo->idxStr == 0);
for (i = 0; i < pInfo->nConstraint; i++){
struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
if (pCons->usable == 0)
continue;
nCol = pCons->iColumn;
if (equals(st->azColumn[nCol], "base"))
score += 2;
else if (equals(st->azColumn[nCol], "rownum"))
score += 1;
}
order_constraints(score, &j, &counter, nidxStr);
for (i = 0; i < pInfo->nConstraint; i++) {
struct sqlite3_index_constraint *pCons =
&pInfo->aConstraint[i];
if (pCons->usable == 0)
continue;
nCol = pCons->iColumn;
if (equals(st->azColumn[nCol], "base")) {
pInfo->aConstraintUsage[i].argvIndex = 1;
} else if (equals(st->azColumn[nCol], "rownum")) {
if (score > 2)
pInfo->aConstraintUsage[i].argvIndex = 2;
else
pInfo->aConstraintUsage[i].argvIndex = 1;
} else {
pInfo->aConstraintUsage[i].argvIndex = counter++;
}
eval_constraint(pCons->op, st->azColumn[nCol], nCol,
score, nidxStr, nidxLen);
pInfo->aConstraintUsage[i].omit = 1;
}
pInfo->needToFreeIdxStr = 1;
if ((((int)strlen(nidxStr)) > 0) &&
0 == (pInfo->idxStr =
sqlite3_mprintf("%s", nidxStr)))

  free( nidxStr );

  // vitaliyb, 09/14/16 ///
  // return SQLITE_NOMEM; 
  return SQLITE_OK;
  /////////////////////////

}
return SQLITE_OK;
}

Best regards,
Vitaly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant