From: Adam Dickmeiss Date: Tue, 9 Dec 2008 15:20:14 +0000 (+0100) Subject: Calling rec_get/rec_del for each record to be deleted in database. X-Git-Tag: v2.0.36~18^2~3 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=b5f030af4f75ee89f6199999132b371a87a29c98;p=idzebra-moved-to-github.git Calling rec_get/rec_del for each record to be deleted in database. --- diff --git a/index/invstat.c b/index/invstat.c index 514378d..192c588 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -291,6 +291,7 @@ int zebra_register_statistics (ZebraHandle zh, int dumpdict) } fprintf (stdout, "%7d- %7d\n", prev, stat_info.isam_occurrences[i]); + rec_prstat(zh->reg->records); xmalloc_trav("unfreed"); /*! while hunting memory leaks */ zebra_end_read (zh); return 0; diff --git a/index/zebraapi.c b/index/zebraapi.c index adc9b6a..28886ff 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1427,7 +1427,6 @@ int delete_w_handle(const char *info, void *handle) { ZebraHandle zh = (ZebraHandle) handle; ISAM_P pos; - ASSERTZH; if (*info == sizeof(pos)) { @@ -1437,6 +1436,33 @@ int delete_w_handle(const char *info, void *handle) return 0; } +int delete_w_all_handle(const char *info, void *handle) +{ + ZebraHandle zh = (ZebraHandle) handle; + ISAM_P pos; + + if (*info == sizeof(pos)) + { + ISAMB_PP pt; + memcpy(&pos, info+1, sizeof(pos)); + pt = isamb_pp_open(zh->reg->isamb, pos, 2); + if (pt) + { + struct it_key key; + key.mem[0] = 0; + while (isamb_pp_read(pt, &key)) + { + Record rec; + yaz_log(YLOG_LOG, "SYSNO=" ZINT_FORMAT, key.mem[0]); + rec = rec_get(zh->reg->records, key.mem[0]); + rec_del(zh->reg->records, &rec); + } + isamb_pp_close(pt); + } + } + return delete_w_handle(info, handle); +} + static int delete_SU_handle(void *handle, int ord, const char *index_type, const char *string_index, zinfo_index_category_t cat) @@ -1445,23 +1471,18 @@ static int delete_SU_handle(void *handle, int ord, char ord_buf[20]; int ord_len; #if 0 - const char *index_type = 0; - const char *db = 0; - const char *string_index = 0; - zebraExplain_lookup_ord(zh->reg->zei, ord, - &index_type, &db, &string_index); - yaz_log(YLOG_LOG, - "delete_SU_handle:: ord=%d index_type=%s db=%s string_index=%s", - ord, index_type, db, string_index); -#endif yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s cat=%d", ord, index_type, string_index, (int) cat); +#endif ord_len = key_SU_encode(ord, ord_buf); ord_buf[ord_len] = '\0'; assert(zh->reg->isamb); + assert(zh->reg->records); dict_delete_subtree(zh->reg->dict, ord_buf, - zh, delete_w_handle); + zh, + !strcmp(string_index, "_ALLRECORDS") ? + delete_w_all_handle : delete_w_handle); return 0; }