本文整理汇总了PHP中format::set_context_replica_set_to_natural_first方法的典型用法代码示例。如果您正苦于以下问题:PHP format::set_context_replica_set_to_natural_first方法的具体用法?PHP format::set_context_replica_set_to_natural_first怎么用?PHP format::set_context_replica_set_to_natural_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::set_context_replica_set_to_natural_first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diff_doc_work
/**
* @NOTICE: sql_format specific!
* Compare dbsteward::$old_database to dbsteward::$new_database
* Generate DDL / DML / DCL statements to upgrade old to new
*
* Changes are outputted to output_file_segementer members of this class
*
* @param object $stage1_ofs stage 1 output file segmentor
* @param object $stage2_ofs stage 2 output file segmentor
* @param object $stage3_ofs stage 3 output file segmentor
* @param object $stage4_ofs stage 4 output file segmentor
* @return void
*/
public static function diff_doc_work($stage1_ofs, $stage2_ofs, $stage3_ofs, $stage4_ofs)
{
// this shouldn't be called if we're not generating slonik, it looks for
// a slony element in <database> which most likely won't be there if
// we're not interested in slony replication
if (dbsteward::$generate_slonik) {
format::set_context_replica_set_to_natural_first(dbsteward::$new_database);
}
if (self::$as_transaction) {
// stage 1 and 3 should not be in a transaction
// as they will be submitted via slonik EXECUTE SCRIPT
if (!dbsteward::$generate_slonik) {
$stage1_ofs->append_header("\nBEGIN;\n");
$stage1_ofs->append_footer("\nCOMMIT;\n");
} else {
$stage1_ofs->append_header("\n-- generateslonik specified: pgsql8 STAGE1 upgrade omitting BEGIN. slonik EXECUTE SCRIPT will wrap stage 1 DDL and DCL in a transaction\n");
}
if (!dbsteward::$single_stage_upgrade) {
$stage2_ofs->append_header("\nBEGIN;\n\n");
$stage2_ofs->append_footer("\nCOMMIT;\n");
// if generating slonik, stage 1 and 3 should not be in a transaction
// as they will be submitted via slonik EXECUTE SCRIPT
if (!dbsteward::$generate_slonik) {
$stage3_ofs->append_header("\nBEGIN;\n\n");
$stage3_ofs->append_footer("\nCOMMIT;\n");
} else {
$stage3_ofs->append_header("\n-- generateslonik specified: pgsql8 STAGE1 upgrade omitting BEGIN. slonik EXECUTE SCRIPT will wrap stage 3 DDL and DCL in a transaction\n");
}
$stage4_ofs->append_header("\nBEGIN;\n\n");
$stage4_ofs->append_footer("\nCOMMIT;\n");
}
}
// start with pre-upgrade sql statements that prepare the database to take on its changes
dbx::build_staged_sql(dbsteward::$new_database, $stage1_ofs, 'STAGE1BEFORE');
dbx::build_staged_sql(dbsteward::$new_database, $stage2_ofs, 'STAGE2BEFORE');
dbsteward::info("Drop Old Schemas");
self::drop_old_schemas($stage3_ofs);
dbsteward::info("Create New Schemas");
self::create_new_schemas($stage1_ofs);
dbsteward::info("Update Structure");
self::update_structure($stage1_ofs, $stage3_ofs, self::$new_table_dependency);
dbsteward::info("Update Permissions");
self::update_permissions($stage1_ofs, $stage3_ofs);
self::update_database_config_parameters($stage1_ofs, dbsteward::$new_database, dbsteward::$old_database);
dbsteward::info("Update Data");
if (dbsteward::$generate_slonik) {
format::set_context_replica_set_to_natural_first(dbsteward::$new_database);
}
self::update_data($stage2_ofs, true);
self::update_data($stage4_ofs, false);
// append any literal SQL in new not in old at the end of data stage 1
$old_sql = dbx::get_sql(dbsteward::$old_database);
$new_sql = dbx::get_sql(dbsteward::$new_database);
for ($n = 0; $n < count($new_sql); $n++) {
if (isset($new_sql[$n]['stage'])) {
// ignore upgrade staged sql elements
continue;
}
// is this new statement in the old database?
$found = false;
for ($o = 0; $o < count($old_sql); $o++) {
if (isset($old_sql[$o]['stage'])) {
// ignore upgrade staged sql elements
continue;
}
if (strcmp($new_sql[$n], $old_sql[$o]) == 0) {
$found = true;
}
}
if (!$found) {
$stage2_ofs->write($new_sql[$n] . "\n");
}
}
// append stage defined sql statements to appropriate stage file
if (dbsteward::$generate_slonik) {
format::set_context_replica_set_to_natural_first(dbsteward::$new_database);
}
dbx::build_staged_sql(dbsteward::$new_database, $stage1_ofs, 'STAGE1');
dbx::build_staged_sql(dbsteward::$new_database, $stage2_ofs, 'STAGE2');
dbx::build_staged_sql(dbsteward::$new_database, $stage3_ofs, 'STAGE3');
dbx::build_staged_sql(dbsteward::$new_database, $stage4_ofs, 'STAGE4');
}