mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Bind columns by name in mdb_read_catalog
This commit is contained in:
parent
acdeac0368
commit
e323873a62
@ -1,6 +1,7 @@
|
||||
Tue Jun 22 22:02:02 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/util/mdb-schema.c: Fix a memory leak
|
||||
* src/libmdb/mem.c: Fix another memory leak
|
||||
* src/libmdb/catalog.c: Bind columns by name in mdb_read_catalog
|
||||
|
||||
Mon Jun 21 23:18:18 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/libmdb/backend.c:
|
||||
|
@ -50,57 +50,56 @@ static char *type_name[] = {"Form",
|
||||
/* new method */
|
||||
GPtrArray *mdb_read_catalog (MdbHandle *mdb, int objtype)
|
||||
{
|
||||
MdbCatalogEntry entry, msysobj, *data;
|
||||
MdbTableDef *table;
|
||||
char parentid[256];
|
||||
char objname[256];
|
||||
char tobjtype[256];
|
||||
int type;
|
||||
MdbCatalogEntry *entry, msysobj;
|
||||
MdbTableDef *table;
|
||||
char obj_id[256];
|
||||
char obj_name[256];
|
||||
char obj_type[256];
|
||||
int type;
|
||||
|
||||
if (mdb->catalog) mdb_free_catalog(mdb);
|
||||
mdb_alloc_catalog(mdb);
|
||||
mdb->num_catalog = 0;
|
||||
if (mdb->catalog) mdb_free_catalog(mdb);
|
||||
mdb_alloc_catalog(mdb);
|
||||
mdb->num_catalog = 0;
|
||||
|
||||
/* dummy up a catalog entry so we may read the table def */
|
||||
memset(&msysobj, 0, sizeof(MdbCatalogEntry));
|
||||
msysobj.mdb = mdb;
|
||||
msysobj.object_type = MDB_TABLE;
|
||||
msysobj.table_pg = 2;
|
||||
strcpy(msysobj.object_name, "MSysObjects");
|
||||
/* dummy up a catalog entry so we may read the table def */
|
||||
memset(&msysobj, 0, sizeof(MdbCatalogEntry));
|
||||
msysobj.mdb = mdb;
|
||||
msysobj.object_type = MDB_TABLE;
|
||||
msysobj.table_pg = 2;
|
||||
strcpy(msysobj.object_name, "MSysObjects");
|
||||
|
||||
/* mdb_table_dump(&msysobj); */
|
||||
/* mdb_table_dump(&msysobj); */
|
||||
|
||||
table = mdb_read_table(&msysobj);
|
||||
if (!table) return NULL;
|
||||
table = mdb_read_table(&msysobj);
|
||||
if (!table) return NULL;
|
||||
|
||||
mdb_read_columns(table);
|
||||
mdb_read_columns(table);
|
||||
|
||||
mdb_bind_column(table, 1, parentid);
|
||||
mdb_bind_column(table, 3, objname);
|
||||
mdb_bind_column(table, 4, tobjtype);
|
||||
mdb_bind_column_by_name(table, "Id", obj_id);
|
||||
mdb_bind_column_by_name(table, "Name", obj_name);
|
||||
mdb_bind_column_by_name(table, "Type", obj_type);
|
||||
|
||||
mdb_rewind_table(table);
|
||||
mdb_rewind_table(table);
|
||||
|
||||
while (mdb_fetch_row(table)) {
|
||||
type = atoi(tobjtype);
|
||||
if (objtype==MDB_ANY || type == objtype) {
|
||||
// fprintf(stdout, "parentid: %10ld objtype: %-3d objname: %s\n",
|
||||
// (atol(parentid) & 0x00FFFFFF), type, objname);
|
||||
memset(&entry,0,sizeof(entry));
|
||||
entry.mdb = mdb;
|
||||
strcpy(entry.object_name, objname);
|
||||
entry.object_type = (type & 0x7F);
|
||||
entry.table_pg = atol(parentid) & 0x00FFFFFF;
|
||||
mdb->num_catalog++;
|
||||
data = g_memdup(&entry,sizeof(MdbCatalogEntry));
|
||||
g_ptr_array_add(mdb->catalog, data);
|
||||
while (mdb_fetch_row(table)) {
|
||||
type = atoi(obj_type);
|
||||
if (objtype==MDB_ANY || type == objtype) {
|
||||
// fprintf(stdout, "obj_id: %10ld objtype: %-3d obj_name: %s\n",
|
||||
// (atol(obj_id) & 0x00FFFFFF), type, obj_name);
|
||||
entry = (MdbCatalogEntry *) g_malloc0(sizeof(MdbCatalogEntry));
|
||||
entry->mdb = mdb;
|
||||
strcpy(entry->object_name, obj_name);
|
||||
entry->object_type = (type & 0x7F);
|
||||
entry->table_pg = atol(obj_id) & 0x00FFFFFF;
|
||||
mdb->num_catalog++;
|
||||
g_ptr_array_add(mdb->catalog, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
//mdb_dump_catalog(mdb, MDB_TABLE);
|
||||
//mdb_dump_catalog(mdb, MDB_TABLE);
|
||||
|
||||
mdb_free_tabledef(table);
|
||||
mdb_free_tabledef(table);
|
||||
|
||||
return mdb->catalog;
|
||||
return mdb->catalog;
|
||||
}
|
||||
|
||||
/* old method */
|
||||
|
Loading…
Reference in New Issue
Block a user