dtinfo subtree DtMmdb
This commit is contained in:
committed by
Jon Trulson
parent
b92cf08899
commit
8c8363f4a5
@@ -23,7 +23,7 @@ XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
|
||||
#define LargePICTable YES
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES) $(DEPENDDEFINES)
|
||||
|
||||
XCOMM In DtMmdb we compile as C_API sources.
|
||||
DEFINES = -DC_API -DPORTABLE_DB
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include "utility/debug.h"
|
||||
|
||||
@@ -1110,7 +1110,7 @@ Boolean page_storage::io_mode(int mode)
|
||||
|
||||
void page_storage::begin_trans()
|
||||
{
|
||||
try {
|
||||
mtry {
|
||||
if ( trans_info.status == store_trans::ENABLED )
|
||||
throw(stringException("trans is still in progress"));
|
||||
|
||||
@@ -1127,7 +1127,7 @@ void page_storage::begin_trans()
|
||||
updateString(0, (char*)&l_max_pages, sizeof(l_max_pages), 0, true);
|
||||
}
|
||||
|
||||
catch (mmdbException&, e) {
|
||||
mcatch (mmdbException&, e) {
|
||||
// workaround for solaris's /SUNWspro/bin/CC compiler.
|
||||
beginTransException x;
|
||||
throw(x);
|
||||
@@ -1141,7 +1141,7 @@ void page_storage::commit_trans()
|
||||
//////////////////////////////
|
||||
// sync the touched pages
|
||||
//////////////////////////////
|
||||
try {
|
||||
mtry {
|
||||
int ind = trans_info.log_index -> first_bucket();
|
||||
|
||||
while ( ind != -1 ) {
|
||||
@@ -1165,7 +1165,7 @@ void page_storage::commit_trans()
|
||||
trans_info.status = store_trans::DISABLED;
|
||||
}
|
||||
|
||||
catch (mmdbException &,e) {
|
||||
mcatch (mmdbException &,e) {
|
||||
// workaround for solaris's /SUNWspro/bin/CC compiler.
|
||||
commitTransException x;
|
||||
throw(x);
|
||||
@@ -1174,7 +1174,7 @@ void page_storage::commit_trans()
|
||||
|
||||
void page_storage::roll_back()
|
||||
{
|
||||
try
|
||||
mtry
|
||||
{
|
||||
if ( exist_file(form("%s.log", name), path) == false )
|
||||
return;
|
||||
@@ -1270,7 +1270,7 @@ void page_storage::roll_back()
|
||||
trans_info.status = store_trans::DISABLED;
|
||||
}
|
||||
|
||||
catch (mmdbException &,e)
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
// workaround for solaris's /SUNWspro/bin/CC compiler.
|
||||
rollbackTransException x;
|
||||
@@ -1310,7 +1310,7 @@ debug(cerr, trans_info.max_pages);
|
||||
|
||||
int log_bytes_before = trans_info.log_store -> bytes();
|
||||
|
||||
try {
|
||||
mtry {
|
||||
if ( swap_order() == true ) // swap to desired order
|
||||
ORDER_SWAP_UINT(l_pid);
|
||||
|
||||
@@ -1331,7 +1331,7 @@ debug(cerr, trans_info.max_pages);
|
||||
trans_info.log_index -> insert(pkey);
|
||||
}
|
||||
|
||||
catch (mmdbException&, e) {
|
||||
mcatch (mmdbException&, e) {
|
||||
trans_info.log_store -> truncate(log_bytes_before);
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include "dstr/dlist.h"
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
#ifdef C_API
|
||||
#include "utility/c_fstream.h"
|
||||
#else
|
||||
#include <fstream.h>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#include "utility/macro.h"
|
||||
|
||||
@@ -86,9 +86,13 @@ MESSAGE(cerr, "~unixf storeage ()");
|
||||
|
||||
void unixf_storage::remove()
|
||||
{
|
||||
#ifdef C_API
|
||||
int fd = rdbuf() -> fd();
|
||||
fsync(fd);
|
||||
::close(fd);
|
||||
#else
|
||||
rdbuf() -> close();
|
||||
#endif
|
||||
del_file(my_name(), my_path());
|
||||
/*
|
||||
int md = mode;
|
||||
@@ -133,7 +137,7 @@ int unixf_storage::_open(int new_mode)
|
||||
}
|
||||
|
||||
if ( v_file_exist == false ) {
|
||||
SET_BIT(new_mode, ios::out);
|
||||
SET_BIT(new_mode, ios::out | ios::app);
|
||||
v_file_exist = true;
|
||||
}
|
||||
|
||||
@@ -157,13 +161,23 @@ int unixf_storage::_open(int new_mode)
|
||||
SET_BIT(mode, new_mode);
|
||||
|
||||
fmt = ::form("%s/%s", path, name);
|
||||
fstream::open((const char *) fmt, mode, open_file_prot());
|
||||
#ifdef C_API
|
||||
fstream::open((const char *) fmt, mode);
|
||||
#else
|
||||
fstream::open((const char *) fmt, (ios_base::openmode)mode);
|
||||
#endif
|
||||
// fstream::open((const char *) fmt, mode, open_file_prot());
|
||||
|
||||
} else {
|
||||
|
||||
if ( ! fstream::rdbuf() -> is_open() ) {
|
||||
fmt = ::form("%s/%s", path, name);
|
||||
fstream::open((const char *) fmt, mode, open_file_prot());
|
||||
#ifdef C_API
|
||||
fstream::open((const char *) fmt, mode);
|
||||
#else
|
||||
fstream::open((const char *) fmt, (ios_base::openmode)mode);
|
||||
#endif
|
||||
// fstream::open((const char *) fmt, mode, open_file_prot());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -254,11 +268,11 @@ fprintf(stderr, "flush option=%d\n", flush_opt);
|
||||
flush();
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%d bytes have been written at offset %d in %s/%s @ %s:%d\n", len, loc+string_ofst, path, name, __FILE__, __LINE__);
|
||||
fprintf(stderr, "%d bytes have been written at offset %ld in %s/%s @ %s:%d\n", len, loc+string_ofst, path, name, __FILE__, __LINE__);
|
||||
#ifndef C_API
|
||||
{
|
||||
char fname[64];
|
||||
sprintf(fname, "%s.%d-%d", name, loc+string_ofst, len);
|
||||
sprintf(fname, "%s.%ld-%d", name, loc+string_ofst, len);
|
||||
ofstream output(fname);
|
||||
output.write(base, len);
|
||||
output.flush();
|
||||
@@ -296,14 +310,18 @@ int unixf_storage::bytes()
|
||||
{
|
||||
if ( total_bytes == -1 ) {
|
||||
|
||||
char* info_lib_file = form("%s/%s", path, name);
|
||||
|
||||
_open(ios::in);
|
||||
|
||||
|
||||
if ( !good() )
|
||||
clear();
|
||||
|
||||
|
||||
#ifdef C_API
|
||||
total_bytes = ::bytes(rdbuf() -> fd());
|
||||
#else
|
||||
total_bytes = ::bytes(info_lib_file);
|
||||
#endif
|
||||
}
|
||||
|
||||
return total_bytes;
|
||||
@@ -318,7 +336,12 @@ Boolean unixf_storage::io_mode(int test_mode)
|
||||
fstream::close();
|
||||
}
|
||||
|
||||
fstream::open(name, test_mode, open_file_prot());
|
||||
#ifdef C_API
|
||||
fstream::open(name, test_mode);
|
||||
#else
|
||||
fstream::open(name, (ios_base::openmode)test_mode);
|
||||
#endif
|
||||
// fstream::open(name, test_mode, open_file_prot());
|
||||
|
||||
if ( ! fstream::rdbuf() -> is_open() )
|
||||
return false;
|
||||
@@ -326,7 +349,12 @@ Boolean unixf_storage::io_mode(int test_mode)
|
||||
fstream::close();
|
||||
|
||||
if ( opened == true )
|
||||
#ifdef C_API
|
||||
fstream::open(name, mode, open_file_prot());
|
||||
#else
|
||||
fstream::open(name, (ios_base::openmode)mode);
|
||||
#endif
|
||||
// fstream::open(name, mode, open_file_prot());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user