public static function diff_clusters_table($ofs, $old_schema, $old_table, $new_schema, $new_table) { if ($old_table == null) { $old_cluster = null; } else { $old_cluster = isset($old_table['clusterIndex']) ? $old_table['clusterIndex'] : null; } $new_cluster = isset($new_table['clusterIndex']) ? $new_table['clusterIndex'] : null; if ($old_cluster == null && $new_cluster != null || $old_cluster != null && $new_cluster != null && strcmp($new_cluster, $old_cluster) != 0) { $ofs->write("ALTER TABLE " . pgsql8::get_quoted_schema_name($new_schema['name']) . '.' . pgsql8::get_quoted_table_name($new_table['name']) . " CLUSTER ON " . pgsql8::get_quoted_column_name($new_cluster) . ";\n"); } else { if ($old_cluster != null && $new_cluster == null && pgsql8_table::contains_index($new_schema, $new_table, $old_cluster)) { $ofs->write("ALTER TABLE " . pgsql8::get_quoted_schema_name($new_schema['name']) . '.' . pgsql8::get_quoted_table_name($table['name']) . " SET WITHOUT CLUSTER;" . "\n"); } } }
/** * Returns list of indexes that should be added. * * @param old_table original table * @param new_table new table * * @return list of indexes that should be added */ public static function get_new_indexes($old_schema, $old_table, $new_schema, $new_table) { $list = array(); if ($new_table != null) { if ($old_table == null) { foreach (format_index::get_table_indexes($new_schema, $new_table) as $index) { $list[] = $index; } } else { foreach (format_index::get_table_indexes($new_schema, $new_table) as $index) { $old_index = dbx::get_table_index($old_schema, $old_table, $index['name']); if (!pgsql8_table::contains_index($old_schema, $old_table, $index['name'])) { $list[] = $index; } else { if (!pgsql8_index::equals($old_index, $index)) { $list[] = $index; } } } } } return $list; }