1
0
mirror of https://github.com/timescale/timescaledb.git synced 2025-06-02 03:13:06 +08:00

18 Commits

Author SHA1 Message Date
Sven Klemm
6defa15c8d Add support for foreign keys to hypertables
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.
2024-06-18 17:54:33 +02:00
Mats Kindahl
c07decfe94 Check for missing memory context switch back
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>
2024-03-07 13:12:46 +01:00
Jan Nidzwetzki
677809d4be Replace memcpy on NameData with namestrcpy
This PR replaces memcpy calls on NameData with namestrcpy. In addition,
a Coccinelle rule is introduced to detect these problems automatically.
2024-02-19 11:14:41 +01:00
Fabrízio de Royes Mello
ba21904041 Fix typo in coccinele script
Forgot to fix some typo raised by Mats before merge .
2024-02-16 11:14:30 -03:00
Fabrízio de Royes Mello
89af50d886 Add coccinele checking for AttrNumberGetAttrOffset
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)
2024-02-16 09:19:00 -03:00
Mats Kindahl
4e17247e76 Add Coccinelle rule to use NameStr
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 .
2023-12-12 22:30:05 +01:00
Jan Nidzwetzki
7f4f23be8f Add Coccinelle rules - bitmap set operations
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.
2023-11-03 11:05:27 +01:00
Lakshmi Narayanan Sreethar
cdea343cc9 Remove PG12 support from github workflows 2023-07-25 16:00:18 +05:30
Jan Nidzwetzki
330bb8f4af Added coccinelle rule to find strlcpy on NameData
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.
2023-02-20 15:23:57 +01:00
Alexander Kuzmenkov
fd66f5936a Warn about mismatched chunk cache sizes
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).
2023-02-14 19:32:41 +04:00
Sven Klemm
5b0bff384b Improve InvalidOid coccinelle check
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.
2022-11-07 11:55:39 +01:00
Fabrízio de Royes Mello
f1535660b0 Honor usage of OidIsValid() macro
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.
2022-11-03 16:10:50 -03:00
Jan Nidzwetzki
f05545883b Add a Coccinelle test for PG 12.3+ ereport syntax
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 , , ). This Coccinelle patch detects such calls and
reports them in the CI run.
2022-10-24 13:41:30 +02:00
Sven Klemm
ee4423c181 Fix coccinelle hash_create script
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.
2022-08-16 08:01:55 +02:00
Sven Klemm
336f4b513f Fix hash_create calls without HASH_CONTEXT flag
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.
2022-07-31 21:47:26 +02:00
Sven Klemm
9b63f4aadd Add more descriptive comment to our CI workflows 2022-05-03 09:51:50 +02:00
Sven Klemm
9e16d9f4e4 Add coccinelle scripts for detecting use-after-free
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.
2022-01-28 01:43:16 +01:00
Sven Klemm
c91faad221 Add coccinelle workflow to CI
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/
2021-11-15 10:56:12 +01:00