-
Notifications
You must be signed in to change notification settings - Fork 204
K8SPXC-1748: add checks before creating functions in collector #2264
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
12537a1
K8SPXC-1748: add checks before creating functions in collector
pooknull a292563
create functions in the entrypoint
pooknull e9d086f
`CREATE FUNCTION` should be executed only on 8.0 ver
pooknull 7a14d1b
temporarily set `wsrep_on = OFF`
pooknull 7f3588a
Merge branch 'main' into K8SPXC-1748
hors 0f86adc
check for functions in 8.4 too
pooknull 5484528
Merge branch 'main' into K8SPXC-1748
pooknull d827e83
update version-service file for smart update tests
pooknull 6233eb6
create functions earlier
pooknull ea6cc17
Merge branch 'main' into K8SPXC-1748
hors 1a1c70d
fix `pitr` test
pooknull b716cf3
Merge branch 'main' into K8SPXC-1748
pooknull 5dbd0ad
Merge branch 'main' into K8SPXC-1748
hors 5e754f6
Merge branch 'main' into K8SPXC-1748
hors 7e1c659
fix entrypoint
pooknull 14704b2
set wsrep_on = OFF for 8.4
pooknull 2e32d7b
Merge branch 'main' into K8SPXC-1748
pooknull 4b4e888
fix entrypoint
pooknull 899f53c
`make manifests`
pooknull 32b12dc
Merge branch 'main' into K8SPXC-1748
egegunes 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,19 +351,27 @@ func (p *PXC) UninstallBinlogUDFComponent(ctx context.Context) error { | |
| } | ||
|
|
||
| func (p *PXC) CreateCollectorFunctions(ctx context.Context) error { | ||
| _, err := p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_last_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'") | ||
| if err != nil { | ||
| return errors.Wrap(err, "create function get_first_record_timestamp_by_binlog") | ||
| m := map[string]string{ | ||
| "get_last_record_timestamp_by_binlog": "INTEGER", | ||
| "get_gtid_set_by_binlog": "STRING", | ||
| "get_first_record_timestamp_by_binlog": "INTEGER", | ||
| } | ||
|
|
||
| _, err = p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_gtid_set_by_binlog RETURNS STRING SONAME 'binlog_utils_udf.so'") | ||
| if err != nil { | ||
| return errors.Wrap(err, "create function get_gtid_set_by_binlog") | ||
| } | ||
| for functionName, returnType := range m { | ||
| var x int | ||
| err := p.db.QueryRowContext(ctx, `SELECT 1 FROM mysql.func WHERE name = ? LIMIT 1`, functionName).Scan(&x) | ||
| if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
| return errors.Wrapf(err, "check if function %s exists", functionName) | ||
| } | ||
| if err == nil { | ||
| log.Printf("function %s already exists", functionName) | ||
| continue | ||
| } | ||
|
|
||
| _, err = p.db.ExecContext(ctx, "CREATE FUNCTION IF NOT EXISTS get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME 'binlog_utils_udf.so'") | ||
| if err != nil { | ||
| return errors.Wrap(err, "create function get_first_record_timestamp_by_binlog") | ||
| createQ := fmt.Sprintf("CREATE FUNCTION IF NOT EXISTS %s RETURNS %s SONAME 'binlog_utils_udf.so'", functionName, returnType) | ||
|
||
| if _, err := p.db.ExecContext(ctx, createQ); err != nil { | ||
| return errors.Wrapf(err, "create function %s", functionName) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
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
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.
Given that we are using the
IF NOT EXISTSon the subsequent query, is this check regarding the existence of the function necessary?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.
yes, that's the whole point.
CREATE IF NOT EXISTSstill counts as DDL