jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/359961 )
Change subject: Fix the tableExists method of MysqlBase
......................................................................
Fix the tableExists method of MysqlBase
The table name generated by Database::tableName() does not work in
MysqlBase's tableExist method, as the syntax of SHOW TABLES does not
function like other foreign db queries. It instead should use FROM
$database rather than the database name in front of the table name.
Bug: T168207
Change-Id: I7806090eaa647959fd34de8bc606eeb952161529
---
M includes/libs/rdbms/database/DatabaseMysqlBase.php
1 file changed, 15 insertions(+), 1 deletion(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php
b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index 50ead83..e237ef4 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -532,11 +532,25 @@
return true; // already known to exist and won't show
in SHOW TABLES anyway
}
+ // Split database and table into proper variables as
Database::tableName() returns
+ // shared tables prefixed with their database, which do not
work in SHOW TABLES statements
+ list( $database, $schema, $prefix, $table ) =
$this->qualifiedTableComponents( $table );
+
+ $table = $prefix . $table;
+
// We can't use buildLike() here, because it specifies an
escape character
// other than the backslash, which is the only one supported by
SHOW TABLES
$encLike = $this->escapeLikeInternal( $table, '\\' );
- return $this->query( "SHOW TABLES LIKE '$encLike'", $fname
)->numRows() > 0;
+ // If the database has been specified (such as for shared
tables), add a FROM $database clause
+ if ( $database !== '' ) {
+ $database = $this->addIdentifierQuotes( $database );
+ $query = "SHOW TABLES FROM $database LIKE '$encLike'";
+ } else {
+ $query = "SHOW TABLES LIKE '$encLike'";
+ }
+
+ return $this->query( $query, $fname )->numRows() > 0;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/359961
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7806090eaa647959fd34de8bc606eeb952161529
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Jcrespo <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mainframe98 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits