Subject | RE: [ib-support] RC1 Error - Responses |
---|---|
Author | Ann W. Harrison |
Post date | 2001-12-06T00:05:57Z |
At 03:42 PM 12/5/2001 -0800, Bill Morrison wrote:
of each file before opening the next.
You might take a look at the code in gstat. I've included
the central part here... You are using the command line
gstat and not the one that's built into the server/IBConsole,
right?
Ann
/* From main */
/* Open database and go to work */
current = db_open (name, strlen (name));
tddba->page_size = sizeof (temp);
tddba->global_buffer = (PAG) temp;
tddba->page_number = -1;
header = (HDR) db_read ((SLONG) 0);
if (header->hdr_ods_version > ODS_VERSION ||
(header->hdr_ods_version < ODS_VERSION8 &&
header->hdr_ods_version != ODS_VERSION6))
{
dba_error (3, (TEXT *)ODS_VERSION, (TEXT *)header->hdr_ods_version,
0, 0, 0); /* msg 3: Wrong ODS version, expected %d,
encountered %d? */
}
strcpy(file_name, name);
dba_print (6, file_name, 0, 0, 0, 0); /* msg 6: \nDatabase \"%s\"\n */
tddba->page_size = header->hdr_page_size;
tddba->buffer1 = (PAG) ALLOC (tddba->page_size);
tddba->buffer2 = (PAG) ALLOC (tddba->page_size);
tddba->global_buffer = (PAG) ALLOC (tddba->page_size);
tddba->page_number = -1;
/* gather continuation files */
page = HEADER_PAGE;
do
{
if (page != HEADER_PAGE)
current = db_open (file_name, strlen (file_name));
do
{
header = (HDR) db_read ((SLONG) page);
if (current != tddba->files)
current->fil_fudge = 1; /* ignore header page once read it */
*file_name = '\0';
for (vp = header->hdr_data, vend = vp + header->hdr_page_size;
vp < vend && *vp != HDR_end; vp += 2 + vp [1])
{
if (*vp == HDR_file)
{
memcpy (file_name, vp + 2, vp [1]);
*(file_name+vp[1]) = '\0';
}
if (*vp == HDR_last_page)
memcpy (¤t->fil_max_page, vp + 2, sizeof
(current->fil_max_page));
}
}
while (page = header->hdr_next_page);
page = current->fil_max_page + 1; /* first page of next file */
}
while (*file_name);
/* Print header page */
page = HEADER_PAGE;
do
{
header = (HDR) db_read ((SLONG) page);
PPG_print_header (header, page, sw_outfile);
}
while (page = header->hdr_next_page);
if (sw_header)
EXIT (FINI_OK);
/* d b _ o p e n */
static DBA_FIL db_open (
UCHAR *file_name,
USHORT file_length)
{
/**************************************
*
* d b _ o p e n ( W I N _ N T )
*
**************************************
*
* Functional description
* Open a database file.
*
**************************************/
DBA_FIL fil;
TDBA tddba;
tddba = GET_THREAD_DATA;
if (tddba->files)
{
for (fil = tddba->files; fil->fil_next; fil = fil->fil_next)
;
fil->fil_next = (DBA_FIL) ALLOC (sizeof (struct dba_fil) + strlen
(file_name) + 1);
fil->fil_next->fil_min_page = fil->fil_max_page+1;
fil = fil->fil_next;
}
else /* empty list */
{
fil = tddba->files = (DBA_FIL) ALLOC (sizeof (struct dba_fil) + strlen
(file_name) + 1);
fil->fil_min_page = 0L;
}
fil->fil_next = NULL;
strcpy (fil->fil_string, file_name);
fil->fil_length = strlen (file_name);
fil->fil_fudge = 0;
fil->fil_max_page = 0L;
if ((fil->fil_desc = CreateFile (file_name,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
0)) == INVALID_HANDLE_VALUE)
{
db_error (GetLastError());
}
return fil;
}
>Unfortunately it worked fine. Question : does it use a different way ofHmmm.... One difference is that it does read the first page
>opening the db if the db is split into different files?
of each file before opening the next.
You might take a look at the code in gstat. I've included
the central part here... You are using the command line
gstat and not the one that's built into the server/IBConsole,
right?
Ann
/* From main */
/* Open database and go to work */
current = db_open (name, strlen (name));
tddba->page_size = sizeof (temp);
tddba->global_buffer = (PAG) temp;
tddba->page_number = -1;
header = (HDR) db_read ((SLONG) 0);
if (header->hdr_ods_version > ODS_VERSION ||
(header->hdr_ods_version < ODS_VERSION8 &&
header->hdr_ods_version != ODS_VERSION6))
{
dba_error (3, (TEXT *)ODS_VERSION, (TEXT *)header->hdr_ods_version,
0, 0, 0); /* msg 3: Wrong ODS version, expected %d,
encountered %d? */
}
strcpy(file_name, name);
dba_print (6, file_name, 0, 0, 0, 0); /* msg 6: \nDatabase \"%s\"\n */
tddba->page_size = header->hdr_page_size;
tddba->buffer1 = (PAG) ALLOC (tddba->page_size);
tddba->buffer2 = (PAG) ALLOC (tddba->page_size);
tddba->global_buffer = (PAG) ALLOC (tddba->page_size);
tddba->page_number = -1;
/* gather continuation files */
page = HEADER_PAGE;
do
{
if (page != HEADER_PAGE)
current = db_open (file_name, strlen (file_name));
do
{
header = (HDR) db_read ((SLONG) page);
if (current != tddba->files)
current->fil_fudge = 1; /* ignore header page once read it */
*file_name = '\0';
for (vp = header->hdr_data, vend = vp + header->hdr_page_size;
vp < vend && *vp != HDR_end; vp += 2 + vp [1])
{
if (*vp == HDR_file)
{
memcpy (file_name, vp + 2, vp [1]);
*(file_name+vp[1]) = '\0';
}
if (*vp == HDR_last_page)
memcpy (¤t->fil_max_page, vp + 2, sizeof
(current->fil_max_page));
}
}
while (page = header->hdr_next_page);
page = current->fil_max_page + 1; /* first page of next file */
}
while (*file_name);
/* Print header page */
page = HEADER_PAGE;
do
{
header = (HDR) db_read ((SLONG) page);
PPG_print_header (header, page, sw_outfile);
}
while (page = header->hdr_next_page);
if (sw_header)
EXIT (FINI_OK);
/* d b _ o p e n */
static DBA_FIL db_open (
UCHAR *file_name,
USHORT file_length)
{
/**************************************
*
* d b _ o p e n ( W I N _ N T )
*
**************************************
*
* Functional description
* Open a database file.
*
**************************************/
DBA_FIL fil;
TDBA tddba;
tddba = GET_THREAD_DATA;
if (tddba->files)
{
for (fil = tddba->files; fil->fil_next; fil = fil->fil_next)
;
fil->fil_next = (DBA_FIL) ALLOC (sizeof (struct dba_fil) + strlen
(file_name) + 1);
fil->fil_next->fil_min_page = fil->fil_max_page+1;
fil = fil->fil_next;
}
else /* empty list */
{
fil = tddba->files = (DBA_FIL) ALLOC (sizeof (struct dba_fil) + strlen
(file_name) + 1);
fil->fil_min_page = 0L;
}
fil->fil_next = NULL;
strcpy (fil->fil_string, file_name);
fil->fil_length = strlen (file_name);
fil->fil_fudge = 0;
fil->fil_max_page = 0L;
if ((fil->fil_desc = CreateFile (file_name,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
0)) == INVALID_HANDLE_VALUE)
{
db_error (GetLastError());
}
return fil;
}