int p_session_sql_dml( /* + */ value v_session, type t_session, /* + */ value v_SQL, type t_SQL, /* - */ value v_rows, type t_rows ) { session_t * session; cursor_t * cursor; char * SQL; word rows, *prows; int res; Check_String(t_SQL); Check_Output_Integer(t_rows); Get_Typed_Object(v_session,t_session,&session_handle_tid,session); cursor = session_sql_prepare(session, StringStart(v_SQL), StringLength(v_SQL), 0); if (NULL == cursor) Bip_Error(dbi_errno); if (res = cursor_sql_execute(cursor, 1)) { cursor_free(cursor); Bip_Error(Error_Code(res)); } cursor_field_value(cursor, rows_processed_count, (void **)&prows); rows = *prows; cursor_free(cursor); Return_Unify_Integer(v_rows, t_rows, rows); }
int trap_FreeCursor(lua_State *s) { CURSOR *cursor; trap_args(s, "FreeCursor", "p", &cursor); cursor_free(cursor); return 0; }
int xlib_free(int ret) { #ifdef module_sorter sorter_free(); #endif #ifdef module_cursor cursor_free(); #endif render_free(); command_free(); XDestroyWindow(dpy, topWin); return ret; }
void test_value(gconstpointer data) { const grn_trie_test_data *test_data = data; const gchar key1[] = "セナ"; const gchar key2[] = "ナセナセ"; const gchar key3[] = "Groonga"; const gchar key4[] = "セナ + Ruby"; const gchar key5[] = "セナセナ"; gchar value2[] = "VALUE2"; gchar value4_1[] = "Groonga"; gchar value4_2[] = "るびい"; gchar value5_1[] = "上書きされる値 - overridden value"; gchar value5_2[] = "上書きされた値 - override value"; trie_test_data_set_parameters(test_data); cut_assert_create_trie(); cut_assert_lookup_add(key1); cut_assert_lookup_add(key2); cut_assert_lookup_add(key3); cut_assert_lookup_add(key4); cut_assert_lookup_add(key5); cut_assert_open_cursor(); while (grn_pat_cursor_next(context, cursor) != GRN_ID_NIL) { void *key; gchar *null_terminated_key; int size; size = grn_pat_cursor_get_key(context, cursor, &key); null_terminated_key = g_string_free(g_string_new_len(key, size), FALSE); if (g_str_equal(null_terminated_key, key2)) { grn_pat_cursor_set_value(context, cursor, value2, GRN_OBJ_SET); } else if (g_str_equal(null_terminated_key, key4)) { grn_pat_cursor_set_value(context, cursor, value4_1, GRN_OBJ_INCR); grn_pat_cursor_set_value(context, cursor, value4_2, GRN_OBJ_INCR); } else if (g_str_equal(null_terminated_key, key5)) { grn_pat_cursor_set_value(context, cursor, value5_1, GRN_OBJ_SET); grn_pat_cursor_set_value(context, cursor, value5_2, GRN_OBJ_SET); } } cursor_free(); cut_assert_open_cursor(); gcut_assert_equal_list_string(test_data->expected_strings, retrieve_all_keys_and_values()); }
CTEST(cursor, empty) { int ret; struct options *opts; struct status *status; struct cache *cache; struct tree *tree; /* create */ opts = options_new(); status = status_new(); cache = dbcache_new(opts); tree = tree_new(DBPATH0, opts, status, cache, 1); /* cursor */ struct cursor *cur; cur = cursor_new(tree); /* first */ tree_cursor_first(cur); ret = tree_cursor_valid(cur); ASSERT_EQUAL(0, ret); /* last */ tree_cursor_last(cur); ret = tree_cursor_valid(cur); ASSERT_EQUAL(0, ret); /* next */ tree_cursor_next(cur); ret = tree_cursor_valid(cur); ASSERT_EQUAL(0, ret); cursor_free(cur); /* free */ dbcache_free(cache); tree_free(tree); options_free(opts); status_free(status); xcheck_all_free(); }
void test_delete(gconstpointer data) { const grn_trie_test_data *test_data = data; const gchar key1[] = "セナ"; const gchar key2[] = "ナセナセ"; const gchar key3[] = "Groonga"; const gchar key4[] = "セナ + Ruby"; const gchar key5[] = "セナセナ"; trie_test_data_set_parameters(test_data); cut_assert_create_trie(); cut_assert_lookup_add(key1); cut_assert_lookup_add(key2); cut_assert_lookup_add(key3); cut_assert_lookup_add(key4); cut_assert_lookup_add(key5); cut_assert_open_cursor(); while (grn_pat_cursor_next(context, cursor) != GRN_ID_NIL) { void *key; gchar *null_terminated_key; int size; size = grn_pat_cursor_get_key(context, cursor, &key); null_terminated_key = g_string_free(g_string_new_len(key, size), FALSE); if (g_str_equal(null_terminated_key, key1) || g_str_equal(null_terminated_key, key5)) { grn_pat_cursor_delete(context, cursor, NULL); } } cursor_free(); cut_assert_open_cursor(); gcut_assert_equal_list_string(test_data->expected_strings, retrieve_all_keys()); }
/* * cursor_close () - Free the area allocated for the cursor identifier and * invalidate the cursor identifier. * return: * cursor_id(in/out): Cursor Identifier */ void cursor_close (CURSOR_ID * cursor_id_p) { /* free the cursor allocated area */ cursor_free (cursor_id_p); /* invalidate the cursor_id */ cursor_id_p->position = C_BEFORE; cursor_id_p->tuple_no = -1; cursor_id_p->is_updatable = false; cursor_id_p->oid_ent_count = 0; cursor_id_p->current_vpid.pageid = NULL_PAGEID; cursor_id_p->next_vpid.pageid = NULL_PAGEID; cursor_id_p->header_vpid.pageid = NULL_PAGEID; cursor_id_p->buffer_tuple_count = 0; cursor_id_p->current_tuple_no = -1; cursor_id_p->current_tuple_offset = -1; cursor_id_p->current_tuple_p = NULL; cursor_id_p->current_tuple_length = -1; cursor_id_p->oid_col_no = NULL; cursor_id_p->oid_col_no_cnt = 0; cursor_initialize_current_tuple_value_position (cursor_id_p); }