26 #define VAR GRN_PROC_GET_VAR_BY_OFFSET
27 #define CONST_STR_LEN(x) x, x ? sizeof(x) - 1 : 0
28 #define TEXT_VALUE_LEN(x) GRN_TEXT_VALUE(x), GRN_TEXT_LEN(x)
31 grn_ctx_get_table_by_name_or_id(
grn_ctx *ctx,
32 const char *name,
unsigned int name_len)
35 const char *end = name + name_len;
36 const char *rest = NULL;
108 grn_obj *v, *query, *columns = NULL;
119 if (parse_bool_value(ctx,
VAR(5))) {
122 if (parse_bool_value(ctx,
VAR(6))) {
137 parse_set_operator_value(ctx,
VAR(4)));
143 grn_output_table_name_or_id(ctx, result_set);
148 command_filter_by_script(
grn_ctx *ctx,
int nargs,
158 if (parse_bool_value(ctx,
VAR(4))) {
173 parse_set_operator_value(ctx,
VAR(3)));
178 grn_output_table_name_or_id(ctx, result_set);
186 grn_obj *table, *column, *result_set = NULL;
201 switch (operator_text[0]) {
203 if (operator_len == 1) {
210 operator_len, operator_text);
224 parse_set_operator_value(ctx,
VAR(5)));
227 grn_output_table_name_or_id(ctx, result_set);
241 grn_obj *table_ = grn_ctx_get_table_by_name_or_id(ctx, table, table_len);
249 set_ = grn_ctx_get_table_by_name_or_id(ctx,
set, set_len);
252 gkeys[0].key, table_, 0);
270 grn_output_table_name_or_id(ctx, set_);
274 #define DEFAULT_LIMIT 10
290 grn_obj *table_ = grn_ctx_get_table_by_name_or_id(ctx, table, table_len);
307 grn_output_table_name_or_id(ctx, sorted);
325 grn_obj *table_ = grn_ctx_get_table_by_name_or_id(ctx, table, table_len);
349 grn_obj *table_ = grn_ctx_get_table_by_name_or_id(ctx, table, table_len);
359 NULL, 0, 0, -1, 0))) {
380 grn_obj *table_ = grn_ctx_get_table_by_name_or_id(ctx, table, table_len);
395 NULL, 0, NULL, 0, 0);
437 "nonexistent table name: <%.*s>", table_name_len, table_name);
446 const char *table_text, *id_text, *key_text;
447 int table_length, id_length, key_length;
451 if (table_length == 0) {
456 *table =
grn_ctx_get(ctx, table_text, table_length);
459 "[table][get] table doesn't exist: <%.*s>", table_length, table_text);
467 switch ((*table)->header.type) {
471 "[table][get] should not specify key for NO_KEY table: <%.*s>: "
473 key_length, key_text,
474 table_length, table_text);
478 const char *rest = NULL;
479 *
id =
grn_atoi(id_text, id_text + id_length, &rest);
480 if (rest == id_text) {
482 "[table][get] ID should be a number: <%.*s>: table: <%.*s>",
484 table_length, table_text);
488 "[table][get] ID isn't specified: table: <%.*s>",
489 table_length, table_text);
495 if (key_length && id_length) {
497 "[table][get] should not specify both key and ID: "
498 "key: <%.*s>: ID: <%.*s>: table: <%.*s>",
499 key_length, key_text,
501 table_length, table_text);
508 "[table][get] nonexistent key: <%.*s>: table: <%.*s>",
509 key_length, key_text,
510 table_length, table_text);
514 const char *rest = NULL;
515 *
id =
grn_atoi(id_text, id_text + id_length, &rest);
516 if (rest == id_text) {
518 "[table][get] ID should be a number: <%.*s>: table: <%.*s>",
520 table_length, table_text);
524 "[table][get] key nor ID isn't specified: table: <%.*s>",
525 table_length, table_text);
531 "[table][get] not a table: <%.*s>", table_length, table_text);
543 if (!command_get_resolve_parameters(ctx, user_data, &table, &
id)) {
573 MUTEX_LOCK(queue->
mutex);
581 NULL, 0, NULL, 0, 0);
587 MUTEX_UNLOCK(queue->
mutex);
620 MUTEX_LOCK(queue->
mutex);
623 MUTEX_UNLOCK(queue->
mutex);
642 MUTEX_UNLOCK(queue->
mutex);
666 #define DEF_VAR(v,x) do {\
668 (v).name_size = (x) ? sizeof(x) - 1 : 0;\
669 GRN_TEXT_INIT(&(v).value, 0);\
672 #define DEF_COMMAND(name,func,nvars,vars)\
673 (grn_proc_create(ctx, CONST_STR_LEN(name),\
674 GRN_PROC_COMMAND, (func), NULL, NULL, (nvars), (vars)))
682 DEF_VAR(vars[1],
"expression");
683 DEF_VAR(vars[2],
"result_set");
684 DEF_VAR(vars[3],
"set_operation");
685 DEF_VAR(vars[4],
"allow_update");
686 DEF_COMMAND(
"filter_by_script", command_filter_by_script, 5, vars);
692 DEF_VAR(vars[4],
"result_set");
693 DEF_VAR(vars[5],
"set_operation");
698 DEF_VAR(vars[2],
"result_set");
715 DEF_VAR(vars[1],
"expression");
725 DEF_VAR(vars[4],
"output_columns");
733 DEF_VAR(vars[2],
"output_columns");
738 DEF_VAR(vars[1],
"output_columns");
745 DEF_VAR(vars[3],
"result_set");
746 DEF_VAR(vars[4],
"set_operation");
747 DEF_VAR(vars[5],
"allow_column_expression");
748 DEF_VAR(vars[6],
"allow_pragma");