2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A/* for db_next_desc */ 2N/A /* chained: db_next_index_desc* */ 2N/A/* Constructor: Create a database using the given name, 'dbname.' 2N/A The database is stored in a file named 'dbname'. 2N/A The log file is stored in a file named 'dbname'.log. 2N/A A temporary file 'dbname'.tmp is also used. */ 2N/A/* destructor: note that associated files should be removed separated */ 2N/A FATAL(
"db::assign_next_desc: cannot allocate space",
2N/A FATAL(
"db::assign_next_desc: cannot allocate space (2)",
2N/A/* Execute the specified action using the rest of the arguments as input. 2N/A Return a structure db_result containing the result. */ 2N/A FATAL3(
"db::exec_action: cannot allocate space for result",
2N/A "db::exec_action: cannot allocate space for DB_FIRST result",
2N/A // invalid previous indicator 2N/A // invalid previous indicator 2N/A WARNING(
"db::exec_action: invalid previous indicator");
2N/A "db::exec_action: cannot allocate space for DB_NEXT result",
2N/A break;
// do nothing 2N/A WARNING(
"db::exec_action: invalid previous indicator");
2N/A * Log the given action and execute it. 2N/A * The minor version of the database is updated after the action has 2N/A * been executed and the database is flagged as being changed. 2N/A * Return the structure db_result, or NULL if the logging failed or the 2N/A * action is unknown. 2N/A * If this is a synchronous operation on the master we should 2N/A * not copy the log for each operation. Doing so causes 2N/A * massive disk IO that hampers the performance of these operations. 2N/A * Where as on the replica these operations are not synchronous 2N/A * (batched) and don't affect the performance as much. 2N/A "wu db::log_action DB_STORAGE_LIMIT");
2N/A "wu db::log_action DB_STORAGE_LIMIT");
2N/A "wu db::log_action DB_STORAGE_LIMIT");
2N/A * Execute 'action' using the rest of the arguments as input. 2N/A * Return the result of the operation in a db_result structure; 2N/A * Return NULL if the request is unknown. 2N/A * If the action involves updates (ADD and REMOVE), it is logged first. 2N/A /* log_action() will do the locking */ 2N/A/* close existing logfile and delete its structure */ 2N/A /* try to close old log file */ 2N/A /* doesnot matter since we do synchronous writes only */ 2N/A/* close existing logfile, but leave its structure if exists */ 2N/A/* open logfile, creating its structure if it does not exist */ 2N/A FATAL3(
"db::reset_log: cannot allocate space",
2N/A * Execute log entry 'j' on the database identified by 'dbchar' if the 2N/A * version of j is later than that of the database. If 'j' is executed, 2N/A * 'count' is incremented and the database's verison is updated to that of 'j'. 2N/A * Returns TRUE always for valid log entries; FALSE otherwise. 2N/A WARNING(
"db::apply_log_entry: unknown action_type");
2N/A return (
TRUE);
/* always want to TRUE if action valid ? */ 2N/A * Execute log entry 'j' on this db. 'j' is executed if its version is 2N/A * later than that of the database; if executed, the database's version 2N/A * will be changed to that of 'j', regardless of the status of the operation. 2N/A * Returns TRUE if 'j' was executed; FALSE if it was not. 2N/A * Log entry is added to this database's log if log_entry is applied. 2N/A * If this is a synchronous operation on the master we should 2N/A * not copy the log for each operation. Doing so causes 2N/A * massive disk IO that hampers the performance of these operations. 2N/A * Where as on the replica these operations are not synchronous 2N/A * (batched) and don't affect the performance as much. 2N/A * should really record the log entry first, but can''t do that without 2N/A * knowing whether the log entry is applicable. 2N/A "db::execute_log_entry: could not add log entry: ");
2N/A// close_log(); /* do this asynchronously */ 2N/A/* Incorporate updates in log to database already loaded. 2N/A Does not affect "logfile" */ 2N/A "wu db::incorporate_log",
2N/A "wu mindex db::incorporate_log");
2N/A/* Load database and incorporate any logged updates into the loaded copy. 2N/A Return TRUE if load succeeds; FALSE otherwise. */ 2N/A "WARNING: the current db '%s' has been changed but not checkpointed",
2N/A /* otherwise, there was just nothing to load */ 2N/A "wu db::load",
"wu internal_db db::load");
2N/A * Initialize the database using table scheme 's'. 2N/A * Because the 'scheme' must be 'remembered' between restarts, 2N/A * after the initialization, the empty database is checkpointed to record 2N/A * the scheme. Returns TRUE if initialization succeeds; FALSE otherwise. 2N/A Write out in-memory copy of database to file. 2N/A 1. Update major version. 2N/A 2. Dump contents to temporary file. 2N/A 3. Rename temporary file to real database file. 2N/A A checkpoint is done only if it has changed since the previous checkpoint. 2N/A Returns TRUE if checkpoint was successful; FALSE otherwise. 2N/A "db::checkpoint: could not rename temp file to db file: ");
2N/A/* For generating log_list */ 2N/A * For the given entry determine, if it is later than the version supplied, 2N/A * 1. increment 'count'. 2N/A * 2. add the entry to the list of log entries found. 2N/A * Since traversal happens on an automatic (struct traverse_info) in 2N/A * db::get_log_entries_since(), no locking is necessary. 2N/A// j->print(); // debug 2N/A/* Return structure db_log_list containing entries that are later 2N/A than the version 'v' given. */ 2N/A FATAL3(
"db::get_log_entries_since: cannot allocate space",
2N/A "db::get_log_entries_since: cannot allocate space for entries",
2N/A/* Delete all files associated with database. */ 2N/A/* Pass configuration information to the db_mindex */