mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 08:47:45 +02:00
[ticket/12747] Drop support for Firebird
PHPBB3-12747
This commit is contained in:
@@ -119,10 +119,6 @@ class acp_database
|
||||
case 'mssqlnative':
|
||||
$extractor = new mssql_extractor($format, $filename, $time, $download, $store);
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
$extractor = new firebird_extractor($format, $filename, $time, $download, $store);
|
||||
break;
|
||||
}
|
||||
|
||||
$extractor->write_start($table_prefix);
|
||||
@@ -141,7 +137,6 @@ class acp_database
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$extractor->flush('DELETE FROM ' . $table_name . ";\n");
|
||||
break;
|
||||
|
||||
@@ -338,20 +333,6 @@ class acp_database
|
||||
}
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
$delim = ";\n";
|
||||
while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false)
|
||||
{
|
||||
$query = trim($sql);
|
||||
if (substr($query, 0, 8) === 'SET TERM')
|
||||
{
|
||||
$delim = $query[9] . "\n";
|
||||
continue;
|
||||
}
|
||||
$db->sql_query($query);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
$delim = ";\n";
|
||||
while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false)
|
||||
@@ -2110,235 +2091,6 @@ class oracle_extractor extends base_extractor
|
||||
}
|
||||
}
|
||||
|
||||
class firebird_extractor extends base_extractor
|
||||
{
|
||||
function write_start($prefix)
|
||||
{
|
||||
$sql_data = "--\n";
|
||||
$sql_data .= "-- phpBB Backup Script\n";
|
||||
$sql_data .= "-- Dump of tables for $prefix\n";
|
||||
$sql_data .= "-- DATE : " . gmdate("d-m-Y H:i:s", $this->time) . " GMT\n";
|
||||
$sql_data .= "--\n";
|
||||
$this->flush($sql_data);
|
||||
}
|
||||
|
||||
function write_data($table_name)
|
||||
{
|
||||
global $db;
|
||||
$ary_type = $ary_name = array();
|
||||
|
||||
// Grab all of the data from current table.
|
||||
$sql = "SELECT *
|
||||
FROM $table_name";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$i_num_fields = ibase_num_fields($result);
|
||||
|
||||
for ($i = 0; $i < $i_num_fields; $i++)
|
||||
{
|
||||
$info = ibase_field_info($result, $i);
|
||||
$ary_type[$i] = $info['type'];
|
||||
$ary_name[$i] = $info['name'];
|
||||
}
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$schema_vals = $schema_fields = array();
|
||||
|
||||
// Build the SQL statement to recreate the data.
|
||||
for ($i = 0; $i < $i_num_fields; $i++)
|
||||
{
|
||||
$str_val = $row[strtolower($ary_name[$i])];
|
||||
|
||||
if (preg_match('#char|text|bool|varbinary|blob#i', $ary_type[$i]))
|
||||
{
|
||||
$str_quote = '';
|
||||
$str_empty = "''";
|
||||
$str_val = sanitize_data_generic(str_replace("'", "''", $str_val));
|
||||
}
|
||||
else if (preg_match('#date|timestamp#i', $ary_type[$i]))
|
||||
{
|
||||
if (empty($str_val))
|
||||
{
|
||||
$str_quote = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$str_quote = "'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$str_quote = '';
|
||||
$str_empty = 'NULL';
|
||||
}
|
||||
|
||||
if (empty($str_val) && $str_val !== '0')
|
||||
{
|
||||
$str_val = $str_empty;
|
||||
}
|
||||
|
||||
$schema_vals[$i] = $str_quote . $str_val . $str_quote;
|
||||
$schema_fields[$i] = '"' . $ary_name[$i] . '"';
|
||||
}
|
||||
|
||||
// Take the ordered fields and their associated data and build it
|
||||
// into a valid sql statement to recreate that field in the data.
|
||||
$sql_data = "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";
|
||||
|
||||
$this->flush($sql_data);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
function write_table($table_name)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql_data = '-- Table: ' . $table_name . "\n";
|
||||
$sql_data .= "DROP TABLE $table_name;\n";
|
||||
|
||||
$data_types = array(7 => 'SMALLINT', 8 => 'INTEGER', 10 => 'FLOAT', 12 => 'DATE', 13 => 'TIME', 14 => 'CHARACTER', 27 => 'DOUBLE PRECISION', 35 => 'TIMESTAMP', 37 => 'VARCHAR', 40 => 'CSTRING', 261 => 'BLOB', 701 => 'DECIMAL', 702 => 'NUMERIC');
|
||||
|
||||
$sql_data .= "\nCREATE TABLE $table_name (\n";
|
||||
|
||||
$sql = 'SELECT DISTINCT R.RDB$FIELD_NAME as FNAME, R.RDB$NULL_FLAG as NFLAG, R.RDB$DEFAULT_SOURCE as DSOURCE, F.RDB$FIELD_TYPE as FTYPE, F.RDB$FIELD_SUB_TYPE as STYPE, F.RDB$FIELD_LENGTH as FLEN
|
||||
FROM RDB$RELATION_FIELDS R
|
||||
JOIN RDB$FIELDS F ON R.RDB$FIELD_SOURCE=F.RDB$FIELD_NAME
|
||||
LEFT JOIN RDB$FIELD_DIMENSIONS D ON R.RDB$FIELD_SOURCE = D.RDB$FIELD_NAME
|
||||
WHERE F.RDB$SYSTEM_FLAG = 0
|
||||
AND R.RDB$RELATION_NAME = \''. $table_name . '\'
|
||||
ORDER BY R.RDB$FIELD_POSITION';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$rows = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$line = "\t" . '"' . $row['fname'] . '" ' . $data_types[$row['ftype']];
|
||||
|
||||
if ($row['ftype'] == 261 && $row['stype'] == 1)
|
||||
{
|
||||
$line .= ' SUB_TYPE TEXT';
|
||||
}
|
||||
|
||||
if ($row['ftype'] == 37 || $row['ftype'] == 14)
|
||||
{
|
||||
$line .= ' (' . $row['flen'] . ')';
|
||||
}
|
||||
|
||||
if (!empty($row['dsource']))
|
||||
{
|
||||
$line .= ' ' . $row['dsource'];
|
||||
}
|
||||
|
||||
if (!empty($row['nflag']))
|
||||
{
|
||||
$line .= ' NOT NULL';
|
||||
}
|
||||
$rows[] = $line;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql_data .= implode(",\n", $rows);
|
||||
$sql_data .= "\n);\n";
|
||||
$keys = array();
|
||||
|
||||
$sql = 'SELECT I.RDB$FIELD_NAME as NAME
|
||||
FROM RDB$RELATION_CONSTRAINTS RC, RDB$INDEX_SEGMENTS I, RDB$INDICES IDX
|
||||
WHERE (I.RDB$INDEX_NAME = RC.RDB$INDEX_NAME)
|
||||
AND (IDX.RDB$INDEX_NAME = RC.RDB$INDEX_NAME)
|
||||
AND (RC.RDB$RELATION_NAME = \''. $table_name . '\')
|
||||
ORDER BY I.RDB$FIELD_POSITION';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$keys[] = $row['name'];
|
||||
}
|
||||
|
||||
if (sizeof($keys))
|
||||
{
|
||||
$sql_data .= "\nALTER TABLE $table_name ADD PRIMARY KEY (" . implode(', ', $keys) . ');';
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'SELECT I.RDB$INDEX_NAME as INAME, I.RDB$UNIQUE_FLAG as UFLAG, S.RDB$FIELD_NAME as FNAME
|
||||
FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON S.RDB$INDEX_NAME=I.RDB$INDEX_NAME
|
||||
WHERE (I.RDB$SYSTEM_FLAG IS NULL OR I.RDB$SYSTEM_FLAG=0)
|
||||
AND I.RDB$FOREIGN_KEY IS NULL
|
||||
AND I.RDB$RELATION_NAME = \''. $table_name . '\'
|
||||
AND I.RDB$INDEX_NAME NOT STARTING WITH \'RDB$\'
|
||||
ORDER BY S.RDB$FIELD_POSITION';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$index = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$index[$row['iname']]['unique'] = !empty($row['uflag']);
|
||||
$index[$row['iname']]['values'][] = $row['fname'];
|
||||
}
|
||||
|
||||
foreach ($index as $index_name => $data)
|
||||
{
|
||||
$sql_data .= "\nCREATE ";
|
||||
if ($data['unique'])
|
||||
{
|
||||
$sql_data .= 'UNIQUE ';
|
||||
}
|
||||
$sql_data .= "INDEX $index_name ON $table_name(" . implode(', ', $data['values']) . ");";
|
||||
}
|
||||
$sql_data .= "\n";
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'SELECT D1.RDB$DEPENDENT_NAME as DNAME, D1.RDB$FIELD_NAME as FNAME, D1.RDB$DEPENDENT_TYPE, R1.RDB$RELATION_NAME
|
||||
FROM RDB$DEPENDENCIES D1
|
||||
LEFT JOIN RDB$RELATIONS R1 ON ((D1.RDB$DEPENDENT_NAME = R1.RDB$RELATION_NAME) AND (NOT (R1.RDB$VIEW_BLR IS NULL)))
|
||||
WHERE (D1.RDB$DEPENDED_ON_TYPE = 0)
|
||||
AND (D1.RDB$DEPENDENT_TYPE <> 3)
|
||||
AND (D1.RDB$DEPENDED_ON_NAME = \'' . $table_name . '\')
|
||||
UNION SELECT DISTINCT F2.RDB$RELATION_NAME, D2.RDB$FIELD_NAME, D2.RDB$DEPENDENT_TYPE, R2.RDB$RELATION_NAME FROM RDB$DEPENDENCIES D2, RDB$RELATION_FIELDS F2
|
||||
LEFT JOIN RDB$RELATIONS R2 ON ((F2.RDB$RELATION_NAME = R2.RDB$RELATION_NAME) AND (NOT (R2.RDB$VIEW_BLR IS NULL)))
|
||||
WHERE (D2.RDB$DEPENDENT_TYPE = 3)
|
||||
AND (D2.RDB$DEPENDENT_NAME = F2.RDB$FIELD_SOURCE)
|
||||
AND (D2.RDB$DEPENDED_ON_NAME = \'' . $table_name . '\')
|
||||
ORDER BY 1, 2';
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = 'SELECT T1.RDB$DEPENDED_ON_NAME as GEN, T1.RDB$FIELD_NAME, T1.RDB$DEPENDED_ON_TYPE
|
||||
FROM RDB$DEPENDENCIES T1
|
||||
WHERE (T1.RDB$DEPENDENT_NAME = \'' . $row['dname'] . '\')
|
||||
AND (T1.RDB$DEPENDENT_TYPE = 2 AND T1.RDB$DEPENDED_ON_TYPE = 14)
|
||||
UNION ALL SELECT DISTINCT D.RDB$DEPENDED_ON_NAME, D.RDB$FIELD_NAME, D.RDB$DEPENDED_ON_TYPE
|
||||
FROM RDB$DEPENDENCIES D, RDB$RELATION_FIELDS F
|
||||
WHERE (D.RDB$DEPENDENT_TYPE = 3)
|
||||
AND (D.RDB$DEPENDENT_NAME = F.RDB$FIELD_SOURCE)
|
||||
AND (F.RDB$RELATION_NAME = \'' . $row['dname'] . '\')
|
||||
ORDER BY 1,2';
|
||||
$result2 = $db->sql_query($sql);
|
||||
$row2 = $db->sql_fetchrow($result2);
|
||||
$db->sql_freeresult($result2);
|
||||
$gen_name = $row2['gen'];
|
||||
|
||||
$sql_data .= "\nDROP GENERATOR " . $gen_name . ";";
|
||||
$sql_data .= "\nSET TERM ^ ;";
|
||||
$sql_data .= "\nCREATE GENERATOR " . $gen_name . "^";
|
||||
$sql_data .= "\nSET GENERATOR " . $gen_name . " TO 0^\n";
|
||||
$sql_data .= "\nCREATE TRIGGER {$row['dname']} FOR $table_name";
|
||||
$sql_data .= "\nBEFORE INSERT\nAS\nBEGIN";
|
||||
$sql_data .= "\n NEW.{$row['fname']} = GEN_ID(" . $gen_name . ", 1);";
|
||||
$sql_data .= "\nEND^\n";
|
||||
$sql_data .= "\nSET TERM ; ^\n";
|
||||
}
|
||||
|
||||
$this->flush($sql_data);
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
// get how much space we allow for a chunk of data, very similar to phpMyAdmin's way of doing things ;-) (hey, we only do this for MySQL anyway :P)
|
||||
function get_usable_memory()
|
||||
{
|
||||
|
@@ -542,7 +542,6 @@ class acp_icons
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$db->sql_query('DELETE FROM ' . $table);
|
||||
break;
|
||||
|
||||
|
@@ -273,7 +273,6 @@ class acp_main
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
|
||||
@@ -379,7 +378,6 @@ class acp_main
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$db->sql_query("DELETE FROM $table");
|
||||
break;
|
||||
|
||||
|
@@ -1267,11 +1267,6 @@ class acp_profile
|
||||
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
$sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' ADD "' . strtoupper($field_ident) . '" ' . $sql_type;
|
||||
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD $field_ident " . $sql_type;
|
||||
|
||||
|
@@ -252,7 +252,6 @@ class acp_reasons
|
||||
// Teh standard
|
||||
case 'postgres':
|
||||
case 'oracle':
|
||||
case 'firebird':
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
// Change the reports using this reason to 'other'
|
||||
|
@@ -2445,7 +2445,6 @@ function phpbb_cache_moderators($db, $cache, $auth)
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
|
||||
break;
|
||||
|
||||
@@ -2900,17 +2899,6 @@ function get_database_size()
|
||||
}
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
global $dbname;
|
||||
|
||||
// if it on the local machine, we can get lucky
|
||||
if (file_exists($dbname))
|
||||
{
|
||||
$database_size = filesize($dbname);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
global $dbhost;
|
||||
|
@@ -2045,7 +2045,6 @@ function update_topics_posted()
|
||||
{
|
||||
case 'sqlite':
|
||||
case 'sqlite3':
|
||||
case 'firebird':
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
|
||||
|
@@ -27,15 +27,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
||||
{
|
||||
global $lang;
|
||||
$available_dbms = array(
|
||||
'firebird' => array(
|
||||
'LABEL' => 'FireBird',
|
||||
'SCHEMA' => 'firebird',
|
||||
'MODULE' => 'interbase',
|
||||
'DELIM' => ';;',
|
||||
'DRIVER' => 'phpbb\db\driver\firebird',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => false,
|
||||
),
|
||||
// Note: php 5.5 alpha 2 deprecated mysql.
|
||||
// Keep mysqli before mysql in this list.
|
||||
'mysqli' => array(
|
||||
@@ -260,7 +251,6 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
||||
$prefix_length = 200;
|
||||
break;
|
||||
|
||||
case 'phpbb\db\driver\firebird':
|
||||
case 'phpbb\db\driver\oracle':
|
||||
$prefix_length = 6;
|
||||
break;
|
||||
@@ -321,87 +311,6 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
||||
}
|
||||
break;
|
||||
|
||||
case 'phpbb\db\driver\firebird':
|
||||
// check the version of FB, use some hackery if we can't get access to the server info
|
||||
if ($db->service_handle !== false && function_exists('ibase_server_info'))
|
||||
{
|
||||
$val = @ibase_server_info($db->service_handle, IBASE_SVC_SERVER_VERSION);
|
||||
preg_match('#V([\d.]+)#', $val, $match);
|
||||
if ($match[1] < 2)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
|
||||
}
|
||||
$db_info = @ibase_db_info($db->service_handle, $dbname, IBASE_STS_HDR_PAGES);
|
||||
|
||||
preg_match('/^\\s*Page size\\s*(\\d+)/m', $db_info, $regs);
|
||||
$page_size = intval($regs[1]);
|
||||
if ($page_size < 8192)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD_PS'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT *
|
||||
FROM RDB$FUNCTIONS
|
||||
WHERE RDB$SYSTEM_FLAG IS NULL
|
||||
AND RDB$FUNCTION_NAME = 'CHAR_LENGTH'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// if its a UDF, its too old
|
||||
if ($row)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT 1 FROM RDB$DATABASE
|
||||
WHERE BIN_AND(10, 1) = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
if (!$result) // This can only fail if BIN_AND is not defined
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Setup the stuff for our random table
|
||||
$char_array = array_merge(range('A', 'Z'), range('0', '9'));
|
||||
$char_len = mt_rand(7, 9);
|
||||
$char_array_len = sizeof($char_array) - 1;
|
||||
|
||||
$final = '';
|
||||
|
||||
for ($i = 0; $i < $char_len; $i++)
|
||||
{
|
||||
$final .= $char_array[mt_rand(0, $char_array_len)];
|
||||
}
|
||||
|
||||
// Create some random table
|
||||
$sql = 'CREATE TABLE ' . $final . " (
|
||||
FIELD1 VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
|
||||
FIELD2 INTEGER DEFAULT 0 NOT NULL);";
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Create an index that should fail if the page size is less than 8192
|
||||
$sql = 'CREATE INDEX ' . $final . ' ON ' . $final . '(FIELD1, FIELD2);';
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (ibase_errmsg() !== false)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD_PS'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Kill the old table
|
||||
$db->sql_query('DROP TABLE ' . $final . ';');
|
||||
}
|
||||
unset($final);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'phpbb\db\driver\oracle':
|
||||
if ($unicode_check)
|
||||
{
|
||||
|
@@ -1360,12 +1360,6 @@ class parse_message extends bbcode_firstpass
|
||||
ORDER BY LEN(code) DESC';
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
$sql = 'SELECT *
|
||||
FROM ' . SMILIES_TABLE . '
|
||||
ORDER BY CHAR_LENGTH(code) DESC';
|
||||
break;
|
||||
|
||||
// LENGTH supported by MySQL, IBM DB2, Oracle and Access for sure...
|
||||
default:
|
||||
$sql = 'SELECT *
|
||||
|
Reference in New Issue
Block a user