Allow same document to be modified multiple times within one transaction.
[idzebra-moved-to-github.git] / test / api / safari1.c
1 /* $Id: safari1.c,v 1.7 2005-09-16 09:58:39 adam Exp $
2    Copyright (C) 1995-2005
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra.  If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 */
22
23 /* safari1 - insert a few Safari records */
24
25 #include "testlib.h"
26
27 const char *myrec[] = 
28 {
29     "1234\n"  /* first record */
30     "00024338 125060 1 any the\n"
31     "00024338 125060 2 any art\n"
32     "00024338 125060 3 any mand\n",
33
34     "5678\n"  /* other record - same owner id */
35     "00024339 125060 1 any den\n"
36     "00024339 125060 2 any gamle\n"
37     "00024339 125060 3 any mand\n",
38
39     "5678\n"  /* same record chunk id as before .. */
40     "00024339 125060 1 any the\n"
41     "00024339 125060 2 any gamle\n"
42     "00024339 125060 3 any mand\n",
43
44     "1000\n"  /* separate record */
45     "00024339 125061 1 any the\n"
46     "00024339 125061 2 any gamle\n"
47     "00024339 125061 3 any mand\n",
48     
49     "1001\n"  /* separate record */
50     "00024340 125062 1 any the\n"
51     "00024340 125062 2 any old\n"
52     "00024340 125062 3 any mand\n",
53     
54     0
55 };
56
57 int main(int argc, char **argv)
58 {
59     zint ids[3];
60     zint limits[3];
61     ZebraService zs = start_up("safari.cfg", argc, argv);
62     
63     ZebraHandle zh = zebra_open(zs, 0);
64
65     init_data(zh, myrec);
66     do_query(__LINE__, zh, "@attr 1=any the", 3);
67     do_query(__LINE__, zh, "@attr 1=any {the art}", 1);
68     do_query(__LINE__, zh, "@attr 1=any {den gamle}", 0);
69     do_query(__LINE__, zh, "@attr 1=any {the gamle}", 1);
70     do_query(__LINE__, zh, "@attr 1=any {the of}", 0);
71
72     /* verify that we get these records exactly */
73     ids[0] = 24338;
74     ids[1] = 24339;
75     ids[2] = 24340;
76     meta_query(__LINE__, zh, "@attr 1=any mand", 3, ids);
77
78     /* limit to 125061 */
79     limits[0] = 125061;
80     limits[1] = 0;
81     zebra_set_limit(zh, 0, limits);
82     ids[0] = 24339;
83     meta_query(__LINE__, zh, "@attr 1=any mand", 1, ids);
84
85     /* limit to 125060, 125061 */
86     limits[0] = 125061;
87     limits[1] = 125060;
88     limits[2] = 0;
89     zebra_set_limit(zh, 0, limits);
90     ids[0] = 24338;
91     ids[1] = 24339;
92     meta_query(__LINE__, zh, "@attr 1=any mand", 2, ids);
93
94     /* all except 125062 */
95     limits[0] = 125062;
96     limits[1] = 0;
97     zebra_set_limit(zh, 1, limits);
98
99     ids[0] = 24338;
100     ids[1] = 24339;
101     meta_query(__LINE__, zh, "@attr 1=any mand", 2, ids);
102
103     /* no limit */
104     zebra_set_limit(zh, 1, 0);
105     do_query(__LINE__, zh, "@attr 1=any mand", 3);
106
107     return close_down(zh, zs, 0);
108 }