home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 December
/
PCWorld_1998-12_cd.iso
/
software
/
sybase
/
ASA
/
asa60.exe
/
data1.cab
/
h_files
/
dbtools.h
< prev
next >
Wrap
C/C++ Source or Header
|
1998-07-27
|
21KB
|
592 lines
/****************************************************************
* Copyright (C) 1988-1998, by Sybase, Inc. *
* All rights reserved. No part of this software may be *
* reproduced in any form or by any means - graphic, *
* electronic or mechanical, including photocopying, *
* recording, taping or information storage and retrieval *
* systems - except with the written permission of *
* Sybase, Inc. *
****************************************************************/
#ifndef _DBTOOLS_H_INCLUDED
#define _DBTOOLS_H_INCLUDED
#include "sqlca.h"
#include "dllapi.h"
#include "dbtlvers.h"
#if defined( _SQL_PACK_STRUCTURES )
#include "pshpk1.h"
#endif
// Changes in this version requiring a version number change:
// - a_compress_db:
// - extended structure to fill in compression statistics to avoid
// writing them directly.
// - a_db_info:
// - extended structure to allow returning of page usage information
// from DBInfo.
//***************************************************************************
// Generic interface pieces
//***************************************************************************
#if defined(__unix) || defined(_AIX)
#if !defined(a_bit_field)
#define a_bit_field unsigned int
#define a_bit_short unsigned int
#endif
#else
#if !defined(a_bit_field)
#define a_bit_field unsigned char
#define a_bit_short unsigned short
#endif
#endif
typedef struct a_name {
struct a_name _fd_ * next;
char name[1];
} a_name, _fd_ * p_name;
typedef struct a_sysinfo {
a_bit_field valid_data : 1; // are following values set?
a_bit_field blank_padding : 1;
a_bit_field case_sensitivity : 1;
a_bit_field encryption : 1;
char default_collation[11];
unsigned short page_size;
} a_sysinfo;
//***************************************************************************
// initialization (DBTINIT) interface
//***************************************************************************
typedef struct a_dbtools_info {
MSG_CALLBACK errorrtn;
} a_dbtools_info;
extern _crtn short _entry DBToolsInit( const a_dbtools_info _fd_ * );
extern _crtn short _entry DBToolsFini( const a_dbtools_info _fd_ * );
//***************************************************************************
// get shared library version
//***************************************************************************
extern _crtn short _entry DBToolsVersion( void );
//***************************************************************************
// backup database (DBBACKUP) interface
//***************************************************************************
typedef struct a_backup_db {
unsigned short version;
const char _fd_ *output_dir;
const char _fd_ *connectparms; // userid,password,database
const char _fd_ *startline; // (NULL for default start line)
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field backup_database : 1;
a_bit_field backup_logfile : 1;
a_bit_field backup_writefile: 1; // only if using write file
a_bit_field no_confirm : 1;
a_bit_field quiet : 1;
a_bit_field rename_log : 1;
a_bit_field truncate_log : 1;
a_bit_field rename_local_log: 1;
const char _fd_ *hotlog_filename;
char backup_interrupted;
} a_backup_db;
extern _crtn short _entry DBBackup( const a_backup_db _fd_ * );
//***************************************************************************
// change database logfile name (DBLOG) interface
//***************************************************************************
typedef struct a_change_log {
unsigned short version;
const char _fd_ * dbname;
const char _fd_ * logname; // (logname = NULL) for no log
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
a_bit_field query_only : 1;
a_bit_field quiet : 1;
a_bit_field mirrorname_present : 1;
a_bit_field change_mirrorname : 1;
a_bit_field change_logname : 1;
a_bit_field ignore_ltm_trunc : 1;
a_bit_field ignore_remote_trunc : 1;
a_bit_field set_generation_number : 1;
// Following fields are new with 5.0:
const char _fd_ * mirrorname;
unsigned short generation_number;
// Following fields are new with 5.5.02
const char _fd_ * key_file;
// Following fields are new with 6.0:
char * zap_current_offset;
char * zap_starting_offset;
} a_change_log;
extern _crtn short _entry DBChangeLogName( const a_change_log _fd_ * );
//***************************************************************************
// (1) change write file to refer to another database file (DBWRITE -d)
// (2) create a database write file (DBWRITE -c)
// (3) get status of a write file (DBWRITE -s)
//***************************************************************************
typedef struct a_writefile {
unsigned short version;
const char _fd_ * writename;
const char _fd_ * wlogname; // "create" only
const char _fd_ * dbname; // "change", "create"
const char _fd_ * forcename; // forced filename reference
MSG_CALLBACK confirmrtn; // "create" only
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
char action; // used internally
a_bit_field quiet : 1;
a_bit_field erase : 1; // "create" only; erase without confirm
a_bit_field force : 1;
a_bit_field mirrorname_present : 1;
// new for v5.0
const char _fd_ * wlogmirrorname; // "create" only
// Following fields are new with 6.0:
// When TRUE, DBCreateWriteFile will use the values in wlogname and
// wlogmirrorname as "base" filenames to determine appropriate filenames
// with the correct path and extensions, etc.
// When FALSE, DBCreateWriteFile will use the two filenames as
// specified (old behaviour).
a_bit_field make_log_and_mirror_names: 1;
} a_writefile;
extern _crtn short _entry DBChangeWriteFile( const a_writefile _fd_ * );
extern _crtn short _entry DBCreateWriteFile( const a_writefile _fd_ * );
extern _crtn short _entry DBStatusWriteFile( const a_writefile _fd_ * );
//***************************************************************************
// compress a database (DBSHRINK) interface
//***************************************************************************
typedef struct a_stats_line {
long pages;
long bytes;
long compressed_bytes;
} a_stats_line;
typedef struct a_compress_stats {
a_stats_line tables;
a_stats_line indices;
a_stats_line other;
a_stats_line free;
a_stats_line total;
long free_pages;
long unchanged;
} a_compress_stats;
typedef struct a_compress_db {
unsigned short version;
const char _fd_ * dbname;
const char _fd_ * compress_name;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field display_free_pages : 1;
a_bit_field quiet : 1;
a_bit_field record_unchanged : 1;
// The following values are new with version 3.2c:
a_compress_stats _fd_ * stats; // filled in if not NULL
// && display_free_pages not zero
// The following values are new with version 3.2d:
MSG_CALLBACK confirmrtn;
a_bit_field noconfirm : 1;
// Following fields are new with 5.5.02
const char _fd_ * key_file;
} a_compress_db;
extern _crtn short _entry DBCompress( const a_compress_db _fd_ * );
//***************************************************************************
// create a new database (DBINIT) interface
//***************************************************************************
enum { // verbosity
VB_QUIET,
VB_NORMAL,
VB_VERBOSE
};
enum { // Possible values for blank_pad
NO_BLANK_PADDING,
BLANK_PADDING
};
typedef struct a_create_db {
unsigned short version;
const char _fd_ * dbname;
const char _fd_ * logname; // (NULL for no log file)
const char _fd_ * startline; // (NULL for default start line)
short page_size;
const char _fd_ * default_collation; // collation identifier
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
short database_version; // used internally
char verbose; // VB_xxx (above)
a_bit_field blank_pad : 2;
a_bit_field respect_case : 1;
a_bit_field encrypt : 1;
a_bit_field debug : 1; // should be FALSE
a_bit_field dbo_avail : 1; // doesn't do anything
a_bit_field mirrorname_present : 1;
a_bit_field avoid_view_collisions : 1; // SYS.SYSCOLUMNS and
// SYS.SYSINDEXES not created
// The following fields are used internally by DBCreate.
short collation_id;
// Following fields are new with 5.0:
// the dbo_username functionality has been dropped as of 6.0
// you can leave it set to NULL
const char _fd_ * dbo_username;
const char _fd_ * mirrorname;
// Following fields are new with 5.5.02
const char _fd_ * encryption_dllname;
// Following fields are new with 6.0:
a_bit_field java_classes : 1;
a_bit_field jconnect : 1;
} a_create_db;
extern _crtn short _entry DBCreate( a_create_db _fd_ * );
//***************************************************************************
// erase a database (DBERASE)
//***************************************************************************
typedef struct an_erase_db {
unsigned short version;
const char _fd_ * dbname;
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
a_bit_field quiet : 1;
a_bit_field erase : 1; // erase without confirmation
// Following fields are new with 5.5.02
const char _fd_ * key_file; // encryption key
} an_erase_db;
extern _crtn short _entry DBErase( const an_erase_db _fd_ * );
//***************************************************************************
// expand a compressed database (DBEXPAND) interface
//***************************************************************************
typedef struct an_expand_db {
unsigned short version;
const char _fd_ * compress_name;
const char _fd_ * dbname;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field quiet : 1;
// The following values are new with version 3.2d:
MSG_CALLBACK confirmrtn;
a_bit_field noconfirm : 1;
// Following fields are new with 5.5.02
const char _fd_ * key_file;
} an_expand_db;
extern _crtn short _entry DBExpand( const an_expand_db _fd_ * );
//***************************************************************************
// get information from a database about how it was created (DBINFO)
//***************************************************************************
typedef struct a_table_info {
struct a_table_info _fd_ * next;
unsigned short table_id; // table id
unsigned long table_pages; // number of table pages
unsigned long index_pages; // number of index pages
unsigned long table_used; // bytes used in table pages
unsigned long index_used; // bytes used in index pages
char _fd_ * table_name; // table name
} a_table_info;
typedef struct a_db_info {
unsigned short version;
MSG_CALLBACK errorrtn;
const char _fd_ *dbname; // file to extract info from
unsigned short dbbufsize; // size of "dbnamebuffer"
char _fd_ * dbnamebuffer; // filled in
unsigned short logbufsize; // size of "lognamebuffer"
char _fd_ * lognamebuffer; // filled in; empty if no log
unsigned short wrtbufsize; // size of "wrtnamebuffer"
char _fd_ * wrtnamebuffer; // filled in; empty if not write file
a_bit_field quiet : 1;
a_bit_field mirrorname_present : 1;
// The following values are returned by DBInfo:
a_sysinfo sysinfo;
unsigned long free_pages;
a_bit_field compressed : 1;
// The following values are new with version 3.2c:
const char _fd_ *connectparms; // userid,password,database
const char _fd_ *startline; // (NULL for default start line)
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field page_usage : 1; // fill in page usage values below?
// The following page usage values are returned by DBInfo:
a_table_info _fd_ * totals; // page usage statistics
unsigned long file_size; // file size (in pages)
unsigned long unused_pages; // number of unused (free) pages
unsigned long other_pages; // number of other pages
// New for v5.0
unsigned short mirrorbufsize; // size of "lognamebuffer"
char _fd_ * mirrornamebuffer; // filled in; empty if no log
// Following fields are new with 5.5.02
const char _fd_ *key_file; // encryption key
} a_db_info;
extern _crtn short _entry DBInfo( a_db_info _fd_ * );
extern _crtn short _entry DBInfoDump( a_db_info _fd_ * );
extern _crtn short _entry DBInfoFree( a_db_info _fd_ * );
//***************************************************************************
// get collation information from database (DBCOLLAT)
//***************************************************************************
typedef struct a_db_collation {
unsigned short version;
const char _fd_ * connectparms; // userid,password,database
const char _fd_ * startline; // (NULL for default start line)
const char _fd_ * collation_label;
const char _fd_ * filename;
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
a_bit_field include_empty : 1;// include lines with no mappings?
a_bit_field hex_for_extended: 1;// use hex for extended chars (> 7E)?
a_bit_field replace : 1;// replace file w/o confirm?
a_bit_field quiet : 1;
// New for v6.0:
const char _fd_ * input_filename; // input collation definition
const char _fd_ * mapping_filename; // syscollationmapping output
} a_db_collation;
extern _crtn short _entry DBCollate( const a_db_collation _fd_ * );
//***************************************************************************
// translate log file to SQL (DBTRAN) interface
//***************************************************************************
typedef enum dbtran_userlist_type {
DBTRAN_INCLUDE_ALL,
DBTRAN_INCLUDE_SOME,
DBTRAN_EXCLUDE_SOME
} dbtran_userlist_type;
typedef struct a_translate_log {
unsigned short version;
const char _fd_ * logname;
const char _fd_ * sqlname;
p_name userlist;
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
char userlisttype; // DBTRAN_xxx (above)
a_bit_field remove_rollback : 1;
a_bit_field ansi_sql : 1;
a_bit_field since_checkpoint: 1;
a_bit_field omit_comments : 1;
a_bit_field replace : 1; // replace SQL file w/o confirm?
a_bit_field debug : 1;
a_bit_field include_trigger_trans : 1;
a_bit_field comment_trigger_trans : 1;
unsigned long since_time;
} a_translate_log;
extern _crtn short _entry DBTranslateLog( const a_translate_log _fd_ * );
//***************************************************************************
// unload the database into files (DBUNLOAD)
//***************************************************************************
enum {
UNLOAD_ALL,
UNLOAD_DATA_ONLY,
UNLOAD_NO_DATA
};
typedef struct an_unload_db {
unsigned short version;
const char _fd_ * connectparms; // userid,password,database
const char _fd_ * startline; // (NULL for default start line)
const char _fd_ * temp_dir; // directory for data files (bad name)
const char _fd_ * reload_filename;// (Must be filled in)
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
MSG_CALLBACK confirmrtn;
char unload_type; // UNLOAD_xxx (above)
char verbose; // VB_xxx (above)
a_bit_field unordered : 1;
a_bit_field no_confirm : 1;
a_bit_field use_internal_unload : 1;
a_bit_field dbo_avail : 1; // doesn't do anything
a_bit_field extract : 1;
a_bit_field table_list_provided : 1;
a_bit_field exclude_tables : 1;
a_bit_field more_flag_bits_present : 1;
// ** NOTE ** Do not add any more flags here!!
// The following values are only written to by DBUnload:
a_sysinfo sysinfo;
const char _fd_ * remote_dir;
// Following fields added in 5.0:
// the dbo_username functionality has been dropped as of 6.0
// you can leave it set to NULL
const char _fd_ * dbo_username;
// Fields for dbextract (added in 5.0)
const char _fd_ * subscriber_username;
const char _fd_ * publisher_address_type;
const char _fd_ * publisher_address;
unsigned short isolation_level;
a_bit_field start_subscriptions : 1;
a_bit_field exclude_foreign_keys : 1;
a_bit_field exclude_procedures : 1;
a_bit_field exclude_triggers : 1;
a_bit_field exclude_views : 1;
a_bit_field isolation_set : 1;
a_bit_field include_where_subscribe : 1;
a_bit_field debug : 1;
p_name table_list; // selective table list
// Extended bits -- these are present if 'more_flag_bits_available' is true
a_bit_short escape_char_present : 1;
a_bit_short view_iterations_present : 1;
a_bit_short use_internal_reload : 1;
unsigned short view_iterations;
char escape_char;
// Fields for automatic reload( added in 5.5.05 )
char _fd_ * reload_connectparms; // userid,password,database for reload database
char _fd_ * reload_db_filename; // filename of reload database to create
a_bit_field output_connections:1;
char unload_interrupted;
} an_unload_db;
extern _crtn short _entry DBUnload( an_unload_db _fd_ * );
//***************************************************************************
// upgrade the system tables of a database (DBUPGRAD)
//***************************************************************************
typedef struct an_upgrade_db {
unsigned short version;
const char _fd_ * connectparms; // userid,password,database
const char _fd_ * startline; // (NULL for default start line)
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field quiet : 1;
a_bit_field dbo_avail : 1; // doesn't do anything
// the dbo_username functionality has been dropped as of 6.0
// you can leave it set to NULL
const char _fd_ * dbo_username;
// following fields added in 6.0
a_bit_field java_classes : 1;
a_bit_field jconnect : 1;
} an_upgrade_db;
extern _crtn short _entry DBUpgrade( const an_upgrade_db _fd_ * );
//***************************************************************************
// validate the tables of a database (DBVALID)
//***************************************************************************
typedef struct a_validate_db {
unsigned short version;
const char _fd_ * connectparms; // userid,password,database
const char _fd_ * startline; // (NULL for default start line)
p_name tables;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
a_bit_field quiet : 1;
} a_validate_db;
extern _crtn short _entry DBValidate( const a_validate_db _fd_ * );
//***************************************************************************
// truncate transaction log interface
//***************************************************************************
typedef struct a_truncate_log {
unsigned short version;
const char _fd_ * connectparms; // userid,password,database
const char _fd_ * startline; // (NULL for default start line)
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
a_bit_field quiet : 1;
char truncate_interrupted;
} a_truncate_log;
extern _crtn short _entry DBTruncateLog( const a_truncate_log _fd_ * );
//***************************************************************************
// encrypt database (DBCRYPT) interface
//***************************************************************************
typedef struct a_crypt_db {
const char _fd_ * dbname;
const char _fd_ * dllname;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_CALLBACK statusrtn;
char verbose;
a_bit_field quiet : 1;
a_bit_field debug : 1;
} a_crypt_db;
extern _crtn short _entry DBCrypt( const a_crypt_db _fd_ * );
#if !defined( _SQL_OS_UNIX )
#include "poppk.h"
#endif
#endif