diff --git a/src/hypertable.c b/src/hypertable.c index cbea0bbbc6d..af19fd09f34 100644 --- a/src/hypertable.c +++ b/src/hypertable.c @@ -415,8 +415,7 @@ hypertable_filter_exclude_compressed_and_materialization(const TupleInfo *ti, vo static int hypertable_scan_limit_internal(ScanKeyData *scankey, int num_scankeys, int indexid, tuple_found_func on_tuple_found, void *scandata, int limit, - LOCKMODE lock, bool tuplock, MemoryContext mctx, - tuple_filter_func filter) + LOCKMODE lock, MemoryContext mctx, tuple_filter_func filter) { Catalog *catalog = ts_catalog_get(); ScannerCtx scanctx = { @@ -458,7 +457,6 @@ ts_hypertable_get_all(void) &result, -1, RowExclusiveLock, - false, CurrentMemoryContext, hypertable_filter_exclude_compressed_and_materialization); @@ -516,7 +514,6 @@ ts_hypertable_update(Hypertable *ht) ht, 1, RowExclusiveLock, - false, CurrentMemoryContext, NULL); } @@ -524,7 +521,7 @@ ts_hypertable_update(Hypertable *ht) int ts_hypertable_scan_with_memory_context(const char *schema, const char *table, tuple_found_func tuple_found, void *data, LOCKMODE lockmode, - bool tuplock, MemoryContext mctx) + MemoryContext mctx) { ScanKeyData scankey[2]; NameData schema_name = { .data = { 0 } }; @@ -555,7 +552,6 @@ ts_hypertable_scan_with_memory_context(const char *schema, const char *table, data, 1, lockmode, - tuplock, mctx, NULL); } @@ -729,7 +725,6 @@ ts_hypertable_delete_by_name(const char *schema_name, const char *table_name) NULL, 0, RowExclusiveLock, - false, CurrentMemoryContext, NULL); } @@ -752,7 +747,6 @@ ts_hypertable_delete_by_id(int32 hypertable_id) NULL, 1, RowExclusiveLock, - false, CurrentMemoryContext, NULL); } @@ -815,92 +809,10 @@ ts_hypertable_reset_associated_schema_name(const char *associated_schema) NULL, 0, RowExclusiveLock, - false, CurrentMemoryContext, NULL); } -static ScanTupleResult -tuple_found_lock(TupleInfo *ti, void *data) -{ - TM_Result *result = data; - - *result = ti->lockresult; - return SCAN_DONE; -} - -TM_Result -ts_hypertable_lock_tuple(Oid table_relid) -{ - TM_Result result; - int num_found; - - num_found = hypertable_scan(get_namespace_name(get_rel_namespace(table_relid)), - get_rel_name(table_relid), - tuple_found_lock, - &result, - RowExclusiveLock, - true); - - if (num_found != 1) - ereport(ERROR, - (errcode(ERRCODE_TS_HYPERTABLE_NOT_EXIST), - errmsg("table \"%s\" is not a hypertable", get_rel_name(table_relid)))); - - return result; -} - -bool -ts_hypertable_lock_tuple_simple(Oid table_relid) -{ - TM_Result result = ts_hypertable_lock_tuple(table_relid); - - switch (result) - { - case TM_SelfModified: - - /* - * Updated by the current transaction already. We equate this with - * a successful lock since the tuple should be locked if updated - * by us. - */ - return true; - case TM_Ok: - /* successfully locked */ - return true; - - case TM_Deleted: - case TM_Updated: - ereport(ERROR, - (errcode(ERRCODE_LOCK_NOT_AVAILABLE), - errmsg("hypertable \"%s\" has already been updated by another transaction", - get_rel_name(table_relid)), - errhint("Retry the operation again."))); - pg_unreachable(); - return false; - - case TM_BeingModified: - ereport(ERROR, - (errcode(ERRCODE_LOCK_NOT_AVAILABLE), - errmsg("hypertable \"%s\" is being updated by another transaction", - get_rel_name(table_relid)), - errhint("Retry the operation again."))); - pg_unreachable(); - return false; - case TM_WouldBlock: - /* Locking would block. Let caller decide what to do */ - return false; - case TM_Invisible: - elog(ERROR, "attempted to lock invisible tuple"); - pg_unreachable(); - return false; - default: - elog(ERROR, "unexpected tuple lock status"); - pg_unreachable(); - return false; - } -} - int ts_hypertable_set_name(Hypertable *ht, const char *newname) { @@ -1033,7 +945,7 @@ ts_hypertable_get_by_name(const char *schema, const char *name) { Hypertable *ht = NULL; - hypertable_scan(schema, name, hypertable_tuple_found, &ht, AccessShareLock, false); + hypertable_scan(schema, name, hypertable_tuple_found, &ht, AccessShareLock); return ht; } @@ -1107,7 +1019,6 @@ ts_hypertable_get_by_id(int32 hypertable_id) &ht, 1, AccessShareLock, - false, CurrentMemoryContext, NULL); return ht; diff --git a/src/hypertable.h b/src/hypertable.h index c2a8a35b2e6..c8a91972663 100644 --- a/src/hypertable.h +++ b/src/hypertable.h @@ -124,10 +124,7 @@ extern Hypertable *ts_resolve_hypertable_from_table_or_cagg(Cache *hcache, Oid r bool allow_matht); extern int ts_hypertable_scan_with_memory_context(const char *schema, const char *table, tuple_found_func tuple_found, void *data, - LOCKMODE lockmode, bool tuplock, - MemoryContext mctx); -extern TM_Result ts_hypertable_lock_tuple(Oid table_relid); -extern bool ts_hypertable_lock_tuple_simple(Oid table_relid); + LOCKMODE lockmode, MemoryContext mctx); extern TSDLLEXPORT int ts_hypertable_update(Hypertable *ht); extern int ts_hypertable_set_name(Hypertable *ht, const char *newname); extern int ts_hypertable_set_schema(Hypertable *ht, const char *newname); @@ -190,13 +187,12 @@ extern TSDLLEXPORT int16 ts_validate_replication_factor(const char *hypertable_n int32 replication_factor, int num_data_nodes); -#define hypertable_scan(schema, table, tuple_found, data, lockmode, tuplock) \ +#define hypertable_scan(schema, table, tuple_found, data, lockmode) \ ts_hypertable_scan_with_memory_context(schema, \ table, \ tuple_found, \ data, \ lockmode, \ - tuplock, \ CurrentMemoryContext) #define hypertable_adaptive_chunking_enabled(ht) \ diff --git a/src/hypertable_cache.c b/src/hypertable_cache.c index 3376f529eb2..046eda42d07 100644 --- a/src/hypertable_cache.c +++ b/src/hypertable_cache.c @@ -109,7 +109,6 @@ hypertable_cache_create_entry(Cache *cache, CacheQuery *query) hypertable_tuple_found, query->result, AccessShareLock, - false, ts_cache_memory_ctx(cache)); switch (number_found)