feat: support postgres query hook#51
Conversation
|
|
||
| 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.
These values should not be constant. Why not use symbol name?
There was a problem hiding this comment.
will take a look and change it ~
There was a problem hiding this comment.
And I think I should drop offset
| @@ -0,0 +1,42 @@ | |||
| #include "ecapture.h" | |||
| #include "common.h" | |||
| // 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.
what is the difference between exec_simple_query and exec_parse_message, Why not exec_parse_message?
There was a problem hiding this comment.
exec_parse_message called in exec_simple_query.
cfc4n
left a comment
There was a problem hiding this comment.
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 |
|
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 valuein anotherPRif could