-
Notifications
You must be signed in to change notification settings - Fork 3
Port hook path to C #68
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
Open
JoshDreamland
wants to merge
9
commits into
main
Choose a base branch
from
port-hook-path-to-c
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8e4705a
Keep track of nested queries stack-style and emit `parent_query_id`
JoshDreamland 0f03866
fix: replace std::vector query stack with fixed-size array to avoid OOM
JoshDreamland b971d52
refactor: port hook-path sources from C++ to C
JoshDreamland a31691e
More bots makes the batter better
JoshDreamland 7baa9e6
refactor: eliminate local frame copies in query stack push/pop
JoshDreamland 7663299
refactor: port hook-path sources from C++ to C
JoshDreamland 89c7140
Cast parent_query_id to int64_t before appending
JoshDreamland a0ab116
refactor: extract query stack helpers and store CPU delta in frame
JoshDreamland cc1991f
Merge nested-query-details: query stack helpers + CPU delta in frame
JoshDreamland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -- Migration: add parent_query_id column | ||
| -- | ||
| -- Introduced in pg_stat_ch 0.4.x. Each event now carries the query_id of its | ||
| -- calling query (e.g. the plpgsql function that issued an SPI statement). | ||
| -- Top-level queries emit 0. Use WHERE parent_query_id = 0 in aggregations to | ||
| -- avoid double-counting CPU and duration across nested calls. | ||
| -- | ||
| -- Run against your ClickHouse instance before upgrading the extension: | ||
| -- clickhouse-client < migrations/001_add_parent_query_id.sql | ||
|
|
||
| ALTER TABLE pg_stat_ch.events_raw | ||
| ADD COLUMN IF NOT EXISTS parent_query_id UInt64 DEFAULT 0; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -93,6 +93,7 @@ void ExportEventStats(const std::vector<PschEvent>& events, StatsExporter* expor | |||||
| auto col_username = exporter->DbUserColumn(); | ||||||
| auto col_pid = exporter->RecordInt32("pid"); | ||||||
| auto col_query_id = exporter->RecordInt64("query_id"); | ||||||
| auto col_parent_query_id = exporter->RecordUInt64("parent_query_id"); | ||||||
| auto col_cmd_type = exporter->DbOperationColumn(); | ||||||
| auto col_rows = exporter->MetricUInt64("rows"); | ||||||
| auto col_query = exporter->DbQueryTextColumn(); | ||||||
|
|
@@ -148,6 +149,7 @@ void ExportEventStats(const std::vector<PschEvent>& events, StatsExporter* expor | |||||
| col_username->Append(std::string(ev.username, ev.username_len)); | ||||||
| col_pid->Append(ev.pid); | ||||||
| col_query_id->Append(static_cast<int64_t>(ev.queryid)); | ||||||
| col_parent_query_id->Append(static_cast<int64_t>(ev.parent_query_id)); | ||||||
|
||||||
| col_parent_query_id->Append(static_cast<int64_t>(ev.parent_query_id)); | |
| col_parent_query_id->Append(ev.parent_query_id); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The migration header says this is introduced in pg_stat_ch 0.4.x, but the extension control file currently advertises default_version = 0.1. Please align the referenced version (or describe it without a specific version) to avoid confusing upgrade guidance.