21 #define GB_INDEX_FIND(gbf, ifs, quark) \
22 for (ifs = GBCONTAINER_IFS(gbf); \
24 ifs = GB_INDEX_FILES_NEXT(ifs)) \
26 if (ifs->key == quark) break; \
77 if (!ifs) error =
"key is not indexed";
124 error =
"GB_create_index used on non CONTAINER Type";
127 error =
"No index tables in DB clients allowed";
141 ifs->
key = key_quark;
152 if (gbf->is_container()) {
157 if (gb2->is_indexable()) gb2->as_entry()->index_check_in();
197 fprintf(stderr,
"'%s' (%s) is no container.\n", db_path,
GB_get_type_name(gbd));
210 if (index_count == 0) {
211 fprintf(stderr,
"Container '%s' has no index.\n", db_path);
216 fprintf(stderr,
"Indices for '%s':\n", db_path);
217 for (pass = 1; pass <= 2; pass++) {
219 fprintf(stderr,
"\nDetailed index contents:\n\n");
224 "* Index %i for key=%s (%i), entries=%li, %s\n",
233 :
"<Error in case_sens>")
240 fprintf(stderr,
"\n");
249 fprintf(stderr,
" - '%s' (@idx=%i)\n", data, index);
252 fprintf(stderr,
"\n");
297 if (ifather->
index < after_index)
continue;
298 if (ifather->
index >= min_index)
continue;
302 min_index = ifather->
index;
354 switch (entry->
type) {
369 for (a = u->
entries; a; a = next) {
472 if (pflags->
flags != (
unsigned)ue->
flag) {
499 error =
"Sorry no more undos/redos available";
507 for (ue=u->
entries; ue && !error; ue = next) {
537 res.
cat(
"Delete new entry: ");
542 res.
cat(
"Rebuild deleted entry: ");
548 res.
cat(
"Undo modified entry: ");
588 if (error)
return error;
682 for (
int index = 0; (index < gbc->
d.
nheader); index++) {
773 error =
"Internal UNDO error";
797 error =
"GB_undo: unknown undo type specified";
838 return GB_export_errorf(
"Not enough UNDO memory specified: should be more than %i",
857 int deletes, changes, creates;
863 counter->count(gbd, t);
866 cb_counter(
GBDATA* gbd_) : gbd(gbd_), deletes(0), changes(0), creates(0), do_trace(
false) {
882 if (do_trace) printf(
"counts: %p d=%i c=%i n=%i\n", gbd, deletes, changes, creates);
910 void TEST_GB_undo__basic() {
916 cb_counter main_counter(main);
920 cb_counter *gbd_counter;
937 gbd_counter =
new cb_counter(gbd);
966 gbd_counter =
new cb_counter(gbd);
999 gbd_counter =
new cb_counter(gbd);
1003 const char*
str =
"testtest9012345";
1062 #endif // UNIT_TESTS
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void gb_init_undo_stack(GB_MAIN_TYPE *Main)
static char * g_b_undo_info(GB_MAIN_TYPE *Main, g_b_undo_header *uh)
GBDATA * GB_open(const char *path, const char *opent)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
#define GB_GBM_INDEX(gbd)
long max_size_of_all_undos
void gb_check_in_undo_create(GB_MAIN_TYPE *Main, GBDATA *gbd)
GB_ERROR gbcmc_send_undo_commands(GBDATA *gbd, enum gb_undo_commands command)
GB_ERROR GB_create_index(GBDATA *gbd, const char *key, GB_CASE case_sens, long estimated_size)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
void gb_touch_header(GBCONTAINER *gbc)
const char * quark2key(GB_MAIN_TYPE *Main, GBQUARK key_quark)
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
#define ASSERT_NO_ERROR(errorExpr)
GB_ERROR GB_undo(GBDATA *gb_main, GB_UNDO_TYPE type)
gb_data_base_type_union info
void SET_GB_IF_ENTRIES_GBD(gb_if_entries *ie, GBDATA *gbd)
GBDATA * GB_find(GBDATA *gbd, const char *key, GB_SEARCH_TYPE gbs)
GB_MAIN_TYPE * GB_MAIN(GBDATA *gbd)
GB_ERROR GB_set_undo_mem(GBDATA *gbd, long memsize)
void gb_del_ref_and_extern_gb_transaction_save(gb_transaction_save *ts)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
int main(int argc, char **argv)
GBDATA * gb_index_find(GBCONTAINER *gbf, gb_index_files *ifs, GBQUARK quark, const char *val, GB_CASE case_sens, int after_index)
static char * g_b_check_undo_size(GB_MAIN_TYPE *Main)
const char * GB_get_type_name(GBDATA *gbd)
char * ARB_strdup(const char *str)
static void delete_g_b_undo_list(g_b_undo_list *u)
CONSTEXPR_INLINE GBCONTAINER * GB_GRANDPA(GBDATA *gbd)
GBDATA * gb_make_pre_defined_entry(GBCONTAINER *father, GBDATA *gbd, long index_pos, GBQUARK keyq)
const char * GBS_global_string(const char *templat,...)
void gb_add_ref_gb_transaction_save(gb_transaction_save *ts)
GB_UNDO_TYPE GB_get_requested_undo_type(GBDATA *gb_main)
void cat(const char *from)
gb_index_files * GB_INDEX_FILES_NEXT(gb_index_files *ixf)
GB_MAIN_TYPE * GBCONTAINER_MAIN(GBCONTAINER *gbc)
static g_b_undo_entry * new_g_b_undo_entry(g_b_undo_list *u)
GBDATA * GB_IF_ENTRIES_GBD(gb_if_entries *ie)
static char * gb_set_undo_type(GBDATA *gb_main, GB_UNDO_TYPE type)
const int GB_MAX_REDO_CNT
static void gb_delete_entry(GBCONTAINER *&gbc)
void gb_check_in_undo_delete(GB_MAIN_TYPE *Main, GBDATA *&gbd)
GB_ERROR GB_push_transaction(GBDATA *gbd)
#define GB_INDEX_FIND(gbf, ifs, quark)
GB_ERROR GB_delete(GBDATA *&source)
NOT4PERL void GB_dump_indices(GBDATA *gbd)
#define TEST_PUBLISH(testfunction)
const int GB_MAX_UNDO_CNT
GB_ERROR GB_export_error(const char *error)
GB_ERROR GB_await_error()
char * gb_set_undo_sync(GBDATA *gb_main)
GBDATA * GB_create(GBDATA *father, const char *key, GB_TYPES type)
bool is_indexable() const
void SET_GB_INDEX_FILES_ENTRIES(gb_index_files *ixf, gb_if_entries **entries)
GB_CSTR GB_read_pntr(GBDATA *gbd)
void gb_pre_delete_entry(GBDATA *gbd)
#define TEST_EXPECT_EQUAL__BROKEN(expr, want, got)
gb_data_base_type_union2 info
#define RETURN_ERROR(err)
static char * gb_free_all_undos(GBDATA *gb_main)
char * gb_disable_undo(GBDATA *gb_main)
bool is_container() const
#define TEST_REJECT_NULL(n)
GBCONTAINER * gb_make_pre_defined_container(GBCONTAINER *father, GBCONTAINER *gbc, long index_pos, GBQUARK keyq)
static void error(const char *msg)
GB_UNDO_TYPE requested_undo_type
GBQUARK GB_find_or_create_quark(GBDATA *gbd, const char *key)
union g_b_undo_entry::@5 d
void SET_GB_INDEX_FILES_NEXT(gb_index_files *ixf, gb_index_files *next)
static void delete_g_b_undo_entry(g_b_undo_entry *entry)
long GB_read_clients(GBDATA *gbd)
GBCONTAINER * as_container() const
unsigned int should_be_indexed
gb_transaction_save * get_oldData() const
GBDATA * GB_find_sub_by_quark(GBDATA *father, GBQUARK key_quark, GBDATA *after, size_t skip_over)
void * gbm_get_mem(size_t size, long index)
CONSTEXPR_INLINE GBCONTAINER * GB_FATHER(GBDATA *gbd)
void gb_destroy_indices(GBCONTAINER *gbc)
void SET_GB_IF_ENTRIES_NEXT(gb_if_entries *ie, gb_if_entries *next)
const int GB_MAX_UNDO_SIZE
static void delete_g_b_undo_header(g_b_undo_header *uh)
gb_index_files * GBCONTAINER_IFS(GBCONTAINER *gbc)
bool stored_external() const
gb_if_entries * GB_IF_ENTRIES_NEXT(gb_if_entries *ie)
char * gbcmc_send_undo_info_commands(GBDATA *gbd, enum gb_undo_commands command)
static GB_ERROR undo_entry(g_b_undo_entry *ue)
static char * g_b_check_undo_size2(g_b_undo_header *uhs, long size, long max_cnt)
GB_ERROR GB_export_errorf(const char *templat,...)
void GB_internal_error(const char *message)
GBQUARK GB_KEY_QUARK(GBDATA *gbd)
TYPE * ARB_calloc(size_t nelem)
#define TEST_EXPECT_NULL(n)
#define SET_GB_ENTRIES_ENTRY(entries, idx, ie)
bool stored_external() const
char * gb_abort_entry(GBDATA *gbd)
void gb_save_extern_data_in_ts(GBENTRY *gbe)
void SET_GBCONTAINER_IFS(GBCONTAINER *gbc, gb_index_files *ifs)
GB_CSTR gb_read_key_pntr(GBDATA *gbd)
GB_ERROR GB_request_undo_type(GBDATA *gb_main, GB_UNDO_TYPE type)
void GB_remove_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
const char * GB_get_db_path(GBDATA *gbd)
char * GB_undo_info(GBDATA *gb_main, GB_UNDO_TYPE type)
GBENTRY * as_entry() const
void gb_free_undo_stack(GB_MAIN_TYPE *Main)
#define GB_CALC_HASH_INDEX(string, index, size, caseSens)
static void g_b_add_size_to_undo_entry(g_b_undo_entry *ue, long size)
static GB_ERROR g_b_undo(GBDATA *gb_main, g_b_undo_header *uh)
void gb_check_in_undo_modify(GB_MAIN_TYPE *Main, GBDATA *gbd)
GB_REL_IFES * GB_INDEX_FILES_ENTRIES(gb_index_files *ifs)
void gb_del_ref_gb_transaction_save(gb_transaction_save *ts)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
void gbm_free_mem(void *block, size_t size, long index)
void GB_FREE_TRANSACTION_SAVE(GBDATA *gbd)
bool GBS_string_matches(const char *str, const char *expr, GB_CASE case_sens)
static GB_CSTR g_b_read_undo_key_pntr(GB_MAIN_TYPE *Main, g_b_undo_entry *ue)
const char * GB_KEY(GBDATA *gbd)
void gb_touch_entry(GBDATA *gbd, GB_CHANGE val)
#define GB_ENTRIES_ENTRY(entries, idx)
static int info[maxsites+1]
size_t gbs_get_a_prime(size_t above_or_equal_this)
#define TEST_EXPECT_EQUAL(expr, want)
void GB_close(GBDATA *gbd)
void set_data(char *data)