mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-01-22 02:52:05 +08:00
Use 'Flags' field in MSysObjects to recognize system tables
This commit is contained in:
@@ -56,18 +56,17 @@ char *the_relation;
|
||||
mdb_set_default_backend(mdb,backend);
|
||||
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
if (entry->object_type != MDB_TABLE)
|
||||
continue;
|
||||
/* Do not show system tables if table name is not specified */
|
||||
if (mdb_is_system_table(entry) && !strlen(tabname))
|
||||
continue;
|
||||
/* If object name does not match the table specified */
|
||||
if (strlen(tabname) && strcmp(entry->object_name, tabname))
|
||||
continue;
|
||||
|
||||
if (entry->object_type == MDB_TABLE) {
|
||||
/* skip the MSys tables */
|
||||
if ((strlen(tabname) && !strcmp(entry->object_name,tabname)) ||
|
||||
(!strlen(tabname) && strncmp (entry->object_name, "MSys", 4))) {
|
||||
|
||||
/* make sure it's a table (may be redundant) */
|
||||
|
||||
if (!strcmp (mdb_get_objtype_string (entry->object_type), "Table")) {
|
||||
/* drop the table if it exists */
|
||||
if (drops=='Y')
|
||||
fprintf(outfile, "DROP TABLE %s;\n", entry->object_name);
|
||||
@@ -101,10 +100,7 @@ char *the_relation;
|
||||
fprintf (outfile, "\n);\n");
|
||||
fprintf (outfile, "-- CREATE ANY INDEXES ...\n");
|
||||
fprintf (outfile, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf (outfile, "\n\n");
|
||||
|
||||
if (relation=='Y') {
|
||||
@@ -183,18 +179,12 @@ gmdb_schema_new_cb(GtkWidget *w, gpointer data)
|
||||
combo = glade_xml_get_widget (schemawin_xml, "table_combo");
|
||||
|
||||
glist = g_list_append(glist, ALL_TABLES);
|
||||
/* loop over each entry in the catalog */
|
||||
/* add all user tables in catalog to list */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
if (entry->object_type == MDB_TABLE) {
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry->object_name, "MSys", 4)) {
|
||||
/* add table to list */
|
||||
glist = g_list_append(glist, entry->object_name);
|
||||
}
|
||||
} /* if MDB_TABLE */
|
||||
if (mdb_is_user_table(entry)) {
|
||||
glist = g_list_append(glist, entry->object_name);
|
||||
}
|
||||
} /* for */
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
|
||||
g_list_free(glist);
|
||||
|
||||
@@ -693,20 +693,14 @@ GtkTreeIter *iter2;
|
||||
GtkWidget *tree = glade_xml_get_widget(xml, "sql_treeview");
|
||||
GtkTreeStore *store = (GtkTreeStore *) gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
|
||||
|
||||
/* loop over each entry in the catalog */
|
||||
/* add all user tables in catalog to tab */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
if (entry->object_type == MDB_TABLE) {
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry->object_name, "MSys", 4)) {
|
||||
/* add table to tab */
|
||||
iter2 = g_malloc(sizeof(GtkTreeIter));
|
||||
gtk_tree_store_append(store, iter2, NULL);
|
||||
gtk_tree_store_set(store, iter2, 0, entry->object_name, -1);
|
||||
}
|
||||
} /* if MDB_TABLE */
|
||||
if (mdb_is_user_table(entry)) {
|
||||
iter2 = g_malloc(sizeof(GtkTreeIter));
|
||||
gtk_tree_store_append(store, iter2, NULL);
|
||||
gtk_tree_store_set(store, iter2, 0, entry->object_name, -1);
|
||||
}
|
||||
} /* for */
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -215,17 +215,11 @@ void gmdb_table_populate(MdbHandle *mdb)
|
||||
int i;
|
||||
MdbCatalogEntry *entry;
|
||||
|
||||
/* loop over each entry in the catalog */
|
||||
/* add all user tables in catalog to tab */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
if (entry->object_type == MDB_TABLE) {
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry->object_name, "MSys", 4)) {
|
||||
/* add table to tab */
|
||||
gmdb_table_add_icon(entry->object_name);
|
||||
}
|
||||
} /* if MDB_TABLE */
|
||||
if (mdb_is_user_table(entry)) {
|
||||
gmdb_table_add_icon(entry->object_name);
|
||||
}
|
||||
} /* for */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user