Skip to content

Commit

Permalink
Add support for foreign keys to hypertables
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
svenklemm committed Jun 9, 2024
1 parent be15ae6 commit 286368a
Show file tree
Hide file tree
Showing 10 changed files with 783 additions and 47 deletions.
7 changes: 4 additions & 3 deletions coccinelle/namedata.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ struct I1
}

@rule_namedata_strlcpy@
expression E1, E2;
identifier I1;
expression E1;
symbol NAMEDATALEN;
@@
- strlcpy(E1, E2, NAMEDATALEN);
- strlcpy(I1, E1, NAMEDATALEN);
+ /* You are using strlcpy with NAMEDATALEN, please consider using NameData and namestrcpy instead. */
+ namestrcpy(E1, E2);
+ namestrcpy(I1, E1);

@rule_namedata_memcpy@
expression E1, E2;
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(SOURCES
extension.c
extension_constants.c
expression_utils.c
foreign_key.c
gapfill.c
guc.c
histogram.c
Expand Down
4 changes: 4 additions & 0 deletions src/chunk_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "dimension_vector.h"
#include "errors.h"
#include "export.h"
#include "foreign_key.h"
#include "hypercube.h"
#include "hypertable.h"
#include "partitioning.h"
Expand Down Expand Up @@ -512,6 +513,9 @@ ts_chunk_constraints_create(const Hypertable *ht, const Chunk *chunk)
Assert(list_length(cookedconstrs) == list_length(newconstrs));
CommandCounterIncrement();
}

/* Copy FK triggers to this chunk */
ts_chunk_copy_referencing_fk(ht, chunk);
}

ScanIterator
Expand Down
Loading

0 comments on commit 286368a

Please sign in to comment.