Bind columns by name in mdb_read_catalog

This commit is contained in:
whydoubt
2004-06-23 03:46:33 +00:00
parent acdeac0368
commit e323873a62
2 changed files with 40 additions and 40 deletions

View File

@@ -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:

View File

@@ -50,12 +50,12 @@ 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);
@@ -75,25 +75,24 @@ int type;
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);
while (mdb_fetch_row(table)) {
type = atoi(tobjtype);
type = atoi(obj_type);
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;
// 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++;
data = g_memdup(&entry,sizeof(MdbCatalogEntry));
g_ptr_array_add(mdb->catalog, data);
g_ptr_array_add(mdb->catalog, entry);
}
}
//mdb_dump_catalog(mdb, MDB_TABLE);