Debian Codegraph @

lib/proc/proc_in_records.c

raw symbols SCIP
1 /*
2 Copyright (C) 2017-2018 Brazil
3 Copyright (C) 2022 Sutou Kouhei <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "../grn_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/
21 #include "../grn_db.h"cxx . . $ `<file>/lib/grn_db.h`/
22 #include "../grn_expr.h"cxx . . $ `<file>/lib/grn_expr.h`/
23 #include "../grn_store.h"cxx . . $ `<file>/lib/grn_store.h`/
24
25 #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/
26
27 typedef structcxx . . $ $anonymous_type_91fe39e54d12f787_0# {
28 size_t n_conditionscxx . . $ $anonymous_type_91fe39e54d12f787_0#n_conditions.;
29 grn_objcxx . . $ grn_obj# *condition_tablecxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_table.;
30 grn_objcxx . . $ grn_obj# condition_columnscxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_columns.;
31 grn_operatorcxx . . $ grn_operator# *condition_modescxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_modes.;
32 grn_objcxx . . $ grn_obj# *search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result.;
33 } grn_in_records_datacxx . . $ grn_in_records_data#;
34
35 static void
36 grn_in_records_data_freecxx . . $ grn_in_records_data_free(d928bb3ad27c79d5).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_in_records_datacxx . . $ grn_in_records_data# *data)
37 {
38 size_t i;
39 size_t n_condition_columns;
40
41 if (!data) {
42 return;
43 }
44
45 GRN_PLUGIN_FREEcxx . . $ `include/groonga/plugin.h:100:9`!(ctx, data->condition_modes);
46
47 n_condition_columns =
48 GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(&(data->condition_columns)) / sizeof(grn_objcxx . . $ grn_obj# *);
49 for (i = 0; i < n_condition_columns; i++) {
50 grn_objcxx . . $ grn_obj# *condition_column;
51 condition_column = GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&(data->condition_columns), i);
52 if (condition_column && condition_column->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. == GRN_ACCESSORcxx . . $ `include/groonga/groonga.h:880:9`!) {
53 grn_obj_unlinkcxx . . $ grn_obj_unlink(4865d068a46d0f83).(ctx, condition_column);
54 }
55 }
56 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(data->condition_columns));
57
58 if (data->search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result.) {
59 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, data->search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result.);
60 }
61
62 GRN_PLUGIN_FREEcxx . . $ `include/groonga/plugin.h:100:9`!(ctx, data);
63 }
64
65 static grn_objcxx . . $ grn_obj# *
66 func_in_records_initcxx . . $ func_in_records_init(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
67 int n_args,
68 grn_objcxx . . $ grn_obj# **args,
69 grn_user_datacxx . . $ grn_user_data# *user_data)
70 {
71 grn_in_records_datacxx . . $ grn_in_records_data# *data;
72 grn_objcxx . . $ grn_obj# *condition_table;
73 grn_expr_codecxx . . $ grn_expr_code# *codes;
74 size_t n_arg_codes;
75 size_t n_logical_args;
76 size_t n_conditions;
77 size_t i;
78 size_t nth;
79
80 {
81 grn_objcxx . . $ grn_obj# *caller;
82 grn_exprcxx . . $ grn_expr# *expr;
83 grn_expr_codecxx . . $ grn_expr_code# *call_code;
84
85 caller = grn_plugin_proc_get_callercxx . . $ grn_plugin_proc_get_caller(409051005bdbf179).(ctx, user_data);
86 expr = (grn_exprcxx . . $ grn_expr# *)caller;
87 call_code = expr->codescxx . . $ _grn_expr#codes. + expr->codes_currcxx . . $ _grn_expr#codes_curr. - 1;
88 n_logical_args = (size_t)(call_code->nargscxx . . $ $anonymous_type_640a68f6a3c9e981_0#nargs. - 1);
89 codes = expr->codescxx . . $ _grn_expr#codes. + 1;
90 n_arg_codes = expr->codes_currcxx . . $ _grn_expr#codes_curr. - 2;
91 }
92
93 if (n_logical_args < 4) {
94 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT,
95 "in_records(): wrong number of arguments "
96 "(%" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! " for 4..)",
97 n_logical_args);
98 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
99 }
100
101 if ((n_logical_args % 3) != 1) {
102 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, GRN_INVALID_ARGUMENT,
103 "in_records(): the number of arguments "
104 "must be 1 + 3n (%" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! ")",
105 n_logical_args);
106 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
107 }
108
109 n_conditions = (size_t)((n_logical_args - 1) / 3);
110
111 condition_table = codes[0].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.;
112 if (!grn_obj_is_tablecxx . . $ grn_obj_is_table(a5760e5c319a06ee).(ctx, condition_table)) {
113 grn_objcxx . . $ grn_obj# inspected;
114 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
115 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
116 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
117 GRN_INVALID_ARGUMENT,
118 "in_records(): the first argument must be a table: <%.*s>",
119 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
120 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
121 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
122 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
123 }
124
125 data = GRN_PLUGIN_CALLOCcxx . . $ `include/groonga/plugin.h:96:9`!(ctx, sizeof(grn_in_records_data));
126 if (!data) {
127 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
128 GRN_INVALID_ARGUMENT,
129 "in_records(): failed to allocate internal data");
130 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
131 }
132 user_data->ptrcxx . . $ $anonymous_type_1555d7cc1d218aa4_5#ptr. = data;
133
134 data->n_conditionscxx . . $ $anonymous_type_91fe39e54d12f787_0#n_conditions. = n_conditions;
135 data->condition_tablecxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_table. = condition_table;
136 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&(data->condition_columns), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
137 data->condition_modescxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_modes. = GRN_PLUGIN_MALLOCNcxx . . $ `include/groonga/plugin.h:90:9`!(ctx, grn_operator, n_conditions);
138 if (!data->condition_modescxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_modes.) {
139 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
140 GRN_INVALID_ARGUMENT,
141 "in_records(): "
142 "failed to allocate internal data for condition modes");
143 goto exit;
144 }
145
146 for (i = 1, nth = 0; i < n_arg_codes; nth++) {
147 int value_i = (int)i;
148 int mode_name_i;
149 grn_objcxx . . $ grn_obj# *mode_name;
150 int column_name_i;
151 grn_objcxx . . $ grn_obj# *column_name;
152 grn_objcxx . . $ grn_obj# *condition_column;
153
154 value_i += codes[value_i].modifycxx . . $ $anonymous_type_640a68f6a3c9e981_0#modify.;
155
156 mode_name_i = value_i + 1;
157 mode_name = codes[mode_name_i].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.;
158 data->condition_modescxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_modes.[nth] = grn_proc_get_value_modecxx . . $ grn_proc_get_value_mode(db52f52f4dd070c1).(ctx,
159 mode_name,
160 GRN_OP_EQUALcxx . . $ GRN_OP_EQUAL.,
161 "in_records()");
162 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
163 goto exit;
164 }
165
166 column_name_i = mode_name_i + 1;
167 column_name = codes[column_name_i].valuecxx . . $ $anonymous_type_640a68f6a3c9e981_0#value.;
168 if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, column_name)) {
169 grn_objcxx . . $ grn_obj# inspected;
170 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
171 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
172 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
173 GRN_INVALID_ARGUMENT,
174 "in_records(): "
175 "the %dth argument must be column name as string: "
176 "<%.*s>",
177 column_name_i,
178 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
179 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
180 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
181 goto exit;
182 }
183
184 condition_column = grn_obj_columncxx . . $ grn_obj_column(c00e49795c44129a).(ctx, condition_table,
185 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(column_name),
186 (uint32_tcxx . . $ uint32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(column_name));
187 if (!condition_column) {
188 grn_objcxx . . $ grn_obj# inspected;
189 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
190 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
191 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
192 GRN_INVALID_ARGUMENT,
193 "in_records(): "
194 "the %dth argument must be existing column name: "
195 "<%.*s>: <%.*s>",
196 column_name_i,
197 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(column_name),
198 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(column_name),
199 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
200 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
201 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
202 goto exit;
203 }
204 GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &(data->condition_columns), condition_column);
205
206 i = (size_t)(column_name_i + 1);
207 }
208
209 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
210
211 exit :
212 grn_in_records_data_freecxx . . $ grn_in_records_data_free(d928bb3ad27c79d5).(ctx, data);
213
214 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
215 }
216
217 static grn_objcxx . . $ grn_obj# *
218 func_in_records_nextcxx . . $ func_in_records_next(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
219 int n_args,
220 grn_objcxx . . $ grn_obj# **args,
221 grn_user_datacxx . . $ grn_user_data# *user_data)
222 {
223 grn_in_records_datacxx . . $ grn_in_records_data# *data = user_data->ptrcxx . . $ $anonymous_type_1555d7cc1d218aa4_5#ptr.;
224 grn_objcxx . . $ grn_obj# *found;
225 grn_objcxx . . $ grn_obj# *condition;
226 grn_objcxx . . $ grn_obj# *variable;
227 int i;
228
229 found = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_BOOLcxx . . $ GRN_DB_BOOL., 0);
230 if (!found) {
231 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
232 }
233 GRN_BOOL_SETcxx . . $ `include/groonga/groonga.h:2879:9`!(ctx, found, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!);
234
235 if (!data) {
236 return found;
237 }
238
239 GRN_EXPR_CREATE_FOR_QUERYcxx . . $ `include/groonga/expr.h:216:9`!(ctx,
240 data->condition_table,
241 condition,
242 variable);
243 if (!condition) {
244 grn_rccxx . . $ grn_rc# rc = ctx->rccxx . . $ _grn_ctx#rc.;
245 if (rc == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
246 rc = GRN_NO_MEMORY_AVAILABLEcxx . . $ GRN_NO_MEMORY_AVAILABLE.;
247 }
248 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
249 rc,
250 "in_records(): "
251 "failed to create internal expression: %s",
252 ctx->errbuf);
253 return found;
254 }
255
256 for (i = 1; i < n_args; i += 3) {
257 int nth = (i - 1) / 3;
258 grn_objcxx . . $ grn_obj# *value = args[i];
259 grn_objcxx . . $ grn_obj# *condition_column;
260 grn_operatorcxx . . $ grn_operator# condition_mode;
261
262 condition_column = GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&(data->condition_columns), nth);
263 condition_mode = data->condition_modescxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_modes.[nth];
264
265 switch (condition_mode) {
266 case GRN_OP_EQUALcxx . . $ GRN_OP_EQUAL. :
267 case GRN_OP_NOT_EQUALcxx . . $ GRN_OP_NOT_EQUAL. :
268 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
269 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
270 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, condition_mode, 2);
271 break;
272 case GRN_OP_LESScxx . . $ GRN_OP_LESS. :
273 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
274 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
275 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, GRN_OP_GREATER_EQUALcxx . . $ GRN_OP_GREATER_EQUAL., 2);
276 break;
277 case GRN_OP_GREATERcxx . . $ GRN_OP_GREATER. :
278 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
279 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
280 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, GRN_OP_LESS_EQUALcxx . . $ GRN_OP_LESS_EQUAL., 2);
281 break;
282 case GRN_OP_LESS_EQUALcxx . . $ GRN_OP_LESS_EQUAL. :
283 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
284 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
285 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, GRN_OP_GREATERcxx . . $ GRN_OP_GREATER., 2);
286 break;
287 case GRN_OP_GREATER_EQUALcxx . . $ GRN_OP_GREATER_EQUAL. :
288 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
289 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
290 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, GRN_OP_LESScxx . . $ GRN_OP_LESS., 2);
291 break;
292 default :
293 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
294 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, condition, condition_column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
295 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, condition_mode, 2);
296 break;
297 }
298
299 if (nth > 0) {
300 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, condition, GRN_OP_ANDcxx . . $ GRN_OP_AND., 2);
301 }
302 }
303
304 data->search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result. = grn_table_selectcxx . . $ grn_table_select(fec47fdf91015e61).(ctx,
305 data->condition_tablecxx . . $ $anonymous_type_91fe39e54d12f787_0#condition_table.,
306 condition,
307 data->search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result.,
308 GRN_OP_ORcxx . . $ GRN_OP_OR.);
309 if (grn_table_sizecxx . . $ grn_table_size(8dd58acc9865e889).(ctx, data->search_resultcxx . . $ $anonymous_type_91fe39e54d12f787_0#search_result.) > 0) {
310 GRN_BOOL_SETcxx . . $ `include/groonga/groonga.h:2879:9`!(ctx, found, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
311
312 GRN_TABLE_EACH_BEGINcxx . . $ `include/groonga/table.h:614:9`!(ctx, data->search_result, cursor, id) {
313 grn_table_cursor_deletecxx . . $ grn_table_cursor_delete(4865d068a46d0f83).(ctx, cursor);
314 } GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor);
315 }
316
317 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, condition);
318
319 return found;
320 }
321
322 static grn_objcxx . . $ grn_obj# *
323 func_in_records_fincxx . . $ func_in_records_fin(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
324 int n_args,
325 grn_objcxx . . $ grn_obj# **args,
326 grn_user_datacxx . . $ grn_user_data# *user_data)
327 {
328 grn_in_records_datacxx . . $ grn_in_records_data# *data = user_data->ptrcxx . . $ $anonymous_type_1555d7cc1d218aa4_5#ptr.;
329
330 grn_in_records_data_freecxx . . $ grn_in_records_data_free(d928bb3ad27c79d5).(ctx, data);
331
332 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
333 }
334
335 static grn_rccxx . . $ grn_rc#
336 selector_in_recordscxx . . $ selector_in_records(2267fc2522c8e143).(grn_ctxcxx . . $ grn_ctx# *ctx,
337 grn_objcxx . . $ grn_obj# *table,
338 grn_objcxx . . $ grn_obj# *index,
339 int n_args,
340 grn_objcxx . . $ grn_obj# **args,
341 grn_objcxx . . $ grn_obj# *res,
342 grn_operatorcxx . . $ grn_operator# op)
343 {
344 grn_objcxx . . $ grn_obj# *condition_table;
345 grn_operatorcxx . . $ grn_operator# *condition_modes = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
346 grn_objcxx . . $ grn_obj# condition_columns;
347 int i, nth;
348
349 /* TODO: Enable me when function call is supported. */
350 return GRN_FUNCTION_NOT_IMPLEMENTEDcxx . . $ GRN_FUNCTION_NOT_IMPLEMENTED.;
351
352 if (n_args < 5) {
353 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
354 GRN_INVALID_ARGUMENT,
355 "in_records(): wrong number of arguments (%d for 4..)",
356 n_args - 1);
357 return ctx->rccxx . . $ _grn_ctx#rc.;
358 }
359
360 condition_table = args[1];
361 if (!grn_obj_is_tablecxx . . $ grn_obj_is_table(a5760e5c319a06ee).(ctx, condition_table)) {
362 grn_objcxx . . $ grn_obj# inspected;
363 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
364 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
365 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
366 GRN_INVALID_ARGUMENT,
367 "in_records(): the first argument must be a table: <%.*s>",
368 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
369 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
370 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
371 return ctx->rccxx . . $ _grn_ctx#rc.;
372 }
373
374 condition_modes = GRN_PLUGIN_MALLOCNcxx . . $ `include/groonga/plugin.h:90:9`!(ctx,
375 grn_operator,
376 (size_t)((n_args - 2) / 3));
377 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&condition_columns, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
378 for (i = 2, nth = 0; i < n_args; i += 3, nth++) {
379 int mode_name_i = i + 1;
380 int column_name_i = i + 2;
381 grn_objcxx . . $ grn_obj# *mode_name;
382 grn_operatorcxx . . $ grn_operator# mode;
383 grn_objcxx . . $ grn_obj# *column_name;
384 grn_objcxx . . $ grn_obj# *condition_column;
385
386 mode_name = args[mode_name_i];
387 mode = grn_proc_get_value_modecxx . . $ grn_proc_get_value_mode(db52f52f4dd070c1).(ctx,
388 mode_name,
389 GRN_OP_EQUALcxx . . $ GRN_OP_EQUAL.,
390 "in_records()");
391 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
392 goto exit;
393 }
394
395 condition_modes[nth] = mode;
396
397 column_name = args[column_name_i];
398 if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, column_name)) {
399 grn_objcxx . . $ grn_obj# inspected;
400 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
401 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
402 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
403 GRN_INVALID_ARGUMENT,
404 "in_records(): "
405 "the %dth argument must be column name as string: "
406 "<%.*s>",
407 column_name_i,
408 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
409 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
410 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
411 goto exit;
412 }
413
414 condition_column = grn_obj_columncxx . . $ grn_obj_column(c00e49795c44129a).(ctx, condition_table,
415 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(column_name),
416 (uint32_tcxx . . $ uint32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(column_name));
417 if (!condition_column) {
418 grn_objcxx . . $ grn_obj# inspected;
419 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
420 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, condition_table);
421 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
422 GRN_INVALID_ARGUMENT,
423 "in_records(): "
424 "the %dth argument must be existing column name: "
425 "<%.*s>: <%.*s>",
426 column_name_i,
427 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(column_name),
428 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(column_name),
429 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
430 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
431 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
432 goto exit;
433 }
434 GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &condition_columns, condition_column);
435 }
436
437 {
438 grn_objcxx . . $ grn_obj# condition_column_value;
439
440 GRN_VOID_INITcxx . . $ `include/groonga/groonga.h:2749:9`!(&condition_column_value);
441 GRN_TABLE_EACH_BEGINcxx . . $ `include/groonga/table.h:614:9`!(ctx, condition_table, cursor, id) {
442 grn_objcxx . . $ grn_obj# *sub_res = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
443
444 for (i = 2; i < n_args; i += 3) {
445 int nth = (i - 2) / 3;
446 grn_operatorcxx . . $ grn_operator# sub_op;
447 grn_objcxx . . $ grn_obj# *condition_column;
448 grn_operatorcxx . . $ grn_operator# condition_mode;
449 grn_objcxx . . $ grn_obj# *column = args[i];
450 grn_objcxx . . $ grn_obj# *expr;
451 grn_objcxx . . $ grn_obj# *variable;
452
453 if (nth == 0) {
454 sub_op = GRN_OP_ORcxx . . $ GRN_OP_OR.;
455 } else {
456 sub_op = GRN_OP_ANDcxx . . $ GRN_OP_AND.;
457 }
458
459 condition_column = GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&condition_columns, nth);
460 condition_mode = condition_modes[nth];
461
462 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&condition_column_value);
463 grn_obj_get_valuecxx . . $ grn_obj_get_value(6e06fec66698a6a).(ctx,
464 condition_column,
465 id,
466 &condition_column_value);
467
468 GRN_EXPR_CREATE_FOR_QUERYcxx . . $ `include/groonga/expr.h:216:9`!(ctx, table, expr, variable);
469 if (!expr) {
470 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
471 GRN_INVALID_ARGUMENT,
472 "in_records(): failed to create expression");
473 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &condition_column_value);
474 if (sub_res) {
475 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, sub_res);
476 }
477 goto exit;
478 }
479 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, expr, column, GRN_OP_GET_VALUEcxx . . $ GRN_OP_GET_VALUE., 1);
480 grn_expr_append_objcxx . . $ grn_expr_append_obj(1a96b2046350ef54).(ctx, expr, &condition_column_value, GRN_OP_PUSHcxx . . $ GRN_OP_PUSH., 1);
481 grn_expr_append_opcxx . . $ grn_expr_append_op(3b5ca24334c1be34).(ctx, expr, condition_mode, 2);
482 sub_res = grn_table_selectcxx . . $ grn_table_select(fec47fdf91015e61).(ctx, table, expr, sub_res, sub_op);
483 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, expr);
484 }
485
486 if (sub_res) {
487 grn_table_setoperationcxx . . $ grn_table_setoperation(44f9f3eeace98db2).(ctx, res, sub_res, res, op);
488 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, sub_res);
489 }
490 } GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor);
491 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &condition_column_value);
492 }
493
494 exit :
495 GRN_PLUGIN_FREEcxx . . $ `include/groonga/plugin.h:100:9`!(ctx, condition_modes);
496
497 for (i = 2; i < n_args; i += 3) {
498 int nth = (i - 2) / 3;
499 grn_objcxx . . $ grn_obj# *condition_column;
500 condition_column = GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&condition_columns, nth);
501 if (condition_column && condition_column->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. == GRN_ACCESSORcxx . . $ `include/groonga/groonga.h:880:9`!) {
502 grn_obj_unlinkcxx . . $ grn_obj_unlink(4865d068a46d0f83).(ctx, condition_column);
503 }
504 }
505 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &condition_columns);
506
507 return ctx->rccxx . . $ _grn_ctx#rc.;
508 }
509
510 void
511 grn_proc_init_in_recordscxx . . $ grn_proc_init_in_records(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
512 {
513 grn_objcxx . . $ grn_obj# *selector_proc;
514
515 selector_proc = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, "in_records", -1, GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
516 func_in_records_initcxx . . $ func_in_records_init(fd082858389c8bb0).,
517 func_in_records_nextcxx . . $ func_in_records_next(fd082858389c8bb0).,
518 func_in_records_fincxx . . $ func_in_records_fin(fd082858389c8bb0).,
519 0,
520 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
521 grn_proc_set_selectorcxx . . $ grn_proc_set_selector(7ce76c9564b607b5).(ctx, selector_proc, selector_in_recordscxx . . $ selector_in_records(2267fc2522c8e143).);
522 grn_proc_set_selector_operatorcxx . . $ grn_proc_set_selector_operator(bbc69e63741a8d0a).(ctx, selector_proc, GRN_OP_NOPcxx . . $ GRN_OP_NOP.);
523 }