Currrently we only allow Hypertables references other tables, with
this patch the opposite direction is supported as well and tables
can have foreign key references into hypertables.
If memory context is switched temporarily and there is no switch back,
it will cause strange errors.
This adds a Coccinelle rule that checks for a case where the memory
context is saved in a temporary variable but this variable is not used
to switch back to the original memory context.
Co-authored-by: Fabrízio de Royes Mello <fabrizio@timescale.com>
Postgres has `AttrNumberGetAttrOffset()` macro to proper access Datum
array members, so added a new coccinele static analysis to check for
missing macro usage.
Example:
`datum[attrno - 1]` should be `datum[AttrNumberGetAttrOffset(attrno)]`
Reference:
* https://github.com/postgres/postgres/blob/master/src/include/access/attnum.h)
Direct access of the `.data` member of `NameData` structures are
discuraged and `NameStr` should be used instead.
Also adding one instance that was missed in #5336.
Some bitmap set operations recycle one of the input parameters or return
a reference to a new bitmap set. The added set of rules checks that the
returned reference is not discarded.
NameData is a fixed-size type of 64 bytes. Using strlcpy to copy data
into a NameData struct can cause problems because any data that follows
the initial null-terminated string will also be part of the data.
Just noticed abysmal INSERT performance when experimenting with one of
our customers' data set, and turns out my cache sizes were
misconfigured, leading to constant hypertable chunk cache thrashing.
Show a warning to detect this misconfiguration. Also use more generous
defaults, we're not supposed to run on a microwave (unlike Postgres).
The initial version of the check did not include a detailed message
about the code failure in the CI output and did not check for
expressions with operands in wrong order.
Postgres source code define the macro `OidIsValid()` to check if the Oid
is valid or not (comparing against the `InvalidOid` type). See
`src/include/c.h` in Postgres source three.
Changed all direct comparisons against `InvalidOid` for the `OidIsValid`
call and add a coccinelle check to make sure the future changes will use
it correctly.
This PR adds a Coccinelle test for ereport(..) calls that use the PG
12.3+ syntax
(postgres/postgres@a867154516). We had
some of these calls in the past, which we had to fix afterward (
see #4733, #4809, #4871). This Coccinelle patch detects such calls and
reports them in the CI run.
Previously the hash_create coccinelle script would not detect
hash_create calls that declared the return variable in the same
statement or that used the return value of hash_create as return
value.
This patch fixes callsites that set an explicit memory context
in the control structure but do not specify the HASH_CONTEXT flag
leading to the hash table being created in TopMemoryContext.
This patch also changes call sites that want to create the hash
table in TopMemoryContext to be explicit about this.
Additionally this patch adds a coccinelle script to detect these
errors and prevent adding similar code in the future.
This patch adds coccinelle scripts for detecting use-after-free
bugs in relation to ts_cache_release.
This will find code using the following pattern:
Use of the hypertable from cache after releasing the cache
and use of the dimension of the hypertable from a cache
after the cache was released.
This patch adds a workflow to run coccinelle scripts against our
codebase. This can be used to find errors in the code base.
The initial patch adds a check to find unbalanced heap_form_tuple
heap_freetuple occurances.
https://coccinelle.gitlabpages.inria.fr/website/