CUBRID Engine  latest
migrate.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
#include "dbi.h"
#include "porting.h"
#include "utility.h"
#include "databases_file.h"
#include "boot_sr.h"
#include "log_impl.h"
#include "btree.h"
#include "transform.h"
#include "message_catalog.h"
#include "error_manager.h"
#include "system_parameter.h"
#include "language_support.h"

Go to the source code of this file.

Classes

struct  r91_disk_var_header
 
struct  VOLUME_UNDO_INFO
 

Macros

#define V9_1_LEVEL   (9.1f)
 
#define V9_2_LEVEL   (9.2f)
 
#define FOPEN_AND_CHECK(fp, filename, mode)
 
#define FSEEK_AND_CHECK(fp, size, origin, filename)
 
#define FREAD_AND_CHECK(ptr, size, n, fp, filename)
 
#define FWRITE_AND_CHECK(ptr, size, n, fp, filename)
 
#define FFLUSH_AND_CHECK(fp, filename)
 
#define FCLOSE_AND_CHECK(fp, filename)
 
#define UNDO_LIST_SIZE   (32)
 
#define QUERY_SIZE   1024
 

Typedefs

typedef struct r91_disk_var_header R91_DISK_VAR_HEADER
 

Functions

static int fix_all_volume_header (const char *db_path)
 
static int fix_volume_header (const char *vol_path)
 
static int undo_fix_volume_header (const char *vol_path, char *undo_page, int size)
 
static char * make_volume_header_undo_page (const char *vol_path, int size)
 
static void free_volume_header_undo_list (void)
 
static int get_active_log_vol_path (const char *db_path, char *logvol_path)
 
static int check_and_fix_compat_level (const char *db_name, const char *vol_path)
 
static int get_db_path (const char *db_name, char *db_full_path)
 
static int fix_codeset_in_active_log (const char *db_path, INTL_CODESET codeset)
 
int catcls_get_db_collation (THREAD_ENTRY *thread_p, LANG_COLL_COMPAT **db_collations, int *coll_cnt)
 
static int undo_fix_compat_level (const char *db_path)
 
static void intr_handler (int sig_no)
 
static int get_codeset_from_db_root (void)
 
int main (int argc, char *argv[])
 

Variables

static int vol_undo_list_length
 
static int vol_undo_count
 
static VOLUME_UNDO_INFOvol_undo_info
 

Macro Definition Documentation

#define FCLOSE_AND_CHECK (   fp,
  filename 
)
Value:
do { \
if (fclose ((fp)) != 0) \
{ \
printf ("file fclose error: %s, %d\n", (filename), errno); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 103 of file migrate.c.

Referenced by check_and_fix_compat_level(), fix_codeset_in_active_log(), fix_volume_header(), get_active_log_vol_path(), undo_fix_compat_level(), and undo_fix_volume_header().

#define FFLUSH_AND_CHECK (   fp,
  filename 
)
Value:
do { \
if (fflush ((fp)) != 0) \
{ \
printf ("file fflush error: %s, %d\n", (filename), errno); \
fclose ((fp)); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 93 of file migrate.c.

Referenced by check_and_fix_compat_level(), fix_codeset_in_active_log(), fix_volume_header(), undo_fix_compat_level(), and undo_fix_volume_header().

#define FOPEN_AND_CHECK (   fp,
  filename,
  mode 
)
Value:
do { \
(fp) = fopen ((filename), (mode)); \
if ((fp) == NULL) \
{ \
printf ("file open error: %s, %d\n", (filename), errno); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
static enum scanner_mode mode
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 51 of file migrate.c.

Referenced by check_and_fix_compat_level(), fix_all_volume_header(), fix_codeset_in_active_log(), fix_volume_header(), get_active_log_vol_path(), undo_fix_compat_level(), and undo_fix_volume_header().

#define FREAD_AND_CHECK (   ptr,
  size,
  n,
  fp,
  filename 
)
Value:
do { \
fread ((ptr), (size), (n), (fp)); \
if (ferror ((fp)) != 0) \
{ \
printf ("file fread error: %s, %d\n", (filename), errno); \
fclose ((fp)); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 71 of file migrate.c.

Referenced by check_and_fix_compat_level(), fix_codeset_in_active_log(), fix_volume_header(), and undo_fix_compat_level().

#define FSEEK_AND_CHECK (   fp,
  size,
  origin,
  filename 
)
Value:
do { \
if (fseek ((fp), (size), (origin)) < 0) \
{ \
printf ("file seek error: %s, %d\n", (filename), errno); \
fclose ((fp)); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 61 of file migrate.c.

#define FWRITE_AND_CHECK (   ptr,
  size,
  n,
  fp,
  filename 
)
Value:
do { \
fwrite ((ptr), (size), (n), (fp)); \
if (ferror ((fp)) != 0) \
{ \
printf ("file fwrite error: %s, %d\n", (filename), errno); \
fclose ((fp)); \
return ER_FAILED; \
} \
} while (0)
#define ER_FAILED
Definition: error_code.h:47
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 82 of file migrate.c.

Referenced by check_and_fix_compat_level(), fix_codeset_in_active_log(), fix_volume_header(), undo_fix_compat_level(), and undo_fix_volume_header().

#define QUERY_SIZE   1024
#define UNDO_LIST_SIZE   (32)

Definition at line 112 of file migrate.c.

Referenced by fix_all_volume_header().

#define V9_1_LEVEL   (9.1f)

Definition at line 48 of file migrate.c.

Referenced by check_and_fix_compat_level(), and undo_fix_compat_level().

#define V9_2_LEVEL   (9.2f)

Definition at line 49 of file migrate.c.

Referenced by check_and_fix_compat_level(), and main().

Typedef Documentation

Definition at line 114 of file migrate.c.

Function Documentation

int catcls_get_db_collation ( THREAD_ENTRY thread_p,
LANG_COLL_COMPAT **  db_collations,
int *  coll_cnt 
)

Definition at line 4910 of file catalog_class.c.

Referenced by main().

Here is the caller graph for this function:

static int check_and_fix_compat_level ( const char *  db_name,
const char *  vol_path 
)
static
static int fix_all_volume_header ( const char *  db_path)
static
static int fix_codeset_in_active_log ( const char *  db_path,
INTL_CODESET  codeset 
)
static
static void free_volume_header_undo_list ( void  )
static

Definition at line 809 of file migrate.c.

References VOLUME_UNDO_INFO::filename, i, p, VOLUME_UNDO_INFO::page, and vol_undo_count.

Referenced by main().

Here is the caller graph for this function:

static int get_active_log_vol_path ( const char *  db_path,
char *  logvol_path 
)
static
static int get_codeset_from_db_root ( void  )
static

Definition at line 362 of file migrate.c.

References DB_CURSOR_END, DB_CURSOR_SUCCESS, db_execute(), db_get_int(), db_query_end(), db_query_get_tuple_value(), db_query_next_tuple(), ER_FAILED, NO_ERROR, and QUERY_SIZE.

Referenced by main().

Here is the caller graph for this function:

static int get_db_path ( const char *  db_name,
char *  db_full_path 
)
static

Definition at line 313 of file migrate.c.

References cfg_find_db_list(), cfg_free_directory(), cfg_read_directory(), COMPOSE_FULL_NAME(), ER_FAILED, NO_ERROR, NULL, and database_info::pathname.

Referenced by main().

Here is the caller graph for this function:

static void intr_handler ( int  sig_no)
static

Definition at line 347 of file migrate.c.

References FALSE, and TRUE.

Referenced by main().

Here is the caller graph for this function:

static char * make_volume_header_undo_page ( const char *  vol_path,
int  size 
)
static

Definition at line 752 of file migrate.c.

References VOLUME_UNDO_INFO::filename, NULL, VOLUME_UNDO_INFO::page, VOLUME_UNDO_INFO::page_size, vol_undo_count, and vol_undo_list_length.

Referenced by fix_volume_header().

Here is the caller graph for this function:

static int undo_fix_compat_level ( const char *  db_path)
static
static int undo_fix_volume_header ( const char *  vol_path,
char *  undo_page,
int  size 
)
static

Definition at line 796 of file migrate.c.

References FCLOSE_AND_CHECK, FFLUSH_AND_CHECK, FOPEN_AND_CHECK, FWRITE_AND_CHECK, NO_ERROR, and NULL.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

int vol_undo_count
static
VOLUME_UNDO_INFO* vol_undo_info
static

Definition at line 152 of file migrate.c.

int vol_undo_list_length
static

Definition at line 150 of file migrate.c.

Referenced by fix_all_volume_header(), and make_volume_header_undo_page().