/** * is old_view different than new_view? * * @param object $old_view * @param object $new_view * * @return boolean */ public static function is_view_modified($old_view, $new_view) { if (dbsteward::$always_recreate_views) { return TRUE; } $different = strcasecmp(pgsql8_view::get_view_query($old_view), pgsql8_view::get_view_query($new_view)) != 0; return $different; }
/** * Creates and returns SQL for creation of the view. * * @return string */ public static function get_creation_sql($db_doc, $node_schema, $node_view) { // set replica set context for view if (pgsql8::set_context_replica_set_id($node_view) === -10) { // view doesn't specify one, set from for schema object pgsql8::set_context_replica_set_id($node_schema); } if (isset($node_view['description']) && strlen($node_view['description']) > 0) { $ddl = "-- " . dbsteward::string_cast($node_view['description']) . "\n"; } $view_name = pgsql8::get_quoted_schema_name($node_schema['name']) . '.' . pgsql8::get_quoted_table_name($node_view['name']); $ddl = "CREATE OR REPLACE VIEW " . $view_name; $ddl .= "\n\tAS " . pgsql8_view::get_view_query($node_view) . ";\n"; if (isset($node_view['owner']) && strlen($node_view['owner']) > 0) { $ddl .= "ALTER VIEW " . $view_name . "\n\tOWNER TO " . xml_parser::role_enum($db_doc, $node_view['owner']) . ";\n"; } return $ddl; }