From c6959870998f868e6a0e9201739fb54aef696bc6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 9 Dec 2005 10:45:04 +0000 Subject: [PATCH] For buffer_extract_sysno, match criteria is only used if SYSNO pointer is NULL. If sysno is non-NULL, that sysno is used. This should make record update with opaque record ID work in a consistent manner. --- index/extract.c | 13 +++++++------ index/zebraapi.c | 11 +++++------ index/zserver.c | 14 ++++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/index/extract.c b/index/extract.c index 45fde5d..f92ca7f 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.199 2005-11-10 11:25:47 adam Exp $ +/* $Id: extract.c,v 1.200 2005-12-09 10:45:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -845,6 +845,7 @@ ZEBRA_RES buffer_extract_record(ZebraHandle zh, int force_update, int allow_update) { + SYSNO sysno0 = 0; RecordAttr *recordAttr; struct recExtractCtrl extractCtrl; int r; @@ -942,14 +943,14 @@ ZEBRA_RES buffer_extract_record(ZebraHandle zh, yaz_log (YLOG_WARN, "extract error: no such filter"); return ZEBRA_FAIL; } - /* match criteria */ - matchStr = NULL; if (extractCtrl.match_criteria[0]) match_criteria = extractCtrl.match_criteria; - if (! *sysno) { - char *rinfo; + if (!sysno) { + + sysno = &sysno0; + if (match_criteria && *match_criteria) { matchStr = match_criteria; } else { @@ -964,7 +965,7 @@ ZEBRA_RES buffer_extract_record(ZebraHandle zh, } } if (matchStr) { - rinfo = dict_lookup (zh->reg->matchDict, matchStr); + char *rinfo = dict_lookup (zh->reg->matchDict, matchStr); if (rinfo) { assert(*rinfo == sizeof(*sysno)); diff --git a/index/zebraapi.c b/index/zebraapi.c index 8cdaa51..38b8989 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.195 2005-12-07 17:00:46 adam Exp $ +/* $Id: zebraapi.c,v 1.196 2005-12-09 10:45:04 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1367,7 +1367,7 @@ ZEBRA_RES zebra_admin_exchange_record (ZebraHandle zh, &sysno, 0, /* match */ 0, /* fname */ - 0, /* force update */ + 0, /* force update */ 1 /* allow update */ ); if (res == ZEBRA_FAIL) @@ -2157,8 +2157,7 @@ NOTE: Now returns 0 at success and updates sysno, which is an int* int zebra_add_record(ZebraHandle zh, const char *buf, int buf_size) { - SYSNO sysno = 0; - return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0); + return zebra_update_record(zh, 0, 0 /* sysno */, 0, 0, buf, buf_size, 0); } ZEBRA_RES zebra_insert_record (ZebraHandle zh, @@ -2199,10 +2198,10 @@ ZEBRA_RES zebra_update_record (ZebraHandle zh, { ZEBRA_RES res; ASSERTZH; - assert(sysno); assert(buf); - yaz_log(log_level, "zebra_update_record sysno=" ZINT_FORMAT, *sysno); + yaz_log(log_level, "zebra_update_record sysno=" ZINT_FORMAT, + sysno ? *sysno : "none"); if (buf_size < 1) buf_size = strlen(buf); diff --git a/index/zserver.c b/index/zserver.c index cd8e8b7..aeddd41 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.142 2005-12-07 17:00:46 adam Exp $ +/* $Id: zserver.c,v 1.143 2005-12-09 10:45:05 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -572,7 +572,8 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) Z_External *rec = notToKeep->elements[i]->record; struct oident *oident = 0; Odr_oct *opaque_recid = 0; - SYSNO sysno = 0; + SYSNO *sysno = 0; + SYSNO sysno_tmp; if (notToKeep->elements[i]->u.opaque) { @@ -582,7 +583,8 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) opaque_recid = notToKeep->elements[i]->u.opaque; break; /* OK, recid already set */ case Z_IUSuppliedRecords_elem_number: - sysno = *notToKeep->elements[i]->u.number; + sysno_tmp = *notToKeep->elements[i]->u.number; + sysno = &sysno_tmp; break; } } @@ -669,7 +671,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) r = zebra_insert_record( zh, 0, /* recordType */ - &sysno, + sysno, 0, /* match */ 0, /* fname */ (const char *) rec->u.octet_aligned->buf, @@ -687,7 +689,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) r = zebra_update_record( zh, 0, /* recordType */ - &sysno, + sysno, 0, /* match */ 0, /* fname */ (const char *) rec->u.octet_aligned->buf, @@ -704,7 +706,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) r = zebra_delete_record( zh, 0, /* recordType */ - &sysno, + sysno, 0, /* match */ 0, /* fname */ (const char *) rec->u.octet_aligned->buf, -- 1.7.10.4