Page MenuHomePhabricator

DatabasePostgres::fieldInfo() can and does return null
Closed, ResolvedPublic

Description

	protected function setDefault( $table, $field, $default ) {
		$info = $this->db->fieldInfo( $table, $field );
		if ( $info->defaultValue() !== $default ) {
			$this->output( "Changing '$table.$field' default value\n" );
			$this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT "
				. $this->db->addQuotes( $default ) );
		}
	}

fieldInfo can return null...

The following line is run: php maintenance/install.php "mywiki" Admin --pass=mysecretpass \
 --dbport=5432 \
 --dbserver=172.18.0.1 \
 --dbtype=postgres \
 --dbname=docker \
 --installdbuser=docker \
 --installdbpass=docker \
 --scriptpath=/


Going to run database updates for docker
Depending on the size of your database this may take a while!
...skipping: 'mwuser' table doesn't exist yet.
...skipping: 'mwuser' table doesn't exist yet.
...skipping: 'pagecontent' table doesn't exist yet.
Creating sequence logging_log_id_seq
Creating sequence page_restrictions_pr_id_seq
Creating sequence filearchive_fa_id_seq
Exception encountered, of type "Error"
[2aa20eea975fe3470ea34360] [no req]   Error from line 737 of /app/web/includes/installer/PostgresUpdater.php: Call to a member function defaultValue() on null
Backtrace:
#0 /app/web/includes/installer/PostgresUpdater.php(605): PostgresUpdater->setDefault(string, string, string)
#1 /app/web/includes/installer/DatabaseUpdater.php(455): PostgresUpdater->addSequence(string, string, string)
#2 /app/web/includes/installer/DatabaseUpdater.php(416): DatabaseUpdater->runUpdates(array, boolean)
#3 /app/web/maintenance/update.php(197): DatabaseUpdater->doUpdates(array)
#4 /app/web/maintenance/doMaintenance.php(103): UpdateMediaWiki->execute()
#5 /app/web/maintenance/update.php(242): require_once(string)
#6 {main}


Accessing the wiki returns:
A database query error has occurred. This may indicate a bug in the software.

Query:
SELECT lc_value FROM "l10n_cache" WHERE lc_lang = 'en-us' AND lc_key = 'deps' LIMIT 1
Function: LCStoreDB::get
Error: 42P01 ERROR: relation "l10n_cache" does not exist LINE 1: SELECT /* LCStoreDB::get */ lc_value FROM "l10n_cache" ... ^

Event Timeline

Also, if you care about installing MW on pgsql... It seems it does break the whole installer too... So possibly two issues to fix here

Krinkle claimed this task.
Krinkle added a subscriber: Krinkle.

We have postgres passing in WMF CI and Travis now, so I'm assuming this issue is implicitly resolved as such.

Change 574610 had a related patch set uploaded (by saper; owner: saper):
[mediawiki/core@master] Stop updater if the database field does not exist

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