| 11572 | } |
| 11573 | |
| 11574 | void stat4dump(int more, char *table, int istrace) |
| 11575 | { |
| 11576 | #ifndef PER_THREAD_MALLOC |
| 11577 | void *thread_oldm; |
| 11578 | #endif |
| 11579 | void *sql_oldm; |
| 11580 | int rc; |
| 11581 | sqlite3 *db = NULL; |
| 11582 | |
| 11583 | thread_memcreate_with_save(128 * 1024, &thread_oldm); |
| 11584 | sql_mem_init_with_save(NULL, &sql_oldm); |
| 11585 | |
| 11586 | struct sql_thread *old_thd = pthread_getspecific(query_info_key); |
| 11587 | struct sql_thread *thd = start_sql_thread(); |
| 11588 | Pthread_setspecific(query_info_key, thd); |
| 11589 | |
| 11590 | struct sqlclntstate clnt; |
| 11591 | start_internal_sql_clnt(&clnt); |
| 11592 | clnt.sql = "select * from sqlite_stat4"; //* from sqlite_master limit 1;"; |
| 11593 | thd->clnt = &clnt; |
| 11594 | |
| 11595 | get_copy_rootpages(thd); |
| 11596 | sql_get_query_id(thd); |
| 11597 | if ((rc = get_curtran(thedb->bdb_env, &clnt)) != 0) { |
| 11598 | goto out; |
| 11599 | } |
| 11600 | if ((rc = sqlite3_open_serial("db", &db, 0)) != SQLITE_OK) { |
| 11601 | goto put; |
| 11602 | } |
| 11603 | clnt.in_sqlite_init = 1; |
| 11604 | if ((rc = sqlite3_exec(db, clnt.sql, NULL, NULL, NULL)) != SQLITE_OK) { |
| 11605 | goto close; |
| 11606 | } |
| 11607 | int (*outFunc)(const char *fmt, ...) = printf_logmsg_wrap; |
| 11608 | if (istrace) { |
| 11609 | ctrace("\n"); |
| 11610 | outFunc = ctracewrap; |
| 11611 | } |
| 11612 | |
| 11613 | for (HashElem *i = sqliteHashFirst(&db->aDb[0].pSchema->idxHash); i; |
| 11614 | i = sqliteHashNext(i)) { |
| 11615 | Index *idx = sqliteHashData(i); |
| 11616 | if (table != NULL && strcmp(idx->pTable->zName, table)) |
| 11617 | continue; |
| 11618 | if (idx->aSample == NULL) |
| 11619 | continue; |
| 11620 | outFunc("idx:%s.%s samples:%d cols:%d aAvgEq: ", idx->pTable->zName, |
| 11621 | idx->zName, idx->nSample, idx->nSampleCol); |
| 11622 | for (int j = 0; j < idx->nSampleCol; ++j) { |
| 11623 | outFunc("%d ", idx->aAvgEq[j]); |
| 11624 | } |
| 11625 | outFunc("\n"); |
| 11626 | if (istrace) |
| 11627 | ctrace("\n"); |
| 11628 | for (int k = 0; k < idx->nSample; ++k) { |
| 11629 | outFunc("sample:%d anEq:", k); |
| 11630 | for (int j = 0; j < idx->nSampleCol; ++j) { |
| 11631 | outFunc("%d ", idx->aSample[k].anEq[j]); |
no test coverage detected