Skip to content
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

Fix #1502 Add triggers support #1503

Merged
merged 18 commits into from
Mar 3, 2025
Merged

Fix #1502 Add triggers support #1503

merged 18 commits into from
Mar 3, 2025

Conversation

yakirgb
Copy link
Contributor

@yakirgb yakirgb commented Mar 3, 2025

Fix #1502
Based on https://github.com/openark/gh-ost/pull/30/files
Also added localtests, and one minor change compare to openark repo,
Changed the query of :

// verifyTriggersDontExist verifies before createing new triggers we want to make sure these triggers dont exist already in the DB
func (this *Inspector) validateGhostTriggersDontExist() error {
	if len(this.migrationContext.Triggers) > 0 {
		var foundTriggers []string
		for _, trigger := range this.migrationContext.Triggers {
			triggerName := this.migrationContext.GetGhostTriggerName(trigger.Name)
			query := "select 1 from information_schema.triggers where trigger_name = ? and trigger_schema = ?

To include also : and event_object_table = ?"

Modify extra_args files for trigger-complex, trigger-multiple, and trigger-self-reference tests to use different trigger suffixes
Update extra_args files for trigger tests to include the new --remove-trigger-suffix-if-exists option, ensuring consistent trigger handling across different test scenarios
Update create.sql files across trigger test scenarios to:
- Consistently drop both original and ghost triggers
- Ensure clean slate before creating triggers
- Align with recent trigger suffix changes

This change improves test reliability and consistency by explicitly dropping all potential trigger variations before test setup.
Refactor local test scenarios for triggers by:
- Merging multiple trigger test configurations into comprehensive test cases
- Updating create.sql files with more complex and diverse trigger scenarios
- Standardizing trigger and table setup across different test configurations
- Removing redundant test directories while preserving test coverage

This change simplifies the trigger testing infrastructure and provides more robust test coverage for gh-ost's trigger handling capabilities.
Enhance ghost trigger existence check by adding detailed debug logging to:
- Log the ghost trigger name being searched
- Log the database schema and query details
- Log when an existing ghost trigger is found

This change improves visibility into the trigger validation process, making troubleshooting easier during migration scenarios.
Modify validateGhostTriggersDontExist() to:
- Add a direct query to log all triggers in the database schema
- Refactor trigger existence check to use count-based query
- Improve debug logging for trigger validation process
- Provide more detailed error reporting for existing ghost triggers

This change enhances the robustness and observability of the trigger validation mechanism in gh-ost's migration process.
Simplify and enhance the validateGhostTriggersDontExist() method by:
- Removing redundant direct query logging
- Streamlining trigger existence check
- Improving debug logging for trigger validation
- Consolidating trigger existence detection logic

The changes provide more concise and focused trigger validation with clearer error reporting.
Refactor validateGhostTriggersDontExist() to:
- Streamline trigger existence check query
- Remove redundant debug logging statements
- Use a more concise approach to detecting existing triggers

The changes reduce code complexity while maintaining the core validation logic for ghost triggers.
Modify validateGhostTriggersDontExist() to:
- Add table name filter to trigger existence check query
- Improve specificity of ghost trigger detection
- Prevent false positives from similarly named triggers in different tables

The change ensures more precise ghost trigger validation by incorporating the original table name into the query criteria.
…dated test scenarios

Update trigger-advanced-features test configuration to:
- Add new column 'color' and 'modified_count' to test table
- Implement more complex trigger logic for color and count tracking
- Consolidate trigger test scenarios with richer data transformations
- Modify event to test both numeric and color-based updates
- Remove redundant trigger-basic-features directory

The changes provide a more comprehensive and nuanced test suite for gh-ost's trigger handling capabilities, demonstrating advanced trigger behaviors and self-referencing updates.
Modify the extra_args file to use '_ght' trigger suffix instead of '_gho', maintaining consistency with recent trigger test configuration updates.
Clean up repository by removing the gh-ost-ci-env submodule, which appears to be no longer needed in the project structure.
@yakirgb yakirgb changed the title Fix https://github.com/github/gh-ost/issues/1502 Fix #1502 Mar 3, 2025
@yakirgb yakirgb changed the title Fix #1502 Fix #1502 Add triggers support Mar 3, 2025
@meiji163
Copy link
Contributor

meiji163 commented Mar 3, 2025

Thanks for opening this backport, LGTM!

@meiji163 meiji163 merged commit 0263a20 into github:master Mar 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backport openark/gh-ost/pull/30 to this repo - add triggers support
3 participants