+ yaz_log(YLOG_WARN|YLOG_ERRNO, "open %s", full_rep);
+ zh->m_record_type = original_record_type;
+ return ZEBRA_FAIL;
+ }
+ streamp = &stream;
+ zebra_create_stream_fd(streamp, fd, 0);
+ }
+ r = zebra_extract_records_stream(zh, streamp,
+ action,
+ zh->m_record_type,
+ sysno,
+ 0, /*match_criteria */
+ fname,
+ recType, recTypeClientData);
+ if (streamp)
+ stream.destroy(streamp);
+ zh->m_record_type = original_record_type;
+ return r;
+}
+
+/*
+ If sysno is provided, then it's used to identify the reocord.
+ If not, and match_criteria is provided, then sysno is guessed
+ If not, and a record is provided, then sysno is got from there
+
+ */
+
+ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh,
+ const char *buf, size_t buf_size,
+ enum zebra_recctrl_action_t action,
+ const char *recordType,
+ zint *sysno,
+ const char *match_criteria,
+ const char *fname)
+{
+ struct ZebraRecStream stream;
+ ZEBRA_RES res;
+ void *clientData;
+ RecType recType = 0;
+
+ if (recordType && *recordType)
+ {
+ yaz_log(log_level_extract,
+ "Record type explicitly specified: %s", recordType);
+ recType = recType_byName(zh->reg->recTypes, zh->res, recordType,
+ &clientData);
+ }
+ else
+ {
+ if (!(zh->m_record_type))
+ {
+ yaz_log(YLOG_WARN, "No such record type defined");
+ return ZEBRA_FAIL;
+ }
+ yaz_log(log_level_extract, "Get record type from rgroup: %s",
+ zh->m_record_type);
+ recType = recType_byName(zh->reg->recTypes, zh->res,
+ zh->m_record_type, &clientData);
+ recordType = zh->m_record_type;
+ }
+
+ if (!recType)
+ {
+ yaz_log(YLOG_WARN, "No such record type: %s", recordType);
+ return ZEBRA_FAIL;
+ }
+
+ zebra_create_stream_mem(&stream, buf, buf_size);
+
+ res = zebra_extract_records_stream(zh, &stream,
+ action,
+ recordType,
+ sysno,
+ match_criteria,
+ fname,
+ recType, clientData);
+ stream.destroy(&stream);
+ return res;
+}
+
+static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh,
+ struct ZebraRecStream *stream,
+ enum zebra_recctrl_action_t action,
+ const char *recordType,
+ zint *sysno,
+ const char *match_criteria,
+ const char *fname,
+ RecType recType,
+ void *recTypeClientData,
+ int *more)
+
+{
+ zint sysno0 = 0;
+ RecordAttr *recordAttr;
+ struct recExtractCtrl extractCtrl;
+ int r;
+ const char *matchStr = 0;
+ Record rec;
+ off_t start_offset = 0, end_offset = 0;
+ const char *pr_fname = fname; /* filename to print .. */
+ int show_progress = zh->records_processed + zh->records_skipped
+ < zh->m_file_verbose_limit ? 1:0;
+
+ zebra_init_log_level();
+
+ if (!pr_fname)
+ pr_fname = "<no file>"; /* make it printable if file is omitted */
+
+ zebra_rec_keys_reset(zh->reg->keys);
+ zebra_rec_keys_reset(zh->reg->sortKeys);
+
+ if (zebraExplain_curDatabase(zh->reg->zei, zh->basenames[0]))
+ {
+ if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0],
+ zh->m_explain_database))
+ return ZEBRA_FAIL;
+ }
+
+ if (stream)
+ {
+ off_t null_offset = 0;
+ extractCtrl.stream = stream;
+
+ start_offset = stream->tellf(stream);
+
+ extractCtrl.first_record = start_offset ? 0 : 1;
+
+ stream->endf(stream, &null_offset);;
+
+ extractCtrl.init = extract_init;
+ extractCtrl.tokenAdd = extract_token_add;
+ extractCtrl.schemaAdd = extract_schema_add;
+ extractCtrl.dh = zh->reg->dh;
+ extractCtrl.handle = zh;
+ extractCtrl.match_criteria[0] = '\0';
+ extractCtrl.staticrank = 0;
+ extractCtrl.action = action;
+
+ init_extractCtrl(zh, &extractCtrl);
+
+ extract_set_store_data_prepare(&extractCtrl);
+
+ r = (*recType->extract)(recTypeClientData, &extractCtrl);
+
+ if (action == action_update)
+ {
+ action = extractCtrl.action;
+ }
+
+ switch (r)
+ {
+ case RECCTRL_EXTRACT_EOF:
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_ERROR_GENERIC:
+ /* error occured during extraction ... */
+ yaz_log(YLOG_WARN, "extract error: generic");
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER:
+ /* error occured during extraction ... */
+ yaz_log(YLOG_WARN, "extract error: no such filter");
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_SKIP:
+ if (show_progress)
+ yaz_log(YLOG_LOG, "skip %s %s " ZINT_FORMAT,
+ recordType, pr_fname, (zint) start_offset);
+ *more = 1;
+
+ end_offset = stream->endf(stream, 0);
+ if (end_offset)
+ stream->seekf(stream, end_offset);
+
+ return ZEBRA_OK;
+ case RECCTRL_EXTRACT_OK:
+ break;
+ default:
+ yaz_log(YLOG_WARN, "extract error: unknown error: %d", r);
+ return ZEBRA_FAIL;
+ }
+ end_offset = stream->endf(stream, 0);
+ if (end_offset)
+ stream->seekf(stream, end_offset);
+ else
+ end_offset = stream->tellf(stream);
+
+ if (extractCtrl.match_criteria[0])
+ match_criteria = extractCtrl.match_criteria;
+ }
+
+ *more = 1;
+
+ if (zh->m_flag_rw == 0)
+ {
+ yaz_log(YLOG_LOG, "test %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ /* test mode .. Do not perform match */
+ return ZEBRA_OK;
+ }
+
+ if (!sysno)
+ {
+ sysno = &sysno0;
+
+ if (match_criteria && *match_criteria)
+ matchStr = match_criteria;
+ else
+ {
+ if (zh->m_record_id && *zh->m_record_id)
+ {
+ matchStr = get_match_from_spec(zh, zh->reg->keys, pr_fname,
+ zh->m_record_id);
+ if (!matchStr)
+ {
+ yaz_log(YLOG_LOG, "error %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ return ZEBRA_FAIL;
+ }
+ if (0 && matchStr)
+ {
+ WRBUF w = wrbuf_alloc();
+ size_t i;
+ for (i = 0; i < strlen(matchStr); i++)
+ {
+ wrbuf_printf(w, "%02X", matchStr[i] & 0xff);
+ }
+ yaz_log(YLOG_LOG, "Got match %s", wrbuf_cstr(w));
+ wrbuf_destroy(w);
+ }
+ }
+ }
+ if (matchStr)
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord,
+ matchStr);
+
+
+ if (log_level_extract)
+ {
+ WRBUF w = wrbuf_hex_str(matchStr);
+ yaz_log(log_level_extract, "matchStr: %s", wrbuf_cstr(w));
+ wrbuf_destroy(w);
+ }
+ if (rinfo)
+ {
+ assert(*rinfo == sizeof(*sysno));
+ memcpy(sysno, rinfo+1, sizeof(*sysno));
+ }
+ }
+ }
+
+ if (! *sysno)
+ {
+ /* new record AKA does not exist already */
+ if (action == action_delete)
+ {
+ yaz_log(YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ yaz_log(YLOG_WARN, "cannot delete record above (seems new)");
+ return ZEBRA_FAIL;
+ }
+ else if (action == action_a_delete)
+ {
+ if (show_progress)
+ yaz_log(YLOG_LOG, "adelete %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ return ZEBRA_OK;
+ }
+ else if (action == action_replace)
+ {
+ yaz_log(YLOG_LOG, "update %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ yaz_log(YLOG_WARN, "cannot update record above (seems new)");
+ return ZEBRA_FAIL;
+ }
+ if (show_progress)
+ yaz_log(YLOG_LOG, "add %s %s " ZINT_FORMAT, recordType, pr_fname,
+ (zint) start_offset);
+ rec = rec_new(zh->reg->records);
+
+ *sysno = rec->sysno;
+
+
+ if (stream)
+ {
+ all_matches_add(&extractCtrl,
+ zebra_rec_keys_get_custom_record_id(zh->reg->keys),
+ *sysno);
+ }
+
+
+ recordAttr = rec_init_attr(zh->reg->zei, rec);
+ if (extractCtrl.staticrank < 0)
+ {
+ yaz_log(YLOG_WARN, "Negative staticrank for record. Set to 0");
+ extractCtrl.staticrank = 0;
+ }
+
+ if (matchStr)
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_insert_ord(zh->reg->matchDict, db_ord, matchStr,
+ sizeof(*sysno), sysno);
+ }
+
+ extract_flush_sort_keys(zh, *sysno, 1, zh->reg->sortKeys);
+#if FLUSH2
+ extract_flush_record_keys2(zh, *sysno,
+ zh->reg->keys, extractCtrl.staticrank,
+ 0, recordAttr->staticrank);
+#else
+ extract_flush_record_keys(zh, *sysno, 1, zh->reg->keys,
+ extractCtrl.staticrank);
+#endif
+ recordAttr->staticrank = extractCtrl.staticrank;
+ zh->records_inserted++;
+ }
+ else
+ {
+ /* record already exists */
+ zebra_rec_keys_t delkeys = zebra_rec_keys_open();
+ zebra_rec_keys_t sortKeys = zebra_rec_keys_open();
+ if (action == action_insert)
+ {
+ yaz_log(YLOG_LOG, "skipped %s %s " ZINT_FORMAT,
+ recordType, pr_fname, (zint) start_offset);
+ logRecord(zh);
+ return ZEBRA_FAIL;
+ }
+
+ rec = rec_get(zh->reg->records, *sysno);
+ assert(rec);
+
+ if (stream)
+ {
+ all_matches_add(&extractCtrl,
+ zebra_rec_keys_get_custom_record_id(zh->reg->keys),
+ *sysno);
+ }
+
+ recordAttr = rec_init_attr(zh->reg->zei, rec);
+
+ /* decrease total size */
+ zebraExplain_recordBytesIncrement(zh->reg->zei,
+ - recordAttr->recordSize);
+
+ zebra_rec_keys_set_buf(delkeys,
+ rec->info[recInfo_delKeys],
+ rec->size[recInfo_delKeys],
+ 0);
+ zebra_rec_keys_set_buf(sortKeys,
+ rec->info[recInfo_sortKeys],
+ rec->size[recInfo_sortKeys],
+ 0);
+
+ extract_flush_sort_keys(zh, *sysno, 0, sortKeys);
+#if !FLUSH2
+ extract_flush_record_keys(zh, *sysno, 0, delkeys,
+ recordAttr->staticrank);
+#endif
+ if (action == action_delete || action == action_a_delete)
+ {
+ /* record going to be deleted */
+#if FLUSH2
+ extract_flush_record_keys2(zh, *sysno, 0, recordAttr->staticrank,
+ delkeys, recordAttr->staticrank);
+#endif
+ if (zebra_rec_keys_empty(delkeys))
+ {
+ yaz_log(YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ yaz_log(YLOG_WARN, "cannot delete file above, "
+ "storeKeys false (3)");
+ }
+ else
+ {
+ if (show_progress)
+ yaz_log(YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ zh->records_deleted++;
+ if (matchStr)
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_ord(zh->reg->matchDict, db_ord, matchStr);
+ }
+ rec_del(zh->reg->records, &rec);
+ }
+ zebra_rec_keys_close(delkeys);
+ zebra_rec_keys_close(sortKeys);
+ rec_free(&rec);
+ logRecord(zh);
+ return ZEBRA_OK;
+ }
+ else
+ { /* update or special_update */
+ if (show_progress)
+ yaz_log(YLOG_LOG, "update %s %s " ZINT_FORMAT, recordType,
+ pr_fname, (zint) start_offset);
+ extract_flush_sort_keys(zh, *sysno, 1, zh->reg->sortKeys);
+
+#if FLUSH2
+ extract_flush_record_keys2(zh, *sysno,
+ zh->reg->keys, extractCtrl.staticrank,
+ delkeys, recordAttr->staticrank);
+#else
+ extract_flush_record_keys(zh, *sysno, 1,
+ zh->reg->keys, extractCtrl.staticrank);
+#endif
+ recordAttr->staticrank = extractCtrl.staticrank;
+ zh->records_updated++;
+ }
+ zebra_rec_keys_close(delkeys);
+ zebra_rec_keys_close(sortKeys);
+ }
+ /* update file type */
+ xfree(rec->info[recInfo_fileType]);
+ rec->info[recInfo_fileType] =
+ rec_strdup(recordType, &rec->size[recInfo_fileType]);
+
+ /* update filename */
+ xfree(rec->info[recInfo_filename]);
+ rec->info[recInfo_filename] =
+ rec_strdup(fname, &rec->size[recInfo_filename]);
+
+ /* update delete keys */
+ xfree(rec->info[recInfo_delKeys]);
+ if (!zebra_rec_keys_empty(zh->reg->keys) && zh->m_store_keys == 1)
+ {
+ zebra_rec_keys_get_buf(zh->reg->keys,
+ &rec->info[recInfo_delKeys],
+ &rec->size[recInfo_delKeys]);
+ }
+ else
+ {
+ rec->info[recInfo_delKeys] = NULL;
+ rec->size[recInfo_delKeys] = 0;
+ }
+ /* update sort keys */
+ xfree(rec->info[recInfo_sortKeys]);
+
+ zebra_rec_keys_get_buf(zh->reg->sortKeys,
+ &rec->info[recInfo_sortKeys],
+ &rec->size[recInfo_sortKeys]);
+
+ if (stream)
+ {
+ recordAttr->recordSize = end_offset - start_offset;
+ zebraExplain_recordBytesIncrement(zh->reg->zei,
+ recordAttr->recordSize);
+ }
+
+ /* set run-number for this record */
+ recordAttr->runNumber =
+ zebraExplain_runNumberIncrement(zh->reg->zei, 0);
+
+ /* update store data */
+ xfree(rec->info[recInfo_storeData]);
+
+ /* update store data */
+ if (zh->store_data_buf)
+ {
+ rec->size[recInfo_storeData] = zh->store_data_size;
+ rec->info[recInfo_storeData] = zh->store_data_buf;
+ zh->store_data_buf = 0;
+ recordAttr->recordSize = zh->store_data_size;
+ }
+ else if (zh->m_store_data)
+ {
+ off_t cur_offset = stream->tellf(stream);
+
+ rec->size[recInfo_storeData] = recordAttr->recordSize;
+ rec->info[recInfo_storeData] = (char *)
+ xmalloc(recordAttr->recordSize);
+ stream->seekf(stream, start_offset);
+ stream->readf(stream, rec->info[recInfo_storeData],
+ recordAttr->recordSize);
+ stream->seekf(stream, cur_offset);
+ }
+ else
+ {
+ rec->info[recInfo_storeData] = NULL;
+ rec->size[recInfo_storeData] = 0;
+ }
+ /* update database name */
+ xfree(rec->info[recInfo_databaseName]);
+ rec->info[recInfo_databaseName] =
+ rec_strdup(zh->basenames[0], &rec->size[recInfo_databaseName]);
+
+ /* update offset */
+ recordAttr->recordOffset = start_offset;
+
+ /* commit this record */
+ rec_put(zh->reg->records, &rec);
+ logRecord(zh);
+ return ZEBRA_OK;
+}
+
+/** \brief extracts records from stream
+ \param zh Zebra Handle
+ \param stream stream that we read from
+ \param action (action_insert, action_replace, action_delete, ..)
+ \param recordType Record filter type "grs.xml", etc.
+ \param sysno pointer to sysno if already known; NULL otherwise
+ \param match_criteria (NULL if not already given)
+ \param fname filename that we read from (for logging purposes only)
+ \param recType record type
+ \param recTypeClientData client data for record type
+ \returns ZEBRA_OK for success; ZEBRA_FAIL for failure
+*/
+ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh,
+ struct ZebraRecStream *stream,
+ enum zebra_recctrl_action_t action,
+ const char *recordType,
+ zint *sysno,
+ const char *match_criteria,
+ const char *fname,
+ RecType recType,
+ void *recTypeClientData)
+{
+ ZEBRA_RES res = ZEBRA_OK;
+ while (1)
+ {
+ int more = 0;
+ res = zebra_extract_record_stream(zh, stream,
+ action,
+ recordType,
+ sysno,
+ match_criteria,
+ fname,
+ recType, recTypeClientData, &more);
+ if (!more)
+ {
+ res = ZEBRA_OK;
+ break;
+ }
+ if (res != ZEBRA_OK)
+ break;
+ if (sysno)
+ break;
+ }
+ return res;
+}
+
+ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n)
+{
+ ZebraHandle zh = (ZebraHandle) handle;
+ struct recExtractCtrl extractCtrl;
+
+ if (zebraExplain_curDatabase(zh->reg->zei,
+ rec->info[recInfo_databaseName]))
+ {
+ abort();
+ if (zebraExplain_newDatabase(zh->reg->zei,
+ rec->info[recInfo_databaseName], 0))
+ abort();
+ }
+
+ zebra_rec_keys_reset(zh->reg->keys);
+ zebra_rec_keys_reset(zh->reg->sortKeys);
+
+ extractCtrl.init = extract_init;
+ extractCtrl.tokenAdd = extract_token_add;
+ extractCtrl.schemaAdd = extract_schema_add;
+ extractCtrl.dh = zh->reg->dh;
+
+ init_extractCtrl(zh, &extractCtrl);
+
+ extractCtrl.flagShowRecords = 0;
+ extractCtrl.match_criteria[0] = '\0';
+ extractCtrl.staticrank = 0;
+ extractCtrl.action = action_update;
+
+ extractCtrl.handle = handle;
+ extractCtrl.first_record = 1;
+
+ extract_set_store_data_prepare(&extractCtrl);
+
+ if (n)
+ grs_extract_tree(&extractCtrl, n);
+
+ if (rec->size[recInfo_delKeys])
+ {
+ zebra_rec_keys_t delkeys = zebra_rec_keys_open();
+
+ zebra_rec_keys_t sortkeys = zebra_rec_keys_open();
+
+ zebra_rec_keys_set_buf(delkeys, rec->info[recInfo_delKeys],
+ rec->size[recInfo_delKeys],
+ 0);
+#if FLUSH2
+ extract_flush_record_keys2(zh, rec->sysno,
+ zh->reg->keys, 0, delkeys, 0);
+#else
+ extract_flush_record_keys(zh, rec->sysno, 0, delkeys, 0);
+ extract_flush_record_keys(zh, rec->sysno, 1, zh->reg->keys, 0);
+#endif
+ zebra_rec_keys_close(delkeys);
+
+ zebra_rec_keys_set_buf(sortkeys, rec->info[recInfo_sortKeys],
+ rec->size[recInfo_sortKeys],
+ 0);
+
+ extract_flush_sort_keys(zh, rec->sysno, 0, sortkeys);
+ zebra_rec_keys_close(sortkeys);
+ }
+ else
+ {
+#if FLUSH2
+ extract_flush_record_keys2(zh, rec->sysno, zh->reg->keys, 0, 0, 0);
+#else
+ extract_flush_record_keys(zh, rec->sysno, 1, zh->reg->keys, 0);
+#endif
+ }
+ extract_flush_sort_keys(zh, rec->sysno, 1, zh->reg->sortKeys);
+
+ xfree(rec->info[recInfo_delKeys]);
+ zebra_rec_keys_get_buf(zh->reg->keys,
+ &rec->info[recInfo_delKeys],
+ &rec->size[recInfo_delKeys]);
+
+ xfree(rec->info[recInfo_sortKeys]);
+ zebra_rec_keys_get_buf(zh->reg->sortKeys,
+ &rec->info[recInfo_sortKeys],
+ &rec->size[recInfo_sortKeys]);
+ return ZEBRA_OK;
+}
+
+void zebra_it_key_str_dump(ZebraHandle zh, struct it_key *key,
+ const char *str, size_t slen, NMEM nmem, int level)
+{
+ char keystr[200]; /* room for zints to print */
+ char *dst_term = 0;
+ int ord = CAST_ZINT_TO_INT(key->mem[0]);
+ const char *index_type;
+ int i;
+ const char *string_index;
+
+ zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
+ 0/* db */, &string_index);
+ assert(index_type);
+ zebra_term_untrans_iconv(zh, nmem, index_type,
+ &dst_term, str);
+ *keystr = '\0';
+ for (i = 0; i < key->len; i++)
+ {
+ sprintf(keystr + strlen(keystr), ZINT_FORMAT " ", key->mem[i]);
+ }
+
+ if (*str < CHR_BASE_CHAR)
+ {
+ int i;
+ char dst_buf[200]; /* room for special chars */
+
+ strcpy(dst_buf , "?");
+
+ if (!strcmp(str, ""))
+ strcpy(dst_buf, "alwaysmatches");
+ if (!strcmp(str, FIRST_IN_FIELD_STR))
+ strcpy(dst_buf, "firstinfield");
+ else if (!strcmp(str, CHR_UNKNOWN))
+ strcpy(dst_buf, "unknown");
+ else if (!strcmp(str, CHR_SPACE))
+ strcpy(dst_buf, "space");
+
+ for (i = 0; i<slen; i++)
+ {
+ sprintf(dst_buf + strlen(dst_buf), " %d", str[i] & 0xff);
+ }
+ yaz_log(level, "%s%s %s %s", keystr, index_type,
+ string_index, dst_buf);
+
+ }
+ else
+ yaz_log(level, "%s%s %s \"%s\"", keystr, index_type,
+ string_index, dst_term);
+}
+
+void extract_rec_keys_log(ZebraHandle zh, int is_insert,
+ zebra_rec_keys_t reckeys,
+ int level)
+{
+ if (zebra_rec_keys_rewind(reckeys))
+ {
+ size_t slen;
+ const char *str;
+ struct it_key key;
+ NMEM nmem = nmem_create();
+
+ while(zebra_rec_keys_read(reckeys, &str, &slen, &key))
+ {
+ zebra_it_key_str_dump(zh, &key, str, slen, nmem, level);
+ nmem_reset(nmem);
+ }
+ nmem_destroy(nmem);
+ }
+}
+
+void extract_rec_keys_adjust(ZebraHandle zh, int is_insert,
+ zebra_rec_keys_t reckeys)
+{
+ ZebraExplainInfo zei = zh->reg->zei;
+ struct ord_stat {
+ int no;
+ int ord;
+ struct ord_stat *next;
+ };
+
+ if (zebra_rec_keys_rewind(reckeys))
+ {
+ struct ord_stat *ord_list = 0;
+ struct ord_stat *p;
+ size_t slen;
+ const char *str;
+ struct it_key key_in;
+ while(zebra_rec_keys_read(reckeys, &str, &slen, &key_in))
+ {
+ int ord = CAST_ZINT_TO_INT(key_in.mem[0]);
+
+ for (p = ord_list; p ; p = p->next)
+ if (p->ord == ord)
+ {
+ p->no++;
+ break;
+ }
+ if (!p)
+ {
+ p = xmalloc(sizeof(*p));
+ p->no = 1;
+ p->ord = ord;
+ p->next = ord_list;
+ ord_list = p;
+ }
+ }
+
+ p = ord_list;
+ while (p)
+ {
+ struct ord_stat *p1 = p;
+
+ if (is_insert)
+ zebraExplain_ord_adjust_occurrences(zei, p->ord, p->no, 1);
+ else
+ zebraExplain_ord_adjust_occurrences(zei, p->ord, - p->no, -1);
+ p = p->next;
+ xfree(p1);