Page MenuHomePhabricator

Change type of gb_address to VARBINARY
Closed, ResolvedPublic

Description

Summary

This task is to make the gb_address column in the globalblocks table be VARBINARY

Background

  • Per T395669: globalblocks table: SQL in extension and production have different type for gb_address and comments in this task, the gb_address column should have the varbinary type and not the varchar type
    • WMF wikis have the column set as varbinary which is correct, but the extension source code has it set as varchar (and so maybe other third-party wikis)
  • We should make these consistent through a schema change that sets the type of gb_address
    • We can apply this schema change to WMF wikis to have the effect of removing the default from the column

Proposed schema changes

Stage 1: Fix the type and remove default from gb_address

Change the type of the gb_address column to VARBINARY(255) NOT NULL

ALTER TABLE /*_*/globalblocks
  CHANGE gb_address gb_address VARBINARY(255) NOT NULL;

Acceptance criteria

Event Timeline

Would appreciate any DBA feedback on this, especially about the datatype being used for gb_target (as we can choose the appropriate one to use).

The equivalent in column in the block_target table is bl_user_text. This is defined as a VARBINARY(255). Additionally, the globaluser has the column gu_name which is VARBINARY(255) too. That suggests going with the binary type as the column would be the appropriate choice.

Timescales on this are likely that we will not start significant work on this for at least several weeks, possibly a few months. So no rush on any feedback. Thanks in advance

Dreamy_Jazz updated the task description. (Show Details)
Dreamy_Jazz moved this task from Inbox to Later sprints on the Product Safety and Integrity board.

On the type: We always use varbinary and it's standardized while abstraction. In most case it won't even make a difference since our charset is binary in the first place.

If you're just renaming the field, I discourage it since any schema change adds a lot of overhead from the work for the DBAs, code maintenance, etc. If you're doing something else and bundling the rename, that's fine.

There was a default that we wanted to remove, but that doesn't necessarily require a schema change. The only other change was to make the type be the same, but I thought it isn't possible to change the data type while there is data in the column.

Maybe to clarify, is it possible to fix the data type without breaking the data in column? If not possible, do we care about having the schema drift remain forever?

So what's the current data type and what's the desired one?

So what's the current data type and what's the desired one?

The current data type is:

  • On WMF wikis it is varbinary(255) NOT NULL DEFAULT ''
  • In tables-generated.sql it is VARCHAR(255) NOT NULL

Ideally I want to make WMF wikis and tables-generated.sql use the same type to avoid the drift (though have no preference either way on what data type is chosen). However, I think I am proposing the data type be VARCHAR(255) NOT NULL on WMF wikis and tables-generated.sql to avoid the need for a schema change in the extension


If this schema drift of the data type should be ignored from the point of view of DBA, then I'd only suggest removing the default from the column

https://www.mediawiki.org/wiki/Manual:Schema_changes

Instead of VARCHAR or CHAR, use VARBINARY or BINARY (otherwise you have to deal with encodings in databases)

https://www.mediawiki.org/wiki/Manual:Schema_changes

Instead of VARCHAR or CHAR, use VARBINARY or BINARY (otherwise you have to deal with encodings in databases)

Okay, then I propose to:

  • Make a schema change in the extension to alter the type of gb_address in globalblocks to VARBINARY from VARCHAR
  • Apply this schema change, which has the effect of removing the default on WMF wikis without changing the data type

Does this make sense? If so, I can update the tasks to reflect this

https://www.mediawiki.org/wiki/Manual:Schema_changes

Instead of VARCHAR or CHAR, use VARBINARY or BINARY (otherwise you have to deal with encodings in databases)

Okay, then I propose to:

  • Make a schema change in the extension to alter the type of gb_address in globalblocks to VARBINARY from VARCHAR
  • Apply this schema change, which has the effect of removing the default on WMF wikis without changing the data type

Does this make sense? If so, I can update the tasks to reflect this

That looks good to me

Dreamy_Jazz renamed this task from Create gb_target in globalblocks table to Change type of gb_address to VARBINARY.Jan 15 2026, 11:07 AM
Dreamy_Jazz updated the task description. (Show Details)

Change #1227810 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/GlobalBlocking@master] Standardise type of gb_address column in globalblocks table

https://gerrit.wikimedia.org/r/1227810

Change #1227810 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Standardise type of gb_address column in globalblocks table

https://gerrit.wikimedia.org/r/1227810

Dreamy_Jazz closed this task as Resolved.EditedJan 19 2026, 1:36 PM
Dreamy_Jazz updated the task description. (Show Details)

Schema change applied to the extension to fix the type inconsistency, filed T414964 to handle the Schema-change-in-production