-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: support postgres query hook #51
Conversation
cli/cmd/postgres.go
Outdated
|
||
func init() { | ||
postgresCmd.PersistentFlags().StringVarP(&postgresConfig.PostgresPath, "postgres", "m", "/usr/bin/postgres", "postgres binary file path, use to hook") | ||
postgresCmd.PersistentFlags().Uint64VarP(&postgresConfig.Offset, "offset", "", 0, "0x710410") |
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.
These values should not be constant. Why not use symbol name?
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.
will take a look and change it ~
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.
And I think I should drop offset
kern/postgres_kern.c
Outdated
@@ -0,0 +1,42 @@ | |||
#include "ecapture.h" | |||
#include "common.h" |
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.
It was included in ecapture.h
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.
copy that
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.
How to know that It works with postgres binrary? Can you give some screenshots of catrure with postgres?
// versions 10 - now | ||
// static void exec_simple_query(const char *query_string) | ||
SEC("uprobe/exec_simple_query") | ||
int postgres_query(struct pt_regs *ctx) { |
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.
what is the difference between exec_simple_query
and exec_parse_message
, Why not exec_parse_message
?
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.
exec_parse_message called in exec_simple_query.
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.
portgres use two function to exec queries in https://github.com/postgres/postgres/blob/7b7ed046cb2ad9f6efac90380757d5977f0f563f/src/backend/tcop/postgres.c#L4539 And https://github.com/postgres/postgres/blob/7b7ed046cb2ad9f6efac90380757d5977f0f563f/src/backend/tcop/postgres.c#L4571 whit params Q
and P
, why is that ? and this PR can capture all query commands?
Done, the screenshoot in the content now. |
yes, it capture all the query I think its the same logic as mysqld And FYI, we can not hook |
@cfc4n Done and clean some code. |
please merge all commits into one commit with command
|
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.
Of course I did that in last And I think the the |
Done |
LGTM, thanks. |
Will do some test on other env and add it to README |
Fix:#48 basic support for
Postgres 10+
will do thereturn value
in anotherPR
if could