1 /* $Id: zinfo.c,v 1.55 2006-02-20 12:41:42 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <sys/types.h>
29 #include <idzebra/version.h>
36 #define ZEB_SU_SET_USE 1
50 struct zebSUInfo info;
51 struct zebSUInfoB *next;
54 typedef struct zebAccessObjectB *zebAccessObject;
55 struct zebAccessObjectB {
62 typedef struct zebAccessInfoB *zebAccessInfo;
63 struct zebAccessInfoB {
64 zebAccessObject attributeSetIds;
65 zebAccessObject schemas;
69 struct zebSUInfoB *SUInfo;
73 data1_node *data1_tree;
74 } *zebAttributeDetails;
76 struct zebDatabaseInfoB {
77 zebAttributeDetails attributeDetails;
80 data1_node *data1_database;
81 zint recordCount; /* records in db */
82 zint recordBytes; /* size of records */
83 SYSNO sysno; /* sysno of database info */
84 int readFlag; /* 1: read is needed when referenced; 0 if not */
85 int dirty; /* 1: database is dirty: write is needed */
86 struct zebDatabaseInfoB *next;
87 zebAccessInfo accessInfo;
90 struct zebraExplainAttset {
93 struct zebraExplainAttset *next;
96 struct zebraCategoryListInfo {
99 data1_node *data1_categoryList;
102 struct zebraExplainInfo {
111 struct zebraExplainAttset *attsets;
113 data1_node *data1_target;
114 struct zebraCategoryListInfo *categoryList;
115 struct zebDatabaseInfoB *databaseInfo;
116 struct zebDatabaseInfoB *curDatabaseInfo;
117 zebAccessInfo accessInfo;
118 char date[15]; /* YYYY MMDD HH MM SS */
119 int (*updateFunc)(void *handle, Record drec, data1_node *n);
123 static void zebraExplain_initCommonInfo(ZebraExplainInfo zei, data1_node *n);
124 static void zebraExplain_initAccessInfo(ZebraExplainInfo zei, data1_node *n);
126 static data1_node *read_sgml_rec(data1_handle dh, NMEM nmem, Record rec)
128 return data1_read_sgml(dh, nmem, rec->info[recInfo_storeData]);
131 static void zebraExplain_writeDatabase(ZebraExplainInfo zei,
132 struct zebDatabaseInfoB *zdi,
134 static void zebraExplain_writeAttributeDetails(ZebraExplainInfo zei,
135 zebAttributeDetails zad,
136 const char *databaseName,
138 static void zebraExplain_writeTarget(ZebraExplainInfo zei, int key_flush);
139 static void zebraExplain_writeAttributeSet(ZebraExplainInfo zei,
142 static void zebraExplain_writeCategoryList(ZebraExplainInfo zei,
143 struct zebraCategoryListInfo *zcl,
147 static Record createRecord(Records records, SYSNO *sysno)
152 rec = rec_get(records, *sysno);
153 xfree(rec->info[recInfo_storeData]);
157 rec = rec_new(records);
160 rec->info[recInfo_fileType] =
161 rec_strdup("grs.sgml", &rec->size[recInfo_fileType]);
162 rec->info[recInfo_databaseName] =
163 rec_strdup("IR-Explain-1",
164 &rec->size[recInfo_databaseName]);
169 void zebraExplain_flush(ZebraExplainInfo zei, void *handle)
173 zei->updateHandle = handle;
176 struct zebDatabaseInfoB *zdi;
179 /* write each database info record */
180 for (zdi = zei->databaseInfo; zdi; zdi = zdi->next)
182 zebraExplain_writeDatabase(zei, zdi, 1);
183 zebraExplain_writeAttributeDetails(zei, zdi->attributeDetails,
184 zdi->databaseName, 1);
186 zebraExplain_writeTarget(zei, 1);
187 zebraExplain_writeCategoryList(zei,
190 assert(zei->accessInfo);
191 for (o = zei->accessInfo->attributeSetIds; o; o = o->next)
193 zebraExplain_writeAttributeSet(zei, o, 1);
194 for (o = zei->accessInfo->schemas; o; o = o->next)
197 /* zebraExplain_writeSchema(zei, o, 1); */
200 for (zdi = zei->databaseInfo; zdi; zdi = zdi->next)
202 zebraExplain_writeDatabase(zei, zdi, 0);
203 zebraExplain_writeAttributeDetails(zei, zdi->attributeDetails,
204 zdi->databaseName, 0);
206 zebraExplain_writeTarget(zei, 0);
210 void zebraExplain_close(ZebraExplainInfo zei)
213 yaz_log(YLOG_LOG, "zebraExplain_close");
217 zebraExplain_flush(zei, zei->updateHandle);
218 nmem_destroy(zei->nmem);
221 void zebraExplain_mergeOids (ZebraExplainInfo zei, data1_node *n,
226 for (np = n->child; np; np = np->next)
233 if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "oid"))
235 len = np->child->u.data.len;
238 memcpy(str, np->child->u.data.data, len);
241 oid = odr_getoidbystr_nmem(zei->nmem, str);
243 for (ao = *op; ao; ao = ao->next)
244 if (!oid_oidcmp(oid, ao->oid))
251 ao = (zebAccessObject) nmem_malloc(zei->nmem, sizeof(*ao));
261 void zebraExplain_mergeAccessInfo(ZebraExplainInfo zei, data1_node *n,
262 zebAccessInfo *accessInfo)
268 *accessInfo = (zebAccessInfo)
269 nmem_malloc(zei->nmem, sizeof(**accessInfo));
270 (*accessInfo)->attributeSetIds = NULL;
271 (*accessInfo)->schemas = NULL;
275 if (!(n = data1_search_tag(zei->dh, n->child, "accessInfo")))
277 if ((np = data1_search_tag(zei->dh, n->child, "attributeSetIds")))
278 zebraExplain_mergeOids(zei, np,
279 &(*accessInfo)->attributeSetIds);
280 if ((np = data1_search_tag(zei->dh, n->child, "schemas")))
281 zebraExplain_mergeOids(zei, np,
282 &(*accessInfo)->schemas);
291 databaseList (list of databases)
296 targetInfo: TargetInfo
303 dateAdded: 20030630190601
304 dateChanged: 20030630190601
310 oid: 1.2.840.10003.3.2
311 oid: 1.2.840.10003.3.5
312 oid: 1.2.840.10003.3.1
314 oid: 1.2.840.10003.13.1000.81.2
315 oid: 1.2.840.10003.13.2
322 attributeDetailsId: 51
326 attributeDetailsId: 53
329 nextResultSetPosition = 2
332 ZebraExplainInfo zebraExplain_open(
333 Records records, data1_handle dh,
337 int (*updateFunc)(void *handle, Record drec, data1_node *n))
340 ZebraExplainInfo zei;
341 struct zebDatabaseInfoB **zdip;
344 NMEM nmem = nmem_create();
347 yaz_log(YLOG_LOG, "zebraExplain_open wr=%d", writeFlag);
349 zei = (ZebraExplainInfo) nmem_malloc(nmem, sizeof(*zei));
350 zei->databaseInfo = 0;
351 zei->write_flag = writeFlag;
352 zei->updateHandle = updateHandle;
353 zei->updateFunc = updateFunc;
355 zei->ordinalDatabase = 1;
356 zei->curDatabaseInfo = NULL;
357 zei->records = records;
362 zei->categoryList = (struct zebraCategoryListInfo *)
363 nmem_malloc(zei->nmem, sizeof(*zei->categoryList));
364 zei->categoryList->sysno = 0;
365 zei->categoryList->dirty = 0;
366 zei->categoryList->data1_categoryList = NULL;
368 if ( atoi(res_get_def(res, "notimestamps", "0") )== 0)
371 tm = localtime(&our_time);
372 sprintf(zei->date, "%04d%02d%02d%02d%02d%02d",
373 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
374 tm->tm_hour, tm->tm_min, tm->tm_sec);
376 sprintf(zei->date, "%04d%02d%02d%02d%02d%02d",
379 zdip = &zei->databaseInfo;
380 trec = rec_get_root(records); /* get "root" record */
385 zebraExplain_mergeAccessInfo(zei, 0, &zei->accessInfo);
386 if (trec) /* targetInfo already exists ... */
388 data1_node *node_tgtinfo, *node_zebra, *node_list, *np;
390 zei->data1_target = read_sgml_rec(zei->dh, zei->nmem, trec);
392 if (!zei->data1_target || !zei->data1_target->u.root.absyn)
394 if (!zei->data1_target)
397 yaz_log(YLOG_FATAL, "Explain schema missing. Check profilePath");
398 nmem_destroy(zei->nmem);
402 data1_pr_tree(zei->dh, zei->data1_target, stderr);
404 node_tgtinfo = data1_search_tag(zei->dh, zei->data1_target,
406 zebraExplain_mergeAccessInfo(zei, node_tgtinfo,
409 node_zebra = data1_search_tag(zei->dh, node_tgtinfo->child,
414 node_list = data1_search_tag(zei->dh, node_zebra->child,
417 np = node_list->child;
419 for(; np; np = np->next)
421 data1_node *node_name = NULL;
422 data1_node *node_id = NULL;
423 data1_node *node_aid = NULL;
425 if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "database"))
427 for(np2 = np->child; np2; np2 = np2->next)
429 if (np2->which != DATA1N_tag)
431 if (!strcmp(np2->u.tag.tag, "name"))
432 node_name = np2->child;
433 else if (!strcmp(np2->u.tag.tag, "id"))
434 node_id = np2->child;
435 else if (!strcmp(np2->u.tag.tag, "attributeDetailsId"))
436 node_aid = np2->child;
438 assert(node_id && node_name && node_aid);
440 *zdip =(struct zebDatabaseInfoB *)
441 nmem_malloc(zei->nmem, sizeof(**zdip));
442 (*zdip)->readFlag = 1;
444 (*zdip)->data1_database = NULL;
445 (*zdip)->recordCount = 0;
446 (*zdip)->recordBytes = 0;
447 zebraExplain_mergeAccessInfo (zei, 0, &(*zdip)->accessInfo);
449 (*zdip)->databaseName = (char *)
450 nmem_malloc (zei->nmem, 1+node_name->u.data.len);
451 memcpy((*zdip)->databaseName, node_name->u.data.data,
452 node_name->u.data.len);
453 (*zdip)->databaseName[node_name->u.data.len] = '\0';
454 (*zdip)->sysno = atoi_zn (node_id->u.data.data,
455 node_id->u.data.len);
456 (*zdip)->attributeDetails = (zebAttributeDetails)
457 nmem_malloc (zei->nmem, sizeof(*(*zdip)->attributeDetails));
458 (*zdip)->attributeDetails->sysno = atoi_zn (node_aid->u.data.data,
459 node_aid->u.data.len);
460 (*zdip)->attributeDetails->readFlag = 1;
461 (*zdip)->attributeDetails->dirty = 0;
462 (*zdip)->attributeDetails->SUInfo = NULL;
464 zdip = &(*zdip)->next;
468 np = data1_search_tag(zei->dh, node_zebra->child,
471 assert (np && np->which == DATA1N_data);
472 zei->ordinalSU = atoi_n(np->u.data.data, np->u.data.len);
474 np = data1_search_tag(zei->dh, node_zebra->child,
477 assert (np && np->which == DATA1N_data);
478 zei->ordinalDatabase = atoi_n(np->u.data.data, np->u.data.len);
480 np = data1_search_tag(zei->dh, node_zebra->child,
483 assert (np && np->which == DATA1N_data);
484 zei->runNumber = atoi_zn(np->u.data.data, np->u.data.len);
485 yaz_log(YLOG_DEBUG, "read runnumber=" ZINT_FORMAT, zei->runNumber);
490 else /* create initial targetInfo */
492 data1_node *node_tgtinfo;
501 data1_read_sgml(zei->dh, zei->nmem,
502 "<explain><targetInfo>TargetInfo\n"
504 "<namedResultSets>1</>\n"
505 "<multipleDBSearch>1</>\n"
506 "<nicknames><name>Zebra</></>\n"
508 if (!zei->data1_target)
510 yaz_log(YLOG_FATAL, "Explain schema missing. Check profilePath");
511 nmem_destroy(zei->nmem);
514 node_tgtinfo = data1_search_tag(zei->dh, zei->data1_target,
516 assert(node_tgtinfo);
518 zebraExplain_initCommonInfo(zei, node_tgtinfo);
519 zebraExplain_initAccessInfo(zei, node_tgtinfo);
521 /* write now because we want to be sure about the sysno */
522 trec = rec_new(records);
523 trec->info[recInfo_fileType] =
524 rec_strdup("grs.sgml", &trec->size[recInfo_fileType]);
525 trec->info[recInfo_databaseName] =
526 rec_strdup("IR-Explain-1", &trec->size[recInfo_databaseName]);
528 sgml_buf = data1_nodetoidsgml(dh, zei->data1_target, 0, &sgml_len);
529 trec->info[recInfo_storeData] = (char *) xmalloc(sgml_len);
530 memcpy(trec->info[recInfo_storeData], sgml_buf, sgml_len);
531 trec->size[recInfo_storeData] = sgml_len;
533 rec_put(records, &trec);
537 zebraExplain_newDatabase(zei, "IR-Explain-1", 0);
539 if (!zei->categoryList->dirty)
541 struct zebraCategoryListInfo *zcl = zei->categoryList;
545 zcl->data1_categoryList =
546 data1_read_sgml(zei->dh, zei->nmem,
547 "<explain><categoryList>CategoryList\n"
550 if (zcl->data1_categoryList)
552 node_cl = data1_search_tag(zei->dh, zcl->data1_categoryList,
555 zebraExplain_initCommonInfo(zei, node_cl);
562 static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei,
563 zebAttributeDetails zad)
566 struct zebSUInfoB **zsuip = &zad->SUInfo;
567 data1_node *node_adinfo, *node_zebra, *node_list, *np;
570 rec = rec_get(zei->records, zad->sysno);
572 zad->data1_tree = read_sgml_rec(zei->dh, zei->nmem, rec);
574 node_adinfo = data1_search_tag(zei->dh, zad->data1_tree,
575 "/attributeDetails");
576 node_zebra = data1_search_tag(zei->dh, node_adinfo->child,
578 node_list = data1_search_tag(zei->dh, node_zebra->child,
580 for (np = node_list->child; np; np = np->next)
582 data1_node *node_set = NULL;
583 data1_node *node_use = NULL;
584 data1_node *node_str = NULL;
585 data1_node *node_ordinal = NULL;
586 data1_node *node_type = NULL;
591 if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "attr"))
593 for (np2 = np->child; np2; np2 = np2->next)
595 if (np2->which != DATA1N_tag || !np2->child ||
596 np2->child->which != DATA1N_data)
598 if (!strcmp(np2->u.tag.tag, "set"))
599 node_set = np2->child;
600 else if (!strcmp(np2->u.tag.tag, "use"))
601 node_use = np2->child;
602 else if (!strcmp(np2->u.tag.tag, "str"))
603 node_str = np2->child;
604 else if (!strcmp(np2->u.tag.tag, "ordinal"))
605 node_ordinal = np2->child;
606 else if (!strcmp(np2->u.tag.tag, "type"))
607 node_type = np2->child;
609 assert(node_ordinal);
611 *zsuip = (struct zebSUInfoB *)
612 nmem_malloc(zei->nmem, sizeof(**zsuip));
614 if (node_type && node_type->u.data.len > 0)
615 (*zsuip)->info.index_type = node_type->u.data.data[0];
618 yaz_log(YLOG_WARN, "Missing attribute 'type' in attribute info");
619 (*zsuip)->info.index_type = 'w';
622 if (node_set && node_use)
624 (*zsuip)->info.which = ZEB_SU_SET_USE;
626 oid_str_len = node_set->u.data.len;
627 if (oid_str_len >= (int) sizeof(oid_str))
628 oid_str_len = sizeof(oid_str)-1;
629 memcpy(oid_str, node_set->u.data.data, oid_str_len);
630 oid_str[oid_str_len] = '\0';
632 (*zsuip)->info.u.su.set = oid_getvalbyname(oid_str);
634 (*zsuip)->info.u.su.use = atoi_n(node_use->u.data.data,
635 node_use->u.data.len);
636 yaz_log(YLOG_DEBUG, "set=%d use=%d ordinal=%d",
637 (*zsuip)->info.u.su.set, (*zsuip)->info.u.su.use,
638 (*zsuip)->info.ordinal);
642 (*zsuip)->info.which = ZEB_SU_STR;
644 (*zsuip)->info.u.str = nmem_strdupn(zei->nmem,
645 node_str->u.data.data,
646 node_str->u.data.len);
650 yaz_log(YLOG_WARN, "Missing set/use/str in attribute info");
653 (*zsuip)->info.ordinal = atoi_n (node_ordinal->u.data.data,
654 node_ordinal->u.data.len);
655 zsuip = &(*zsuip)->next;
662 static void zebraExplain_readDatabase (ZebraExplainInfo zei,
663 struct zebDatabaseInfoB *zdi)
666 data1_node *node_dbinfo, *node_zebra, *np;
669 rec = rec_get (zei->records, zdi->sysno);
671 zdi->data1_database = read_sgml_rec (zei->dh, zei->nmem, rec);
673 node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database,
675 assert (node_dbinfo);
676 zebraExplain_mergeAccessInfo (zei, node_dbinfo, &zdi->accessInfo);
678 node_zebra = data1_search_tag (zei->dh, node_dbinfo->child,
681 && (np = data1_search_tag (zei->dh, node_zebra->child,
683 && np->child && np->child->which == DATA1N_data)
684 zdi->recordBytes = atoi_zn (np->child->u.data.data,
685 np->child->u.data.len);
688 && (np = data1_search_tag (zei->dh, node_zebra->child,
690 && np->child && np->child->which == DATA1N_data)
691 zdi->ordinalDatabase = atoi_n(np->child->u.data.data,
692 np->child->u.data.len);
694 if ((np = data1_search_tag (zei->dh, node_dbinfo->child,
696 (np = data1_search_tag (zei->dh, np->child,
697 "recordCountActual")) &&
698 np->child->which == DATA1N_data)
700 zdi->recordCount = atoi_zn (np->child->u.data.data,
701 np->child->u.data.len);
707 int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle)
709 struct zebDatabaseInfoB **zdip = &zei->databaseInfo;
713 if (*zdip == zei->curDatabaseInfo)
715 struct zebDatabaseInfoB *zdi = *zdip;
719 zei->updateHandle = update_handle;
721 if (zdi->attributeDetails)
723 /* remove attribute details keys and delete it */
724 zebAttributeDetails zad = zdi->attributeDetails;
726 rec = rec_get(zei->records, zad->sysno);
727 (*zei->updateFunc)(zei->updateHandle, rec, 0);
730 /* remove database record keys and delete it */
731 rec = rec_get (zei->records, zdi->sysno);
732 (*zei->updateFunc)(zei->updateHandle, rec, 0);
735 /* remove from list */
738 /* current database is IR-Explain-1 */
741 zdip = &(*zdip)->next;
746 int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database)
748 struct zebDatabaseInfoB *zdi;
749 const char *database_n = strrchr (database, '/');
754 database_n = database;
757 if (zei->curDatabaseInfo &&
758 !STRCASECMP (zei->curDatabaseInfo->databaseName, database))
760 for (zdi = zei->databaseInfo; zdi; zdi=zdi->next)
762 if (!STRCASECMP (zdi->databaseName, database_n))
768 yaz_log(YLOG_LOG, "zebraExplain_curDatabase: %s", database);
773 yaz_log(YLOG_LOG, "zebraExplain_readDatabase: %s", database);
775 zebraExplain_readDatabase (zei, zdi);
777 if (zdi->attributeDetails->readFlag)
780 yaz_log(YLOG_LOG, "zebraExplain_readAttributeDetails: %s", database);
782 zebraExplain_readAttributeDetails (zei, zdi->attributeDetails);
784 zei->curDatabaseInfo = zdi;
788 static void zebraExplain_initCommonInfo (ZebraExplainInfo zei, data1_node *n)
790 data1_node *c = data1_mk_tag (zei->dh, zei->nmem, "commonInfo", 0, n);
791 data1_mk_tag_data_text (zei->dh, c, "dateAdded", zei->date, zei->nmem);
792 data1_mk_tag_data_text (zei->dh, c, "dateChanged", zei->date, zei->nmem);
793 data1_mk_tag_data_text (zei->dh, c, "languageCode", "EN", zei->nmem);
796 static void zebraExplain_updateCommonInfo (ZebraExplainInfo zei, data1_node *n)
798 data1_node *c = data1_search_tag (zei->dh, n->child, "commonInfo");
800 data1_mk_tag_data_text_uni (zei->dh, c, "dateChanged", zei->date,
804 static void zebraExplain_initAccessInfo (ZebraExplainInfo zei, data1_node *n)
806 data1_node *c = data1_mk_tag (zei->dh, zei->nmem, "accessInfo", 0, n);
807 data1_node *d = data1_mk_tag (zei->dh, zei->nmem, "unitSystems", 0, c);
808 data1_mk_tag_data_text (zei->dh, d, "string", "ISO", zei->nmem);
811 static void zebraExplain_updateAccessInfo (ZebraExplainInfo zei, data1_node *n,
812 zebAccessInfo accessInfo)
814 data1_node *c = data1_search_tag (zei->dh, n->child, "accessInfo");
820 data1_pr_tree (zei->dh, n, stdout);
825 if ((p = accessInfo->attributeSetIds))
827 d = data1_mk_tag_uni (zei->dh, zei->nmem, "attributeSetIds", c);
828 for (; p; p = p->next)
829 data1_mk_tag_data_oid (zei->dh, d, "oid", p->oid, zei->nmem);
831 if ((p = accessInfo->schemas))
833 d = data1_mk_tag_uni (zei->dh, zei->nmem, "schemas", c);
834 for (; p; p = p->next)
835 data1_mk_tag_data_oid (zei->dh, d, "oid", p->oid, zei->nmem);
839 int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database,
840 int explain_database)
842 struct zebDatabaseInfoB *zdi;
843 data1_node *node_dbinfo, *node_adinfo;
844 const char *database_n = strrchr (database, '/');
849 database_n = database;
852 yaz_log(YLOG_LOG, "zebraExplain_newDatabase: %s", database);
855 for (zdi = zei->databaseInfo; zdi; zdi=zdi->next)
857 if (!STRCASECMP (zdi->databaseName, database_n))
862 /* it's new really. make it */
863 zdi = (struct zebDatabaseInfoB *) nmem_malloc (zei->nmem, sizeof(*zdi));
864 zdi->next = zei->databaseInfo;
865 zei->databaseInfo = zdi;
867 zdi->recordCount = 0;
868 zdi->recordBytes = 0;
870 zdi->databaseName = nmem_strdup (zei->nmem, database_n);
872 zdi->ordinalDatabase = zei->ordinalDatabase++;
874 zebraExplain_mergeAccessInfo (zei, 0, &zdi->accessInfo);
879 zdi->data1_database =
880 data1_read_sgml (zei->dh, zei->nmem,
881 "<explain><databaseInfo>DatabaseInfo\n"
883 if (!zdi->data1_database)
886 node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database,
888 assert (node_dbinfo);
890 zebraExplain_initCommonInfo (zei, node_dbinfo);
891 zebraExplain_initAccessInfo (zei, node_dbinfo);
893 data1_mk_tag_data_text (zei->dh, node_dbinfo, "name",
894 database, zei->nmem);
896 if (explain_database)
897 data1_mk_tag_data_text (zei->dh, node_dbinfo, "explainDatabase",
900 data1_mk_tag_data_text (zei->dh, node_dbinfo, "userFee",
903 data1_mk_tag_data_text (zei->dh, node_dbinfo, "available",
907 data1_pr_tree (zei->dh, zdi->data1_database, stderr);
911 zei->curDatabaseInfo = zdi;
913 zdi->attributeDetails = (zebAttributeDetails)
914 nmem_malloc (zei->nmem, sizeof(*zdi->attributeDetails));
915 zdi->attributeDetails->readFlag = 0;
916 zdi->attributeDetails->sysno = 0;
917 zdi->attributeDetails->dirty = 1;
918 zdi->attributeDetails->SUInfo = NULL;
919 zdi->attributeDetails->data1_tree =
920 data1_read_sgml (zei->dh, zei->nmem,
921 "<explain><attributeDetails>AttributeDetails\n"
924 node_adinfo = data1_search_tag (zei->dh, zdi->attributeDetails->data1_tree,
925 "/attributeDetails");
926 assert (node_adinfo);
928 zebraExplain_initCommonInfo (zei, node_adinfo);
933 static void writeAttributeValueDetails (ZebraExplainInfo zei,
934 zebAttributeDetails zad,
935 data1_node *node_atvs, data1_attset *attset)
938 struct zebSUInfoB *zsui;
939 int set_ordinal = attset->reference;
940 data1_attset_child *c;
942 for (c = attset->children; c; c = c->next)
943 writeAttributeValueDetails (zei, zad, node_atvs, c->child);
944 for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
946 if (zsui->info.which == ZEB_SU_SET_USE &&
947 set_ordinal == zsui->info.u.su.set)
949 data1_node *node_attvalue, *node_value;
950 node_attvalue = data1_mk_tag (zei->dh, zei->nmem, "attributeValue",
951 0 /* attr */, node_atvs);
952 node_value = data1_mk_tag (zei->dh, zei->nmem, "value",
953 0 /* attr */, node_attvalue);
954 data1_mk_tag_data_int (zei->dh, node_value, "numeric",
955 zsui->info.u.su.use, zei->nmem);
960 static void zebraExplain_writeCategoryList (ZebraExplainInfo zei,
961 struct zebraCategoryListInfo *zcl,
968 data1_node *node_ci, *node_categoryList;
970 static char *category[] = {
982 node_categoryList = zcl->data1_categoryList;
985 yaz_log(YLOG_LOG, "zebraExplain_writeCategoryList");
988 drec = createRecord (zei->records, &sysno);
990 node_ci = data1_search_tag (zei->dh, node_categoryList,
993 node_ci = data1_mk_tag (zei->dh, zei->nmem, "categories", 0 /* attr */,
997 for (i = 0; category[i]; i++)
999 data1_node *node_cat = data1_mk_tag (zei->dh, zei->nmem, "category",
1000 0 /* attr */, node_ci);
1002 data1_mk_tag_data_text (zei->dh, node_cat, "name",
1003 category[i], zei->nmem);
1005 /* extract *searchable* keys from it. We do this here, because
1006 record count, etc. is affected */
1008 (*zei->updateFunc)(zei->updateHandle, drec, node_categoryList);
1010 /* convert to "SGML" and write it */
1012 data1_pr_tree (zei->dh, node_categoryList, stderr);
1014 sgml_buf = data1_nodetoidsgml(zei->dh, node_categoryList, 0, &sgml_len);
1015 drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
1016 memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
1017 drec->size[recInfo_storeData] = sgml_len;
1019 rec_put (zei->records, &drec);
1022 static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei,
1023 zebAttributeDetails zad,
1024 const char *databaseName,
1030 data1_node *node_adinfo, *node_list, *node_zebra, *node_attributesBySet;
1031 struct zebSUInfoB *zsui;
1039 yaz_log(YLOG_LOG, "zebraExplain_writeAttributeDetails");
1042 drec = createRecord (zei->records, &zad->sysno);
1043 assert (zad->data1_tree);
1045 node_adinfo = data1_search_tag (zei->dh, zad->data1_tree,
1046 "/attributeDetails");
1047 zebraExplain_updateCommonInfo (zei, node_adinfo);
1049 data1_mk_tag_data_text (zei->dh, node_adinfo, "name",
1050 databaseName, zei->nmem);
1052 /* extract *searchable* keys from it. We do this here, because
1053 record count, etc. is affected */
1055 (*zei->updateFunc)(zei->updateHandle, drec, zad->data1_tree);
1057 node_attributesBySet = data1_mk_tag_uni (zei->dh, zei->nmem,
1058 "attributesBySet", node_adinfo);
1062 data1_node *node_asd;
1063 data1_attset *attset;
1064 int set_ordinal = -1;
1065 for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
1067 if (zsui->info.which == ZEB_SU_SET_USE &&
1068 (set_ordinal < 0 || set_ordinal > zsui->info.u.su.set)
1069 && zsui->info.u.su.set > set_min)
1070 set_ordinal = zsui->info.u.su.set;
1072 if (set_ordinal < 0)
1074 set_min = set_ordinal;
1075 node_asd = data1_mk_tag (zei->dh, zei->nmem,
1076 "attributeSetDetails",
1077 0 /* attr */, node_attributesBySet);
1079 attset = data1_attset_search_id (zei->dh, set_ordinal);
1082 zebraExplain_loadAttsets (zei->dh, zei->res);
1083 attset = data1_attset_search_id (zei->dh, set_ordinal);
1090 oe.proto = PROTO_Z3950;
1091 oe.oclass = CLASS_ATTSET;
1092 oe.value = (enum oid_value) set_ordinal;
1094 if (oid_ent_to_oid (&oe, oid))
1096 data1_node *node_abt, *node_atd, *node_atvs;
1097 data1_mk_tag_data_oid (zei->dh, node_asd, "oid",
1100 node_abt = data1_mk_tag (zei->dh, zei->nmem,
1102 0 /*attr */, node_asd);
1103 node_atd = data1_mk_tag (zei->dh, zei->nmem,
1104 "attributeTypeDetails",
1105 0 /* attr */, node_abt);
1106 data1_mk_tag_data_int (zei->dh, node_atd,
1107 "type", 1, zei->nmem);
1108 node_atvs = data1_mk_tag (zei->dh, zei->nmem,
1110 0 /* attr */, node_atd);
1111 writeAttributeValueDetails (zei, zad, node_atvs, attset);
1115 /* zebra info (private) */
1116 node_zebra = data1_mk_tag_uni (zei->dh, zei->nmem,
1117 "zebraInfo", node_adinfo);
1118 node_list = data1_mk_tag_uni (zei->dh, zei->nmem,
1119 "attrlist", node_zebra);
1120 for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
1122 struct oident oident;
1124 data1_node *node_attr;
1125 char index_type_str[2];
1128 node_attr = data1_mk_tag (zei->dh, zei->nmem, "attr", 0 /* attr */,
1131 index_type_str[0] = zsui->info.index_type;
1132 index_type_str[1] = '\0';
1133 data1_mk_tag_data_text (zei->dh, node_attr, "type",
1134 index_type_str, zei->nmem);
1135 if (zsui->info.which == ZEB_SU_SET_USE)
1137 oident.proto = PROTO_Z3950;
1138 oident.oclass = CLASS_ATTSET;
1139 oident.value = (enum oid_value) zsui->info.u.su.set;
1140 oid_ent_to_oid (&oident, oid);
1142 data1_mk_tag_data_text (zei->dh, node_attr, "set",
1143 oident.desc, zei->nmem);
1144 data1_mk_tag_data_int (zei->dh, node_attr, "use",
1145 zsui->info.u.su.use, zei->nmem);
1147 else if (zsui->info.which == ZEB_SU_STR)
1149 data1_mk_tag_data_text (zei->dh, node_attr, "str",
1150 zsui->info.u.str, zei->nmem);
1152 data1_mk_tag_data_int (zei->dh, node_attr, "ordinal",
1153 zsui->info.ordinal, zei->nmem);
1155 /* convert to "SGML" and write it */
1157 data1_pr_tree (zei->dh, zad->data1_tree, stderr);
1159 sgml_buf = data1_nodetoidsgml(zei->dh, zad->data1_tree,
1161 drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
1162 memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
1163 drec->size[recInfo_storeData] = sgml_len;
1165 rec_put (zei->records, &drec);
1168 static void zebraExplain_writeDatabase (ZebraExplainInfo zei,
1169 struct zebDatabaseInfoB *zdi,
1175 data1_node *node_dbinfo, *node_count, *node_zebra;
1182 yaz_log(YLOG_LOG, "zebraExplain_writeDatabase %s", zdi->databaseName);
1184 drec = createRecord (zei->records, &zdi->sysno);
1185 assert (zdi->data1_database);
1187 node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database,
1190 assert (node_dbinfo);
1191 zebraExplain_updateCommonInfo (zei, node_dbinfo);
1192 zebraExplain_updateAccessInfo (zei, node_dbinfo, zdi->accessInfo);
1194 /* extract *searchable* keys from it. We do this here, because
1195 record count, etc. is affected */
1197 (*zei->updateFunc)(zei->updateHandle, drec, zdi->data1_database);
1199 node_count = data1_mk_tag_uni (zei->dh, zei->nmem,
1200 "recordCount", node_dbinfo);
1201 data1_mk_tag_data_zint (zei->dh, node_count, "recordCountActual",
1202 zdi->recordCount, zei->nmem);
1204 /* zebra info (private) */
1205 node_zebra = data1_mk_tag_uni (zei->dh, zei->nmem,
1206 "zebraInfo", node_dbinfo);
1207 data1_mk_tag_data_zint (zei->dh, node_zebra,
1208 "recordBytes", zdi->recordBytes, zei->nmem);
1210 data1_mk_tag_data_zint(zei->dh, node_zebra,
1211 "ordinalDatabase", zdi->ordinalDatabase, zei->nmem);
1213 /* convert to "SGML" and write it */
1215 data1_pr_tree (zei->dh, zdi->data1_database, stderr);
1217 sgml_buf = data1_nodetoidsgml(zei->dh, zdi->data1_database,
1219 drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
1220 memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
1221 drec->size[recInfo_storeData] = sgml_len;
1223 rec_put (zei->records, &drec);
1226 static void writeAttributeValues (ZebraExplainInfo zei,
1227 data1_node *node_values,
1228 data1_attset *attset)
1231 data1_attset_child *c;
1236 for (c = attset->children; c; c = c->next)
1237 writeAttributeValues (zei, node_values, c->child);
1238 for (atts = attset->atts; atts; atts = atts->next)
1240 data1_node *node_value;
1242 node_value = data1_mk_tag (zei->dh, zei->nmem, "attributeValue",
1243 0 /* attr */, node_values);
1244 data1_mk_tag_data_text (zei->dh, node_value, "name",
1245 atts->name, zei->nmem);
1246 node_value = data1_mk_tag (zei->dh, zei->nmem, "value",
1247 0 /* attr */, node_value);
1248 data1_mk_tag_data_int (zei->dh, node_value, "numeric",
1249 atts->value, zei->nmem);
1254 static void zebraExplain_writeAttributeSet (ZebraExplainInfo zei,
1261 data1_node *node_root, *node_attinfo, *node_attributes, *node_atttype;
1262 data1_node *node_values;
1263 struct oident *entp;
1264 struct data1_attset *attset = NULL;
1266 if ((entp = oid_getentbyoid (o->oid)))
1267 attset = data1_attset_search_id (zei->dh, entp->value);
1270 yaz_log(YLOG_LOG, "zebraExplain_writeAttributeSet %s",
1271 attset ? attset->name : "<unknown>");
1274 drec = createRecord (zei->records, &o->sysno);
1276 data1_read_sgml (zei->dh, zei->nmem,
1277 "<explain><attributeSetInfo>AttributeSetInfo\n"
1280 node_attinfo = data1_search_tag (zei->dh, node_root,
1281 "/attributeSetInfo");
1283 assert (node_attinfo);
1284 zebraExplain_initCommonInfo (zei, node_attinfo);
1285 zebraExplain_updateCommonInfo (zei, node_attinfo);
1287 data1_mk_tag_data_oid (zei->dh, node_attinfo,
1288 "oid", o->oid, zei->nmem);
1289 if (attset && attset->name)
1290 data1_mk_tag_data_text (zei->dh, node_attinfo,
1291 "name", attset->name, zei->nmem);
1293 node_attributes = data1_mk_tag_uni (zei->dh, zei->nmem,
1294 "attributes", node_attinfo);
1295 node_atttype = data1_mk_tag_uni (zei->dh, zei->nmem,
1296 "attributeType", node_attributes);
1297 data1_mk_tag_data_text (zei->dh, node_atttype,
1298 "name", "Use", zei->nmem);
1299 data1_mk_tag_data_text (zei->dh, node_atttype,
1300 "description", "Use Attribute", zei->nmem);
1301 data1_mk_tag_data_int (zei->dh, node_atttype,
1302 "type", 1, zei->nmem);
1303 node_values = data1_mk_tag (zei->dh, zei->nmem,
1304 "attributeValues", 0 /* attr */, node_atttype);
1306 writeAttributeValues (zei, node_values, attset);
1308 /* extract *searchable* keys from it. We do this here, because
1309 record count, etc. is affected */
1311 (*zei->updateFunc)(zei->updateHandle, drec, node_root);
1312 /* convert to "SGML" and write it */
1314 data1_pr_tree (zei->dh, node_root, stderr);
1316 sgml_buf = data1_nodetoidsgml(zei->dh, node_root, 0, &sgml_len);
1317 drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
1318 memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
1319 drec->size[recInfo_storeData] = sgml_len;
1321 rec_put (zei->records, &drec);
1324 static void zebraExplain_writeTarget (ZebraExplainInfo zei, int key_flush)
1326 struct zebDatabaseInfoB *zdi;
1327 data1_node *node_tgtinfo, *node_list, *node_zebra;
1336 trec = rec_get_root(zei->records);
1337 xfree (trec->info[recInfo_storeData]);
1339 node_tgtinfo = data1_search_tag (zei->dh, zei->data1_target,
1341 assert (node_tgtinfo);
1343 zebraExplain_updateCommonInfo (zei, node_tgtinfo);
1344 zebraExplain_updateAccessInfo (zei, node_tgtinfo, zei->accessInfo);
1346 /* convert to "SGML" and write it */
1348 (*zei->updateFunc)(zei->updateHandle, trec, zei->data1_target);
1350 node_zebra = data1_mk_tag_uni (zei->dh, zei->nmem,
1351 "zebraInfo", node_tgtinfo);
1352 data1_mk_tag_data_text (zei->dh, node_zebra, "version",
1353 ZEBRAVER, zei->nmem);
1354 node_list = data1_mk_tag (zei->dh, zei->nmem,
1355 "databaseList", 0 /* attr */, node_zebra);
1356 for (zdi = zei->databaseInfo; zdi; zdi = zdi->next)
1358 data1_node *node_db;
1359 node_db = data1_mk_tag (zei->dh, zei->nmem,
1360 "database", 0 /* attr */, node_list);
1361 data1_mk_tag_data_text (zei->dh, node_db, "name",
1362 zdi->databaseName, zei->nmem);
1363 data1_mk_tag_data_zint (zei->dh, node_db, "id",
1364 zdi->sysno, zei->nmem);
1365 data1_mk_tag_data_zint (zei->dh, node_db, "attributeDetailsId",
1366 zdi->attributeDetails->sysno, zei->nmem);
1368 data1_mk_tag_data_int (zei->dh, node_zebra, "ordinalSU",
1369 zei->ordinalSU, zei->nmem);
1371 data1_mk_tag_data_int (zei->dh, node_zebra, "ordinalDatabase",
1372 zei->ordinalDatabase, zei->nmem);
1374 data1_mk_tag_data_zint (zei->dh, node_zebra, "runNumber",
1375 zei->runNumber, zei->nmem);
1378 data1_pr_tree (zei->dh, zei->data1_target, stderr);
1380 sgml_buf = data1_nodetoidsgml(zei->dh, zei->data1_target,
1382 trec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
1383 memcpy (trec->info[recInfo_storeData], sgml_buf, sgml_len);
1384 trec->size[recInfo_storeData] = sgml_len;
1386 rec_put (zei->records, &trec);
1389 int zebraExplain_lookup_attr_su_any_index(ZebraExplainInfo zei,
1392 struct zebSUInfoB *zsui;
1394 assert (zei->curDatabaseInfo);
1395 for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
1396 zsui; zsui=zsui->next)
1397 if (zsui->info.which == ZEB_SU_SET_USE &&
1398 zsui->info.u.su.use == use && zsui->info.u.su.set == set)
1399 return zsui->info.ordinal;
1403 int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type,
1406 struct zebSUInfoB *zsui;
1408 assert (zei->curDatabaseInfo);
1409 for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
1410 zsui; zsui=zsui->next)
1411 if (zsui->info.index_type == index_type &&
1412 zsui->info.which == ZEB_SU_SET_USE &&
1413 zsui->info.u.su.use == use && zsui->info.u.su.set == set)
1414 return zsui->info.ordinal;
1418 int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type,
1421 struct zebSUInfoB *zsui;
1423 assert (zei->curDatabaseInfo);
1424 for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
1425 zsui; zsui=zsui->next)
1426 if (zsui->info.index_type == index_type &&
1427 zsui->info.which == ZEB_SU_STR && !strcmp(zsui->info.u.str, str))
1428 return zsui->info.ordinal;
1432 int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle,
1433 int (*f)(void *handle, int ord))
1435 struct zebDatabaseInfoB *zdb = zei->curDatabaseInfo;
1438 struct zebSUInfoB *zsui = zdb->attributeDetails->SUInfo;
1439 for ( ;zsui; zsui = zsui->next)
1440 (*f)(handle, zsui->info.ordinal);
1445 int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord,
1450 struct zebDatabaseInfoB *zdb;
1451 for (zdb = zei->databaseInfo; zdb; zdb = zdb->next)
1453 struct zebSUInfoB *zsui;
1455 if (zdb->attributeDetails->readFlag)
1456 zebraExplain_readAttributeDetails (zei, zdb->attributeDetails);
1458 for (zsui = zdb->attributeDetails->SUInfo; zsui; zsui = zsui->next)
1459 if (zsui->info.ordinal == ord)
1462 *db = zdb->databaseName;
1463 if (zsui->info.which == ZEB_SU_SET_USE)
1466 *set = zsui->info.u.su.set;
1468 *use = zsui->info.u.su.use;
1471 *index_type = zsui->info.index_type;
1478 zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei,
1479 zebAccessObject *op,
1484 for (ao = *op; ao; ao = ao->next)
1485 if (!oid_oidcmp (oid, ao->oid))
1489 ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao));
1492 ao->oid = odr_oiddup_nmem (zei->nmem, oid);
1499 void zebraExplain_addAttributeSet (ZebraExplainInfo zei, int set)
1504 oe.proto = PROTO_Z3950;
1505 oe.oclass = CLASS_ATTSET;
1506 oe.value = (enum oid_value) set;
1508 if (oid_ent_to_oid (&oe, oid))
1510 zebraExplain_announceOid (zei, &zei->accessInfo->attributeSetIds, oid);
1511 zebraExplain_announceOid (zei, &zei->curDatabaseInfo->
1512 accessInfo->attributeSetIds, oid);
1516 int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
1519 struct zebSUInfoB *zsui;
1521 assert (zei->curDatabaseInfo);
1522 zebraExplain_addAttributeSet (zei, set);
1523 zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui));
1524 zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo;
1525 zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
1526 zei->curDatabaseInfo->attributeDetails->dirty = 1;
1528 zsui->info.index_type = index_type;
1529 zsui->info.which = ZEB_SU_SET_USE;
1530 zsui->info.u.su.set = set;
1531 zsui->info.u.su.use = use;
1532 zsui->info.ordinal = (zei->ordinalSU)++;
1533 return zsui->info.ordinal;
1536 int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type,
1537 const char *index_name)
1539 struct zebSUInfoB *zsui;
1541 assert (zei->curDatabaseInfo);
1542 zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui));
1543 zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo;
1544 zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
1545 zei->curDatabaseInfo->attributeDetails->dirty = 1;
1547 zsui->info.index_type = index_type;
1548 zsui->info.which = ZEB_SU_STR;
1549 zsui->info.u.str = nmem_strdup(zei->nmem, index_name);
1550 zsui->info.ordinal = (zei->ordinalSU)++;
1551 return zsui->info.ordinal;
1554 void zebraExplain_addSchema (ZebraExplainInfo zei, Odr_oid *oid)
1556 zebraExplain_announceOid (zei, &zei->accessInfo->schemas, oid);
1557 zebraExplain_announceOid (zei, &zei->curDatabaseInfo->
1558 accessInfo->schemas, oid);
1561 void zebraExplain_recordBytesIncrement (ZebraExplainInfo zei, int adjust_num)
1563 assert (zei->curDatabaseInfo);
1567 zei->curDatabaseInfo->recordBytes += adjust_num;
1568 zei->curDatabaseInfo->dirty = 1;
1572 void zebraExplain_recordCountIncrement (ZebraExplainInfo zei, int adjust_num)
1574 assert (zei->curDatabaseInfo);
1578 zei->curDatabaseInfo->recordCount += adjust_num;
1579 zei->curDatabaseInfo->dirty = 1;
1583 zint zebraExplain_runNumberIncrement (ZebraExplainInfo zei, int adjust_num)
1589 return zei->runNumber += adjust_num;
1592 RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec)
1594 RecordAttr *recordAttr;
1596 if (rec->info[recInfo_attr])
1597 return (RecordAttr *) rec->info[recInfo_attr];
1598 recordAttr = (RecordAttr *) xmalloc (sizeof(*recordAttr));
1599 rec->info[recInfo_attr] = (char *) recordAttr;
1600 rec->size[recInfo_attr] = sizeof(*recordAttr);
1602 recordAttr->recordSize = 0;
1603 recordAttr->recordOffset = 0;
1604 recordAttr->runNumber = zei->runNumber;
1605 recordAttr->staticrank = 0;
1609 static void att_loadset(void *p, const char *n, const char *name)
1611 data1_handle dh = (data1_handle) p;
1612 if (!data1_get_attset (dh, name))
1613 yaz_log(YLOG_WARN, "Directive attset failed for %s", name);
1616 int zebraExplain_get_database_ord(ZebraExplainInfo zei)
1618 if (!zei->curDatabaseInfo)
1620 return zei->curDatabaseInfo->ordinalDatabase;
1623 void zebraExplain_loadAttsets (data1_handle dh, Res res)
1625 res_trav(res, "attset", dh, att_loadset);
1629 zebraExplain_addSU adds to AttributeDetails for a database and
1630 adds attributeSet (in AccessInfo area) to DatabaseInfo if it doesn't
1631 exist for the database.
1633 If the database doesn't exist globally (in TargetInfo) an
1634 AttributeSetInfo must be added (globally).