update_105

Versions
4.6
update_105()

Code

database/updates.inc, line 1809

<?php
function update_105() {
  $ret = array();

  $shadowupdates = db_query("SELECT nid,tid FROM {forum} WHERE shadow=0");
  while ($shadowrecord = db_fetch_object($shadowupdates)) {
    db_query("DELETE FROM {term_node} WHERE nid = %d AND tid <> %d", $shadowrecord->nid, $shadowrecord->tid);
  }

  if ($GLOBALS['db_type'] == 'mysql') {
    $ret[] = update_sql("ALTER TABLE {forum} DROP shadow");
    $ret[] = update_sql('ALTER TABLE {node} ADD INDEX node_status_type (status, type, nid)');
  }
  else {
    // PostgreSQL is incapable of dropping columns in all but the latest versions.
    $ret[] = update_sql("CREATE INDEX {node}_status_type_idx ON {node} (status, type, nid)");

    $ret[] = update_sql("CREATE FUNCTION \"if\"(integer, text, text) RETURNS text AS '
      BEGIN
        IF $1 THEN
          RETURN $2;
        END IF;
        IF NOT $1 THEN
          RETURN $3;
        END IF;
      END;
      ' LANGUAGE 'plpgsql'");
  }

  return $ret;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.