Page MenuHomePhabricator

Upgrading pagelinks table makes pl_target_id NOT NULL, creating from scratch doesn’t
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Upgrade MediaWiki from an older version to 1.43 and note that the patch for T299947 will perform the alter CHANGE pl_target_id pl_target_id BIGINT UNSIGNED NOT NULL;
  • Consult the schema for new wikis as currently specified in tables.json and tables-generated.sql and notice that they do NOT mark the column as NOT NULL, see here
  • Run Ladsgroup’s drift checker and see a reported drift, even when update.php has finished running - pagelinks pl_target_id field-nullable-mismatch. The abstract schema says that the column is nullable, and the schema changes performed by the updater make it not null.

What happens?:
There is a drift, the schema changes performed by the updater result in a schema different from the schema that would be created by the installer.

What should have happened instead?:
The schemas should match, either with the column nullable in both cases (new wiki vs upgrade) or not nullable in both cases. No drift should be reported by the drift checker.

Software version
MediaWiki 1.43

Event Timeline

Change #1249425 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@master] sql: Mark pl_target_id as non-nullable in abstract schema

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

Consult the schema for new wikis as currently specified in tables.json and tables-generated.sql and notice that they do NOT mark the column as NOT NULL, see here

This is actually only the case in the json file and not the generated sql files. See their current content.

MySQL

CREATE TABLE /*_*/pagelinks (
  pl_from INT UNSIGNED DEFAULT 0 NOT NULL,
  pl_target_id BIGINT UNSIGNED NOT NULL,
  pl_from_namespace INT DEFAULT 0 NOT NULL,
  INDEX pl_target_id (pl_target_id, pl_from),
  INDEX pl_backlinks_namespace_target_id (
    pl_from_namespace, pl_target_id,
    pl_from
  ),
  PRIMARY KEY(pl_from, pl_target_id)
) /*$wgDBTableOptions*/;

SQLite

CREATE TABLE /*_*/pagelinks (
  pl_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
  pl_target_id BIGINT UNSIGNED NOT NULL,
  pl_from_namespace INTEGER DEFAULT 0 NOT NULL,
  PRIMARY KEY(pl_from, pl_target_id)
);

PostgreSQL

CREATE TABLE pagelinks (
  pl_from INT DEFAULT 0 NOT NULL,
  pl_target_id BIGINT NOT NULL,
  pl_from_namespace INT DEFAULT 0 NOT NULL,
  PRIMARY KEY(pl_from, pl_target_id)
);

Change #1249425 merged by jenkins-bot:

[mediawiki/core@master] sql: Mark pl_target_id as non-nullable in abstract schema

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

Thank you, @Zabe

I see it in master. Can the patch be backported to REL1_43, please?

Change #1255903 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_45] sql: Mark pl_target_id as non-nullable in abstract schema

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

Change #1255904 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_44] sql: Mark pl_target_id as non-nullable in abstract schema

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

Change #1255905 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@REL1_43] sql: Mark pl_target_id as non-nullable in abstract schema

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

Change #1255905 merged by jenkins-bot:

[mediawiki/core@REL1_43] sql: Mark pl_target_id as non-nullable in abstract schema

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

Change #1255903 merged by jenkins-bot:

[mediawiki/core@REL1_45] sql: Mark pl_target_id as non-nullable in abstract schema

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

Change #1255904 merged by jenkins-bot:

[mediawiki/core@REL1_44] sql: Mark pl_target_id as non-nullable in abstract schema

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