mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-09-19 10:37:54 +08:00
Temp table improvements
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
Sun Sep 12 14:03:10 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* include/mdbtools.h:
|
||||
* src/libmdb/write.c:
|
||||
* src/libmdb/worktable.c: Temp table improvements
|
||||
|
||||
Wed Sep 8 22:24:29 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* HACKING: Small format documentation correction
|
||||
* include/mdbtools.h:
|
||||
|
@@ -517,6 +517,7 @@ extern MdbTableDef *mdb_create_temp_table(MdbHandle *mdb, char *name);
|
||||
extern void mdb_temp_table_add_col(MdbTableDef *table, MdbColumn *col);
|
||||
extern void mdb_fill_temp_col(MdbColumn *tcol, char *col_name, int col_size, int col_type, int is_fixed);
|
||||
extern void mdb_fill_temp_field(MdbField *field, void *value, int siz, int is_fixed, int is_null, int start, int column);
|
||||
extern void mdb_temp_columns_end(MdbTableDef *table);
|
||||
|
||||
/* options.c */
|
||||
extern int mdb_get_option(unsigned long optnum);
|
||||
|
@@ -33,8 +33,12 @@ mdb_fill_temp_col(MdbColumn *tcol, char *col_name, int col_size, int col_type, i
|
||||
{
|
||||
memset(tcol,0,sizeof(MdbColumn));
|
||||
strcpy(tcol->name, col_name);
|
||||
tcol->col_size = col_size;
|
||||
tcol->col_type = col_type;
|
||||
if ((col_type == MDB_TEXT) || (col_type == MDB_MEMO)) {
|
||||
tcol->col_size = col_size;
|
||||
} else {
|
||||
tcol->col_size = mdb_col_fixed_size(tcol);
|
||||
}
|
||||
tcol->is_fixed = is_fixed;
|
||||
}
|
||||
void
|
||||
@@ -76,3 +80,20 @@ mdb_temp_table_add_col(MdbTableDef *table, MdbColumn *col)
|
||||
g_ptr_array_add(table->columns, g_memdup(col, sizeof(MdbColumn)));
|
||||
table->num_cols++;
|
||||
}
|
||||
/*
|
||||
* Should be called after setting up all temp table columns
|
||||
*/
|
||||
void mdb_temp_columns_end(MdbTableDef *table)
|
||||
{
|
||||
MdbColumn *col;
|
||||
unsigned int i;
|
||||
unsigned int start = 0;
|
||||
|
||||
for (i=0; i<table->num_cols; i++) {
|
||||
col = g_ptr_array_index(table->columns, i);
|
||||
if (col->is_fixed) {
|
||||
col->fixed_offset = start;
|
||||
start += col->col_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -329,7 +329,9 @@ mdb_pack_row4(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fi
|
||||
for (i=0;i<num_fields;i++) {
|
||||
if (fields[i].is_fixed) {
|
||||
fields[i].offset = pos;
|
||||
if (!fields[i].is_null) {
|
||||
memcpy(&row_buffer[pos], fields[i].value, fields[i].siz);
|
||||
}
|
||||
pos += fields[i].siz;
|
||||
}
|
||||
}
|
||||
@@ -383,7 +385,9 @@ mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fi
|
||||
for (i=0;i<num_fields;i++) {
|
||||
if (fields[i].is_fixed) {
|
||||
fields[i].offset = pos;
|
||||
if (!fields[i].is_null) {
|
||||
memcpy(&row_buffer[pos], fields[i].value, fields[i].siz);
|
||||
}
|
||||
pos += fields[i].siz;
|
||||
}
|
||||
}
|
||||
@@ -440,6 +444,19 @@ mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fi
|
||||
int
|
||||
mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, int unsigned num_fields, MdbField *fields)
|
||||
{
|
||||
if (table->is_temp_table) {
|
||||
unsigned int i;
|
||||
for (i=0; i<num_fields; i++) {
|
||||
MdbColumn *c = g_ptr_array_index(table->columns, i);
|
||||
fields[i].is_null = (fields[i].value) ? 0 : 1;
|
||||
fields[i].colnum = i;
|
||||
fields[i].is_fixed = c->is_fixed;
|
||||
if ((c->col_type != MDB_TEXT)
|
||||
&& (c->col_type != MDB_MEMO)) {
|
||||
fields[i].siz = c->col_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (IS_JET4(table->entry->mdb)) {
|
||||
return mdb_pack_row4(table, row_buffer, num_fields, fields);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user