Kouhei Sutou
null+****@clear*****
Mon Jul 30 15:21:28 JST 2018
Kouhei Sutou 2018-07-30 15:21:28 +0900 (Mon, 30 Jul 2018) New Revision: 6bda42d909f226ee08d224174e777c9e2c9082c4 https://github.com/groonga/groonga/commit/6bda42d909f226ee08d224174e777c9e2c9082c4 Message: grn_table_delete: prepare in lock Modified files: lib/db.c Modified: lib/db.c (+24 -10) =================================================================== --- lib/db.c 2018-07-30 14:57:22 +0900 (3ac942f0f) +++ lib/db.c 2018-07-30 15:21:28 +0900 (3c0d1e048) @@ -2209,10 +2209,6 @@ grn_table_delete(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key if (table) { if (key && key_size) { rid = grn_table_get(ctx, table, key, key_size); } if (rid) { - rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); - if (rc != GRN_SUCCESS) { - goto exit; - } switch (table->header.type) { case GRN_DB : /* todo : delete tables and columns from db */ @@ -2222,11 +2218,17 @@ grn_table_delete(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key grn_pat *pat = (grn_pat *)table; if (pat->io && !(pat->io->flags & GRN_IO_TEMPORARY)) { if (!(rc = grn_io_lock(ctx, pat->io, grn_lock_timeout))) { - rc = grn_pat_delete(ctx, pat, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_pat_delete(ctx, pat, key, key_size, NULL); + } grn_io_unlock(pat->io); } } else { - rc = grn_pat_delete(ctx, pat, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_pat_delete(ctx, pat, key, key_size, NULL); + } } }); break; @@ -2235,11 +2237,17 @@ grn_table_delete(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key grn_dat *dat = (grn_dat *)table; if (dat->io && !(dat->io->flags & GRN_IO_TEMPORARY)) { if (!(rc = grn_io_lock(ctx, dat->io, grn_lock_timeout))) { - rc = grn_dat_delete(ctx, dat, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_dat_delete(ctx, dat, key, key_size, NULL); + } grn_io_unlock(dat->io); } } else { - rc = grn_dat_delete(ctx, dat, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_dat_delete(ctx, dat, key, key_size, NULL); + } } }); break; @@ -2248,11 +2256,17 @@ grn_table_delete(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key grn_hash *hash = (grn_hash *)table; if (hash->io && !(hash->io->flags & GRN_IO_TEMPORARY)) { if (!(rc = grn_io_lock(ctx, hash->io, grn_lock_timeout))) { - rc = grn_hash_delete(ctx, hash, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_hash_delete(ctx, hash, key, key_size, NULL); + } grn_io_unlock(hash->io); } } else { - rc = grn_hash_delete(ctx, hash, key, key_size, NULL); + rc = grn_table_delete_prepare(ctx, table, rid, key, key_size); + if (rc == GRN_SUCCESS) { + rc = grn_hash_delete(ctx, hash, key, key_size, NULL); + } } }); break; -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180730/6d69698e/attachment-0001.htm