Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.40
diff -u -Ff -r1.40 install.php
--- install.php 25 Mar 2007 23:34:17 -0000 1.40
+++ install.php 31 Mar 2007 12:13:35 -0000
@@ -214,75 +214,85 @@ $form['basic_options']['db_type'
$db_path_description = st('The name of the %db_type database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('%db_type' => $db_types[0], '@drupal' => drupal_install_profile_name()));
}
}
-
- // Database name
- $form['basic_options']['db_path'] = array(
- '#type' => 'textfield',
- '#title' => st('Database name'),
- '#default_value' => $db_path,
- '#size' => 45,
- '#maxlength' => 45,
- '#required' => TRUE,
- '#description' => $db_path_description
- );
-
- // Database username
- $form['basic_options']['db_user'] = array(
- '#type' => 'textfield',
- '#title' => st('Database username'),
- '#default_value' => $db_user,
- '#size' => 45,
- '#maxlength' => 45,
- '#required' => TRUE,
- );
-
- // Database username
- $form['basic_options']['db_pass'] = array(
- '#type' => 'password',
- '#title' => st('Database password'),
- '#default_value' => $db_pass,
- '#size' => 45,
- '#maxlength' => 45,
- );
-
- $form['advanced_options'] = array(
- '#type' => 'fieldset',
- '#title' => st('Advanced options'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider.")
- );
-
- // Database host
- $form['advanced_options']['db_host'] = array(
- '#type' => 'textfield',
- '#title' => st('Database host'),
- '#default_value' => $db_host,
- '#size' => 45,
- '#maxlength' => 45,
- '#required' => TRUE,
- '#description' => st('If your database is located on a different server, change this.'),
- );
-
- // Database port
- $form['advanced_options']['db_port'] = array(
- '#type' => 'textfield',
- '#title' => st('Database port'),
- '#default_value' => $db_port,
- '#size' => 45,
- '#maxlength' => 45,
- '#description' => st('If your database server is listening to a non-standard port, enter its number.'),
- );
-
- // Table prefix
- $form['advanced_options']['db_prefix'] = array(
- '#type' => 'textfield',
- '#title' => st('Table prefix'),
- '#default_value' => $db_prefix,
- '#size' => 45,
- '#maxlength' => 45,
- '#description' => st('If more than one @drupal website will be sharing this database, enter a table prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name())),
- );
+
+ if (count($db_types) > 1 || $db_types[0] != 'sqlite') {
+ // Database name
+ $form['basic_options']['db_path'] = array(
+ '#type' => 'textfield',
+ '#title' => st('Database name'),
+ '#default_value' => $db_path,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#description' => $db_path_description,
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+
+ // Database username
+ $form['basic_options']['db_user'] = array(
+ '#type' => 'textfield',
+ '#title' => st('Database username'),
+ '#default_value' => $db_user,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#prefix' => '',
+ '#suffix' => '
',
+ );
+
+ // Database username
+ $form['basic_options']['db_pass'] = array(
+ '#type' => 'password',
+ '#title' => st('Database password'),
+ '#default_value' => $db_pass,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#prefix' => '',
+ '#suffix' => '
',
+ );
+
+ $form['advanced_options'] = array(
+ '#type' => 'fieldset',
+ '#title' => st('Advanced options'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#prefix' => '',
+ '#suffix' => '
',
+ '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider.")
+ );
+
+ // Database host
+ $form['advanced_options']['db_host'] = array(
+ '#type' => 'textfield',
+ '#title' => st('Database host'),
+ '#default_value' => $db_host,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#required' => TRUE,
+ '#description' => st('If your database is located on a different server, change this.'),
+ );
+
+ // Database port
+ $form['advanced_options']['db_port'] = array(
+ '#type' => 'textfield',
+ '#title' => st('Database port'),
+ '#default_value' => $db_port,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#description' => st('If your database server is listening to a non-standard port, enter its number.'),
+ );
+
+ // Table prefix
+ $form['advanced_options']['db_prefix'] = array(
+ '#type' => 'textfield',
+ '#title' => st('Table prefix'),
+ '#default_value' => $db_prefix,
+ '#size' => 45,
+ '#maxlength' => 45,
+ '#description' => st('If more than one @drupal web site will be sharing this database, enter a table prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name())),
+ );
+
+ drupal_add_js('misc/install.js');
+ }
$form['save'] = array(
'#type' => 'submit',
@@ -310,26 +320,45 @@ * Helper function for install_settings_
*/
function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form = NULL) {
global $db_url;
-
- // Check for default username/password
- if ($db_user == 'username' && $db_pass == 'password') {
- form_set_error('db_user', st('You have configured @drupal to use the default username and password. This is not allowed for security reasons.', array('@drupal' => drupal_install_profile_name())));
- }
-
- // Verify the table prefix
- if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) {
- form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, underscores or dots.', array('%db_prefix' => $db_prefix)), 'error');
- }
-
- if (!empty($db_port) && !is_numeric($db_port)) {
- form_set_error('db_port', st('Database port must be a number.'));
- }
-
// Check database type
if (!isset($form)) {
$_db_url = is_array($db_url) ? $db_url['default'] : $db_url;
$db_type = substr($_db_url, 0, strpos($_db_url, '://'));
}
+
+ if ($db_type != 'sqlite') {
+ // Check for default username/password
+ if ($db_user == 'username' && $db_pass == 'password') {
+ form_set_error('db_user', st('You have configured @drupal to use the default username and password. This is not allowed for security reasons.', array('@drupal' => drupal_install_profile_name())));
+ }
+
+ // Verify the table prefix
+ if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) {
+ form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, underscores or dots.', array('%db_prefix' => $db_prefix)), 'error');
+ }
+
+ if (!empty($db_port) && !is_numeric($db_port)) {
+ form_set_error('db_port', st('Database port must be a number.'));
+ }
+
+ if (empty($db_path)) {
+ form_set_error('db_path', st('Path is a requred field for MySQL and Postgres databases.'));
+ }
+ if (!empty($db_user)) {
+ form_set_error('db_user', st('Path is a requred field for MySQL and Postgres databases.'));
+ }
+ }
+ else {
+ if ($db_user != 'dummy') {
+ $db_user = 'dummy';
+ // get current site path
+ $db_host = conf_path();
+ // Take a random starting point in the randomly
+ // generated string, not going any higher then 24
+ $db_path = $i . 'database-'.substr(md5(time()), rand(0, 24), 8).'.php';
+ }
+ }
+
$databases = drupal_detect_database_types();
if (!in_array($db_type, $databases)) {
form_set_error('db_type', st("In your %settings_file file you have configured @drupal to use a %db_type server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_name(), '%db_type' => $db_type)));
Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.214
diff -u -Ff -r1.214 update.php
--- update.php 28 Mar 2007 07:02:47 -0000 1.214
+++ update.php 31 Mar 2007 12:13:37 -0000
@@ -195,6 +195,10 @@ db_add_column($ret, 'system', 's
case 'mysqli':
db_query('ALTER TABLE {system} ADD schema_version smallint(3) not null default -1');
break;
+
+ case 'sqlite':
+ db_query("ALTER TABLE {system} ADD schema_version INTEGER NOT NULL default '-1'");
+ break;
}
// Set all enabled (contrib) modules to schema version 0 (installed)
db_query('UPDATE {system} SET schema_version = 0 WHERE status = 1');
@@ -220,6 +224,9 @@ if (drupal_get_installed_schema_versio
if ($GLOBALS['db_type'] == 'mysql') {
db_query("ALTER TABLE {sessions} ADD cache int(11) NOT NULL default '0' AFTER timestamp");
}
+ else if ($GLOBALS['db_type'] == 'sqlite') {
+ db_query("ALTER TABLE {sessions} ADD cache INTEGER NOT NULL default '0'");
+ }
elseif ($GLOBALS['db_type'] == 'pgsql') {
db_add_column($ret, 'sessions', 'cache', 'int', array('default' => 0, 'not null' => TRUE));
}
@@ -240,6 +247,9 @@ if (drupal_get_installed_schema_versio
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {watchdog} ADD severity tinyint(3) unsigned NOT NULL default '0'");
}
+ else if ($GLOBALS['db_type'] == 'sqlite') {
+ $ret[] = update_sql("ALTER TABLE {watchdog} ADD severity INTEGER NOT NULL default '0'");
+ }
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('ALTER TABLE {watchdog} ADD severity smallint');
$ret[] = update_sql('UPDATE {watchdog} SET severity = 0');
@@ -269,6 +279,9 @@ db_add_column($ret, 'watchdog',
case 'mysqli':
db_query("ALTER TABLE {watchdog} ADD COLUMN referer varchar(128) NOT NULL");
break;
+ case 'sqlite':
+ db_query("ALTER TABLE {watchdog} ADD referer varchar(128) NOT NULL DEFAULT ''");
+ break;
}
variable_set('update_watchdog_fixed', TRUE);
@@ -618,6 +631,10 @@ if (!isset($row->weight)) {
db_add_column($ret, 'system', 'weight', 'smallint', array('not null' => TRUE, 'default' => 0));
$ret[] = update_sql('CREATE INDEX {system}_weight_idx ON {system} (weight)');
break;
+ case 'sqlite':
+ $ret[] = update_sql("ALTER TABLE {system} ADD weight INTEGER default '0' NOT NULL)");
+ $ret[] = update_sql('CREATE INDEX {system}_weight_idx ON {system} (weight)');
+ break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {system} ADD weight tinyint(2) default '0' NOT NULL, ADD KEY (weight)");
@@ -642,6 +659,7 @@ if (version_compare(mysql_get_serv
}
break;
case 'pgsql':
+ case 'sqlite':
return;
}
@@ -754,27 +772,56 @@ expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid)
- )");
- $ret[] = update_sql("CREATE TABLE {cache_menu} (
- cid varchar(255) NOT NULL default '',
- data bytea,
- expire int NOT NULL default '0',
- created int NOT NULL default '0',
- headers text,
- PRIMARY KEY (cid)
- )");
- $ret[] = update_sql("CREATE TABLE {cache_page} (
- cid varchar(255) NOT NULL default '',
- data bytea,
- expire int NOT NULL default '0',
- created int NOT NULL default '0',
- headers text,
- PRIMARY KEY (cid)
- )");
- $ret[] = update_sql("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
- $ret[] = update_sql("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
- $ret[] = update_sql("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
- break;
+ )");
+ $ret[] = update_sql("CREATE TABLE {cache_menu} (
+ cid varchar(255) NOT NULL default '',
+ data bytea,
+ expire int NOT NULL default '0',
+ created int NOT NULL default '0',
+ headers text,
+ PRIMARY KEY (cid)
+ )");
+ $ret[] = update_sql("CREATE TABLE {cache_page} (
+ cid varchar(255) NOT NULL default '',
+ data bytea,
+ expire int NOT NULL default '0',
+ created int NOT NULL default '0',
+ headers text,
+ PRIMARY KEY (cid)
+ )");
+ $ret[] = update_sql("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
+ $ret[] = update_sql("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
+ $ret[] = update_sql("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
+ break;
+ case 'sqlite':
+ $ret[] = update_sql("CREATE TABLE {cache_filter} (
+ cid varchar(255) NOT NULL default '',
+ data blob,
+ expire int NOT NULL default '0',
+ created int NOT NULL default '0',
+ headers text,
+ PRIMARY KEY (cid)
+ )");
+ $ret[] = update_sql("CREATE TABLE {cache_menu} (
+ cid varchar(255) NOT NULL default '',
+ data blob,
+ expire int NOT NULL default '0',
+ created int NOT NULL default '0',
+ headers text,
+ PRIMARY KEY (cid)
+ )");
+ $ret[] = update_sql("CREATE TABLE {cache_page} (
+ cid varchar(255) NOT NULL default '',
+ data blob,
+ expire int NOT NULL default '0',
+ created int NOT NULL default '0',
+ headers text,
+ PRIMARY KEY (cid)
+ )");
+ $ret[] = update_sql("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
+ $ret[] = update_sql("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
+ $ret[] = update_sql("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
+ break;
}
return $ret;
}
Index: includes/database.sqlite.inc
===================================================================
RCS file: includes/database.sqlite.inc
diff -N includes/database.sqlite.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ includes/database.sqlite.inc 7 Mar 2007 08:18:18 -0000
@@ -0,0 +1,529 @@
+ $t('SQLite database'),
+ 'value' => $version,
+ );
+
+ if (version_compare($version, DRUPAL_MINIMUM_SQLITE) < 0) {
+ $form['sqlite']['severity'] = REQUIREMENT_ERROR;
+ $form['sqlite']['description'] = $t('Your SQLite library is too old. Drupal requires at least SQLite %version.', array('%version' => DRUPAL_MINIMUM_SQLITE));
+ }
+
+ return $form;
+}
+
+/**
+ * Returns the version of the database server currently in use.
+ *
+ * @return Database server version
+ */
+function db_version() {
+ list($version) = explode('-', sqlite_libversion());
+ return $version;
+}
+
+/**
+ * Initialize a database connection.
+ *
+ * @param $url
+ * URL
+ * @return
+ * connection
+ */
+function db_connect($url) {
+ // Check if Sqlite support is present in PHP
+ if (!function_exists('sqlite_open')) {
+ // Redirect to installer if using default DB credentials
+ if ($url['user'] == 'username' && $url['pass'] == 'password') {
+ include_once 'includes/install.inc';
+ install_goto('install.php');
+ }
+ drupal_maintenance_theme();
+ drupal_set_title('PHP SQLITE support not enabled');
+ print theme('maintenance_page', 'We were unable to use the SQLITE database because the SQLITE extension for PHP is not installed. Check your PHP.ini
to see how you can enable it.
+ If you are unsure what these terms mean you should probably contact your hosting provider.
');
+ exit;
+ }
+
+ // get database filename
+ $url = explode("@", $url);
+ $connection = sqlite_open(urldecode($url[1]));
+
+ // did it connect successfully ?
+ if (!$connection) {
+ drupal_maintenance_theme();
+ drupal_set_title('Unable to open the database');
+ print theme('maintenance_page', 'This either means that the database path in your settings.php
file is incorrect or you have insufficient privileges to access the database file.
+Currently, the database path is '. theme('placeholder', $url) .'.
+If you are unsure what these terms mean you should probably contact your hosting provider.
');
+ exit;
+ }
+
+ sqlite_query($connection, "PRAGMA synchronous = OFF;"); // equivalent to MyISAM in MySQL
+ sqlite_query($connection, "PRAGMA short_column_names = 1;"); // no more rewrites
+ sqlite_query($connection, "PRAGMA temp_store = MEMORY;");
+ sqlite_query($connection, "PRAGMA cache_size = 5000");
+ sqlite_query($connection, "PRAGMA count_changes=OFF;"); // no need for that (insert/update returning number of changes as result)
+
+ // register functions which are not buil-in sqlite
+ sqlite_create_function($connection, 'concat', '_sqlite_concat');
+ sqlite_create_function($connection, 'greatest', '_sqlite_greatest');
+ sqlite_create_function($connection, 'rand', '_sqlite_rand');
+ sqlite_create_function($connection, 'if', '_sqlite_if', 3);
+ sqlite_create_function($connection, 'year', '_sqlite_year', 1);
+ sqlite_create_function($connection, 'month', '_sqlite_month', 1);
+ sqlite_create_function($connection, 'FROM_UNIXTIME', '_sqlite_from_unix_timestamp', 1);
+ sqlite_create_function($connection, 'pow', '_sqlite_pow', 2);
+ return $connection;
+}
+
+/**
+ * A user defined function to replace the CONCAT in MYSQL
+ * sqlite_udf_encode_binary in the PHP manual says sg. about first byte should not be 0x01 and there should not be 0x00 chars.
+ * But we can safely assume only UTF-8 strings will be CONCATed, no problem with that.
+ *
+ * @return
+ * string
+ */
+function _sqlite_concat() {
+ $a = func_get_args();
+ return implode('', $a);
+}
+
+function _sqlite_year($date) {
+ return date("Y", strtotime($fate));
+}
+
+function _sqlite_month($date) {
+ return date("m", strtotime($fate));
+}
+
+//YYYY-MM-DD HH:MM:SS
+function _sqlite_from_unix_timestamp($timestamp) {
+ return date("Y-m-d G:i:s", $timestamp);
+}
+
+function _sqlite_pow($num, $exp) {
+ return pow($num, $exp);
+}
+
+/**
+ * A user defined function to replace the GREATEST in MYSQL
+ *
+ * @return
+ * int
+ */
+function _sqlite_greatest() {
+ $a = func_get_args();
+ return max($a);
+}
+
+function _sqlite_rand() {
+ return rand();
+}
+
+/**
+ * A user defined function to replace the IF in MYSQL
+ *
+ * @param $expr
+ * Boolean expression to evaluate
+ * @param $true_part
+ * What should be returned if $expr evaluates to true
+ * @param $false_part
+ * What should be returned if $expr evaluates to false
+ * @return
+ * true_part if true, false_part else
+ */
+function _sqlite_if($expr, $true_part, $false_part) {
+ if ($expr)
+ return ($true_part);
+ else
+ return ($false_part);
+}
+
+/**
+ * Route to _sqlite_set_query()
+ *
+ * @return
+ * string
+ */
+function _sqlite_get_query() {
+ return _sqlite_set_query();
+}
+
+/**
+ * Query caching
+ *
+ * @param $query
+ * string
+ * @return
+ * string
+ */
+function _sqlite_set_query($query=NULL) {
+ static $query_cache;
+ if ($query) $query_cache = $query;
+ return $query_cache;
+}
+
+function _sqlite_rewrite_query($query)
+{
+ $old_query = $query;
+
+ $query = preg_replace('/^SELECT COUNT\(DISTINCT\(([^.)]+\.)?([^\)]+)\)\)( AS [^ ]+)? FROM(.+)$/i',
+ 'SELECT COUNT(\2)\3 FROM (SELECT DISTINCT \1\2 FROM\4)',
+ $query);
+
+ return $query;
+}
+
+/**
+ * Helper function for db_query().
+ *
+ * @param $query
+ * string
+ * @param $debug
+ * integer
+ * @return
+ * result
+ */
+function _db_query($query, $debug = 0) {
+ global $active_db, $queries;
+
+ if (variable_get('dev_query', 0)) {
+ list($usec, $sec) = explode(' ', microtime());
+ $timer = (float)$usec + (float)$sec;
+ }
+
+ // special call for ALTER TABLE queries
+ if(strtolower(substr(ltrim($query), 0, 5)) == 'alter') {
+ $queryparts = preg_split("/[\s]+/", $query, 4, PREG_SPLIT_NO_EMPTY);
+ $tablename = $queryparts[2];
+ $alterdefs = $queryparts[3];
+
+ if(strtolower($queryparts[1]) != 'table' || $queryparts[2] == '') {
+ trigger_error (check_plain('near "'.$queryparts[0] . '": syntax error'), E_USER_WARNING);
+ }
+ else {
+ require_once './includes/sqlite.inc';
+ $result = sqlite_altertable($tablename, $alterdefs);
+ }
+ }
+ // this rewrites the TRUNCATE table clause
+ else if (strtolower(substr(ltrim($query), 0, 8)) == 'truncate') {
+ $queryparts = preg_split("/[\s]+/", $query, 3, PREG_SPLIT_NO_EMPTY);
+ $tablename = $queryparts[2];
+
+ if(strtolower($queryparts[1]) != 'table' || $queryparts[2] == '') {
+ trigger_error (check_plain('near "'.$queryparts[0] . '": syntax error'), E_USER_WARNING);
+ }
+ else {
+ $result = sqlite_query($active_db, "DELETE FROM ". $tablename);
+ }
+ }
+ // compatible queries
+ else {
+ $old_query = $query;
+
+ $query = _sqlite_rewrite_query($query);
+
+ $result = sqlite_query($active_db, $query);
+ }
+
+ if (variable_get('dev_query', 0)) {
+ $bt = debug_backtrace();
+ $query = $bt[2]['function'] . "\n" . $query;
+ list($usec, $sec) = explode(' ', microtime());
+ $stop = (float)$usec + (float)$sec;
+ $diff = $stop - $timer;
+ $queries[] = array($query, $diff);
+ }
+
+ if ($debug != 0)
+ print 'query: '. $query .'
error:'. sqlite_last_error($active_db) .'
';
+
+ if (!($error_code = sqlite_last_error($active_db))) {
+ return $result;
+ }
+ else {
+ trigger_error(check_plain(sqlite_error_string($error_code) ."\nquery: ". htmlspecialchars($query)), E_USER_WARNING);
+ }
+}
+
+/**
+ * Fetch one result row from the previous query as an object.
+ *
+ * @param $result
+ * A database query result resource, as returned from db_query().
+ * @return
+ * An object representing the next row of the result. The attributes of this
+ * object are the table fields selected by the query.
+ */
+function db_fetch_object($result) {
+ if ($result && sqlite_has_more($result)) {
+ return (object)sqlite_fetch_array($result, SQLITE_ASSOC);
+ }
+}
+
+/**
+ * Fetch one result row from the previous query as an array.
+ *
+ * @param $result
+ * A database query result resource, as returned from db_query().
+ * @return
+ * An associative array representing the next row of the result. The keys of
+ * this object are the names of the table fields selected by the query, and
+ * the values are the field values for this result row.
+ */
+function db_fetch_array($result) {
+ if ($result && sqlite_has_more($result)) {
+ return sqlite_fetch_array($result, SQLITE_ASSOC);
+ }
+}
+
+/**
+ * Determine how many result rows were found by the preceding query.
+ *
+ * @param $result
+ * A database query result resource, as returned from db_query().
+ * @return
+ * The number of result rows.
+ */
+function db_num_rows($result) {
+ if ($result) {
+ return sqlite_num_rows($result);
+ }
+}
+
+/**
+ * Return an individual result field from the previous query.
+ * Only use this function if exactly one field is being selected; otherwise,
+ * use db_fetch_object() or db_fetch_array().
+ *
+ * @param $result
+ * A database query result resource, as returned from db_query().
+ * @param $row
+ * The index of the row whose result is needed.
+ * @return
+ * The resulting field.
+ */
+function db_result($result, $row = 0) {
+ if ($result && sqlite_num_rows($result) > $row) {
+ sqlite_seek($result, $row);
+ return sqlite_fetch_single($result);
+ }
+ return FALSE;
+}
+
+/**
+ * Determine whether the previous query caused an error.
+ *
+ * @return
+ * string
+ */
+function db_error() {
+ global $active_db;
+ return sqlite_last_error($active_db);
+}
+
+/**
+ * Return a new unique ID in the given sequence.
+ * For compatibility reasons, Drupal does not use auto-numbered fields in its
+ * database tables. Instead, this function is used to return a new unique ID
+ * of the type requested. If necessary, a new sequence with the given name
+ * will be created.
+ *
+ * @param $name
+ * string
+ * @return
+ * integer
+ */
+function db_next_id($name) {
+ global $active_db;
+ $name = db_prefix_tables($name);
+ db_lock_table("{sequences}");
+ $id = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", $name)) + 1;
+ db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id);
+ db_unlock_tables();
+ return $id;
+}
+
+/**
+ * Determine the number of rows changed by the preceding query.
+ *
+ * @return
+ * integer
+ */
+function db_affected_rows() {
+ global $active_db;
+ return sqlite_changes($active_db);
+}
+
+/**
+ * Runs a limited-range query in the active database.
+ * Use this as a substitute for db_query() when a subset of the query is to be
+ * returned.
+ * User-supplied arguments to the query should be passed in as separate parameters
+ * so that they can be properly escaped to avoid SQL injection attacks.
+ * @param $query
+ * A string containing an SQL query.
+ * @param ...
+ * A variable number of arguments which are substituted into the query using
+ * printf() syntax.
+ * @param $from
+ * The first result row to return.
+ * @param $count
+ * The maximum number of result rows to return.
+ * @return
+ * A database query result resource, or FALSE if the query was not executed
+ * correctly.
+ */
+function db_query_range($query) {
+ $args = func_get_args();
+ $count = array_pop($args);
+ $from = array_pop($args);
+
+ array_shift($args);
+
+ $query = db_prefix_tables($query);
+ if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
+ $args = $args[0];
+ }
+ _db_query_callback($args, TRUE);
+ $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
+ $query .= ' LIMIT '. (int)$count .' OFFSET '. (int)$from ;
+ return _db_query($query);
+}
+
+
+/**
+ * Runs a SELECT query and stores its results in a temporary table.
+ *
+ * Use this as a substitute for db_query() when the results need to stored
+ * in a temporary table. Temporary tables exist for the duration of the page
+ * request.
+ * User-supplied arguments to the query should be passed in as separate parameters
+ * so that they can be properly escaped to avoid SQL injection attacks.
+ *
+ * Note that if you need to know how many results were returned, you should do
+ * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and
+ * db_affected_rows() do not give consistent result across different database
+ * types in this case.
+ *
+ * @param $query
+ * A string containing a normal SELECT SQL query.
+ * @param ...
+ * A variable number of arguments which are substituted into the query
+ * using printf() syntax. The query arguments can be enclosed in one
+ * array instead.
+ * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ * in '') and %%.
+ *
+ * NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
+ * and TRUE values to decimal 1.
+ *
+ * @param $table
+ * The name of the temporary table to select into. This name will not be
+ * prefixed as there is no risk of collision.
+ * @return
+ * A database query result resource, or FALSE if the query was not executed
+ * correctly.
+ */
+function db_query_temporary($query) {
+ $args = func_get_args();
+ $tablename = array_pop($args);
+ array_shift($args);
+
+ $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' AS SELECT', db_prefix_tables($query));
+ if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
+ $args = $args[0];
+ }
+ _db_query_callback($args, TRUE);
+ $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
+ return _db_query($query);
+}
+
+
+/**
+ * Returns a properly formatted Binary Large OBject value.
+ *
+ * @param $data
+ * Data to encode.
+ * @return
+ * Encoded data.
+ */
+function db_encode_blob($data) {
+ return "'". sqlite_udf_encode_binary(sqlite_escape_string($data)) ."'";
+}
+
+/**
+ * Returns text from a Binary Large OBject value.
+ *
+ * @param $data
+ * Data to decode.
+ * @return
+ * Decoded data.
+ */
+function db_decode_blob($data) {
+ return sqlite_udf_decode_binary($data);
+}
+
+/**
+ * Prepare user input for use in a database query, preventing SQL injection attacks.
+ *
+ * @param $text
+ * String to escape
+ * @return
+ * Escaped string
+ */
+function db_escape_string($text) {
+ return sqlite_escape_string($text);
+}
+
+/**
+ * Lock a table.
+ *
+ * @param $table
+ * string
+ */
+function db_lock_table($table) {
+ db_query('BEGIN');
+}
+
+/**
+ * Unlock all locked tables.
+ */
+function db_unlock_tables() {
+ db_query('COMMIT');
+}
+
+/**
+ * Check if a table exists.
+ */
+function db_table_exists($table) {
+ return db_num_rows(db_query("SELECT * FROM sqlite_master WHERE tbl_name = '".$table."'"));
+}
+
+/**
+ * @} End of "ingroup database".
+ */
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.35
diff -u -Ff -r1.35 install.inc
--- includes/install.inc 27 Mar 2007 05:13:53 -0000 1.35
+++ includes/install.inc 31 Mar 2007 12:13:38 -0000
@@ -144,7 +144,7 @@ * An array of database types compiled
function drupal_detect_database_types() {
$databases = array();
- foreach (array('mysql', 'mysqli', 'pgsql') as $type) {
+ foreach (array('mysql', 'mysqli', 'pgsql', 'sqlite') as $type) {
if (file_exists('./includes/install.'. $type .'.inc')) {
include_once './includes/install.'. $type .'.inc';
$function = $type .'_is_available';
Index: includes/install.sqlite.inc
===================================================================
RCS file: includes/install.sqlite.inc
diff -N includes/install.sqlite.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ includes/install.sqlite.inc 7 Mar 2007 08:18:32 -0000
@@ -0,0 +1,100 @@
+If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => $error)), 'error');
+ return FALSE;
+ }
+
+ $success = array('CONNECT');
+
+ // Test CREATE.
+ $query = 'CREATE TABLE drupal_install_test (id int NULL)';
+ $result = sqlite_query($connection, $query);
+ if ($error = sqlite_last_error($connection)) {
+ drupal_set_message(st('We were unable to create a test table on your SQLite database server with the command %query. SQLite reports the following message: %error.
For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%query' => $query, '%error' => $error)), 'error');
+ return FALSE;
+ }
+ $err = FALSE;
+ $success[] = 'SELECT';
+ $success[] = 'CREATE';
+
+ // Test INSERT.
+ $query = 'INSERT INTO drupal_install_test (id) VALUES (1)';
+ $result = sqlite_query($connection, $query);
+ if ($error = sqlite_last_error($connection)) {
+ drupal_set_message(st('We were unable to insert a value into a test table on your SQLite database server. We tried inserting a value with the command %query and SQLite reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
+ $err = TRUE;
+ }
+ else {
+ $success[] = 'INSERT';
+ }
+
+ // Test UPDATE.
+ $query = 'UPDATE drupal_install_test SET id = 2';
+ $result = sqlite_query($connection, $query);
+ if ($error = sqlite_last_error($connection)) {
+ drupal_set_message(st('We were unable to update a value in a test table on your SQLite database server. We tried updating a value with the command %query and SQLite reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
+ $err = TRUE;
+ }
+ else {
+ $success[] = 'UPDATE';
+ }
+
+ // Test DELETE.
+ $query = 'DELETE FROM drupal_install_test';
+ $result = sqlite_query($connection, $query);
+ if ($error = sqlite_last_error($connection)) {
+ drupal_set_message(st('We were unable to delete a value from a test table on your SQLite database server. We tried deleting a value with the command %query and SQLite reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
+ $err = TRUE;
+ }
+ else {
+ $success[] = 'DELETE';
+ }
+
+ // Test DROP.
+ $query = 'DROP TABLE drupal_install_test';
+ $result = sqlite_query($connection, $query);
+ if ($error = sqlite_last_error($connection)) {
+ drupal_set_message(st('We were unable to drop a test table from your SQLite database server. We tried dropping a table with the command %query and SQLite reported the following error %error.', array('%query' => $query, '%error' => $error)), 'error');
+ $err = TRUE;
+ }
+ else {
+ $success[] = 'DROP';
+ }
+
+ if ($err) {
+ return FALSE;
+ }
+
+ sqlite_close($connection);
+ //unlink('sqlite-database-test');
+ return TRUE;
+}
+
+?>
Index: includes/sqlite.inc
===================================================================
RCS file: includes/sqlite.inc
diff -N includes/sqlite.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ includes/sqlite.inc 11 Oct 2006 19:28:08 -0000
@@ -0,0 +1,343 @@
+
+// $Id:
+
+/**
+ * @file
+ * This is a supplemental file for the sqlite database layer.
+ * It is only included when ALTER TABLE sql statements are used
+ */
+
+
+/**
+ * @ingroup database
+ * @{
+ */
+
+/**
+ * Executes the alter table statement.
+ * This is executer in 6 steps:
+ * 1. create a temporaty table with the schema identical to the original table
+ * 2. copy the data over
+ * -- alter the original table schema
+ * 3. drop the original table
+ * 4. create the new table, also recreate all indicies
+ * 5. copy the data from the temp table to the new table
+ * 6. drop the temporaty table
+ *
+ * @param $table
+ * string - name of table to alter
+ * @param $alterdef
+ * string - the part of alter table statement, without the "ALTER TABLE -tablename-" part
+ */
+function sqlite_altertable($table, $alterdef) {
+ global $active_db, $queries;
+ if($alterdef != '') {
+ $schema = _sqlite_get_table_schema($table);
+ if($schema['columns']) {
+
+ // create an exact copy of the original table
+ $tmpname = 't'. time();
+ $createtemptableSQL = 'CREATE TEMPORARY TABLE '. $tmpname . ' (' . implode(",", _build_cols_sql($schema)) . ')';
+
+ $prevword = $table;
+ $newcols = array();
+ $replace = array();
+
+ $oldcols = _sqlite_get_columns($table);
+ foreach ($oldcols as $inner_field) {
+ $newcols[$inner_field] = $inner_field;
+ }
+
+ // copy the data from the original table to ist temporary copy
+ $cols = implode(", ", $newcols);
+ $copytotempsql = 'INSERT INTO '.$tmpname.'('.$cols.') SELECT '.$cols.' FROM '.$table;
+
+ // split the ALTER sentence
+ // this cuold be done, by extracting the first substring till ' '
+ $defparts = preg_split("/[\s]+/", $alterdef, -1, PREG_SPLIT_NO_EMPTY);
+ $action = strtolower($defparts[0]);
+
+ switch($action) {
+ case 'add':
+ if ($defparts[1] == 'PRIMARY' && $defparts[2] == 'KEY') {
+ $defparts[3] = str_replace("(", "", $defparts[3]);
+ $defparts[3] = str_replace(")", "", $defparts[3]);
+ // new primary keys
+ foreach (explode(",", $defparts[3]) as $npk) {
+ $schema['pk'][$npk] = $npk;
+ }
+ break;
+ }
+
+ array_shift($defparts);
+
+ if(sizeof($defparts) <= 2) {
+ trigger_error('near "'. $defparts[0].($defparts[1] ? ' '. $defparts[1] : '') .'": syntax error', E_USER_WARNING);
+ return false;
+ }
+
+ $default = '';
+ if (strstr($defparts[2], "NOT")) {
+ $notnull = 1;
+ }
+ else if (strstr($defparts[2], "DEFAULT")) {
+ $default = $defparts[3];
+
+ if (strstr($defparts[4], "NOT")) {
+ $notnull = 1;
+ }
+ }
+
+ $schema['columns'][] = array('cid' => '99',
+ 'name' => $defparts[0],
+ 'type' => $defparts[1],
+ 'notnull' => $notnull ? 99 : 0,
+ 'dflt_value' => $default,
+ );
+ break;
+
+ case 'change':
+ if(sizeof($defparts) < 3){
+ trigger_error('near "' .$defparts[0].($defparts[1] ? ' '. $defparts[1] : '').($defparts[2] ? ' '. $defparts[2] : '').'": syntax error', E_USER_WARNING);
+ return false;
+ }
+ if($schema['columns'][$defparts[1]]){
+ array_shift($defparts);
+
+ if($newcols[$defparts[0]] != $defparts[0]){
+ trigger_error('unknown column "'. $defparts[1] .'" in "'. $table .'"', E_USER_WARNING);
+ return false;
+ }
+
+ if (strstr($defparts[3], "NOT")) {
+ $notnull = 1;
+ }
+ else if (strstr($defparts[3], "DEFAULT")) {
+ $default = $defparts[4];
+
+ if (strstr($defparts[5], "NOT")) {
+ $notnull = 1;
+ }
+ }
+
+ $schema['columns'][$defparts[0]]['name'] = $defparts[1];
+ $schema['columns'][$defparts[0]]['type'] = $defparts[2];
+ $schema['columns'][$defparts[0]]['notnull'] = $notnull ? 99 : 0;
+ $schema['columns'][$defparts[0]]['dflt_value'] = $default;
+
+ // update mappings
+ $newcols[$defparts[0]] = $defparts[1];
+ }
+ else{
+ trigger_error('unknown column "'. $defparts[1] .'" in "'. $table .'"', E_USER_WARNING);
+ return false;
+ }
+ break;
+
+ case 'drop':
+ if(sizeof($defparts) < 2){
+ trigger_error('near "'.$defparts[0].($defparts[1]?' '.$defparts[1]:'').'": syntax error', E_USER_WARNING);
+ return false;
+ }
+
+ // are we dropping the primary key
+ if ($defparts[1] == 'PRIMARY' && $defparts[2] == 'KEY') {
+ unset($schema['pk']);
+ break;
+ }
+ else {
+ // dropping a column
+ if($schema['columns'][$defparts[1]]){
+ // update mappings
+ unset($schema['columns'][$defparts[1]]);
+ unset($schema['pk'][$defparts[1]]);
+ unset($newcols[$defparts[1]]);
+ _remove_col_index($schema, $defparts[1]);
+ }
+ else{
+ trigger_error('unknown column "'. $defparts[1] .'" in "'. $table .'"', E_USER_WARNING);
+ return false;
+ }
+ }
+ break;
+
+ default:
+ trigger_error('near "'. $prevword .'": syntax error modifying table '. $table, E_USER_WARNING);
+ return false;
+ }
+ $prevword = $defparts[sizeof($defparts)-1];
+
+ //this block of code generates a test table simply to verify that the columns specifed are valid in an sql statement
+ //this ensures that no reserved words are used as columns, for example
+ $newColsSQL = implode(",", _build_cols_sql($schema));
+ $createtesttableSQL = 'CREATE TABLE '. $tmpname . ' (' . $newColsSQL . ')';
+
+ sqlite_query($active_db, $createtesttableSQL);
+ if($error_code = sqlite_last_error($active_db)) {
+ trigger_error('near "'. $prevword .'": ' . sqlite_error_string($error_code). ' -> syntax error modifying table '. $table, E_USER_WARNING);
+ return false;
+ }
+ $droptempsql = 'DROP TABLE '. $tmpname;
+ // in the end drop the original table
+ $dropoldsql = 'DROP TABLE '.$table;
+ sqlite_query($active_db, $droptempsql);
+ //end block
+
+ $createnewtableSQL = 'CREATE TABLE '. $table . ' (' . $newColsSQL . ')';
+ $newcolumns = '';
+ $oldcolumns = '';
+ reset($newcols);
+ while(list($key,$val) = each($newcols)) {
+ $newcolumns .= ($newcolumns?', ':'').$val;
+ $oldcolumns .= ($oldcolumns?', ':'').$key;
+ }
+ $copytonewsql = 'INSERT INTO '. $table .'('. $newcolumns .') SELECT '. $oldcolumns .' FROM '. $tmpname;
+
+ sqlite_query($active_db, "BEGIN TRANSACTION");
+ sqlite_query($active_db, $createtemptableSQL); //create temp table
+ sqlite_query($active_db, $copytotempsql); //copy to table
+ sqlite_query($active_db, $dropoldsql); //drop old table
+ sqlite_query($active_db, $createnewtableSQL); //recreate original table
+
+ // all timings will be accounted in the _db_query, this is just to log
+ // which queries are actualli being executed, hence diff = -1;
+ if (variable_get('dev_query', 0)) {
+ $queries[] = array($createtemptableSQL, -1);
+ $queries[] = array($copytotempsql, -1);
+ $queries[] = array($dropoldsql, -1);
+ $queries[] = array($createnewtableSQL, -1);
+ }
+
+ // recreate indices
+ $sqls = _get_indices_sql($schema);
+ foreach($sqls as $index_sql) {
+ if (variable_get('dev_query', 0)) {
+ $queries[] = array($index_sql, -1);
+ }
+ sqlite_query($active_db, $index_sql);
+ }
+
+ sqlite_query($active_db, $copytonewsql); //copy back to original table
+ sqlite_query($active_db, $droptempsql); //drop temp table?
+
+ if (variable_get('dev_query', 0)) {
+ $queries[] = array($copytonewsql, -1);
+ $queries[] = array($droptempsql, -1);
+ }
+
+ if($error_code = sqlite_last_error($active_db)) {
+ trigger_error('no such table: '. sqlite_error_string($error_code), E_USER_WARNING);
+ sqlite_query($active_db, "ROLLBACK");
+ return false;
+ }
+ else {
+ sqlite_query($active_db, "COMMIT");
+ return true;
+ }
+
+ }
+ else{
+ trigger_error('no such table: '. $table, E_USER_WARNING);
+ return false;
+ }
+ return true;
+ }
+}
+
+function _sqlite_get_columns($table) {
+ global $active_db;
+
+ $result = sqlite_query($active_db, "SELECT * FROM $table LIMIT 1");
+ $num = sqlite_num_fields($result);
+
+ for ($i=0; $i < $num; $i++) {
+ $cols[] = sqlite_field_name ($result, $i);
+ }
+ return $cols;
+}
+
+function _build_cols_sql($schema) {
+ $out_sql = array();
+ foreach ($schema['columns'] as $col => $defs) {
+ $notnull = $defs['notnull'] ? 'NOT NULL' : '';
+ $dflt_value = " DEFAULT '" . $defs['dflt_value'] . "'";
+ $sql = $defs['name'] . " " . $defs['type'] . " " . $notnull . $dflt_value;
+
+ $out_sql[] = $sql;
+ }
+ if (count($schema['pk']) > 0) {
+ $out_sql[] = "PRIMARY KEY (". implode(",", $schema['pk']) . ")";
+ }
+ return $out_sql;
+}
+
+function _sqlite_get_table_schema($tbl_name) {
+ global $active_db;
+
+ $result = sqlite_unbuffered_query($active_db, "PRAGMA table_info('".$tbl_name."')");
+ $schema = array();
+ $schema['tbl_name'] = $tbl_name;
+ $schema['columns'] = array();
+ $schema['pk'] = array();
+ while ($result && sqlite_has_more($result)) {
+ $col = sqlite_fetch_array($result, SQLITE_ASSOC);
+ $schema['columns'][$col['name']] = $col;
+ if ($col[pk]) {
+ $schema['pk'][$col['name']] = $col['name'];
+ }
+ }
+
+ // build index info, so we can recreate them
+ $schema['indices'] = array();
+ $query = "SELECT * FROM sqlite_master WHERE tbl_name ='".$tbl_name."' AND type='index'";
+ $result = sqlite_unbuffered_query($active_db, $query);
+ while ($result && sqlite_has_more($result)) {
+ $index = sqlite_fetch_array($result, SQLITE_ASSOC);
+ // we don't need to create autoindices
+ if (strstr($index['name'], 'autoindex')) {
+ continue;
+ }
+ preg_match("/\((.+)\)/", $index['sql'], $matches);
+ $entry = array();
+ if (count($matches)) {
+ $expl = explode(",", $matches[1]);
+ if (count($expl)) {
+ foreach ($expl as $col_name) {
+ $entry['cols'][] = trim($col_name);
+ }
+ }
+ else {
+ $entry['cols'][] = trim($matches[1]);
+ }
+ }
+ $entry['unique'] = strstr($index['sql'], "UNIQUE") ? 1 : 0;
+ $entry['name'] = $index['name'];
+ $entry['sql'] = $index['sql'];
+ $schema['indices'][] = $entry;
+ }
+ return $schema;
+}
+
+function _get_indices_sql($schema) {
+ $sql = array();
+ foreach ($schema['indices'] as $index) {
+ $unique = $index['unique'] ? 'UNIQUE ' : '';
+ $sql[] = 'CREATE '. $unique . 'INDEX ' . $index['name'] . ' ON ' . $schema['tbl_name'] . " (" . implode(",", $index['cols']) . ");";
+ }
+ return $sql;
+}
+
+function _remove_col_index(&$schema, $column) {
+ foreach ($schema['indices'] as $key => $index) {
+ if (isset($index['cols']) && $key = array_search($column, $index['cols']) !== FALSE) {
+ unset($index['cols'][$key]);
+ if (count($index['cols']) == 0) {
+ unset($schema['indices'][$key]);
+ }
+ }
+ }
+}
+
+/**
+ * @} End of "ingroup database".
+ */
\ No newline at end of file
Index: misc/install.js
===================================================================
RCS file: misc/install.js
diff -N misc/install.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ misc/install.js 7 Mar 2007 08:13:12 -0000
@@ -0,0 +1,20 @@
+// Global Killswitch
+if (Drupal.jsEnabled) {
+ $(document).ready(
+ function(){
+ if ($("input[@value='sqlite'][@checked]").val() == 'sqlite') {
+ $("#db_path,#db_user,#db_pass,#advanced_options").hide();
+ }
+ $("input[@name='db_type']").click(function(){
+ if ($("input[@value='sqlite'][@checked]").val() == null) {
+ if ($("#advanced_options").css("display") == 'none') {
+ $("#db_path,#db_user,#db_pass,#advanced_options").show();
+ }
+ }
+ else {
+ $("#db_path,#db_user,#db_pass,#advanced_options").hide();
+ }
+ });
+ }
+ );
+}
\ No newline at end of file
Index: modules/aggregator/aggregator.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v
retrieving revision 1.8
diff -u -Ff -r1.8 aggregator.install
--- modules/aggregator/aggregator.install 26 Sep 2006 14:19:00 -0000 1.8
+++ modules/aggregator/aggregator.install 23 Jan 2007 21:35:40 -0000
@@ -113,6 +113,56 @@ timestamp int default NULL,
db_query("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");
break;
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {aggregator_category} (
+ cid INTEGER PRIMARY KEY,
+ title varchar(255) NOT NULL default '',
+ description longtext NOT NULL,
+ block tinyint(2) NOT NULL default '0',
+ UNIQUE (title)
+ );");
+
+ db_query("CREATE TABLE {aggregator_category_feed} (
+ fid int(10) NOT NULL default '0',
+ cid int(10) NOT NULL default '0',
+ PRIMARY KEY (fid,cid)
+ );");
+
+ db_query("CREATE TABLE {aggregator_category_item} (
+ iid int(10) NOT NULL default '0',
+ cid int(10) NOT NULL default '0',
+ PRIMARY KEY (iid,cid)
+ );");
+
+ db_query("CREATE TABLE {aggregator_feed} (
+ fid INTEGER PRIMARY KEY,
+ title varchar(255) NOT NULL default '',
+ url varchar(255) NOT NULL default '',
+ refresh int(10) NOT NULL default '0',
+ checked int(10) NOT NULL default '0',
+ link varchar(255) NOT NULL default '',
+ description longtext NOT NULL default '',
+ image longtext NOT NULL default '',
+ etag varchar(255) NOT NULL default '',
+ modified int(10) NOT NULL default '0',
+ block tinyint(2) NOT NULL default '0',
+ UNIQUE (url),
+ UNIQUE (title)
+ );");
+
+ db_query("CREATE TABLE {aggregator_item} (
+ iid INTEGER PRIMARY KEY,
+ fid int(10) NOT NULL default '0',
+ title varchar(255) NOT NULL default '',
+ link varchar(255) NOT NULL default '',
+ author varchar(255) NOT NULL default '',
+ description longtext NOT NULL,
+ timestamp int(11) default NULL
+ );");
+ db_query("CREATE INDEX {aggregator_item}_fid ON {aggregator_item} (fid)");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/book/book.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.install,v
retrieving revision 1.6
diff -u -Ff -r1.6 book.install
--- modules/book/book.install 1 Sep 2006 07:40:08 -0000 1.6
+++ modules/book/book.install 23 Jan 2007 21:35:40 -0000
@@ -29,6 +29,19 @@ weight smallint NOT NULL default
db_query("CREATE INDEX {book}_nid_idx ON {book} (nid)");
db_query("CREATE INDEX {book}_parent_idx ON {book} (parent)");
break;
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {book} (
+ vid int(10) NOT NULL default '0',
+ nid int(10) NOT NULL default '0',
+ parent int(10) NOT NULL default '0',
+ weight tinyint(3) NOT NULL default '0',
+ PRIMARY KEY (vid)
+ );");
+ db_query("CREATE INDEX {book}_nid ON {book}(nid);");
+ db_query("CREATE INDEX {book}_parent ON {book}(parent);");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/contact/contact.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v
retrieving revision 1.6
diff -u -Ff -r1.6 contact.install
--- modules/contact/contact.install 2 Jan 2007 05:30:29 -0000 1.6
+++ modules/contact/contact.install 23 Jan 2007 21:35:40 -0000
@@ -31,6 +31,17 @@ selected smallint NOT NULL defau
UNIQUE (category)
)");
break;
+ case 'sqlite':
+ db_query("CREATE TABLE {contact} (
+ cid INTEGER PRIMARY KEY,
+ category varchar(255) NOT NULL default '',
+ recipients longtext NOT NULL default '',
+ reply longtext NOT NULL default '',
+ weight tinyint(3) NOT NULL default '0',
+ selected tinyint(1) NOT NULL default '0',
+ UNIQUE (category)
+ );");
+ break;
}
}
Index: modules/drupal/drupal.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/drupal/drupal.install,v
retrieving revision 1.5
diff -u -Ff -r1.5 drupal.install
--- modules/drupal/drupal.install 1 Sep 2006 07:40:08 -0000 1.5
+++ modules/drupal/drupal.install 23 Jan 2007 21:35:40 -0000
@@ -53,6 +53,31 @@ type varchar(255) NOT NULL defau
PRIMARY KEY (cid,name)
)");
break;
+
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {client} (
+ cid INTEGER PRIMARY KEY,
+ link varchar(255) NOT NULL default '',
+ name varchar(128) NOT NULL default '',
+ mail varchar(128) NOT NULL default '',
+ slogan longtext NOT NULL,
+ mission longtext NOT NULL,
+ users int(10) NOT NULL default '0',
+ nodes int(10) NOT NULL default '0',
+ version varchar(35) NOT NULL default'',
+ created int(11) NOT NULL default '0',
+ changed int(11) NOT NULL default '0'
+ );");
+
+ db_query("CREATE TABLE {client_system} (
+ cid int(10) NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ type varchar(255) NOT NULL default '',
+ PRIMARY KEY (cid,name)
+ );");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.6
diff -u -Ff -r1.6 forum.install
--- modules/forum/forum.install 1 Sep 2006 07:40:08 -0000 1.6
+++ modules/forum/forum.install 23 Jan 2007 21:35:40 -0000
@@ -27,6 +27,16 @@ tid int_unsigned NOT NULL defaul
db_query("CREATE INDEX {forum}_nid_idx ON {forum} (nid)");
db_query("CREATE INDEX {forum}_tid_idx ON {forum} (tid)");
break;
+ case 'sqlite':
+ db_query("CREATE TABLE {forum} (
+ nid int(10) NOT NULL default '0',
+ vid int(10) NOT NULL default '0',
+ tid int(10) NOT NULL default '0',
+ PRIMARY KEY (vid)
+ );");
+ db_query("CREATE INDEX {forum}_tid ON {forum}(tid);");
+ db_query("CREATE INDEX {forum}_nid ON {forum}(nid);");
+ break;
}
}
Index: modules/locale/locale.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v
retrieving revision 1.8
diff -u -Ff -r1.8 locale.install
--- modules/locale/locale.install 26 Mar 2007 01:32:22 -0000 1.8
+++ modules/locale/locale.install 31 Mar 2007 12:38:37 -0000
@@ -81,6 +81,42 @@ plural int NOT NULL default '0'
db_query("CREATE INDEX {locales_target}_plural_idx ON {locales_target} (plural)");
db_query("CREATE INDEX {locales_source}_source_idx ON {locales_source} (source)");
break;
+
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {languages} (
+ language varchar(12) NOT NULL default '',
+ name varchar(64) NOT NULL default '',
+ native varchar(64) NOT NULL default '',
+ direction int NOT NULL default '0',
+ enabled int(2) NOT NULL default '0',
+ isdefault int(2) NOT NULL default '0',
+ plurals int(1) NOT NULL default '0',
+ formula varchar(128) NOT NULL default '',
+ domain varchar(128) NOT NULL default '',
+ prefix varchar(128) NOT NULL default '',
+ weight int NOT NULL default '0',
+ PRIMARY KEY (language)
+ );");
+ db_query("CREATE TABLE {locales_source} (
+ lid INTEGER PRIMARY KEY,
+ location varchar(255) NOT NULL default '',
+ source text NOT NULL
+ );");
+ db_query("CREATE INDEX {locales_source}_source ON {locales_source} (source)");
+ db_query("CREATE TABLE {locales_target} (
+ lid int(11) NOT NULL default '0',
+ translation text NOT NULL,
+ language varchar(12) NOT NULL default '',
+ plid int(11) NOT NULL default '0',
+ plural int(1) NOT NULL default '0'
+ );");
+ db_query("CREATE INDEX {locales_target}_lid ON {locales_target}(lid);");
+ db_query("CREATE INDEX {locales_target}_language ON {locales_target}(language);");
+ db_query("CREATE INDEX {locales_target}_plid ON {locales_target}(plid);");
+ db_query("CREATE INDEX {locales_target}_plural ON {locales_target}(plural);");
+ db_query("COMMIT");
+ break;
}
db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight) VALUES ('en', 'English', 'English', '0', '1', '0')");
}
Index: modules/poll/poll.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.install,v
retrieving revision 1.7
diff -u -Ff -r1.7 poll.install
--- modules/poll/poll.install 1 Sep 2006 07:40:08 -0000 1.7
+++ modules/poll/poll.install 23 Jan 2007 21:35:40 -0000
@@ -64,6 +64,35 @@ chorder int NOT NULL default '0'
)");
db_query("CREATE INDEX {poll_choices}_nid_idx ON {poll_choices} (nid)");
break;
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {poll} (
+ nid int(10) NOT NULL default '0',
+ runtime int(10) NOT NULL default '0',
+ active int(2) NOT NULL default '0',
+ PRIMARY KEY (nid)
+ );");
+
+ db_query("CREATE TABLE {poll_votes} (
+ nid int(10) NOT NULL,
+ uid int(10) NOT NULL default 0,
+ hostname varchar(128) NOT NULL default ''
+ );");
+
+ db_query("CREATE INDEX {poll_votes}_nid ON {poll_votes}(nid);");
+ db_query("CREATE INDEX {poll_votes}_uid ON {poll_votes}(uid);");
+ db_query("CREATE INDEX {poll_votes}_hostname ON {poll_votes}(hostname);");
+
+ db_query("CREATE TABLE {poll_choices} (
+ chid INTEGER PRIMARY KEY,
+ nid int(10) NOT NULL default '0',
+ chtext varchar(128) NOT NULL default '',
+ chvotes int(6) NOT NULL default '0',
+ chorder int(2) NOT NULL default '0'
+ );");
+ db_query("CREATE INDEX {poll_choices}_nid ON {poll_choices}(nid);");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/profile/profile.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.install,v
retrieving revision 1.8
diff -u -Ff -r1.8 profile.install
--- modules/profile/profile.install 28 Nov 2006 14:37:44 -0000 1.8
+++ modules/profile/profile.install 23 Jan 2007 21:35:40 -0000
@@ -64,6 +64,36 @@ uid int_unsigned default '0',
db_query("CREATE INDEX {profile_values}_uid_idx ON {profile_values} (uid)");
db_query("CREATE INDEX {profile_values}_fid_idx ON {profile_values} (fid)");
break;
+
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {profile_fields} (
+ fid INTEGER PRIMARY KEY,
+ title varchar(255) default NULL,
+ name varchar(128) default NULL,
+ explanation TEXT default NULL,
+ category varchar(255) default NULL,
+ page varchar(255) default NULL,
+ type varchar(128) default NULL,
+ weight tinyint(1) DEFAULT '0' NOT NULL,
+ required tinyint(1) DEFAULT '0' NOT NULL,
+ register tinyint(1) DEFAULT '0' NOT NULL,
+ visibility tinyint(1) DEFAULT '0' NOT NULL,
+ autocomplete tinyint(1) DEFAULT '0' NOT NULL,
+ options text,
+ UNIQUE (name)
+ );");
+ db_query("CREATE INDEX {profile_fields_category} ON {profile_fields}(category);");
+
+ db_query("CREATE TABLE {profile_values (
+ fid int(10) default '0',
+ uid int(10) default '0',
+ value text
+ );");
+ db_query("CREATE INDEX {profile_values}_uid ON {profile_values}(uid);");
+ db_query("CREATE INDEX {profile_values}_fid ON {profile_values}(fid);");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/search/search.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.install,v
retrieving revision 1.6
diff -u -Ff -r1.6 search.install
--- modules/search/search.install 1 Sep 2006 07:40:08 -0000 1.6
+++ modules/search/search.install 23 Jan 2007 21:35:40 -0000
@@ -59,6 +59,35 @@ count float default NULL,
PRIMARY KEY (word)
)");
break;
+
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE {search_dataset} (
+ sid int(10) NOT NULL default '0',
+ type varchar(16) default NULL,
+ data longtext NOT NULL
+ );");
+ db_query("CREATE INDEX {search_dataset}_sid ON {search_dataset}(sid, type);");
+
+ db_query("CREATE TABLE {search_index} (
+ word varchar(50) NOT NULL default '',
+ sid int(10) NOT NULL default '0',
+ type varchar(16) default NULL,
+ fromsid int(10) NOT NULL default '0',
+ fromtype varchar(16) default NULL,
+ score float default NULL
+ );");
+ db_query("CREATE INDEX {search_index}_sid ON {search_index}(sid);");
+ db_query("CREATE INDEX {search_index}_fromsid ON {search_index}(fromsid);");
+ db_query("CREATE INDEX {search_index}_word ON {search_index}(word);");
+
+ db_query("CREATE TABLE {search_total} (
+ word varchar(50) NOT NULL default '',
+ count float default NULL,
+ PRIMARY KEY (word)
+ );");
+ db_query("COMMIT");
+ break;
}
}
Index: modules/statistics/statistics.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v
retrieving revision 1.7
diff -u -Ff -r1.7 statistics.install
--- modules/statistics/statistics.install 7 Nov 2006 22:27:07 -0000 1.7
+++ modules/statistics/statistics.install 7 Mar 2007 10:10:50 -0000
@@ -37,6 +37,21 @@ timestamp int_unsigned NOT NULL
)");
db_query("CREATE INDEX {accesslog}_accesslog_timestamp_idx ON {accesslog} (timestamp)");
break;
+
+ case 'sqlite':
+ db_query("CREATE TABLE {accesslog} (
+ aid INTEGER PRIMARY KEY,
+ sid varchar(64) NOT NULL default '',
+ title varchar(255) default NULL,
+ path varchar(255) default NULL,
+ url varchar(255) default NULL,
+ hostname varchar(128) default NULL,
+ uid int(10) default '0',
+ timer int(10) NOT NULL default '0',
+ timestamp int(11) NOT NULL default '0'
+ );");
+ db_query("CREATE INDEX {accesslog_timestamp} ON {accesslog}(timestamp ASC);");
+ break;
}
}
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.88
diff -u -Ff -r1.88 system.install
--- modules/system/system.install 30 Mar 2007 08:47:58 -0000 1.88
+++ modules/system/system.install 31 Mar 2007 12:54:48 -0000
@@ -1104,6 +1104,452 @@ timestamp int NOT NULL default '
)");
db_query("CREATE INDEX {watchdog}_type_idx ON {watchdog} (type)");
break;
+
+ case 'sqlite':
+ db_query("BEGIN");
+ db_query("CREATE TABLE '