.libs
Makefile
Makefile.in
-t[0-9]
-t[0-9][0-9]
+test_rank
+test_resources
+test_update_record
+test_start_stop
+test_result_sets
+test_insert_fetch
+test_search
+test_trunc
+test_sort_set
+test_create_databases
+test_icu_indexing
+test_private_attset
+test_scan
+test_special_elements
+test_zebra_fork
test_safari
test_sortindex
*.mf
noinst_PROGRAMS = testclient
testclient_SOURCES = testclient.c
-check_PROGRAMS = t0 t1 t2 t3 t4 t5 t6 t7 t8 \
- t9 t10 t11 t12 t13 t14 t15 t16 t17 \
+check_PROGRAMS = test_start_stop test_result_sets \
+ test_insert_fetch test_search test_trunc test_sort_set \
+ test_rank test_private_attset \
+ test_scan test_create_databases test_resources test_update_record \
+ test_zebra_fork test_special_elements test_icu_indexing \
test_sortindex test_safari
TESTS = $(check_PROGRAMS)
-EXTRA_DIST=zebra.cfg zebra6.cfg zebra8.cfg zebra10.cfg zebra15.cfg \
- t10.att t10.abs zebra17.cfg t17.idx \
+EXTRA_DIST=zebra.cfg test_trunc.cfg test_private_attset.cfg \
+ private_attset.att private_attset.abs \
+ test_zebra_fork.cfg \
+ test_icu_indexing.cfg test_icu_indexing.idx \
test_safari.cfg test_sortindex.cfg
noinst_LIBRARIES = libtestlib.a
libtestlib_a_SOURCES = testlib.c testlib.h
-t0_SOURCES = t0.c
-t1_SOURCES = t1.c
-t2_SOURCES = t2.c
-t3_SOURCES = t3.c
-t4_SOURCES = t4.c
-t5_SOURCES = t5.c
-t6_SOURCES = t6.c
-t7_SOURCES = t7.c
-t8_SOURCES = t8.c
-t9_SOURCES = t9.c rankingrecords.h
-t10_SOURCES = t10.c
-t11_SOURCES = t11.c
-t12_SOURCES = t12.c
-t13_SOURCES = t13.c
-t14_SOURCES = t14.c
-t15_SOURCES = t15.c
-t16_SOURCES = t16.c
-t17_SOURCES = t17.c
+test_start_stop_SOURCES = test_start_stop.c
+test_result_sets_SOURCES = test_result_sets.c
+test_insert_fetch_SOURCES = test_insert_fetch.c
+test_search_SOURCES = test_search.c
+test_trunc_SOURCES = test_trunc.c
+test_sort_set_SOURCES = test_sort_set.c
+test_rank_SOURCES = test_rank.c
+test_private_attset_SOURCES = test_private_attset.c
+test_scan_SOURCES = test_scan.c
+test_create_databases_SOURCES = test_create_databases.c
+test_resouces_SOURCES = test_resouces.c
+test_update_record_SOURCES = test_update_record.c
+test_zebra_fork_SOURCES = test_zebra_fork.c
+test_special_elements_SOURCES = test_special_elements.c
+test_icu_indexing_SOURCES = test_icu_indexing.c
test_sortindex_SOURCES = test_sortindex.c
test_safari_SOURCES = test_safari.c testlib.c
--- /dev/null
+# This is the abstract syntax (and most of the top-level profile info)
+# for GILS version 2.
+#
+
+name my_private_attset
+attset private_attset.att
+
+esetname F @
+
+systag sysno none
+
+elm title title title:w,extra_title:w
--- /dev/null
+# Bib-1 Attribute Set
+name private_attset
+reference 1.2.840.10003.3.1000.1000.1
+
+att 7 title
+att 8 extra_title
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** rankingrecords.h - some test data for t9, and t10 */
-
-const char *recs[] = {
- "<gils>\n"
- " <title>The first title</title>\n"
- " <abstract> \n"
- " The first common word is the: the the the \n"
- " The second common word is word \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</gils>\n",
-
- "<gils>\n"
- " <title>The second title</title>\n"
- " <abstract> \n"
- " The first common word is the: the \n"
- " The second common word is foo: foo foo \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</gils>\n",
-
- "<gils>\n"
- " <title>The third title</title>\n"
- " <abstract> \n"
- " The first common word is the: the \n"
- " The third common word is bar: bar \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</gils>\n",
-
- 0 };
-
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t0 - test zebra_start .. */
-
-#include "testlib.h"
-
-static void tst(int argc, char **argv)
-{
- YAZ_CHECK(!zebra_start("xxxxpoiasdfasfd.cfg")); /* should fail */
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t1 - just start and stop */
-
-#include <yaz/test.h>
-#include "testlib.h"
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-# This is the abstract syntax (and most of the top-level profile info)
-# for GILS version 2.
-#
-
-name t10
-attset t10.att
-
-esetname F @
-
-systag sysno none
-
-elm title title title:w,extra_title:w
+++ /dev/null
-# Bib-1 Attribute Set
-name t10
-reference 1.2.840.10003.3.1000.1000.1
-
-att 7 title
-att 8 extra_title
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/* Creates a few result sets */
-
-#include "testlib.h"
-
-const char *myrec[] ={
- "<t10>\n"
- " <title>My title</title>\n"
- "</t10>\n",
- 0};
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up("zebra10.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- zebra_commit(zh);
-
- // string attributes in search
- YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=title titlex", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1));
-
- // numeric attributes with Bib-1 should produce an error
- YAZ_CHECK(tl_query_x(zh,
- "@attr 1=4 my", 0, 121));
- YAZ_CHECK(tl_query_x(zh,
- "@attr 1=7 my", 0, 121));
- // private OID with incorrect use attribute
- YAZ_CHECK(tl_query_x(zh,
- "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114));
- // private OID with OK use attribute
- YAZ_CHECK(tl_query(zh,
- "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1));
-
- YAZ_CHECK(tl_query(zh,
- "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** testing of scan */
-#include "testlib.h"
-
-const char *myrec[] = {
- "<gils>\n<title>a b</title>\n</gils>\n",
- "<gils>\n<title>c d</title>\n</gils>\n",
- "<gils>\n<title>e f</title>\n</gils>\n" ,
- 0} ;
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(zh);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- /*
- int tl_scan
- (
- ZebraHandle zh, const char *query,
- int pos, int num,
- int exp_pos, int exp_num, int exp_partial,
- const char **exp_entries
- )
- */
-
-
- {
- /* bad string use attrite, bug #647 */
- YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0));
- }
-
- {
- /* bad numeric use attributes, bug #647 */
- YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0));
- }
-
- {
- /* scan before. nothing must be returned */
- const char *ent[] = { "a", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent));
- }
-
- {
- /* scan after. nothing must be returned */
- const char *ent[] = { 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent));
- }
-
- {
- const char *ent[] = { "a", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent));
- }
-
- {
- const char *ent[] = { "b", "c", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
- }
-
- {
- const char *ent[] = { "b", "c", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
- }
-
- {
- const char *ent[] = { "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent));
- }
-
- {
- const char *ent[] = { "c", "d", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent));
- }
-
- {
- const char *ent[] = { "d", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent));
- }
-
- {
- const char *ent[] = { "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent));
- }
-
- {
- const char *ent[] = { "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent));
- }
-
- {
- const char *ent[] = { "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent));
- }
-
- {
- const char *ent[] = { "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent));
- }
-
- {
- const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent));
- }
-
- {
- const char *ent[] = { "b", "c", "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent));
- }
-
- {
- const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent));
- }
-
- {
- const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent));
- }
-
- {
- const char *ent[] = { 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent));
- }
-
- {
- const char *ent[] = { "c", "d", 0 };
-
- YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1));
-
- /* must fail, because x is not a result set */
- YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0));
-
- /* bug 1114 */
- YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0",
- 1, 20, 1, 2, 1, ent));
-
- }
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** Create many databases */
-
-#include "testlib.h"
-
-static void tst(int argc, char **argv)
-{
- int i;
- int no_db = 140;
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
- YAZ_CHECK(zebra_init(zh) == ZEBRA_OK);
- zebra_close(zh);
-
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
-
- for (i = 0; i<no_db; i++)
- {
- char dbstr[20];
- char rec_buf[100];
-
- sprintf(dbstr, "%d", i);
- YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK);
-
- sprintf(rec_buf, "<gils><title>title %d</title></gils>\n", i);
- zebra_add_record (zh, rec_buf, strlen(rec_buf));
-
- }
- YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
-
- zebra_close(zh);
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
- for (i = 0; i<=no_db; i++)
- {
- char dbstr[20];
- char querystr[50];
- sprintf(dbstr, "%d", i);
- YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK);
-
- sprintf(querystr, "@attr 1=4 %d", i);
- if (i == no_db)
- {
- YAZ_CHECK(tl_query_x(zh, querystr, 0, 109));
- }
- else
- {
- YAZ_CHECK(tl_query(zh, querystr, 1));
- }
- }
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** test resources */
-#include <stdlib.h>
-#include <string.h>
-#include "testlib.h"
-#include <idzebra/api.h>
-
-static void tst_res(void)
-{
- Res default_res; /* default resources */
- Res temp_res; /* temporary resources */
- ZebraService zs;
- ZebraHandle zh;
- const char *val;
- int i;
-
- default_res = res_open(0, 0); /* completely empty */
- YAZ_CHECK(default_res);
-
- res_set(default_res, "name1", "value1");
-
- temp_res = res_open(0, 0); /* completely empty */
- YAZ_CHECK(temp_res);
-
- zs = zebra_start_res(0, default_res, temp_res);
- YAZ_CHECK(zs);
-
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- /* run this a few times so we can see leaks easier */
- for (i = 0; i<10; i++)
- {
- /* we should find the name1 from default_res */
- val = zebra_get_resource(zh, "name1", 0);
- YAZ_CHECK(val && !strcmp(val, "value1"));
-
- /* make local override */
- res_set(temp_res, "name1", "value2");
- res_set(temp_res, "name4", "value4");
-
- /* we should find the name1 from temp_res */
- val = zebra_get_resource(zh, "name1", 0);
- YAZ_CHECK(val && !strcmp(val, "value2"));
-
- val = zebra_get_resource(zh, "name4", 0);
- YAZ_CHECK(val && !strcmp(val, "value4"));
-
- res_clear(temp_res);
- }
- zebra_close(zh);
- zebra_stop(zs);
-
- res_close(temp_res);
- res_close(default_res);
-}
-
-static void tst_no_config(void)
-{
- static char *xml_buf = "<gils><title>myx</title></gils>";
- ZebraService zs;
- ZebraHandle zh;
- zint sysno = 0;
-
- zs = zebra_start_res(0, 0, 0);
- YAZ_CHECK(zs);
-
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK);
-
- YAZ_CHECK_EQ(zebra_init(zh), ZEBRA_OK);
-
- zebra_set_resource(zh, "profilePath", "${srcdir:-.}/../../tab");
-
- YAZ_CHECK_EQ(zebra_update_record(zh /* handle */,
- action_insert,
- "grs.sgml" /* record type */,
- &sysno, 0 /* match */,
- 0 /* fname */,
- xml_buf, strlen(xml_buf)),
- ZEBRA_OK);
-
- zebra_close(zh);
- zebra_stop(zs);
-}
-
-static void tst(int argc, char **argv)
-{
- tst_res();
- tst_no_config();
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-#include "testlib.h"
-
-static void create_search_drop(ZebraHandle zh)
-{
- const char *rec = "<gils><title>some</title></gils>";
- const char *opaque_id = "9";
-
- YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
-
- /* bug #447 */
- YAZ_CHECK(zebra_update_record(
- zh, action_update,
- 0 /* record type */,
- 0 /* sysno */,
- opaque_id,
- 0 /* fname */,
- rec, strlen(rec))
- == ZEBRA_OK); /* insert really */
-
- YAZ_CHECK(zebra_update_record(
- zh, action_update,
- 0 /* record type */,
- 0 /* sysno */,
- opaque_id,
- 0 /* fname */,
- rec, strlen(rec))
- == ZEBRA_OK); /* replace really */
-
- YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1));
-
- zebra_drop_database(zh, "Default");
-
- YAZ_CHECK(tl_query_x(zh, "@attr 1=4 some", 0, 109));
-
-}
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up("zebra.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- zebra_init(zh);
-
- create_search_drop(zh);
- /* bug #447 */
- create_search_drop(zh);
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#if HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
-#endif
-
-#include <string.h>
-
-#include "testlib.h"
-
-static void update_process(ZebraService zs, int iter)
-{
- int i;
- for (i = 0; i<iter; i++)
- {
- const char *rec = "<gils><title>some</title></gils>";
- ZebraHandle zh = zebra_open(zs, 0);
- zebra_add_record(zh, rec, strlen(rec));
- if ((i % 30) == 0 || i == iter-1)
- zebra_commit(zh);
- zebra_close(zh);
- }
-}
-
-static void search_process(ZebraService zs, int iter)
-{
- zint hits_max = 0;
- int i;
- for (i = 0; i<iter; i++)
- {
- ZebraHandle zh = zebra_open(zs, 0);
- zint hits;
- ZEBRA_RES res = zebra_search_PQF(zh, "@attr 1=4 some", "default",
- &hits);
- YAZ_CHECK(res == ZEBRA_OK);
-
- YAZ_CHECK(hits >= hits_max);
- if (hits < hits_max)
- printf("i=%d hits=%lld hits_max=%lld\n", i, hits, hits_max);
- hits_max = hits;
- zebra_close(zh);
- }
-}
-
-static pid_t fork_service(ZebraService zs, int iter,
- void (*f)(ZebraService zs, int iter))
-{
- pid_t pid = fork();
-
- YAZ_CHECK(pid != -1);
- if (pid)
- return pid;
-
- (*f)(zs, iter);
- YAZ_CHECK_TERM;
-}
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs;
- ZebraHandle zh;
-
- mkdir("register", 0775);
- mkdir("shadow", 0775);
-
- zs = tl_start_up("zebra15.cfg", argc, argv);
- YAZ_CHECK(zs);
-
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- zebra_init(zh);
-
- YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
- zebra_close(zh);
-
- update_process(zs, 1);
-
-#if HAVE_SYS_WAIT_H
-#if HAVE_UNISTD_H
-#if HAVE_SYS_UTSNAME_H
-
- if (1)
- {
- int tst_with_fork = 1;
- int status[3];
- pid_t pids[3];
- struct utsname s;
- uname(&s);
- if (!strcmp(s.sysname, "FreeBSD"))
- tst_with_fork = 0;
-
- yaz_log(YLOG_LOG, "s.sysname=%s tst_with_fork=%d", s.sysname,
- tst_with_fork);
- if (tst_with_fork)
- {
- pids[0] = fork_service(zs, 200, search_process);
- pids[1] = fork_service(zs, 20, update_process);
- pids[2] = fork_service(zs, 20, update_process);
- waitpid(pids[0], &status[0], 0);
- YAZ_CHECK(status[0] == 0);
- waitpid(pids[1], &status[1], 0);
- YAZ_CHECK(status[1] == 0);
- waitpid(pids[2], &status[2], 0);
- YAZ_CHECK(status[2] == 0);
- }
- }
-#endif
-#endif
-#endif
- YAZ_CHECK(tl_close_down(0, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** \brief test special element set names zebra:: and friends */
-
-#include "testlib.h"
-
-const char *myrec[] = {
- "<gils>\n"
- " <title>My title</title>\n"
- "</gils>\n",
- 0};
-
-static void tst(int argc, char **argv)
-{
- zint hits;
- ZEBRA_RES res;
- const char * zebra_xml_sysno
- = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\"/>\n";
-
- const char * zebra_xml_meta
- = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" base=\"Default\" type=\"grs.sgml\" rank=\"0\" size=\"41\" set=\"zebra::meta\"/>\n";
-
- const char * zebra_xml_index_title_p
- = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" set=\"zebra::index::title:p/\">\n"
-" <index name=\"title\" type=\"p\" seq=\"4\">my title</index>\n"
-"</record>\n";
-
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- res = zebra_search_PQF(zh, "@attr 1=4 my", "rsetname", &hits);
- YAZ_CHECK_EQ(res, ZEBRA_OK);
- YAZ_CHECK_EQ(hits, 1);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
- "mismatch"), ZEBRA_FAIL);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_sutrs,
- myrec[0]), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
- myrec[0]), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
- yaz_oid_recsyn_sutrs,
- "2"), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
- yaz_oid_recsyn_xml,
- zebra_xml_sysno), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta", yaz_oid_recsyn_xml,
- zebra_xml_meta), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:p",
- yaz_oid_recsyn_xml,
- zebra_xml_index_title_p), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::nonexistent",
- yaz_oid_recsyn_xml, ""), ZEBRA_OK);
-
- YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::nonexistent",
- yaz_oid_recsyn_xml, ""), ZEBRA_OK);
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** \file
- \brief tests ICU enabled maps
-*/
-#include <yaz/test.h>
-#include "testlib.h"
-
-/* utf-8 sequences for some characters */
-#define char_ae "\xc3\xa6"
-#define char_AE "\xc3\x86"
-
-#define char_oslash "\xc3\xb8"
-#define char_Oslash "\xc3\x98"
-
-#define char_aring "\xc3\xa5"
-#define char_Aring "\xc3\x85"
-
-#define char_comb_ring_above "\xcc\x8a"
-
-#define char_aring1 "a" char_comb_ring_above
-#define char_Aring1 "A" char_comb_ring_above
-
-const char *myrec[] = {
- "<gils>\n<title>My computer</title>\n</gils>\n",
- "<gils>\n<title>My x computer</title>\n</gils>\n",
- "<gils>\n<title>My computer x</title>\n</gils>\n" ,
- "<gils>\n<title>" char_ae "</title>\n</gils>\n" ,
- "<gils>\n<title>B" char_aring "d</title>\n"
- "<abstract>זיהוי סדר הארועים בסיפור המרד הגדול מאת צביה בן-שלום 提示:直接点击数据库名称,将进入单库检索 Ngày xửa ngày xưa D.W. all wet</abstract>\n</gils>\n" ,
- 0} ;
-
-static void tst(int argc, char **argv)
-{
-#if YAZ_HAVE_ICU
- ZebraService zs = tl_start_up("zebra17.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- /* simple term */
- YAZ_CHECK(tl_query(zh, "@attr 1=title notfound", 0));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 5=1 comput", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title .computer.", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title x", 2));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title my", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=title mY", 3));
-
- YAZ_CHECK(tl_query(zh, char_ae, 1));
- YAZ_CHECK(tl_query(zh, char_AE, 1));
-
- YAZ_CHECK(tl_query(zh, "b" char_aring "d", 1));
- YAZ_CHECK(tl_query(zh, "B" char_Aring "D", 1));
- YAZ_CHECK(tl_query(zh, "b" char_aring1 "d", 1));
- YAZ_CHECK(tl_query(zh, "B" char_Aring1 "D", 1));
-
- /* Abstract searches . Chinese mostly */
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract בן", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract צביה", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract הגדול", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract בסיפור", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract בסיפ", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract 点", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract wet", 1));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בסיפ", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 סיפ", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בסי", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בס", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 ב", 1));
-
- /* phrase search */
- YAZ_CHECK(tl_query(zh, "@attr 1=title {my computer}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=1 {my computer}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=title {computer x}", 1));
-
- /* complete-subfield search */
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my computer}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my}", 0));
-
- /* always matches */
- YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {}", 5));
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 2=103 {}", 5));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {does not match}", 1));
-
- /* scan */
- { /* word search */
- const char *ent[] = { char_ae, "B" char_aring "d", "computer",
- "My", "x", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=title 0", 1, 10, 1, 5, 1, ent));
- }
-
- { /* word search */
- const char *ent[] = { "My", "x", 0 };
- YAZ_CHECK(tl_scan(zh, "@attr 1=title cp", 1, 10, 1, 2, 1, ent));
- }
-
- { /* phrase search */
- const char *ent[] = { char_ae, "B" char_aring "d", "My computer" };
- YAZ_CHECK(tl_scan(zh, "@attr 1=title @attr 6=2 0", 1, 3, 1, 3, 0, ent));
- }
-
- YAZ_CHECK(tl_close_down(zh, zs));
-#endif
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-# Zebra indexes as referred to from the *.abs-files.
-#
-
-# Traditional word index
-# Used if completenss is 'incomplete field' (@attr 6=1) and
-# structure is word/phrase/word-list/free-form-text/document-text
-index w
-completeness 0
-position 1
-alwaysmatches 1
-firstinfield 1
-# simplechain dummy
-icuchain words-icu.xml
-debug 1
-
-# Phrase index
-# Used if completeness is 'complete {sub}field' (@attr 6=2, @attr 6=1)
-# and structure is word/phrase/word-list/free-form-text/document-text
-index p
-completeness 1
-icuchain phrases-icu.xml
-# debug 1
-
-# Sort register
-sort s
-completeness 1
-charmap string.chr
-
-# Staticrank (uncomment to enable)
-#staticrank r
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-#include "testlib.h"
-
-const char *myrec[] = {
- "<gils>\n"
- " <title>My title</title>\n"
- "</gils>\n",
- 0};
-
-void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
- YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=title nope", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 nope", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 2=103 dummy", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 dummy", 1));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/* Creates a few result sets */
-
-#include "testlib.h"
-
-const char *myrec[] ={
- "<gils>\n"
- " <title>My title</title>\n"
- "</gils>\n",
- 0};
-
-static void tst(int argc, char **argv)
-{
- int i;
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- for (i = 0; i<4; i++)
- {
- char setname[20];
- char *setnamep = setname;
- int status;
- ODR odr_input = odr_createmem (ODR_DECODE);
- ODR odr_output = odr_createmem (ODR_ENCODE);
- YAZ_PQF_Parser parser = yaz_pqf_create();
- Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input,
- "@attr 1=4 my");
- zint hits;
- if (zebra_begin_trans (zh, 1) != ZEBRA_OK)
- {
- fprintf(stderr, "zebra_begin_trans failed\n");
- exit(1);
- }
- if (zebra_begin_trans (zh, 0) != ZEBRA_OK)
- {
- fprintf(stderr, "zebra_begin_trans failed\n");
- exit(1);
- }
-
- sprintf(setname, "s%d", i+1);
- zebra_search_RPN (zh, odr_input, query, setname, &hits);
-
- if (zebra_end_trans (zh) != ZEBRA_OK)
- {
- fprintf(stderr, "zebra_end_trans failed\n");
- exit(1);
- }
- if (zebra_end_trans (zh) != ZEBRA_OK)
- {
- fprintf(stderr, "zebra_end_trans failed\n");
- exit(1);
- }
- yaz_pqf_destroy(parser);
- zebra_deleteResultSet(zh, Z_DeleteRequest_list,
- 1, &setnamep, &status);
- odr_destroy(odr_input);
- odr_destroy(odr_output);
- }
- zebra_commit(zh);
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/* t4 - insert a small pile of records, search and fetch them */
-
-#include "testlib.h"
-
-const char *myrec[] = {
- "<gils>\n"
- " <title>My title</title>\n"
- "</gils>\n",
- 0};
-
-#define NUMBER_TO_FETCH_MAX 1000
-
-static void tst(int argc, char **argv)
-{
- int i;
- int number_to_be_inserted = 5;
- int number_to_fetch = 5;
-
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
-
- for (i = 0; i< number_to_be_inserted-1; i++)
- { /* -1 since already inserted one in init_data */
- zebra_add_record(zh, myrec[0], strlen(myrec[0]));
- }
- YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
-
- zebra_close(zh);
- zebra_stop(zs);
-
- zs = tl_zebra_start("");
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
- zebra_set_resource(zh, "sortmax", "3"); /* make small sort boundary */
-
- for (i = 0; i<2; i++)
- {
- ZEBRA_RES ret;
- ZebraRetrievalRecord retrievalRecord[NUMBER_TO_FETCH_MAX];
- char setname[20];
- int j;
- ODR odr_input = odr_createmem(ODR_DECODE);
- ODR odr_output = odr_createmem(ODR_DECODE);
- YAZ_PQF_Parser parser = yaz_pqf_create();
- Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
- zint hits;
-
- sprintf(setname, "s%d", i+1);
- ret = zebra_search_RPN(zh, odr_input, query, setname, &hits);
- if (ret != ZEBRA_OK)
- {
- int code = zebra_errCode(zh);
- yaz_log(YLOG_WARN, "Unexpected error code=%d", code);
- exit(1);
- }
- if (hits != number_to_be_inserted)
- {
- yaz_log(YLOG_WARN, "Unexpected hit count " ZINT_FORMAT
- "(should be %d)", hits, number_to_be_inserted);
- exit(1);
- }
-
- yaz_pqf_destroy(parser);
-
- odr_destroy(odr_input);
-
- YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK);
-
- for (j = 0; j < number_to_fetch; j++)
- retrievalRecord[j].position = j+1;
-
- ret = zebra_records_retrieve(zh, odr_output, setname, 0,
- yaz_oid_recsyn_xml, number_to_fetch,
- retrievalRecord);
- if (ret != ZEBRA_OK)
- {
- int code = zebra_errCode(zh);
- yaz_log(YLOG_FATAL, "zebra_records_retrieve returned error %d",
- code);
- exit(1);
- }
-
- for (j = 0; j < number_to_fetch; j++)
- {
- if (!retrievalRecord[j].buf)
- {
- yaz_log(YLOG_FATAL, "No record buf at position %d", j);
- exit(1);
- }
- if (!retrievalRecord[j].len)
- {
- yaz_log(YLOG_FATAL, "No record len at position %d", j);
- exit(1);
- }
- }
- odr_destroy(odr_output);
-
- YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
- }
- zebra_commit(zh);
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** \file
- \brief test various search attributes */
-#include <yaz/test.h>
-#include "testlib.h"
-
-const char *myrec[] = {
- "<gils>\n<title>My title</title>\n</gils>\n",
- "<gils>\n<title>My x title</title>\n</gils>\n",
- "<gils>\n<title>My title x</title>\n</gils>\n" ,
- 0} ;
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, myrec));
-
- /* simple term */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 notfound", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 3));
- tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
- "term 3 3: my\n"
- "term 3 3: title\n"
- "term 2 2: x\n");
-
- /* trunc right */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 titl", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 x", 2));
- tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
- "term 2 2: my\n"
- "term 2 2: title\n"
- "term 2 2: x\n");
-
- /* trunc left */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 le", 3));
-
- /* trunc left&right */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 titl", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 le", 3));
-
- /* trunc none */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 le", 0));
-
- /* trunc: process # in term */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 #le", 3));
-
- /* trunc: re-1 */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 .*le", 3));
-
- /* trunc: re-2 */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titl", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titlx", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titlxx", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 .*le", 3));
-
- /* trunc: CCL #=. ?=.* (?[0-9] = n times .) */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 tit#e", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?le", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?1le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?2le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?3le", 3));
-
- /* trunc: * = .* ! = . and right truncate */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 titl", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 tit!e", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 *le", 3));
-
- /* trunc: * = .* ! = . and do not truncate */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 titl", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 tit!e", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 le", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 *le", 3));
-
- /* string relations, < */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 0", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 0));
-
- /* string relations, <= */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 0));
-
- /* = */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=3 my", 3));
-
- /* string relations, >= */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 x", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 tu", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 title", 3));
-
- /* string relations, > */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 x", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 tu", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 title", 2));
-
- /* always-matches relation */
- YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 3));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));
-
- /* and searches */
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 notfound", 0));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 x", 2));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 my", 2));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 x", 2));
- YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 my", 3));
-
- /* or searches */
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 x", 2));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 notfound", 2));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 notfound", 0));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 x", 2));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 my", 3));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 x", 3));
- YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 my", 3));
-
- /* not searches */
- /* bug 619 */
- YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 x", 0));
- YAZ_CHECK(tl_query(zh, "@not @attr 1=4 x @attr 1=4 x", 0));
- YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 x", 1));
- YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 notfound", 3));
- YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 notfound", 0));
-
- /* phrase searches */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=1 {my x}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 {x my}", 0));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x title}", 1));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 {my title}", 2));
-
- /* and-list searches */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {x my}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my x}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my my}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {e x}", 0));
-
- /* or-list searches */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {x my}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my x}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my my}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {e x}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=106 {e x}", 2));
-
- /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 my x", 2));
-
- /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 x my", 0));
-
- /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 0 2 k 2 x my", 2));
-
- /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 3 k 2 my x", 1));
-
- /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
-
- /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=0 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=1 x", 0, 0));
- /* Non-indexed numeric use and unspecified in bib1.att */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 14=1 x", 0, 114));
- /* Non-indexed string use attribute */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=0 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=1 x", 0, 0));
-
- /* provoke unsupported use attribute */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=105 x", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=109 123", 0, 114));
- YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.840.10003.3.1 @attr 1=999 x",
- 0, 114));
- /* provoke unsupported attribute set */
- YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=1 x", 0, 121));
- YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=6 x", 0,
- 121));
- YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=105 x", 0,
- 121));
- YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=109 123",
- 0, 121));
-
- /* provoke unsupported relation */
- YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117));
- YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
-
- /* position , phrase searches */
- YAZ_CHECK(tl_query(zh, "@attr 3=1 title", 0));
- YAZ_CHECK(tl_query(zh, "@attr 3=1 my", 3));
-
- YAZ_CHECK(tl_query(zh, "@attr 3=1 {my title}", 2));
- YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {my title}", 2));
-
- YAZ_CHECK(tl_query(zh, "@attr 3=1 {title my}", 0));
- YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0));
-
- YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0));
-
- /* position , or-list */
- YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title my}", 3));
- YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title x}", 0));
-
- /* position, and-list */
- YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title my}", 0));
- YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title x}", 0));
- YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 my", 3));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t6.c Insert a number of randomly generated words */
-
-#include "testlib.h"
-
-static void tst(int argc, char **argv)
-{
- int i;
- ZebraService zs = tl_start_up("zebra6.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- srand(17);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
- zebra_init(zh);
- zebra_close(zh);
-
- for (i = 0; i<10; i++)
- {
- int l;
-
- zh = zebra_open (zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
-
- for (l = 0; l<100; l++)
- {
- char rec_buf[5120];
- int j;
- *rec_buf = '\0';
- strcat(rec_buf, "<gils><title>");
- if (i == 0)
- {
- sprintf(rec_buf + strlen(rec_buf), "aaa");
- }
- else
- {
- j = (rand() & 15) + 1;
- while (--j >= 0)
- {
- int c = 65 + (rand() & 15);
- sprintf(rec_buf + strlen(rec_buf), "%c", c);
- }
- }
- strcat(rec_buf, "</title><Control-Identifier>");
- j = rand() & 31;
- sprintf(rec_buf + strlen(rec_buf), "%d", j);
- strcat(rec_buf, "</Control-Identifier></gils>");
- zebra_add_record (zh, rec_buf, strlen(rec_buf));
- }
- YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
- zebra_close(zh);
- }
- zh = zebra_open(zs, 0);
- YAZ_CHECK(zh);
-
- YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
- zebra_set_resource(zh, "trunclimit", "2");
-
- /* check massive truncation: bug #281 */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 z", -1));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t7.c sorting */
-
-#include "testlib.h"
-#include <yaz/sortspec.h>
-
-const char *recs[] = {
- "<gils>\n"
- " <title>My title</title>\n"
- "</gils>\n",
- 0};
-
-static void tst(int argc, char **argv)
-{
- const char *setname1 = "set1";
- const char *setname2 = "set2";
- const char *setname3 = "set3";
- int status;
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open (zs, 0);
- ODR odr_input = odr_createmem (ODR_DECODE);
- ODR odr_output = odr_createmem (ODR_ENCODE);
- YAZ_PQF_Parser parser = yaz_pqf_create();
- Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
- Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <!");
- zint hits;
-
- YAZ_CHECK(tl_init_data(zh, recs));
-
- YAZ_CHECK(zebra_begin_trans(zh, 0) == ZEBRA_OK);
-
- YAZ_CHECK(zebra_search_RPN(zh, odr_input, query, setname1, &hits) ==
- ZEBRA_OK);
-
- YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
- &status)
- == ZEBRA_OK);
- YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname2, setname3, spec,
- &status) == ZEBRA_OK);
-
- spec = yaz_sort_spec(odr_output, "1=5 <!"); /* invalid sort spec */
-
- YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
- &status) == ZEBRA_FAIL);
-
- YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
-
- yaz_pqf_destroy(parser);
-
- /*
- zebra_deleteResultSet(zh, Z_DeleteRequest_list,
- 1, &setnamep, &status);
- */
- odr_destroy(odr_input);
- odr_destroy(odr_output);
-
- zebra_commit(zh);
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t8: test numeric attributes */
-
-#include "testlib.h"
-
-const char *recs[] = {
- "<gils>\n"
- " <title>My title</title>\n"
- " <abstract>test record with single coordset, negatives</abstract>\n"
- " <Spatial-Domain><Bounding-Coordinates>\n"
- " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
- " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
- " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
- " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
- " </Bounding-Coordinates></Spatial-Domain>"
- "</gils>\n",
-
- "<gils>\n"
- " <title>Another title</title>\n"
- " <abstract>second test with two coord sets</abstract>\n"
- " <Spatial-Domain><Bounding-Coordinates>\n"
- " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
- " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
- " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
- " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
- " </Bounding-Coordinates>"
- " <Bounding-Coordinates>\n"
- " <West-Bounding-Coordinate> -125 </West-Bounding-Coordinate>\n"
- " <East-Bounding-Coordinate> -108 </East-Bounding-Coordinate>\n"
- " <North-Bounding-Coordinate> 41 </North-Bounding-Coordinate>\n"
- " <South-Bounding-Coordinate> 25 </South-Bounding-Coordinate>\n"
- " </Bounding-Coordinates></Spatial-Domain>"
- "</gils>\n",
- 0};
-
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up("zebra8.cfg", argc, argv);
- ZebraHandle zh = zebra_open (zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, recs));
-
- /* couple of simple queries just to see that we have indexed the stuff */
- YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 2));
-
- /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
- /* 4=109: numeric string */
- /* 2=3: equal 2=1: less, 2=4: greater or equal 2=5 greater */
-
- /* N>=25, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 25", 2));
-
- /* N>49, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 49", 0));
-
- /* N>=49, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 49", 2));
-
- /* N>48, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 48", 2));
-
- /* N<48, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2040 @attr 4=109 48", 1));
-
- /* N<=48, search attributes work */
- YAZ_CHECK(tl_query(zh, "@attr 2=2 @attr gils 1=2040 @attr 4=109 48", 1));
-
- /* N=41, get rec1 only */
- YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 41", 1));
-
- /* N=49, get both records */
- YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 49", 2));
-
- /* W=-120 get both records */
- YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120", 2));
-
- /* W<-122 get only rec1 */
- YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ", 1));
-
- /* N=41 and N=49 get only rec2 */
- YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ", 1));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-/** t9.c - test rank-1 */
-
-#include "testlib.h"
-
-#include "rankingrecords.h"
-
-static void tst(int argc, char **argv)
-{
- ZebraService zs = tl_start_up(0, argc, argv);
- ZebraHandle zh = zebra_open(zs, 0);
-
- YAZ_CHECK(tl_init_data(zh, recs));
-
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=4 @attr 2=102 the",
- 3, "first title", 936 ));
-
- YAZ_CHECK(tl_ranking_query(zh, "@attr 1=62 @attr 2=102 foo",
- 3, "second title", 850 ));
-
- YAZ_CHECK(tl_close_down(zh, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** Create many databases */
+
+#include "testlib.h"
+
+static void tst(int argc, char **argv)
+{
+ int i;
+ int no_db = 140;
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+ YAZ_CHECK(zebra_init(zh) == ZEBRA_OK);
+ zebra_close(zh);
+
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
+
+ for (i = 0; i<no_db; i++)
+ {
+ char dbstr[20];
+ char rec_buf[100];
+
+ sprintf(dbstr, "%d", i);
+ YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK);
+
+ sprintf(rec_buf, "<gils><title>title %d</title></gils>\n", i);
+ zebra_add_record (zh, rec_buf, strlen(rec_buf));
+
+ }
+ YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
+
+ zebra_close(zh);
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+ for (i = 0; i<=no_db; i++)
+ {
+ char dbstr[20];
+ char querystr[50];
+ sprintf(dbstr, "%d", i);
+ YAZ_CHECK(zebra_select_database(zh, dbstr) == ZEBRA_OK);
+
+ sprintf(querystr, "@attr 1=4 %d", i);
+ if (i == no_db)
+ {
+ YAZ_CHECK(tl_query_x(zh, querystr, 0, 109));
+ }
+ else
+ {
+ YAZ_CHECK(tl_query(zh, querystr, 1));
+ }
+ }
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** \file
+ \brief tests ICU enabled maps
+*/
+#include <yaz/test.h>
+#include "testlib.h"
+
+/* utf-8 sequences for some characters */
+#define char_ae "\xc3\xa6"
+#define char_AE "\xc3\x86"
+
+#define char_oslash "\xc3\xb8"
+#define char_Oslash "\xc3\x98"
+
+#define char_aring "\xc3\xa5"
+#define char_Aring "\xc3\x85"
+
+#define char_comb_ring_above "\xcc\x8a"
+
+#define char_aring1 "a" char_comb_ring_above
+#define char_Aring1 "A" char_comb_ring_above
+
+const char *myrec[] = {
+ "<gils>\n<title>My computer</title>\n</gils>\n",
+ "<gils>\n<title>My x computer</title>\n</gils>\n",
+ "<gils>\n<title>My computer x</title>\n</gils>\n" ,
+ "<gils>\n<title>" char_ae "</title>\n</gils>\n" ,
+ "<gils>\n<title>B" char_aring "d</title>\n"
+ "<abstract>זיהוי סדר הארועים בסיפור המרד הגדול מאת צביה בן-שלום 提示:直接点击数据库名称,将进入单库检索 Ngày xửa ngày xưa D.W. all wet</abstract>\n</gils>\n" ,
+ 0} ;
+
+static void tst(int argc, char **argv)
+{
+#if YAZ_HAVE_ICU
+ ZebraService zs = tl_start_up("test_icu_indexing.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ /* simple term */
+ YAZ_CHECK(tl_query(zh, "@attr 1=title notfound", 0));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 5=1 comput", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title .computer.", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title x", 2));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title my", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=title mY", 3));
+
+ YAZ_CHECK(tl_query(zh, char_ae, 1));
+ YAZ_CHECK(tl_query(zh, char_AE, 1));
+
+ YAZ_CHECK(tl_query(zh, "b" char_aring "d", 1));
+ YAZ_CHECK(tl_query(zh, "B" char_Aring "D", 1));
+ YAZ_CHECK(tl_query(zh, "b" char_aring1 "d", 1));
+ YAZ_CHECK(tl_query(zh, "B" char_Aring1 "D", 1));
+
+ /* Abstract searches . Chinese mostly */
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract בן", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract צביה", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract הגדול", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract בסיפור", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract בסיפ", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract 点", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract wet", 1));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בסיפ", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 סיפ", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בסי", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 בס", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 ב", 1));
+
+ /* phrase search */
+ YAZ_CHECK(tl_query(zh, "@attr 1=title {my computer}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=1 {my computer}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title {computer x}", 1));
+
+ /* complete-subfield search */
+ YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my computer}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=2 {my}", 0));
+
+ /* always matches */
+ YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {}", 5));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 2=103 {}", 5));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {does not match}", 1));
+
+ /* scan */
+ { /* word search */
+ const char *ent[] = { char_ae, "B" char_aring "d", "computer",
+ "My", "x", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=title 0", 1, 10, 1, 5, 1, ent));
+ }
+
+ { /* word search */
+ const char *ent[] = { "My", "x", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=title cp", 1, 10, 1, 2, 1, ent));
+ }
+
+ { /* phrase search */
+ const char *ent[] = { char_ae, "B" char_aring "d", "My computer" };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=title @attr 6=2 0", 1, 3, 1, 3, 0, ent));
+ }
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+#endif
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+profilepath: ${srcdir:-.}:${srcdir:-.}/../../tab
+modulePath: ../../index/.libs
+
+attset: bib1.att
+attset: explain.att
+
+recordType: grs.xml
+
+index: test_icu_indexing.idx
+
+isam: b
+
+encoding: utf-8
+
--- /dev/null
+# Zebra indexes as referred to from the *.abs-files.
+#
+
+# Traditional word index
+# Used if completenss is 'incomplete field' (@attr 6=1) and
+# structure is word/phrase/word-list/free-form-text/document-text
+index w
+completeness 0
+position 1
+alwaysmatches 1
+firstinfield 1
+# simplechain dummy
+icuchain words-icu.xml
+debug 1
+
+# Phrase index
+# Used if completeness is 'complete {sub}field' (@attr 6=2, @attr 6=1)
+# and structure is word/phrase/word-list/free-form-text/document-text
+index p
+completeness 1
+icuchain phrases-icu.xml
+# debug 1
+
+# Sort register
+sort s
+completeness 1
+charmap string.chr
+
+# Staticrank (uncomment to enable)
+#staticrank r
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/* insert a small pile of records, search and fetch them */
+
+#include "testlib.h"
+
+const char *myrec[] = {
+ "<gils>\n"
+ " <title>My title</title>\n"
+ "</gils>\n",
+ 0};
+
+#define NUMBER_TO_FETCH_MAX 1000
+
+static void tst(int argc, char **argv)
+{
+ int i;
+ int number_to_be_inserted = 5;
+ int number_to_fetch = 5;
+
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
+
+ for (i = 0; i< number_to_be_inserted-1; i++)
+ { /* -1 since already inserted one in init_data */
+ zebra_add_record(zh, myrec[0], strlen(myrec[0]));
+ }
+ YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
+
+ zebra_close(zh);
+ zebra_stop(zs);
+
+ zs = tl_zebra_start("");
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+ zebra_set_resource(zh, "sortmax", "3"); /* make small sort boundary */
+
+ for (i = 0; i<2; i++)
+ {
+ ZEBRA_RES ret;
+ ZebraRetrievalRecord retrievalRecord[NUMBER_TO_FETCH_MAX];
+ char setname[20];
+ int j;
+ ODR odr_input = odr_createmem(ODR_DECODE);
+ ODR odr_output = odr_createmem(ODR_DECODE);
+ YAZ_PQF_Parser parser = yaz_pqf_create();
+ Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
+ zint hits;
+
+ sprintf(setname, "s%d", i+1);
+ ret = zebra_search_RPN(zh, odr_input, query, setname, &hits);
+ if (ret != ZEBRA_OK)
+ {
+ int code = zebra_errCode(zh);
+ yaz_log(YLOG_WARN, "Unexpected error code=%d", code);
+ exit(1);
+ }
+ if (hits != number_to_be_inserted)
+ {
+ yaz_log(YLOG_WARN, "Unexpected hit count " ZINT_FORMAT
+ "(should be %d)", hits, number_to_be_inserted);
+ exit(1);
+ }
+
+ yaz_pqf_destroy(parser);
+
+ odr_destroy(odr_input);
+
+ YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK);
+
+ for (j = 0; j < number_to_fetch; j++)
+ retrievalRecord[j].position = j+1;
+
+ ret = zebra_records_retrieve(zh, odr_output, setname, 0,
+ yaz_oid_recsyn_xml, number_to_fetch,
+ retrievalRecord);
+ if (ret != ZEBRA_OK)
+ {
+ int code = zebra_errCode(zh);
+ yaz_log(YLOG_FATAL, "zebra_records_retrieve returned error %d",
+ code);
+ exit(1);
+ }
+
+ for (j = 0; j < number_to_fetch; j++)
+ {
+ if (!retrievalRecord[j].buf)
+ {
+ yaz_log(YLOG_FATAL, "No record buf at position %d", j);
+ exit(1);
+ }
+ if (!retrievalRecord[j].len)
+ {
+ yaz_log(YLOG_FATAL, "No record len at position %d", j);
+ exit(1);
+ }
+ }
+ odr_destroy(odr_output);
+
+ YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
+ }
+ zebra_commit(zh);
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#include "testlib.h"
+
+const char *myrec[] ={
+ "<private_attset>\n"
+ " <title>My title</title>\n"
+ "</private_attset>\n",
+ 0};
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs = tl_start_up("test_private_attset.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ zebra_commit(zh);
+
+ // string attributes in search
+ YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=title titlex", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1));
+
+ // numeric attributes with Bib-1 should produce an error
+ YAZ_CHECK(tl_query_x(zh,
+ "@attr 1=4 my", 0, 121));
+ YAZ_CHECK(tl_query_x(zh,
+ "@attr 1=7 my", 0, 121));
+ // private OID with incorrect use attribute
+ YAZ_CHECK(tl_query_x(zh,
+ "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114));
+ // private OID with OK use attribute
+ YAZ_CHECK(tl_query(zh,
+ "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1));
+
+ YAZ_CHECK(tl_query(zh,
+ "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1));
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+profilepath: ${srcdir:-.}:${srcdir:-.}/../../tab
+
+attset: private_attset.att
+
+recordType: grs.sgml
+
+
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#include "testlib.h"
+
+const char *recs[] = {
+ "<gils>\n"
+ " <title>The first title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the the the \n"
+ " The second common word is word \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</gils>\n",
+
+ "<gils>\n"
+ " <title>The second title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the \n"
+ " The second common word is foo: foo foo \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</gils>\n",
+
+ "<gils>\n"
+ " <title>The third title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the \n"
+ " The third common word is bar: bar \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</gils>\n",
+
+ 0 };
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, recs));
+
+ YAZ_CHECK(tl_ranking_query(zh, "@attr 1=4 @attr 2=102 the",
+ 3, "first title", 936 ));
+
+ YAZ_CHECK(tl_ranking_query(zh, "@attr 1=62 @attr 2=102 foo",
+ 3, "second title", 850 ));
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** test resources */
+#include <stdlib.h>
+#include <string.h>
+#include "testlib.h"
+#include <idzebra/api.h>
+
+static void tst_res(void)
+{
+ Res default_res; /* default resources */
+ Res temp_res; /* temporary resources */
+ ZebraService zs;
+ ZebraHandle zh;
+ const char *val;
+ int i;
+
+ default_res = res_open(0, 0); /* completely empty */
+ YAZ_CHECK(default_res);
+
+ res_set(default_res, "name1", "value1");
+
+ temp_res = res_open(0, 0); /* completely empty */
+ YAZ_CHECK(temp_res);
+
+ zs = zebra_start_res(0, default_res, temp_res);
+ YAZ_CHECK(zs);
+
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+
+ /* run this a few times so we can see leaks easier */
+ for (i = 0; i<10; i++)
+ {
+ /* we should find the name1 from default_res */
+ val = zebra_get_resource(zh, "name1", 0);
+ YAZ_CHECK(val && !strcmp(val, "value1"));
+
+ /* make local override */
+ res_set(temp_res, "name1", "value2");
+ res_set(temp_res, "name4", "value4");
+
+ /* we should find the name1 from temp_res */
+ val = zebra_get_resource(zh, "name1", 0);
+ YAZ_CHECK(val && !strcmp(val, "value2"));
+
+ val = zebra_get_resource(zh, "name4", 0);
+ YAZ_CHECK(val && !strcmp(val, "value4"));
+
+ res_clear(temp_res);
+ }
+ zebra_close(zh);
+ zebra_stop(zs);
+
+ res_close(temp_res);
+ res_close(default_res);
+}
+
+static void tst_no_config(void)
+{
+ static char *xml_buf = "<gils><title>myx</title></gils>";
+ ZebraService zs;
+ ZebraHandle zh;
+ zint sysno = 0;
+
+ zs = zebra_start_res(0, 0, 0);
+ YAZ_CHECK(zs);
+
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(zebra_init(zh), ZEBRA_OK);
+
+ zebra_set_resource(zh, "profilePath", "${srcdir:-.}/../../tab");
+
+ YAZ_CHECK_EQ(zebra_update_record(zh /* handle */,
+ action_insert,
+ "grs.sgml" /* record type */,
+ &sysno, 0 /* match */,
+ 0 /* fname */,
+ xml_buf, strlen(xml_buf)),
+ ZEBRA_OK);
+
+ zebra_close(zh);
+ zebra_stop(zs);
+}
+
+static void tst(int argc, char **argv)
+{
+ tst_res();
+ tst_no_config();
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/* Creates a few result sets */
+
+#include "testlib.h"
+
+const char *myrec[] ={
+ "<gils>\n"
+ " <title>My title</title>\n"
+ "</gils>\n",
+ 0};
+
+static void tst(int argc, char **argv)
+{
+ int i;
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ for (i = 0; i<4; i++)
+ {
+ char setname[20];
+ char *setnamep = setname;
+ int status;
+ ODR odr_input = odr_createmem (ODR_DECODE);
+ ODR odr_output = odr_createmem (ODR_ENCODE);
+ YAZ_PQF_Parser parser = yaz_pqf_create();
+ Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input,
+ "@attr 1=4 my");
+ zint hits;
+ if (zebra_begin_trans (zh, 1) != ZEBRA_OK)
+ {
+ fprintf(stderr, "zebra_begin_trans failed\n");
+ exit(1);
+ }
+ if (zebra_begin_trans (zh, 0) != ZEBRA_OK)
+ {
+ fprintf(stderr, "zebra_begin_trans failed\n");
+ exit(1);
+ }
+
+ sprintf(setname, "s%d", i+1);
+ zebra_search_RPN (zh, odr_input, query, setname, &hits);
+
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ fprintf(stderr, "zebra_end_trans failed\n");
+ exit(1);
+ }
+ if (zebra_end_trans (zh) != ZEBRA_OK)
+ {
+ fprintf(stderr, "zebra_end_trans failed\n");
+ exit(1);
+ }
+ yaz_pqf_destroy(parser);
+ zebra_deleteResultSet(zh, Z_DeleteRequest_list,
+ 1, &setnamep, &status);
+ odr_destroy(odr_input);
+ odr_destroy(odr_output);
+ }
+ zebra_commit(zh);
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** testing of scan */
+#include "testlib.h"
+
+const char *myrec[] = {
+ "<gils>\n<title>a b</title>\n</gils>\n",
+ "<gils>\n<title>c d</title>\n</gils>\n",
+ "<gils>\n<title>e f</title>\n</gils>\n" ,
+ 0} ;
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ /*
+ int tl_scan
+ (
+ ZebraHandle zh, const char *query,
+ int pos, int num,
+ int exp_pos, int exp_num, int exp_partial,
+ const char **exp_entries
+ )
+ */
+
+
+ {
+ /* bad string use attrite, bug #647 */
+ YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0));
+ }
+
+ {
+ /* bad numeric use attributes, bug #647 */
+ YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0));
+ }
+
+ {
+ /* scan before. nothing must be returned */
+ const char *ent[] = { "a", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent));
+ }
+
+ {
+ /* scan after. nothing must be returned */
+ const char *ent[] = { 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "a", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "b", "c", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "b", "c", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "c", "d", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "d", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent));
+ }
+
+ {
+ const char *ent[] = { "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "b", "c", "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent));
+ }
+
+ {
+ const char *ent[] = { 0 };
+ YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent));
+ }
+
+ {
+ const char *ent[] = { "c", "d", 0 };
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1));
+
+ /* must fail, because x is not a result set */
+ YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0));
+
+ /* bug 1114 */
+ YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0",
+ 1, 20, 1, 2, 1, ent));
+
+ }
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** \file
+ \brief test various search attributes */
+#include <yaz/test.h>
+#include "testlib.h"
+
+const char *myrec[] = {
+ "<gils>\n<title>My title</title>\n"
+ " <abstract>test record with single coordset, negatives</abstract>\n"
+ " <Spatial-Domain><Bounding-Coordinates>\n"
+ " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
+ " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
+ " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
+ " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
+ " </Bounding-Coordinates></Spatial-Domain>"
+ "</gils>\n",
+ "<gils>\n<title>My x title</title>\n"
+ " <abstract>second test with two coord sets</abstract>\n"
+ " <Spatial-Domain><Bounding-Coordinates>\n"
+ " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
+ " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
+ " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
+ " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
+ " </Bounding-Coordinates>"
+ " <Bounding-Coordinates>\n"
+ " <West-Bounding-Coordinate> -125 </West-Bounding-Coordinate>\n"
+ " <East-Bounding-Coordinate> -108 </East-Bounding-Coordinate>\n"
+ " <North-Bounding-Coordinate> 41 </North-Bounding-Coordinate>\n"
+ " <South-Bounding-Coordinate> 25 </South-Bounding-Coordinate>\n"
+ " </Bounding-Coordinates></Spatial-Domain>"
+ "</gils>\n",
+ "<gils>\n<title>My title x</title>\n</gils>\n" ,
+ 0} ;
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ /* simple term */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 notfound", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 3));
+ tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
+ "term 3 3: my\n"
+ "term 3 3: title\n"
+ "term 2 2: x\n");
+
+ /* trunc right */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 titl", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 x", 2));
+ tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs,
+ "term 2 2: my\n"
+ "term 2 2: title\n"
+ "term 2 2: x\n");
+
+ /* trunc left */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 le", 3));
+
+ /* trunc left&right */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 titl", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=3 le", 3));
+
+ /* trunc none */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=100 le", 0));
+
+ /* trunc: process # in term */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=101 #le", 3));
+
+ /* trunc: re-1 */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 .*le", 3));
+
+ /* trunc: re-2 */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titl", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titlx", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 titlxx", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 .*le", 3));
+
+ /* trunc: CCL #=. ?=.* (?[0-9] = n times .) */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 tit#e", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?le", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?1le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?2le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 ?3le", 3));
+
+ /* trunc: * = .* ! = . and right truncate */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 titl", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 tit!e", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=105 *le", 3));
+
+ /* trunc: * = .* ! = . and do not truncate */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 titl", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 tit!e", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 le", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=106 *le", 3));
+
+ /* string relations, < */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 0", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 my", 0));
+
+ /* string relations, <= */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 my", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=2 mn", 0));
+
+ /* = */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=3 my", 3));
+
+ /* string relations, >= */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 x", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 tu", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 title", 3));
+
+ /* string relations, > */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 x", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 tu", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 title", 2));
+
+ /* always-matches relation */
+ YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 3));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114));
+
+ /* and searches */
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 notfound", 0));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 x", 2));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 my", 2));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 x", 2));
+ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 my", 3));
+
+ /* or searches */
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 x", 2));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 notfound", 2));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 notfound", 0));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 x", 2));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 my", 3));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 x", 3));
+ YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 my", 3));
+
+ /* not searches */
+ /* bug 619 */
+ YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 x", 0));
+ YAZ_CHECK(tl_query(zh, "@not @attr 1=4 x @attr 1=4 x", 0));
+ YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 x", 1));
+ YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 notfound", 3));
+ YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 notfound", 0));
+
+ /* phrase searches */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=1 {my x}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 {x my}", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x title}", 1));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 {my title}", 2));
+
+ /* and-list searches */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {x my}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my x}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {my my}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=6 {e x}", 0));
+
+ /* or-list searches */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {x my}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my x}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {my my}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=105 {e x}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=106 {e x}", 2));
+
+ /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 my x", 2));
+
+ /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 x my", 0));
+
+ /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 0 2 k 2 x my", 2));
+
+ /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 3 k 2 my x", 1));
+
+ /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
+
+ /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=0 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=1 x", 0, 0));
+ /* Non-indexed numeric use and unspecified in bib1.att */
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 14=1 x", 0, 114));
+ /* Non-indexed string use attribute */
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=0 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=1 x", 0, 0));
+
+ /* provoke unsupported use attribute */
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=105 x", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=109 123", 0, 114));
+ YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.840.10003.3.1 @attr 1=999 x",
+ 0, 114));
+ /* provoke unsupported attribute set */
+ YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=1 x", 0, 121));
+ YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=6 x", 0,
+ 121));
+ YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=105 x", 0,
+ 121));
+ YAZ_CHECK(tl_query_x(zh, "@attrset 1.2.8 @attr 1=999 @attr 4=109 123",
+ 0, 121));
+
+ /* provoke unsupported relation */
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117));
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
+
+ /* position , phrase searches */
+ YAZ_CHECK(tl_query(zh, "@attr 3=1 title", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 3=1 my", 3));
+
+ YAZ_CHECK(tl_query(zh, "@attr 3=1 {my title}", 2));
+ YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {my title}", 2));
+
+ YAZ_CHECK(tl_query(zh, "@attr 3=1 {title my}", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0));
+
+ YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0));
+
+ /* position , or-list */
+ YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title my}", 3));
+ YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title x}", 0));
+
+ /* position, and-list */
+ YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title my}", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title x}", 0));
+ YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 my", 3));
+
+
+ /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
+ /* 4=109: numeric string */
+ /* 2=3: equal 2=1: less, 2=4: greater or equal 2=5 greater */
+
+ /* N>=25, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 25", 2));
+
+ /* N>49, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 49", 0));
+
+ /* N>=49, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 49", 2));
+
+ /* N>48, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 48", 2));
+
+ /* N<48, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2040 @attr 4=109 48", 1));
+
+ /* N<=48, search attributes work */
+ YAZ_CHECK(tl_query(zh, "@attr 2=2 @attr gils 1=2040 @attr 4=109 48", 1));
+
+ /* N=41, get rec1 only */
+ YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 41", 1));
+
+ /* N=49, get both records */
+ YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 49", 2));
+
+ /* W=-120 get both records */
+ YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120", 2));
+
+ /* W<-122 get only rec1 */
+ YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ", 1));
+
+ /* N=41 and N=49 get only rec2 */
+ YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ", 1));
+
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#include "testlib.h"
+#include <yaz/sortspec.h>
+
+const char *recs[] = {
+ "<gils>\n"
+ " <title>My title</title>\n"
+ "</gils>\n",
+ 0};
+
+static void tst(int argc, char **argv)
+{
+ const char *setname1 = "set1";
+ const char *setname2 = "set2";
+ const char *setname3 = "set3";
+ int status;
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open (zs, 0);
+ ODR odr_input = odr_createmem (ODR_DECODE);
+ ODR odr_output = odr_createmem (ODR_ENCODE);
+ YAZ_PQF_Parser parser = yaz_pqf_create();
+ Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
+ Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <!");
+ zint hits;
+
+ YAZ_CHECK(tl_init_data(zh, recs));
+
+ YAZ_CHECK(zebra_begin_trans(zh, 0) == ZEBRA_OK);
+
+ YAZ_CHECK(zebra_search_RPN(zh, odr_input, query, setname1, &hits) ==
+ ZEBRA_OK);
+
+ YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
+ &status)
+ == ZEBRA_OK);
+ YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname2, setname3, spec,
+ &status) == ZEBRA_OK);
+
+ spec = yaz_sort_spec(odr_output, "1=5 <!"); /* invalid sort spec */
+
+ YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
+ &status) == ZEBRA_FAIL);
+
+ YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
+
+ yaz_pqf_destroy(parser);
+
+ /*
+ zebra_deleteResultSet(zh, Z_DeleteRequest_list,
+ 1, &setnamep, &status);
+ */
+ odr_destroy(odr_input);
+ odr_destroy(odr_output);
+
+ zebra_commit(zh);
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/** \brief test special element set names zebra:: and friends */
+
+#include "testlib.h"
+
+const char *myrec[] = {
+ "<gils>\n"
+ " <title>My title</title>\n"
+ "</gils>\n",
+ 0};
+
+static void tst(int argc, char **argv)
+{
+ zint hits;
+ ZEBRA_RES res;
+ const char * zebra_xml_sysno
+ = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\"/>\n";
+
+ const char * zebra_xml_meta
+ = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" base=\"Default\" type=\"grs.sgml\" rank=\"0\" size=\"41\" set=\"zebra::meta\"/>\n";
+
+ const char * zebra_xml_index_title_p
+ = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" set=\"zebra::index::title:p/\">\n"
+" <index name=\"title\" type=\"p\" seq=\"4\">my title</index>\n"
+"</record>\n";
+
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(tl_init_data(zh, myrec));
+
+ res = zebra_search_PQF(zh, "@attr 1=4 my", "rsetname", &hits);
+ YAZ_CHECK_EQ(res, ZEBRA_OK);
+ YAZ_CHECK_EQ(hits, 1);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
+ "mismatch"), ZEBRA_FAIL);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_sutrs,
+ myrec[0]), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
+ myrec[0]), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
+ yaz_oid_recsyn_sutrs,
+ "2"), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
+ yaz_oid_recsyn_xml,
+ zebra_xml_sysno), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta", yaz_oid_recsyn_xml,
+ zebra_xml_meta), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:p",
+ yaz_oid_recsyn_xml,
+ zebra_xml_index_title_p), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::nonexistent",
+ yaz_oid_recsyn_xml, ""), ZEBRA_OK);
+
+ YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::nonexistent",
+ yaz_oid_recsyn_xml, ""), ZEBRA_OK);
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#include <yaz/test.h>
+#include "testlib.h"
+
+static void tst(int argc, char **argv)
+{
+ YAZ_CHECK(!zebra_start("xxxxpoiasdfasfd.cfg")); /* should fail */
+
+ {
+ ZebraService zs = tl_start_up(0, argc, argv);
+ ZebraHandle zh = 0;
+ YAZ_CHECK(zs);
+
+ if (zs)
+ {
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+ }
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+ }
+}
+
+TL_MAIN
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+/* Insert a number of randomly generated words and truncate */
+
+#include "testlib.h"
+
+static void tst(int argc, char **argv)
+{
+ int i;
+ ZebraService zs = tl_start_up("test_trunc.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ srand(17);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+ zebra_init(zh);
+ zebra_close(zh);
+
+ for (i = 0; i<10; i++)
+ {
+ int l;
+
+ zh = zebra_open (zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+
+ YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK);
+
+ for (l = 0; l<100; l++)
+ {
+ char rec_buf[5120];
+ int j;
+ *rec_buf = '\0';
+ strcat(rec_buf, "<gils><title>");
+ if (i == 0)
+ {
+ sprintf(rec_buf + strlen(rec_buf), "aaa");
+ }
+ else
+ {
+ j = (rand() & 15) + 1;
+ while (--j >= 0)
+ {
+ int c = 65 + (rand() & 15);
+ sprintf(rec_buf + strlen(rec_buf), "%c", c);
+ }
+ }
+ strcat(rec_buf, "</title><Control-Identifier>");
+ j = rand() & 31;
+ sprintf(rec_buf + strlen(rec_buf), "%d", j);
+ strcat(rec_buf, "</Control-Identifier></gils>");
+ zebra_add_record (zh, rec_buf, strlen(rec_buf));
+ }
+ YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
+ zebra_close(zh);
+ }
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+
+ zebra_set_resource(zh, "trunclimit", "2");
+
+ /* check massive truncation: bug #281 */
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=1 z", -1));
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+profilepath: ${srcdir:-.}/../../tab
+
+attset: bib1.att
+
+recordType: grs.sgml
+
+isam: b
+
+recordId: (bib1,identifier-standard)
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#include "testlib.h"
+
+static void create_search_drop(ZebraHandle zh)
+{
+ const char *rec = "<gils><title>some</title></gils>";
+ const char *opaque_id = "9";
+
+ YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
+
+ /* bug #447 */
+ YAZ_CHECK(zebra_update_record(
+ zh, action_update,
+ 0 /* record type */,
+ 0 /* sysno */,
+ opaque_id,
+ 0 /* fname */,
+ rec, strlen(rec))
+ == ZEBRA_OK); /* insert really */
+
+ YAZ_CHECK(zebra_update_record(
+ zh, action_update,
+ 0 /* record type */,
+ 0 /* sysno */,
+ opaque_id,
+ 0 /* fname */,
+ rec, strlen(rec))
+ == ZEBRA_OK); /* replace really */
+
+ YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1));
+
+ zebra_drop_database(zh, "Default");
+
+ YAZ_CHECK(tl_query_x(zh, "@attr 1=4 some", 0, 109));
+
+}
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs = tl_start_up("zebra.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs, 0);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+
+ zebra_init(zh);
+
+ create_search_drop(zh);
+ /* bug #447 */
+ create_search_drop(zh);
+
+ YAZ_CHECK(tl_close_down(zh, zs));
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+#if HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
+#include <string.h>
+
+#include "testlib.h"
+
+static void update_process(ZebraService zs, int iter)
+{
+ int i;
+ for (i = 0; i<iter; i++)
+ {
+ const char *rec = "<gils><title>some</title></gils>";
+ ZebraHandle zh = zebra_open(zs, 0);
+ zebra_add_record(zh, rec, strlen(rec));
+ if ((i % 30) == 0 || i == iter-1)
+ zebra_commit(zh);
+ zebra_close(zh);
+ }
+}
+
+static void search_process(ZebraService zs, int iter)
+{
+ zint hits_max = 0;
+ int i;
+ for (i = 0; i<iter; i++)
+ {
+ ZebraHandle zh = zebra_open(zs, 0);
+ zint hits;
+ ZEBRA_RES res = zebra_search_PQF(zh, "@attr 1=4 some", "default",
+ &hits);
+ YAZ_CHECK(res == ZEBRA_OK);
+
+ YAZ_CHECK(hits >= hits_max);
+ if (hits < hits_max)
+ printf("i=%d hits=%lld hits_max=%lld\n", i, hits, hits_max);
+ hits_max = hits;
+ zebra_close(zh);
+ }
+}
+
+static pid_t fork_service(ZebraService zs, int iter,
+ void (*f)(ZebraService zs, int iter))
+{
+ pid_t pid = fork();
+
+ YAZ_CHECK(pid != -1);
+ if (pid)
+ return pid;
+
+ (*f)(zs, iter);
+ YAZ_CHECK_TERM;
+}
+
+static void tst(int argc, char **argv)
+{
+ ZebraService zs;
+ ZebraHandle zh;
+
+ mkdir("register", 0775);
+ mkdir("shadow", 0775);
+
+ zs = tl_start_up("test_zebra_fork.cfg", argc, argv);
+ YAZ_CHECK(zs);
+
+ zh = zebra_open(zs, 0);
+ YAZ_CHECK(zh);
+
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+
+ zebra_init(zh);
+
+ YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
+ YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
+ zebra_close(zh);
+
+ update_process(zs, 1);
+
+#if HAVE_SYS_WAIT_H
+#if HAVE_UNISTD_H
+#if HAVE_SYS_UTSNAME_H
+
+ if (1)
+ {
+ int tst_with_fork = 1;
+ int status[3];
+ pid_t pids[3];
+ struct utsname s;
+ uname(&s);
+ if (!strcmp(s.sysname, "FreeBSD"))
+ tst_with_fork = 0;
+
+ yaz_log(YLOG_LOG, "s.sysname=%s tst_with_fork=%d", s.sysname,
+ tst_with_fork);
+ if (tst_with_fork)
+ {
+ pids[0] = fork_service(zs, 200, search_process);
+ pids[1] = fork_service(zs, 20, update_process);
+ pids[2] = fork_service(zs, 20, update_process);
+ waitpid(pids[0], &status[0], 0);
+ YAZ_CHECK(status[0] == 0);
+ waitpid(pids[1], &status[1], 0);
+ YAZ_CHECK(status[1] == 0);
+ waitpid(pids[2], &status[2], 0);
+ YAZ_CHECK(status[2] == 0);
+ }
+ }
+#endif
+#endif
+#endif
+ YAZ_CHECK(tl_close_down(0, zs));
+}
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+profilepath: ${srcdir:-.}/../../tab
+
+attset: bib1.att
+
+recordType: grs.sgml
+
+isam: b
+
+register: register:100M
+shadow: shadow:100M
profilepath: ${srcdir:-.}/../../tab
attset: bib1.att
+attset: gils.att
attset: explain.att
recordType: grs.sgml
+++ /dev/null
-profilepath: ${srcdir:-.}:${srcdir:-.}/../../tab
-
-attset: t10.att
-
-recordType: grs.sgml
-
-
-
+++ /dev/null
-profilepath: ${srcdir:-.}/../../tab
-
-attset: bib1.att
-
-recordType: grs.sgml
-
-isam: b
-
-register: register:100M
-shadow: shadow:100M
+++ /dev/null
-profilepath: ${srcdir:-.}:${srcdir:-.}/../../tab
-modulePath: ../../index/.libs
-
-attset: bib1.att
-attset: explain.att
-
-recordType: grs.xml
-
-index: t17.idx
-
-isam: b
-
-encoding: utf-8
-
+++ /dev/null
-profilepath: ${srcdir:-.}/../../tab
-
-attset: bib1.att
-
-recordType: grs.sgml
-
-isam: b
-
-recordId: (bib1,identifier-standard)
+++ /dev/null
-profilepath: ${srcdir:-.}/../../tab
-
-attset: bib1.att
-attset: gils.att
-
-recordType: grs.sgml
-
-isam: b
-