-/* $Id: zrpn.c,v 1.133 2003-04-15 20:48:04 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: zrpn.c,v 1.139 2004-06-02 12:29:03 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
struct rpn_char_map_info rcmi;
int space_split = complete_flag ? 0 : 1;
+ int bases_ok = 0; /* no of databases with OK attribute */
+ int errCode = 0; /* err code (if any is not OK) */
+ char *errString = 0; /* addinfo */
+
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
attr_init (&use, zapt, 1);
use_value = attr_find_ex (&use, &curAttributeSet, &use_string);
zh->errString = basenames[base_no];
return -1;
}
- if (use_value == -2) /* string attribute (assume IDXPATH/any) */
+ if (xpath_use > 0 && use_value == -2)
{
use_value = xpath_use;
attp.local_attributes = &id_xpath_attr;
}
else
{
- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value)))
+ if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value,
+ use_string)))
{
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
curAttributeSet, use_value, r);
if (r == -1)
{
/* set was found, but value wasn't defined */
- char val_str[32];
- sprintf (val_str, "%d", use_value);
- zh->errCode = 114;
- zh->errString = nmem_strdup (stream, val_str);
+ errCode = 114;
+ if (use_string)
+ errString = nmem_strdup(stream, use_string);
+ else
+ {
+ char val_str[32];
+ sprintf (val_str, "%d", use_value);
+ errString = nmem_strdup (stream, val_str);
+ }
}
else
{
oident.value = curAttributeSet;
oid_ent_to_oid (&oident, oid);
- zh->errCode = 121;
- zh->errString = nmem_strdup (stream, oident.desc);
+ errCode = 121;
+ errString = nmem_strdup (stream, oident.desc);
}
- return -1;
+ continue;
}
}
for (local_attr = attp.local_attributes; local_attr;
}
if (!prefix_len)
{
+#if 1
+ bases_ok++;
+#else
char val_str[32];
sprintf (val_str, "%d", use_value);
- zh->errCode = 114;
- zh->errString = nmem_strdup (stream, val_str);
- return -1;
+ errCode = 114;
+ errString = nmem_strdup (stream, val_str);
+#endif
+ continue;
}
+ bases_ok++; /* this has OK attributes */
+
term_dict[prefix_len++] = ')';
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
break;
}
}
+ if (!bases_ok)
+ {
+ zh->errCode = errCode;
+ zh->errString = errString;
+ return -1;
+ }
*term_sub = termp;
logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx);
return 1;
bool_parms.rset_r = rset[i];
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
+ bool_parms.log_item = key_logdump_txt;
result = rset_create (rset_kind_or, &bool_parms);
}
return result;
bool_parms.rset_r = rset[i];
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
+ bool_parms.log_item = key_logdump_txt;
result = rset_create (rset_kind_and, &bool_parms);
}
return result;
const char *termp;
struct rpn_char_map_info rcmi;
+ int bases_ok = 0; /* no of databases with OK attribute */
+ int errCode = 0; /* err code (if any is not OK) */
+ char *errString = 0; /* addinfo */
+
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
attr_init (&use, zapt, 1);
use_value = attr_find_ex (&use, &curAttributeSet, &use_string);
}
else
{
- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value)))
+ if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value,
+ use_string)))
{
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
curAttributeSet, use_value, r);
{
char val_str[32];
sprintf (val_str, "%d", use_value);
- zh->errString = nmem_strdup (stream, val_str);
- zh->errCode = 114;
+ errString = nmem_strdup (stream, val_str);
+ errCode = 114;
}
else
- zh->errCode = 121;
- return -1;
+ errCode = 121;
+ continue;
}
}
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
char val_str[32];
sprintf (val_str, "%d", use_value);
- zh->errCode = 114;
- zh->errString = nmem_strdup (stream, val_str);
- return -1;
+ errCode = 114;
+ errString = nmem_strdup (stream, val_str);
+ continue;
}
+ bases_ok++;
term_dict[prefix_len++] = ')';
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
term_dst))
return 0;
}
+ if (!bases_ok)
+ {
+ zh->errCode = errCode;
+ zh->errString = errString;
+ return -1;
+ }
*term_sub = termp;
logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx);
return 1;
bool_parms.rset_r = rset[i];
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
+ bool_parms.log_item = key_logdump_txt;
result = rset_create (rset_kind_and, &bool_parms);
}
return result;
sks->sortRelation = (int *)
nmem_malloc (stream, sizeof(*sks->sortRelation));
if (sort_relation_value == 1)
- *sks->sortRelation = Z_SortRelation_ascending;
+ *sks->sortRelation = Z_SortKeySpec_ascending;
else if (sort_relation_value == 2)
- *sks->sortRelation = Z_SortRelation_descending;
+ *sks->sortRelation = Z_SortKeySpec_descending;
else
- *sks->sortRelation = Z_SortRelation_ascending;
+ *sks->sortRelation = Z_SortKeySpec_ascending;
sks->caseSensitivity = (int *)
nmem_malloc (stream, sizeof(*sks->caseSensitivity));
return rset_create (rset_kind_null, &parms);
}
-/* pop - moved to xpath.c */
-#if 0
-
-struct xpath_predicate {
- int which;
- union {
-#define XPATH_PREDICATE_RELATION 1
- struct {
- char *name;
- char *op;
- char *value;
- } relation;
-#define XPATH_PREDICATE_BOOLEAN 2
- struct {
- const char *op;
- struct xpath_predicate *left;
- struct xpath_predicate *right;
- } boolean;
- } u;
-};
-
-struct xpath_location_step {
- char *part;
- struct xpath_predicate *predicate;
-};
-
-#endif
static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
oid_value attributeSet,
xpath[level].predicate->which == XPATH_PREDICATE_RELATION &&
xpath[level].predicate->u.relation.name[0])
{
- char predicate_str[128];
-
- strcpy (predicate_str,
- xpath[level].predicate->u.relation.name+1);
+ WRBUF wbuf = wrbuf_alloc();
+ wrbuf_puts(wbuf, xpath[level].predicate->u.relation.name+1);
if (xpath[level].predicate->u.relation.value)
{
- strcat (predicate_str, "=");
- strcat (predicate_str,
- xpath[level].predicate->u.relation.value);
+ const char *cp = xpath[level].predicate->u.relation.value;
+ wrbuf_putc(wbuf, '=');
+
+ while (*cp)
+ {
+ if (strchr(REGEX_CHARS, *cp))
+ wrbuf_putc(wbuf, '\\');
+ wrbuf_putc(wbuf, *cp);
+ cp++;
+ }
}
+ wrbuf_puts(wbuf, "");
rset_attr = xpath_trunc (
- zh, stream, '0', predicate_str, 3, curAttributeSet);
+ zh, stream, '0', wrbuf_buf(wbuf), 3, curAttributeSet);
+ wrbuf_free(wbuf, 1);
}
else
{
}
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
+ bool_parms.log_item = key_logdump_txt;
switch (zop->which)
{
char termz[IT_MAX_WORD+20];
AttrType use;
int use_value;
+ const char *use_string = 0;
struct scan_info *scan_info_array;
ZebraScanEntry *glist;
int ords[32], ord_no = 0;
int ptr[32];
+ int bases_ok = 0; /* no of databases with OK attribute */
+ int errCode = 0; /* err code (if any is not OK) */
+ char *errString = 0; /* addinfo */
+
unsigned reg_id;
char *search_type = NULL;
char rank_type[128];
pos, num, attributeset);
attr_init (&use, zapt, 1);
- use_value = attr_find (&use, &attributeset);
+ use_value = attr_find_ex (&use, &attributeset, &use_string);
if (zebra_maps_attr (zh->reg->zebra_maps, zapt, ®_id, &search_type,
rank_type, &complete_flag, &sort_flag))
attent attp;
data1_local_attribute *local_attr;
- if ((r=att_getentbyatt (zh, &attp, attributeset, use_value)))
+ if ((r=att_getentbyatt (zh, &attp, attributeset, use_value,
+ use_string)))
{
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
attributeset, use_value);
{
char val_str[32];
sprintf (val_str, "%d", use_value);
- zh->errCode = 114;
- zh->errString = odr_strdup (stream, val_str);
+ errCode = 114;
+ errString = odr_strdup (stream, val_str);
}
else
- zh->errCode = 121;
- *num_entries = 0;
- return;
+ errCode = 121;
+ continue;
}
if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
{
*num_entries = 0;
return;
}
+ bases_ok++;
for (local_attr = attp.local_attributes; local_attr && ord_no < 32;
local_attr = local_attr->next)
{
ords[ord_no++] = ord;
}
}
+ if (!bases_ok && errCode)
+ {
+ zh->errCode = errCode;
+ zh->errString = errString;
+ *num_entries = 0;
+ }
if (ord_no == 0)
{
+ char val_str[32];
+ sprintf (val_str, "%d", use_value);
+ zh->errCode = 114;
+ zh->errString = odr_strdup (stream, val_str);
+
*num_entries = 0;
- zh->errCode = 113;
return;
}
/* prepare dictionary scanning */
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
- bool_parms.rset_l = rset;
+ bool_parms.log_item = key_logdump_txt;
+ bool_parms.rset_l = rset;
bool_parms.rset_r = rset2;
rset = rset_create (rset_kind_or, &bool_parms);
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
- bool_parms.rset_l = rset;
+ bool_parms.log_item = key_logdump_txt;
+ bool_parms.rset_l = rset;
bool_parms.rset_r = rset_dup(limit_set);
rset = rset_create (rset_kind_and, &bool_parms);
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
- bool_parms.rset_l = rset;
+ bool_parms.log_item = key_logdump_txt;
+ bool_parms.rset_l = rset;
bool_parms.rset_r = rset2;
rset = rset_create (rset_kind_or, &bool_parms);
bool_parms.key_size = sizeof(struct it_key);
bool_parms.cmp = key_compare_it;
+ bool_parms.log_item = key_logdump_txt;
bool_parms.rset_l = rset;
bool_parms.rset_r = rset_dup(limit_set);