Add function mdb_read_table_by_name

This commit is contained in:
whydoubt
2004-07-02 12:29:09 +00:00
parent 30e79efcce
commit 3d47cc5570
14 changed files with 159 additions and 245 deletions

View File

@@ -258,22 +258,7 @@ char *mdb_get_relationships(MdbHandle *mdb)
}
if (is_init == 0) {
MdbCatalogEntry *entry;
mdb_read_catalog (mdb, MDB_TABLE);
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
if ((entry->object_type == MDB_TABLE) &&
(strncmp (entry->object_name, "MSysRelationships", 17) == 0))
break;
}
if (i == mdb->num_catalog) {
return NULL;
}
table = mdb_read_table (entry);
table = mdb_read_table_by_name(mdb, "MSysRelationships", MDB_TABLE);
if ((!table) || (table->num_rows == 0)) {
return NULL;
}

View File

@@ -117,6 +117,21 @@ MdbTableDef *mdb_read_table(MdbCatalogEntry *entry)
return table;
}
MdbTableDef *mdb_read_table_by_name(MdbHandle *mdb, gchar *table_name, int obj_type)
{
unsigned int i;
MdbCatalogEntry *entry;
mdb_read_catalog(mdb, obj_type);
for (i=0; i<mdb->num_catalog; i++) {
entry = g_ptr_array_index(mdb->catalog, i);
if (!strcasecmp(entry->object_name, table_name))
return mdb_read_table(entry);
}
return NULL;
}
/*
** read the next page if offset is > pg_size