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

Allow counters to be created with same name, provider and source as a deleted one #10223

Open
wants to merge 6 commits into
base: 4.19
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,20 @@
-- Add last_id to the volumes table
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.volumes', 'last_id', 'bigint(20) unsigned DEFAULT NULL');

ALTER TABLE `cloud`.`counter` DROP KEY `uc_counter__provider__source__value`;
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value_removed', '(provider, source, value, removed)');
SELECT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call @weizhouapache that will help with a lot of these parallel upgrade issues.

COUNT(*)
INTO @exists
FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = 'cloud'
AND TABLE_NAME = 'counter'
AND INDEX_NAME = 'uc_counter__provider__source__value';

-- Drop the key if it exists
SET @sql = IF(@exists > 0, 'ALTER TABLE counter DROP KEY uc_counter__provider__source__value', NULL);

-- Execute the drop statement if the index exists
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)');
Loading