51 if ( !self::isPresent() ) {
52 throw new MWException(
"Can't check SQL syntax: SQLite not found" );
54 if ( !is_array( $files ) ) {
58 $allowedTypes = array_fill_keys( [
66 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
68 foreach ( $files as
$file ) {
69 $err = $db->sourceFile(
$file );
75 $tables = $db->query(
"SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
76 foreach ( $tables as $table ) {
77 if ( strpos( $table->name,
'sqlite_' ) === 0 ) {
81 $columns = $db->query(
82 'PRAGMA table_info(' . $db->addIdentifierQuotes( $table->name ) .
')',
85 foreach ( $columns as $col ) {
86 if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
87 $db->close( __METHOD__ );
89 return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
94 return $e->getMessage();
96 $db->close( __METHOD__ );