+static int explain_extract (void *handle, Record rec, data1_node *n)
+{
+ struct recordGroup *rGroup = (struct recordGroup*) handle;
+ struct recExtractCtrl extractCtrl;
+ int i;
+
+ if (zebraExplain_curDatabase (zti, rec->info[recInfo_databaseName]))
+ {
+ if (zebraExplain_newDatabase (zti, rec->info[recInfo_databaseName], 0))
+ abort ();
+ }
+
+ reckeys.buf_used = 0;
+ reckeys.prevAttrUse = -1;
+ reckeys.prevAttrSet = -1;
+ reckeys.prevSeqNo = 0;
+
+ extractCtrl.init = wordInit;
+ extractCtrl.addWord = addRecordKey;
+ extractCtrl.addSchema = addSchema;
+ extractCtrl.dh = rGroup->dh;
+ for (i = 0; i<256; i++)
+ extractCtrl.seqno[i] = 0;
+ extractCtrl.zebra_maps = rGroup->zebra_maps;
+ extractCtrl.flagShowRecords = !rGroup->flagRw;
+
+ grs_extract_tree(&extractCtrl, n);
+
+ logf (LOG_DEBUG, "flush explain record, sysno=%d", rec->sysno);
+
+ if (rec->size[recInfo_delKeys])
+ {
+ struct recKeys delkeys;
+
+ delkeys.buf_used = rec->size[recInfo_delKeys];
+ delkeys.buf = rec->info[recInfo_delKeys];
+ flushSortKeys (rec->sysno, 0);
+ flushRecordKeys (rec->sysno, 0, &delkeys);
+ }
+ flushRecordKeys (rec->sysno, 1, &reckeys);
+ flushSortKeys (rec->sysno, 1);
+
+ xfree (rec->info[recInfo_delKeys]);
+ rec->size[recInfo_delKeys] = reckeys.buf_used;
+ rec->info[recInfo_delKeys] = reckeys.buf;
+ reckeys.buf = NULL;
+ reckeys.buf_max = 0;
+
+ return 0;
+}