mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/14739] Remove SQLite 2.8.x database driver
PHPBB3-14739
This commit is contained in:
@@ -136,37 +136,6 @@ class tools implements tools_interface
|
||||
'VARBINARY' => 'raw(255)',
|
||||
),
|
||||
|
||||
'sqlite' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'ULINT' => 'INTEGER UNSIGNED', // 'int(10) UNSIGNED',
|
||||
'UINT' => 'INTEGER UNSIGNED', // 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'INTEGER UNSIGNED', // 'mediumint(4) UNSIGNED',
|
||||
'BOOL' => 'INTEGER UNSIGNED', // 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'text(65535)',
|
||||
'STEXT' => 'text(65535)',
|
||||
'TEXT' => 'text(65535)',
|
||||
'MTEXT' => 'mediumtext(16777215)',
|
||||
'XSTEXT_UNI'=> 'text(65535)',
|
||||
'STEXT_UNI' => 'text(65535)',
|
||||
'TEXT_UNI' => 'text(65535)',
|
||||
'MTEXT_UNI' => 'mediumtext(16777215)',
|
||||
'TIMESTAMP' => 'INTEGER UNSIGNED', // 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar(255)',
|
||||
'VARBINARY' => 'blob',
|
||||
),
|
||||
|
||||
'sqlite3' => array(
|
||||
'INT:' => 'INT(%d)',
|
||||
'BINT' => 'BIGINT(20)',
|
||||
@@ -277,12 +246,6 @@ class tools implements tools_interface
|
||||
$sql = 'SHOW TABLES';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
$sql = 'SELECT name
|
||||
FROM sqlite_master
|
||||
WHERE type = "table"';
|
||||
break;
|
||||
|
||||
case 'sqlite3':
|
||||
$sql = 'SELECT name
|
||||
FROM sqlite_master
|
||||
@@ -398,7 +361,6 @@ class tools implements tools_interface
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')';
|
||||
break;
|
||||
@@ -420,7 +382,6 @@ class tools implements tools_interface
|
||||
break;
|
||||
|
||||
case 'mysql_40':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$table_sql .= "\n);";
|
||||
$statements[] = $table_sql;
|
||||
@@ -497,7 +458,7 @@ class tools implements tools_interface
|
||||
$sqlite = false;
|
||||
|
||||
// For SQLite we need to perform the schema changes in a much more different way
|
||||
if (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') && $this->return_statements)
|
||||
if ($this->db->get_sql_layer() == 'sqlite3' && $this->return_statements)
|
||||
{
|
||||
$sqlite_data = array();
|
||||
$sqlite = true;
|
||||
@@ -884,7 +845,6 @@ class tools implements tools_interface
|
||||
WHERE LOWER(table_name) = '" . strtolower($table_name) . "'";
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$sql = "SELECT sql
|
||||
FROM sqlite_master
|
||||
@@ -967,7 +927,6 @@ class tools implements tools_interface
|
||||
$col = 'index_name';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$sql = "PRAGMA index_list('" . $table_name . "');";
|
||||
$col = 'name';
|
||||
@@ -986,7 +945,6 @@ class tools implements tools_interface
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'oracle':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$row[$col] = substr($row[$col], strlen($table_name) + 1);
|
||||
break;
|
||||
@@ -1026,7 +984,6 @@ class tools implements tools_interface
|
||||
$col = 'index_name';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$sql = "PRAGMA index_list('" . $table_name . "');";
|
||||
$col = 'name';
|
||||
@@ -1041,7 +998,7 @@ class tools implements tools_interface
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($this->sql_layer == 'sqlite' || $this->sql_layer == 'sqlite3') && !$row['unique'])
|
||||
if ($this->sql_layer == 'sqlite3' && !$row['unique'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1061,7 +1018,6 @@ class tools implements tools_interface
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$row[$col] = substr($row[$col], strlen($table_name) + 1);
|
||||
break;
|
||||
@@ -1193,18 +1149,12 @@ class tools implements tools_interface
|
||||
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$return_array['primary_key_set'] = false;
|
||||
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
|
||||
{
|
||||
$sql .= ' INTEGER PRIMARY KEY';
|
||||
$sql .= ' INTEGER PRIMARY KEY AUTOINCREMENT';
|
||||
$return_array['primary_key_set'] = true;
|
||||
|
||||
if ($this->sql_layer === 'sqlite3')
|
||||
{
|
||||
$sql .= ' AUTOINCREMENT';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1306,57 +1256,6 @@ class tools implements tools_interface
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql'];
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
if ($inline && $this->return_statements)
|
||||
{
|
||||
return $column_name . ' ' . $column_data['column_type_sql'];
|
||||
}
|
||||
|
||||
$recreate_queries = $this->sqlite_get_recreate_table_queries($table_name);
|
||||
if (empty($recreate_queries))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$statements[] = 'begin';
|
||||
|
||||
$sql_create_table = array_shift($recreate_queries);
|
||||
|
||||
// Create a backup table and populate it, destroy the existing one
|
||||
$statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table);
|
||||
$statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name;
|
||||
$statements[] = 'DROP TABLE ' . $table_name;
|
||||
|
||||
preg_match('#\((.*)\)#s', $sql_create_table, $matches);
|
||||
|
||||
$new_table_cols = trim($matches[1]);
|
||||
$old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols);
|
||||
$column_list = array();
|
||||
|
||||
foreach ($old_table_cols as $declaration)
|
||||
{
|
||||
$entities = preg_split('#\s+#', trim($declaration));
|
||||
if ($entities[0] == 'PRIMARY')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$column_list[] = $entities[0];
|
||||
}
|
||||
|
||||
$columns = implode(',', $column_list);
|
||||
|
||||
$new_table_cols = $column_name . ' ' . $column_data['column_type_sql'] . ',' . $new_table_cols;
|
||||
|
||||
// create a new table and fill it up. destroy the temp one
|
||||
$statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');';
|
||||
$statements = array_merge($statements, $recreate_queries);
|
||||
|
||||
$statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;';
|
||||
$statements[] = 'DROP TABLE ' . $table_name . '_temp';
|
||||
|
||||
$statements[] = 'commit';
|
||||
break;
|
||||
|
||||
case 'sqlite3':
|
||||
if ($inline && $this->return_statements)
|
||||
{
|
||||
@@ -1388,7 +1287,6 @@ class tools implements tools_interface
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name;
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
|
||||
if ($inline && $this->return_statements)
|
||||
@@ -1465,7 +1363,6 @@ class tools implements tools_interface
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name;
|
||||
break;
|
||||
@@ -1529,7 +1426,6 @@ class tools implements tools_interface
|
||||
$statements[] = 'ALTER TABLE ' . $table_name . ' add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
|
||||
if ($inline && $this->return_statements)
|
||||
@@ -1596,7 +1492,6 @@ class tools implements tools_interface
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'oracle':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||
break;
|
||||
@@ -1628,7 +1523,6 @@ class tools implements tools_interface
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'oracle':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||
break;
|
||||
@@ -1693,7 +1587,6 @@ class tools implements tools_interface
|
||||
$col = 'index_name';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$sql = "PRAGMA index_info('" . $table_name . "');";
|
||||
$col = 'name';
|
||||
@@ -1711,7 +1604,6 @@ class tools implements tools_interface
|
||||
switch ($this->sql_layer)
|
||||
{
|
||||
case 'oracle':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
$row[$col] = substr($row[$col], strlen($table_name) + 1);
|
||||
break;
|
||||
@@ -1818,7 +1710,6 @@ class tools implements tools_interface
|
||||
$this->return_statements = $old_return_statements;
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
|
||||
if ($inline && $this->return_statements)
|
||||
@@ -1899,7 +1790,6 @@ class tools implements tools_interface
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
// Not supported
|
||||
throw new \Exception('DBMS is not supported');
|
||||
|
Reference in New Issue
Block a user