-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ABI for tracking events #7791
base: main
Are you sure you want to change the base?
Conversation
6088e9e
to
2cd2858
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7791 +/- ##
==========================================
+ Coverage 80.06% 81.88% +1.82%
==========================================
Files 190 247 +57
Lines 37181 45466 +8285
Branches 9450 11372 +1922
==========================================
+ Hits 29770 37232 +7462
- Misses 2997 3752 +755
- Partials 4414 4482 +68 ☔ View full report in Codecov by Sentry. |
If another extension want to track TimescaleDB events it is necessary to have a structure that can use the rendezvouz interface available in PostgreSQL in a safe manner. This commit adds such a structure containing: The size of the structure to be able to check that function pointers are not out-of-bounds. PostgreSQL magic to get compilation parameters affecting the ABI. This allow the plugin to check that it is compatible with the PostgreSQL server. PostgreSQL and TimescaleDB full version to be able to control usage from the plugin side. The PostgreSQL magic contains the major version of the server, but not the minor version, so we store `PG_VERSION_NUM` in this field and generate a similar `TS_VERSION_NUM` constant for TimescaleDB. This is mostly intended to deal with bugs inside a minor version.
2cd2858
to
b0bcbc2
Compare
#define TS_PLUGIN_CALLBACK(PTR, FUNC, ...) \ | ||
do \ | ||
{ \ | ||
if ((PTR) && offsetof(TimescaleDBPlugin, FUNC) < (PTR)->size && (PTR)->FUNC) \ | ||
(*(PTR)->FUNC)(__VA_ARGS__); \ | ||
} while (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is prepared to call a function passing some parameters but without returning values. I think we also need a way to cover execute a callback function from other extension returning some value. I.e.: https://github.com/timescale/timescaledb/blob/main/src/tss_callbacks.h#L16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is prepared to call a function passing some parameters but without returning values.
Yes, I did that since I was unsure if the added functions need a return value. It is easy to add/modify if we need, even in later versions, since this is just a convenience macro.
I think we also need a way to cover execute a callback function from other extension returning some value. I.e.: https://github.com/timescale/timescaledb/blob/main/src/tss_callbacks.h#L16
Ah, good, I was wondering if there were anything else that we should add at this time.
It is possible to have callbacks both ways, but setting it up is a little tricky so thinking about good schemes for dealing with this to reduce the risk of mistakes.
If another extension want to track TimescaleDB events it is necessary to have a structure that can use the rendezvouz interface available in PostgreSQL in a safe manner.
This commit adds such a structure containing:
The size of the structure to be able to check that function pointers are not out-of-bounds.
PostgreSQL magic to get compilation parameters affecting the ABI. This allow the plugin to check that it is compatible with the PostgreSQL server.
PostgreSQL and TimescaleDB full version to be able to control usage from the plugin side. The PostgreSQL magic contains the major version of the server, but not the minor version, so we store
PG_VERSION_NUM
in this field and generate a similarTS_VERSION_NUM
constant for TimescaleDB. It is mostly useful to deal with issues inside a minor release and make sure that we have a venue to handle bugs.