mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-23 06:22:03 +08:00
Support compiler-agnostic annotations
This change adds a compiler-agnostic annotation for fall-throughs in switch statements. The definition is put in `annotations.h`, which can be expanded to hold definitions for similar functionality in the future. The `clang` compiler (as of version 12) seems to have have dropped support for the previous comment-based annotations to allow fall-throughs in favor of native annotations or GCC-style attributes.
This commit is contained in:
parent
6cc9871be8
commit
882a247244
24
src/annotations.h
Normal file
24
src/annotations.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* This file and its contents are licensed under the Apache License 2.0.
|
||||||
|
* Please see the included NOTICE for copyright information and
|
||||||
|
* LICENSE-APACHE for a copy of the license.
|
||||||
|
*/
|
||||||
|
#ifndef TIMESCALEDB_ANNOTATIONS_H
|
||||||
|
#define TIMESCALEDB_ANNOTATIONS_H
|
||||||
|
|
||||||
|
/* Fall-through annotation */
|
||||||
|
#if defined(__clang__)
|
||||||
|
#if (__clang_major__ >= 12) || (__clang_analyzer__)
|
||||||
|
#define TS_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
#define TS_FALLTHROUGH /* FALLTHROUGH */
|
||||||
|
#endif /* __clang__ */
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
/* Supported since GCC 7 */
|
||||||
|
#define TS_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
/* MSVC and other compilers */
|
||||||
|
#define TS_FALLTHROUGH /* FALLTHROUGH */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* TIMESCALEDB_ANNOTATIONS_H */
|
@ -12,6 +12,7 @@
|
|||||||
#include <miscadmin.h>
|
#include <miscadmin.h>
|
||||||
#include <utils/syscache.h>
|
#include <utils/syscache.h>
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
@ -130,6 +131,7 @@ cache_invalidate_xact_end(XactEvent event, void *arg)
|
|||||||
* backends cannot have the invalid state.
|
* backends cannot have the invalid state.
|
||||||
*/
|
*/
|
||||||
cache_invalidate_relcache_all();
|
cache_invalidate_relcache_all();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -148,6 +150,7 @@ cache_invalidate_subxact_end(SubXactEvent event, SubTransactionId mySubid,
|
|||||||
* in cache_invalidate_xact_end.
|
* in cache_invalidate_xact_end.
|
||||||
*/
|
*/
|
||||||
cache_invalidate_relcache_all();
|
cache_invalidate_relcache_all();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <utils/lsyscache.h>
|
#include <utils/lsyscache.h>
|
||||||
#include <utils/syscache.h>
|
#include <utils/syscache.h>
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "dimension.h"
|
#include "dimension.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "hypertable_cache.h"
|
#include "hypertable_cache.h"
|
||||||
@ -61,7 +62,7 @@ index_has_attribute(List *indexelems, const char *attrname)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
TS_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "unsupported index list element");
|
elog(ERROR, "unsupported index list element");
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "cross_module_fn.h"
|
#include "cross_module_fn.h"
|
||||||
#include "license_guc.h"
|
#include "license_guc.h"
|
||||||
#include "hypertable_cache.h"
|
#include "hypertable_cache.h"
|
||||||
@ -791,7 +792,7 @@ timescaledb_set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, Rang
|
|||||||
ts_cm_functions->set_rel_pathlist_dml(root, rel, rti, rte, ht);
|
ts_cm_functions->set_rel_pathlist_dml(root, rel, rti, rte, ht);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
TS_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
apply_optimizations(root, reltype, rel, rte, ht);
|
apply_optimizations(root, reltype, rel, rte, ht);
|
||||||
break;
|
break;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <miscadmin.h>
|
#include <miscadmin.h>
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "process_utility.h"
|
#include "process_utility.h"
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
@ -3847,6 +3848,7 @@ process_utility_xact_abort(XactEvent event, void *arg)
|
|||||||
* transactions.
|
* transactions.
|
||||||
*/
|
*/
|
||||||
expect_chunk_modification = false;
|
expect_chunk_modification = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3861,6 +3863,7 @@ process_utility_subxact_abort(SubXactEvent event, SubTransactionId mySubid,
|
|||||||
case SUBXACT_EVENT_ABORT_SUB:
|
case SUBXACT_EVENT_ABORT_SUB:
|
||||||
/* see note in process_utility_xact_abort */
|
/* see note in process_utility_xact_abort */
|
||||||
expect_chunk_modification = false;
|
expect_chunk_modification = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <utils/tqual.h>
|
#include <utils/tqual.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "annotations.h"
|
||||||
#include "timer_mock.h"
|
#include "timer_mock.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
@ -60,7 +61,7 @@ mock_wait(TimestampTz until)
|
|||||||
WaitForBackgroundWorkerShutdown(bgw_handle);
|
WaitForBackgroundWorkerShutdown(bgw_handle);
|
||||||
bgw_handle = NULL;
|
bgw_handle = NULL;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
TS_FALLTHROUGH;
|
||||||
case IMMEDIATELY_SET_UNTIL:
|
case IMMEDIATELY_SET_UNTIL:
|
||||||
ts_params_set_time(until, false);
|
ts_params_set_time(until, false);
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
#include "with_clause_parser.h"
|
#include "with_clause_parser.h"
|
||||||
|
#include "annotations.h"
|
||||||
|
|
||||||
static DefElem *
|
static DefElem *
|
||||||
def_elem_from_texts(Datum *texts, int nelems)
|
def_elem_from_texts(Datum *texts, int nelems)
|
||||||
@ -30,7 +31,7 @@ def_elem_from_texts(Datum *texts, int nelems)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
elem->arg = (Node *) makeString(text_to_cstring(DatumGetTextP(texts[2])));
|
elem->arg = (Node *) makeString(text_to_cstring(DatumGetTextP(texts[2])));
|
||||||
/* FALLTHROUGH */
|
TS_FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
elem->defname = text_to_cstring(DatumGetTextP(texts[1]));
|
elem->defname = text_to_cstring(DatumGetTextP(texts[1]));
|
||||||
elem->defnamespace = text_to_cstring(DatumGetTextP(texts[0]));
|
elem->defnamespace = text_to_cstring(DatumGetTextP(texts[0]));
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <catalog/namespace.h>
|
#include <catalog/namespace.h>
|
||||||
#include <nodes/parsenodes.h>
|
#include <nodes/parsenodes.h>
|
||||||
|
|
||||||
|
#include <annotations.h>
|
||||||
#include <guc.h>
|
#include <guc.h>
|
||||||
#include "hypertable_data_node.h"
|
#include "hypertable_data_node.h"
|
||||||
#include "chunk_index.h"
|
#include "chunk_index.h"
|
||||||
@ -421,8 +422,7 @@ dist_ddl_preprocess(ProcessUtilityArgs *args)
|
|||||||
/* Those commands are also targets for execute_on_start in since they
|
/* Those commands are also targets for execute_on_start in since they
|
||||||
* are not supported by event triggers. */
|
* are not supported by event triggers. */
|
||||||
set_dist_exec_type(DIST_DDL_EXEC_ON_START);
|
set_dist_exec_type(DIST_DDL_EXEC_ON_START);
|
||||||
|
TS_FALLTHROUGH;
|
||||||
/* fall through */
|
|
||||||
default:
|
default:
|
||||||
dist_ddl_error_raise_unsupported();
|
dist_ddl_error_raise_unsupported();
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user