summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-21 01:15:15 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-21 01:15:15 +0000
commita7527fecadec47bf6d5d4fe5b0d63e5a811bb5b5 (patch)
treebdb9c3e44322cc568ddee29cae2386cc8f0bb762 /includes
parent2c5a198366b035f5b37d6446d620aa86b3abbf83 (diff)
downloadbrdo-a7527fecadec47bf6d5d4fe5b0d63e5a811bb5b5.tar.gz
brdo-a7527fecadec47bf6d5d4fe5b0d63e5a811bb5b5.tar.bz2
#564394 follow-up by Damien Tournoud: Remove crappy old pgsql-only db_add/change_column() functions from database layer.
Diffstat (limited to 'includes')
-rw-r--r--includes/update.inc115
1 files changed, 0 insertions, 115 deletions
diff --git a/includes/update.inc b/includes/update.inc
index f199784ff..44e246757 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -9,121 +9,6 @@
* installation. It is included and used extensively by update.php.
*/
-
-/**
- * Add a column to a database using syntax appropriate for PostgreSQL.
- *
- * Saves the result of the SQL commands in the referenced $ret array.
- *
- * Note: when you add a column with NOT NULL and you are not sure if there are
- * already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL
- * won't work when the table is not empty, and db_add_column() will fail.
- * To have an empty string as the default, you must use: 'default' => "''"
- * in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL
- * version will set values of the added column in old rows to the
- * DEFAULT value.
- *
- * @param $ret
- * Reference to an array to which results will be added.
- * @param $table
- * Name of the table, without {}
- * @param $column
- * Name of the column
- * @param $type
- * Type of column
- * @param $attributes
- * Additional optional attributes. Recognized attributes:
- * not null => TRUE|FALSE
- * default => NULL|FALSE|value (the value must be enclosed in '' marks)
- * @return
- * nothing, but modifies $ret parameter.
- */
-function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
- if (array_key_exists('not null', $attributes) and $attributes['not null']) {
- $not_null = 'NOT NULL';
- }
- if (array_key_exists('default', $attributes)) {
- if (is_null($attributes['default'])) {
- $default_val = 'NULL';
- $default = 'default NULL';
- }
- elseif ($attributes['default'] === FALSE) {
- $default = '';
- }
- else {
- $default_val = "$attributes[default]";
- $default = "default $attributes[default]";
- }
- }
-
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column $type");
- if (!empty($default)) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET $default");
- }
- if (!empty($not_null)) {
- if (!empty($default)) {
- $ret[] = update_sql("UPDATE {" . $table . "} SET $column = $default_val");
- }
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET NOT NULL");
- }
-}
-
-/**
- * Change a column definition using syntax appropriate for PostgreSQL.
- * Save result of SQL commands in $ret array.
- *
- * Remember that changing a column definition involves adding a new column
- * and dropping an old one. This means that any indices, primary keys and
- * sequences from serial-type columns are dropped and might need to be
- * recreated.
- *
- * @param $ret
- * Array to which results will be added.
- * @param $table
- * Name of the table, without {}
- * @param $column
- * Name of the column to change
- * @param $column_new
- * New name for the column (set to the same as $column if you don't want to change the name)
- * @param $type
- * Type of column
- * @param $attributes
- * Additional optional attributes. Recognized attributes:
- * not null => TRUE|FALSE
- * default => NULL|FALSE|value (with or without '', it won't be added)
- * @return
- * nothing, but modifies $ret parameter.
- */
-function db_change_column(&$ret, $table, $column, $column_new, $type, $attributes = array()) {
- if (array_key_exists('not null', $attributes) and $attributes['not null']) {
- $not_null = 'NOT NULL';
- }
- if (array_key_exists('default', $attributes)) {
- if (is_null($attributes['default'])) {
- $default_val = 'NULL';
- $default = 'default NULL';
- }
- elseif ($attributes['default'] === FALSE) {
- $default = '';
- }
- else {
- $default_val = "$attributes[default]";
- $default = "default $attributes[default]";
- }
- }
-
- $ret[] = update_sql("ALTER TABLE {" . $table . "} RENAME $column TO " . $column . "_old");
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column_new $type");
- $ret[] = update_sql("UPDATE {" . $table . "} SET $column_new = " . $column . "_old");
- if ($default) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET $default");
- }
- if ($not_null) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET NOT NULL");
- }
- $ret[] = update_sql("ALTER TABLE {" . $table . "} DROP " . $column . "_old");
-}
-
/**
* Disable anything in the {system} table that is not compatible with the
* current version of Drupal core.