This list is closed, nobody may subscribe to it.
2000 |
Jan
|
Feb
(1) |
Mar
(53) |
Apr
(28) |
May
(5) |
Jun
(7) |
Jul
(16) |
Aug
(15) |
Sep
(10) |
Oct
(1) |
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(9) |
Feb
(7) |
Mar
(1) |
Apr
(7) |
May
(6) |
Jun
|
Jul
(15) |
Aug
(10) |
Sep
(2) |
Oct
(12) |
Nov
(3) |
Dec
(2) |
2002 |
Jan
(2) |
Feb
(12) |
Mar
(33) |
Apr
(30) |
May
(5) |
Jun
(18) |
Jul
(18) |
Aug
(47) |
Sep
(8) |
Oct
(7) |
Nov
(8) |
Dec
(13) |
2003 |
Jan
(48) |
Feb
(8) |
Mar
(10) |
Apr
(30) |
May
(6) |
Jun
(8) |
Jul
(19) |
Aug
(36) |
Sep
(19) |
Oct
(16) |
Nov
(11) |
Dec
(17) |
2004 |
Jan
(11) |
Feb
(22) |
Mar
(52) |
Apr
(45) |
May
(18) |
Jun
(72) |
Jul
(14) |
Aug
(31) |
Sep
(19) |
Oct
(27) |
Nov
(19) |
Dec
(25) |
2005 |
Jan
(16) |
Feb
(46) |
Mar
(50) |
Apr
(3) |
May
(21) |
Jun
(3) |
Jul
(24) |
Aug
(33) |
Sep
(25) |
Oct
(23) |
Nov
(30) |
Dec
(20) |
2006 |
Jan
(12) |
Feb
(11) |
Mar
(8) |
Apr
(15) |
May
(27) |
Jun
(15) |
Jul
(19) |
Aug
(5) |
Sep
(9) |
Oct
(1) |
Nov
(2) |
Dec
(3) |
2007 |
Jan
|
Feb
(3) |
Mar
(18) |
Apr
(5) |
May
(9) |
Jun
|
Jul
(10) |
Aug
(3) |
Sep
(8) |
Oct
(1) |
Nov
(7) |
Dec
(9) |
2008 |
Jan
(2) |
Feb
|
Mar
(10) |
Apr
(4) |
May
|
Jun
(5) |
Jul
(9) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(8) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(1) |
Dec
(20) |
2010 |
Jan
|
Feb
(2) |
Mar
|
Apr
(7) |
May
|
Jun
(23) |
Jul
(3) |
Aug
(6) |
Sep
(1) |
Oct
(4) |
Nov
(1) |
Dec
|
2011 |
Jan
(1) |
Feb
(26) |
Mar
(25) |
Apr
(11) |
May
(5) |
Jun
(5) |
Jul
(2) |
Aug
(39) |
Sep
(12) |
Oct
(6) |
Nov
|
Dec
|
2012 |
Jan
(19) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
|
Aug
(8) |
Sep
|
Oct
(3) |
Nov
(2) |
Dec
(3) |
2013 |
Jan
(6) |
Feb
|
Mar
(1) |
Apr
|
May
(7) |
Jun
(5) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(4) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2016 |
Jan
(5) |
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Brian B. <ca...@um...> - 2000-04-22 21:43:22
|
Strike that, I found it...just checked it in if you want to take a look at it. Brian On Sat, 22 Apr 2000, Brian Bruns wrote: > Carl, > > Sorry to have taken so long with this, been very busy. > > This patch doesn't apply cleanly, can you double check it? the part with > "void do_first () {" looks like something is missing there. > > Brian > > On Mon, 10 Apr 2000, Carl Seutter wrote: > > > Ok, here's the initial cut at generating foreign keys. To accomplish > > this, I basically set about reading the MSysRelationships table using > > existing routines. I made the following changes. There were 4 files > > that I made changes to include/mdbtools.h, libmdb/mem.c, > > libmdb/backend.c, and util/schema.c. > > > > In include/mdbtools.h: > > -- I added this to the MdbHandle structure > > char *backend_name; > > -- I added this to the backend.c declarations > > extern char *mdb_get_relationships(MdbHandle *mdb); > > > > In libmdb/mem.c: > > -- I added to the mdb_free_handle function > > if (mdb->backend_name) free(mdb->backend_name); > > > > In util/schema.c > > -- I added the variable declaration of > > char *the_relation; > > -- I placed this code just before the call to mdb_free_handle > > fprintf (stdout, "\n\n"); > > fprintf (stdout, "-- CREATE ANY Relationships ...\n"); > > fprintf (stdout, "\n"); > > the_relation=mdb_get_relationships(mdb); > > while (the_relation[0] != '\0') { > > fprintf(stdout,"%s\n",the_relation); > > the_relation=mdb_get_relationships(mdb); > > } > > > > In libmdb/schema.c: > > -- I added these variables to the beginning: > > char *bound_values[256]; > > char *relationships[4]; > > MdbColumn *col; > > MdbCatalogEntry entry; > > MdbTableDef *table; > > int did_first; > > > > -- I added this code to mdb_set_default_backend before the return 1 > > mdb->backend_name = (char *) > > malloc(strlen(backend_name)+1); > > strcpy(mdb->backend_name,backend_name); > > did_first = 0; > > > > -- I added this function: > > char *mdb_get_relationships(MdbHandle *mdb) { > > > > int i, j, k; > > static char text[255]; > > void do_first () { > > mdb_read_catalog (mdb, MDB_TABLE); > > > > /* loop over each entry in the catalog */ > > for (i=0; i < mdb->num_catalog; i++) { > > entry = g_array_index (mdb->catalog, MdbCatalogEntry, i); > > if ((entry.object_type == MDB_TABLE) && > > (strncmp (entry.object_name, "MSysRelationships", 17) == 0)) > > { > > table = mdb_read_table (&entry); > > if ( table->num_rows > 0 ) { > > mdb_read_columns(table); > > mdb_rewind_table(table); > > for (k=0;k<table->num_cols;k++) { > > bound_values[k] = (char *) malloc(256); > > bound_values[k][0] = '\0'; > > mdb_bind_column(table,k+1,bound_values[k]); > > } > > relationships[0] = (char *) malloc(256); /* child column */ > > > > relationships[1] = (char *) malloc(256); /* child table */ > > relationships[2] = (char *) malloc(256); /* parent column > > */ > > relationships[3] = (char *) malloc(256); /* parent table */ > > > > } > > did_first = 1; > > return; > > } > > } > > } > > /* > > * generate relationships by "reading" the MSysRelationships table > > * szColumn contains the column name of the child table > > * szObject contains the table name of the child table > > * szReferencedColumn contains the column name of the parent table > > * szReferencedObject contains the table name of the parent table > > */ > > sprintf(text,"%c",0); > > if ( did_first == 0) > > do_first(); > > if (table->cur_row < table->num_rows) { > > if (mdb_fetch_row(table)) { > > relationships[0][0] = '\0'; > > relationships[1][0] = '\0'; > > relationships[2][0] = '\0'; > > relationships[3][0] = '\0'; > > for (k=0;k<table->num_cols;k++) { > > col=g_ptr_array_index(table->columns,k); > > if (strncmp(col->name,"szColumn",8) == 0) > > strcpy(relationships[0],bound_values[k]); > > else if (strncmp(col->name,"szObject",8) == 0) > > strcpy(relationships[1],bound_values[k]); > > else if (strncmp(col->name,"szReferencedColumn",18) == 0) > > strcpy(relationships[2],bound_values[k]); > > else if (strncmp(col->name,"szReferencedObject",18) == 0) > > strcpy(relationships[3],bound_values[k]); > > } > > if (strncmp(mdb->backend_name,"oracle",6) == 0) > > sprintf(text,"alter table %s add constraint %s_%s foreign key > > (%s) references %s(%s)", > > > > relationships[1],relationships[3],relationships[1], > > > > relationships[0],relationships[3],relationships[2]); > > else > > sprintf(text,"relationships are not supported for > > %s",mdb->backend_name); > > } /* got a row */ > > } > > else { > > for (k=0;k<table->num_cols;k++) { > > free(bound_values[k]); > > } > > free(relationships[0]); > > free(relationships[1]); > > free(relationships[2]); > > free(relationships[3]); > > did_first = 0; > > } > > return text; > > } > > > > > > > > _______________________________________________ > > mdbtools-dev mailing list > > mdb...@li... > > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > > > > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > |
From: Brian B. <ca...@um...> - 2000-04-22 21:29:59
|
Carl, Sorry to have taken so long with this, been very busy. This patch doesn't apply cleanly, can you double check it? the part with "void do_first () {" looks like something is missing there. Brian On Mon, 10 Apr 2000, Carl Seutter wrote: > Ok, here's the initial cut at generating foreign keys. To accomplish > this, I basically set about reading the MSysRelationships table using > existing routines. I made the following changes. There were 4 files > that I made changes to include/mdbtools.h, libmdb/mem.c, > libmdb/backend.c, and util/schema.c. > > In include/mdbtools.h: > -- I added this to the MdbHandle structure > char *backend_name; > -- I added this to the backend.c declarations > extern char *mdb_get_relationships(MdbHandle *mdb); > > In libmdb/mem.c: > -- I added to the mdb_free_handle function > if (mdb->backend_name) free(mdb->backend_name); > > In util/schema.c > -- I added the variable declaration of > char *the_relation; > -- I placed this code just before the call to mdb_free_handle > fprintf (stdout, "\n\n"); > fprintf (stdout, "-- CREATE ANY Relationships ...\n"); > fprintf (stdout, "\n"); > the_relation=mdb_get_relationships(mdb); > while (the_relation[0] != '\0') { > fprintf(stdout,"%s\n",the_relation); > the_relation=mdb_get_relationships(mdb); > } > > In libmdb/schema.c: > -- I added these variables to the beginning: > char *bound_values[256]; > char *relationships[4]; > MdbColumn *col; > MdbCatalogEntry entry; > MdbTableDef *table; > int did_first; > > -- I added this code to mdb_set_default_backend before the return 1 > mdb->backend_name = (char *) > malloc(strlen(backend_name)+1); > strcpy(mdb->backend_name,backend_name); > did_first = 0; > > -- I added this function: > char *mdb_get_relationships(MdbHandle *mdb) { > > int i, j, k; > static char text[255]; > void do_first () { > mdb_read_catalog (mdb, MDB_TABLE); > > /* loop over each entry in the catalog */ > for (i=0; i < mdb->num_catalog; i++) { > entry = g_array_index (mdb->catalog, MdbCatalogEntry, i); > if ((entry.object_type == MDB_TABLE) && > (strncmp (entry.object_name, "MSysRelationships", 17) == 0)) > { > table = mdb_read_table (&entry); > if ( table->num_rows > 0 ) { > mdb_read_columns(table); > mdb_rewind_table(table); > for (k=0;k<table->num_cols;k++) { > bound_values[k] = (char *) malloc(256); > bound_values[k][0] = '\0'; > mdb_bind_column(table,k+1,bound_values[k]); > } > relationships[0] = (char *) malloc(256); /* child column */ > > relationships[1] = (char *) malloc(256); /* child table */ > relationships[2] = (char *) malloc(256); /* parent column > */ > relationships[3] = (char *) malloc(256); /* parent table */ > > } > did_first = 1; > return; > } > } > } > /* > * generate relationships by "reading" the MSysRelationships table > * szColumn contains the column name of the child table > * szObject contains the table name of the child table > * szReferencedColumn contains the column name of the parent table > * szReferencedObject contains the table name of the parent table > */ > sprintf(text,"%c",0); > if ( did_first == 0) > do_first(); > if (table->cur_row < table->num_rows) { > if (mdb_fetch_row(table)) { > relationships[0][0] = '\0'; > relationships[1][0] = '\0'; > relationships[2][0] = '\0'; > relationships[3][0] = '\0'; > for (k=0;k<table->num_cols;k++) { > col=g_ptr_array_index(table->columns,k); > if (strncmp(col->name,"szColumn",8) == 0) > strcpy(relationships[0],bound_values[k]); > else if (strncmp(col->name,"szObject",8) == 0) > strcpy(relationships[1],bound_values[k]); > else if (strncmp(col->name,"szReferencedColumn",18) == 0) > strcpy(relationships[2],bound_values[k]); > else if (strncmp(col->name,"szReferencedObject",18) == 0) > strcpy(relationships[3],bound_values[k]); > } > if (strncmp(mdb->backend_name,"oracle",6) == 0) > sprintf(text,"alter table %s add constraint %s_%s foreign key > (%s) references %s(%s)", > > relationships[1],relationships[3],relationships[1], > > relationships[0],relationships[3],relationships[2]); > else > sprintf(text,"relationships are not supported for > %s",mdb->backend_name); > } /* got a row */ > } > else { > for (k=0;k<table->num_cols;k++) { > free(bound_values[k]); > } > free(relationships[0]); > free(relationships[1]); > free(relationships[2]); > free(relationships[3]); > did_first = 0; > } > return text; > } > > > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > |
From: Michael W. <wo...@ki...> - 2000-04-17 15:43:47
|
Hi Here's a small cleanup for command line arguments of the tools. Index: src/extras/dump.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/extras/dump.c,v retrieving revision 1.2 diff -u -r1.2 dump.c --- src/extras/dump.c 2000/03/03 01:50:08 1.2 +++ src/extras/dump.c 2000/04/17 15:10:38 @@ -21,7 +21,14 @@ int pg=0; char addr[10]; - in = fopen(argv[1],"r"); + if (argc != 2) { + fprintf(stderr, "Usage: %s <file>\n", argv[0]); + exit(1); + } + if ((in = fopen(argv[1],"r")) == NULL) { + perror(argv[1]); + exit(1); + } while (length = fread(data,1,16,in)) { sprintf(addr, "%06x", i); if (!strcmp(&addr[3],"000") || ! strcmp(&addr[3],"800")) { Index: src/util/header.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/header.c,v retrieving revision 1.2 diff -u -r1.2 header.c --- src/util/header.c 2000/04/02 17:08:30 1.2 +++ src/util/header.c 2000/04/17 15:10:38 @@ -40,7 +40,7 @@ FILE *headerfile; FILE *cfile; - if (argc < 2) { + if (argc != 2) { fprintf (stderr, "Usage: %s <file>\n",argv[0]); exit (1); } @@ -49,9 +49,10 @@ /* open the database */ - mdb = mdb_open (argv[1]); - if (!mdb) { - mdb_exit(); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); exit(1); } Index: src/util/mdb-array.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/mdb-array.c,v retrieving revision 1.2 diff -u -r1.2 mdb-array.c --- src/util/mdb-array.c 2000/04/10 01:20:43 1.2 +++ src/util/mdb-array.c 2000/04/17 15:10:38 @@ -39,14 +39,19 @@ int count; int started; - if (argc < 2) + if (argc != 3) { fprintf (stderr, "Usage: %s <file> <table>\n", argv [0]); exit (1); } mdb_init(); - mdb = mdb_open (argv [1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_catalog (mdb, MDB_TABLE); Index: src/util/mdb-export.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/mdb-export.c,v retrieving revision 1.5 diff -u -r1.5 mdb-export.c --- src/util/mdb-export.c 2000/04/10 01:20:43 1.5 +++ src/util/mdb-export.c 2000/04/17 15:10:38 @@ -35,14 +35,19 @@ char header_row = 1; char quote_text = 1; - if (argc<2) { + if (argc != 3) { fprintf(stderr,"Usage: %s <file> <table>\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_catalog(mdb, MDB_TABLE); Index: src/util/parsecsv.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/parsecsv.c,v retrieving revision 1.2 diff -u -r1.2 parsecsv.c --- src/util/parsecsv.c 2000/03/19 02:50:05 1.2 +++ src/util/parsecsv.c 2000/04/17 15:10:38 @@ -50,7 +50,7 @@ int lastcomma; int i; - if (argc < 2) + if (argc != 2) { fprintf (stderr, "Usage: %s <file> (assumed extension .txt)\n",argv[0]); exit (1); Index: src/util/prcat.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/prcat.c,v retrieving revision 1.6 diff -u -r1.6 prcat.c --- src/util/prcat.c 2000/04/02 17:08:30 1.6 +++ src/util/prcat.c 2000/04/17 15:10:38 @@ -30,14 +30,19 @@ MdbHandle *mdb; - if (argc<2) { + if (argc < 2 || argc > 3) { fprintf(stderr,"Usage: %s <file> [<objtype>]\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_dump_catalog(mdb,(argc > 2) ? atoi(argv[2]) : MDB_TABLE); Index: src/util/prdata.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/prdata.c,v retrieving revision 1.4 diff -u -r1.4 prdata.c --- src/util/prdata.c 2000/04/10 01:20:43 1.4 +++ src/util/prdata.c 2000/04/17 15:10:38 @@ -31,13 +31,18 @@ GList *l; - if (argc<2) { + if (argc != 3) { fprintf(stderr,"Usage: %s <file> <table>\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_catalog(mdb, MDB_TABLE); Index: src/util/prdump.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/prdump.c,v retrieving revision 1.3 diff -u -r1.3 prdump.c --- src/util/prdump.c 2000/04/02 17:08:30 1.3 +++ src/util/prdump.c 2000/04/17 15:10:38 @@ -32,13 +32,18 @@ int j; int page, start, stop; - if (argc<4) { + if (argc != 5) { fprintf(stderr,"Usage: %s <file> <page> <start> <stop>\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_catalog(mdb, MDB_TABLE); Index: src/util/prkkd.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/prkkd.c,v retrieving revision 1.3 diff -u -r1.3 prkkd.c --- src/util/prkkd.c 2000/04/02 17:08:30 1.3 +++ src/util/prkkd.c 2000/04/17 15:10:38 @@ -27,13 +27,18 @@ MdbCatalogEntry entry; - if (argc<2) { + if (argc != 3) { fprintf(stderr,"Usage: %s <file> <table>\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_pg(mdb, MDB_CATALOG_PG); rows = mdb_catalog_rows(mdb); Index: src/util/prtable.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/prtable.c,v retrieving revision 1.6 diff -u -r1.6 prtable.c --- src/util/prtable.c 2000/04/07 00:48:48 1.6 +++ src/util/prtable.c 2000/04/17 15:10:38 @@ -30,13 +30,18 @@ GList *l; - if (argc<3) { + if (argc != 3) { fprintf(stderr,"Usage: %s <file> <table>\n",argv[0]); exit(1); } mdb_init(); - mdb = mdb_open(argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } mdb_read_catalog(mdb, MDB_TABLE); Index: src/util/schema.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/schema.c,v retrieving revision 1.4 diff -u -r1.4 schema.c --- src/util/schema.c 2000/04/02 17:08:30 1.4 +++ src/util/schema.c 2000/04/17 15:10:38 @@ -28,7 +28,7 @@ MdbTableDef *table; MdbColumn *col; - if (argc < 2) { + if (argc < 2 || argc > 3) { fprintf (stderr, "Usage: %s <file> [<backend>]\n",argv[0]); exit (1); } @@ -37,7 +37,12 @@ /* open the database */ - mdb = mdb_open (argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } if (argc>2) { if (!mdb_set_default_backend(mdb, argv[2])) { fprintf(stderr,"Invalid backend type\n"); Index: src/util/tables.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/util/tables.c,v retrieving revision 1.2 diff -u -r1.2 tables.c --- src/util/tables.c 2000/04/02 17:08:30 1.2 +++ src/util/tables.c 2000/04/17 15:10:38 @@ -28,7 +28,7 @@ MdbTableDef *table; MdbColumn *col; - if (argc < 2) { + if (argc != 2) { fprintf (stderr, "Usage: %s <file>\n",argv[0]); exit (1); } @@ -38,7 +38,12 @@ /* open the database */ - mdb = mdb_open (argv[1]); + if ((mdb = mdb_open(argv[1])) == NULL) { + fprintf(stderr, "Could not open database %s\n", + argv[1]); + mdb_exit(); + exit(1); + } /* read the catalog */ -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ wo...@ki... | Fax: +27 21 761 9930 | Kingsley Technologies |
From: leandro <le...@ib...> - 2000-04-15 16:55:11
|
hi all... sorry if it=B4s an off topic question.. I am trying to stole some data aou of a dbm file.... access keeps asking = me my username and passwd... Does anybody knows a way to do it (don=B4t put username,passwd) thanx, leandro |
From: Juan G. <jgr...@bi...> - 2000-04-13 15:40:09
|
At 03:25 PM 4/12/00 -0300, you wrote: > > I'm trying to erase a MS-Access 2.0 passwd... I am also unsure of 2.0, but as of 95/97, you must write the XOR key to erase, not just blanks. The offset is ok for newer mdbs. >Does somebody knows if I'm at the right file pos ?? >or the passwd lenght ????? >thanx cheers, juan |
From: Carl S. <cgs...@wo...> - 2000-04-12 23:33:48
|
I don't know about 2.0. With 95/97, yes. What I did to find out in 97, was I created a database and saved it. Then, I made a copy of it and added a password to the copy. Then I ran mdb-dump on both files, redirected the output, and then did a diff on the two output files. You could try doing the same thing with 2.0. leandro wrote: > > I'm trying to erase a MS-Access 2.0 passwd... > > I'm am using the following app to accomplish this : > #include <stdio.h> > #include <stdlib.h> > #include </usr/include/g++-2/iostream.h> > > const int LEN=13; > > int main(int argc, char* argv[]) > { > unsigned char buffer[LEN+1]; > FILE *file; > char buff[LEN+1]; > > cout << "// erases a mssccess passwd //" << endl; > > if (argc != 2) { > cout << "Uso: access base.mdb" << endl; > exit(0); > } > > file = fopen (argv[1], "r+b"); > if (file == NULL) { > cerr << "Erro ao abrir arquivo " << argv[1] << endl; > exit(-1); > } > > fseek (file, 0x42, SEEK_SET); > fgets(buff,13,stdin); > fputs(buff,file); > fclose(file); > } > Does somebody knows if I'm at the right file pos ?? > or the passwd lenght ????? > thanx > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev |
From: leandro <le...@ib...> - 2000-04-12 18:35:14
|
> I'm trying to erase a MS-Access 2.0 passwd... I'm am using the following app to accomplish this : #include <stdio.h> #include <stdlib.h> #include </usr/include/g++-2/iostream.h> const int LEN=13; int main(int argc, char* argv[]) { unsigned char buffer[LEN+1]; FILE *file; char buff[LEN+1]; cout << "// erases a mssccess passwd //" << endl; if (argc != 2) { cout << "Uso: access base.mdb" << endl; exit(0); } file = fopen (argv[1], "r+b"); if (file == NULL) { cerr << "Erro ao abrir arquivo " << argv[1] << endl; exit(-1); } fseek (file, 0x42, SEEK_SET); fgets(buff,13,stdin); fputs(buff,file); fclose(file); } Does somebody knows if I'm at the right file pos ?? or the passwd lenght ????? thanx |
From: Brian B. <ca...@um...> - 2000-04-11 11:48:23
|
Carl, Very cool. I'll merge this stuff in when I get a chance (tonight or tommorow...probably) Brian On Mon, 10 Apr 2000, Carl Seutter wrote: > Ok, here's the initial cut at generating foreign keys. To accomplish > this, I basically set about reading the MSysRelationships table using > existing routines. I made the following changes. There were 4 files > that I made changes to include/mdbtools.h, libmdb/mem.c, > libmdb/backend.c, and util/schema.c. > > In include/mdbtools.h: > -- I added this to the MdbHandle structure > char *backend_name; > -- I added this to the backend.c declarations > extern char *mdb_get_relationships(MdbHandle *mdb); > > In libmdb/mem.c: > -- I added to the mdb_free_handle function > if (mdb->backend_name) free(mdb->backend_name); > > In util/schema.c > -- I added the variable declaration of > char *the_relation; > -- I placed this code just before the call to mdb_free_handle > fprintf (stdout, "\n\n"); > fprintf (stdout, "-- CREATE ANY Relationships ...\n"); > fprintf (stdout, "\n"); > the_relation=mdb_get_relationships(mdb); > while (the_relation[0] != '\0') { > fprintf(stdout,"%s\n",the_relation); > the_relation=mdb_get_relationships(mdb); > } > > In libmdb/schema.c: > -- I added these variables to the beginning: > char *bound_values[256]; > char *relationships[4]; > MdbColumn *col; > MdbCatalogEntry entry; > MdbTableDef *table; > int did_first; > > -- I added this code to mdb_set_default_backend before the return 1 > mdb->backend_name = (char *) > malloc(strlen(backend_name)+1); > strcpy(mdb->backend_name,backend_name); > did_first = 0; > > -- I added this function: > char *mdb_get_relationships(MdbHandle *mdb) { > > int i, j, k; > static char text[255]; > void do_first () { > mdb_read_catalog (mdb, MDB_TABLE); > > /* loop over each entry in the catalog */ > for (i=0; i < mdb->num_catalog; i++) { > entry = g_array_index (mdb->catalog, MdbCatalogEntry, i); > if ((entry.object_type == MDB_TABLE) && > (strncmp (entry.object_name, "MSysRelationships", 17) == 0)) > { > table = mdb_read_table (&entry); > if ( table->num_rows > 0 ) { > mdb_read_columns(table); > mdb_rewind_table(table); > for (k=0;k<table->num_cols;k++) { > bound_values[k] = (char *) malloc(256); > bound_values[k][0] = '\0'; > mdb_bind_column(table,k+1,bound_values[k]); > } > relationships[0] = (char *) malloc(256); /* child column */ > > relationships[1] = (char *) malloc(256); /* child table */ > relationships[2] = (char *) malloc(256); /* parent column > */ > relationships[3] = (char *) malloc(256); /* parent table */ > > } > did_first = 1; > return; > } > } > } > /* > * generate relationships by "reading" the MSysRelationships table > * szColumn contains the column name of the child table > * szObject contains the table name of the child table > * szReferencedColumn contains the column name of the parent table > * szReferencedObject contains the table name of the parent table > */ > sprintf(text,"%c",0); > if ( did_first == 0) > do_first(); > if (table->cur_row < table->num_rows) { > if (mdb_fetch_row(table)) { > relationships[0][0] = '\0'; > relationships[1][0] = '\0'; > relationships[2][0] = '\0'; > relationships[3][0] = '\0'; > for (k=0;k<table->num_cols;k++) { > col=g_ptr_array_index(table->columns,k); > if (strncmp(col->name,"szColumn",8) == 0) > strcpy(relationships[0],bound_values[k]); > else if (strncmp(col->name,"szObject",8) == 0) > strcpy(relationships[1],bound_values[k]); > else if (strncmp(col->name,"szReferencedColumn",18) == 0) > strcpy(relationships[2],bound_values[k]); > else if (strncmp(col->name,"szReferencedObject",18) == 0) > strcpy(relationships[3],bound_values[k]); > } > if (strncmp(mdb->backend_name,"oracle",6) == 0) > sprintf(text,"alter table %s add constraint %s_%s foreign key > (%s) references %s(%s)", > > relationships[1],relationships[3],relationships[1], > > relationships[0],relationships[3],relationships[2]); > else > sprintf(text,"relationships are not supported for > %s",mdb->backend_name); > } /* got a row */ > } > else { > for (k=0;k<table->num_cols;k++) { > free(bound_values[k]); > } > free(relationships[0]); > free(relationships[1]); > free(relationships[2]); > free(relationships[3]); > did_first = 0; > } > return text; > } > > > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > |
From: Carl S. <cgs...@wo...> - 2000-04-11 04:49:52
|
Ok, here's the initial cut at generating foreign keys. To accomplish this, I basically set about reading the MSysRelationships table using existing routines. I made the following changes. There were 4 files that I made changes to include/mdbtools.h, libmdb/mem.c, libmdb/backend.c, and util/schema.c. In include/mdbtools.h: -- I added this to the MdbHandle structure char *backend_name; -- I added this to the backend.c declarations extern char *mdb_get_relationships(MdbHandle *mdb); In libmdb/mem.c: -- I added to the mdb_free_handle function if (mdb->backend_name) free(mdb->backend_name); In util/schema.c -- I added the variable declaration of char *the_relation; -- I placed this code just before the call to mdb_free_handle fprintf (stdout, "\n\n"); fprintf (stdout, "-- CREATE ANY Relationships ...\n"); fprintf (stdout, "\n"); the_relation=mdb_get_relationships(mdb); while (the_relation[0] != '\0') { fprintf(stdout,"%s\n",the_relation); the_relation=mdb_get_relationships(mdb); } In libmdb/schema.c: -- I added these variables to the beginning: char *bound_values[256]; char *relationships[4]; MdbColumn *col; MdbCatalogEntry entry; MdbTableDef *table; int did_first; -- I added this code to mdb_set_default_backend before the return 1 mdb->backend_name = (char *) malloc(strlen(backend_name)+1); strcpy(mdb->backend_name,backend_name); did_first = 0; -- I added this function: char *mdb_get_relationships(MdbHandle *mdb) { int i, j, k; static char text[255]; void do_first () { mdb_read_catalog (mdb, MDB_TABLE); /* loop over each entry in the catalog */ for (i=0; i < mdb->num_catalog; i++) { entry = g_array_index (mdb->catalog, MdbCatalogEntry, i); if ((entry.object_type == MDB_TABLE) && (strncmp (entry.object_name, "MSysRelationships", 17) == 0)) { table = mdb_read_table (&entry); if ( table->num_rows > 0 ) { mdb_read_columns(table); mdb_rewind_table(table); for (k=0;k<table->num_cols;k++) { bound_values[k] = (char *) malloc(256); bound_values[k][0] = '\0'; mdb_bind_column(table,k+1,bound_values[k]); } relationships[0] = (char *) malloc(256); /* child column */ relationships[1] = (char *) malloc(256); /* child table */ relationships[2] = (char *) malloc(256); /* parent column */ relationships[3] = (char *) malloc(256); /* parent table */ } did_first = 1; return; } } } /* * generate relationships by "reading" the MSysRelationships table * szColumn contains the column name of the child table * szObject contains the table name of the child table * szReferencedColumn contains the column name of the parent table * szReferencedObject contains the table name of the parent table */ sprintf(text,"%c",0); if ( did_first == 0) do_first(); if (table->cur_row < table->num_rows) { if (mdb_fetch_row(table)) { relationships[0][0] = '\0'; relationships[1][0] = '\0'; relationships[2][0] = '\0'; relationships[3][0] = '\0'; for (k=0;k<table->num_cols;k++) { col=g_ptr_array_index(table->columns,k); if (strncmp(col->name,"szColumn",8) == 0) strcpy(relationships[0],bound_values[k]); else if (strncmp(col->name,"szObject",8) == 0) strcpy(relationships[1],bound_values[k]); else if (strncmp(col->name,"szReferencedColumn",18) == 0) strcpy(relationships[2],bound_values[k]); else if (strncmp(col->name,"szReferencedObject",18) == 0) strcpy(relationships[3],bound_values[k]); } if (strncmp(mdb->backend_name,"oracle",6) == 0) sprintf(text,"alter table %s add constraint %s_%s foreign key (%s) references %s(%s)", relationships[1],relationships[3],relationships[1], relationships[0],relationships[3],relationships[2]); else sprintf(text,"relationships are not supported for %s",mdb->backend_name); } /* got a row */ } else { for (k=0;k<table->num_cols;k++) { free(bound_values[k]); } free(relationships[0]); free(relationships[1]); free(relationships[2]); free(relationships[3]); did_first = 0; } return text; } |
From: Carl S. <cgs...@wo...> - 2000-04-11 03:07:24
|
suggested names: in libmdb/catalog.c: in mdb_get_objtype_string change the "Unknown 08" to Relationship in mdb_get_objtype_string change the "Unknown 0b" to Database Properties in include/mdbtools.h change the enum MDB_UNKNOWN_08 to MDB_RELATIONSHIP change the enum MDB_UNKNOWN_0B to MDB_DATABASE_PROPERTY |
From: Carl S. <cgs...@wo...> - 2000-04-11 03:00:23
|
My previous code might have been the long way around. I just discovered with prcat that Unknown 08 are for relationships. So, it might be possible to read for the object type instead of the way that I had done it. Therefore, I don't know if it would be better to work from that angle. Any comments? |
From: Brian B. <ca...@um...> - 2000-04-10 02:57:00
|
On Sun, 9 Apr 2000, Carl Seutter wrote: > Well right now, I just get the parent table with column name and the child table > with column name. I can try moving that to backend.c if that's where we should > put it. Then that routine can be called and the values will be returned. If > you want to put in schema.c I can post it. > I'll check it in whichever way you want to do it, your call. We need to revist the backend thing at some point. I think it's pretty much on the right track, just relies a little bit much on things being standard SQL. Maybe that can't be avoided. Brian > > Brian Bruns wrote: > > > On Sun, 9 Apr 2000, Carl Seutter wrote: > > > > > I have written some code that will extract the parent/child > > > relationship. While I currently have it in util/schema.c, should it be > > Cool! > > > left there or moved to libmdb/backend.c? Right now I just display the > > > information as comments because I don't know if all of the backends that > > > are currently being supported use foreign keys. Also, I'm not sure if > > > the syntax is the same. > > > > > > Ex. In Oracle: > > > alter table table_name add constraint constraint_name foreign key > > > (columns) references parent_table(columns); > > > > > > I'm not sure that Postgress has foreign keys. > > > > Postgres 7.0 adds foreign keys, but a very valid point. I would think > > backend.c and the MdbBackend typedef struct would be the right place for > > handling this stuff. If a backend doesn't support it, then is simply > > outputs nothing when asked?! Otherwise, code for each backend may have to be > > in schema.c if it's anything but sql standard (for instance early Sybase > > engines with sp_primarykey/sp_foreignkey). > > > > > > > > Therefore, my question is how to handle/display the relationships? > > > > > > > I'm not sure how to handle the details, but I think that is the proper > > place to do it. The current approach in backend.c is fairly simplistic > > though. > > > > Brian > > > > _______________________________________________ > > mdbtools-dev mailing list > > mdb...@li... > > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > |
From: Carl S. <cgs...@wo...> - 2000-04-10 02:15:09
|
Well right now, I just get the parent table with column name and the child table with column name. I can try moving that to backend.c if that's where we should put it. Then that routine can be called and the values will be returned. If you want to put in schema.c I can post it. Brian Bruns wrote: > On Sun, 9 Apr 2000, Carl Seutter wrote: > > > I have written some code that will extract the parent/child > > relationship. While I currently have it in util/schema.c, should it be > Cool! > > left there or moved to libmdb/backend.c? Right now I just display the > > information as comments because I don't know if all of the backends that > > are currently being supported use foreign keys. Also, I'm not sure if > > the syntax is the same. > > > > Ex. In Oracle: > > alter table table_name add constraint constraint_name foreign key > > (columns) references parent_table(columns); > > > > I'm not sure that Postgress has foreign keys. > > Postgres 7.0 adds foreign keys, but a very valid point. I would think > backend.c and the MdbBackend typedef struct would be the right place for > handling this stuff. If a backend doesn't support it, then is simply > outputs nothing when asked?! Otherwise, code for each backend may have to be > in schema.c if it's anything but sql standard (for instance early Sybase > engines with sp_primarykey/sp_foreignkey). > > > > > Therefore, my question is how to handle/display the relationships? > > > > I'm not sure how to handle the details, but I think that is the proper > place to do it. The current approach in backend.c is fairly simplistic > though. > > Brian > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev |
From: Brian B. <ca...@um...> - 2000-04-10 01:59:04
|
On Sun, 9 Apr 2000, Carl Seutter wrote: > I have written some code that will extract the parent/child > relationship. While I currently have it in util/schema.c, should it be Cool! > left there or moved to libmdb/backend.c? Right now I just display the > information as comments because I don't know if all of the backends that > are currently being supported use foreign keys. Also, I'm not sure if > the syntax is the same. > > Ex. In Oracle: > alter table table_name add constraint constraint_name foreign key > (columns) references parent_table(columns); > > I'm not sure that Postgress has foreign keys. Postgres 7.0 adds foreign keys, but a very valid point. I would think backend.c and the MdbBackend typedef struct would be the right place for handling this stuff. If a backend doesn't support it, then is simply outputs nothing when asked?! Otherwise, code for each backend may have to be in schema.c if it's anything but sql standard (for instance early Sybase engines with sp_primarykey/sp_foreignkey). > > Therefore, my question is how to handle/display the relationships? > I'm not sure how to handle the details, but I think that is the proper place to do it. The current approach in backend.c is fairly simplistic though. Brian |
From: Carl S. <cgs...@wo...> - 2000-04-10 01:45:56
|
I have written some code that will extract the parent/child relationship. While I currently have it in util/schema.c, should it be left there or moved to libmdb/backend.c? Right now I just display the information as comments because I don't know if all of the backends that are currently being supported use foreign keys. Also, I'm not sure if the syntax is the same. Ex. In Oracle: alter table table_name add constraint constraint_name foreign key (columns) references parent_table(columns); I'm not sure that Postgress has foreign keys. Therefore, my question is how to handle/display the relationships? |
From: Brian B. <ca...@um...> - 2000-04-10 01:27:48
|
On Fri, 7 Apr 2000, Michael Wood wrote: > By the way, the fix in prtable.c also needs to be applied to > mdb-array.c, mdb-export.c and prdata.c. Done. > If you insert the following at the top of mdb_fetch_row() in > data.c, I think that will sort it out. I haven't tried it yet, > though. > [patch snipped] Done also. > > > BTW, I'm curious how helpful the documentation was to you. > > It was useful. I refer back to it fairly often. It's just a > bit out of date in parts. Also, it could be organised better, I > think. I don't have a problem with it as it is at the moment, > but for the final release of mdbtools it would be a bit rough :) > Well, I never claimed to be a tech writer :-) But seriously, if you have a better outline for organizing it, let me know. It's mostly in straight brain-dump format at the moment. I work on a couple other projects besides this one, so doc doesn't always get the time it should when there is coding to be done! Brian |
From: Michael W. <wo...@ki...> - 2000-04-07 06:40:20
|
Hi On Thu, Apr 06, 2000 at 08:56:36PM -0400, Brian Bruns wrote: > Hi, > > Thanks for this and the other patches. I've checked them all in. Glad I could contribute :) By the way, the fix in prtable.c also needs to be applied to mdb-array.c, mdb-export.c and prdata.c. Also, last night I was testing the tools out on a test database I had created. The database was created as follows: Create new database, Create new table with one column called 'id' of type Autonumber (I think that was the type). It doesn't matter if you make id the primary key or if you leave the table with no keys/indexes. Then save the table definition and exit the database. i.e. there is one table and no data in the table. mdb-export was giving an "offset blah is beyond EOF" error. It seems the page number that is read by mdb_read_table() is past the end of the file. The obvious solution to this problem is not to read the data page in if the number of rows in the table is 0. If you insert the following at the top of mdb_fetch_row() in data.c, I think that will sort it out. I haven't tried it yet, though. --- data.c.orig Fri Apr 7 08:32:06 2000 +++ data.c Fri Apr 7 08:32:30 2000 @@ -192,6 +192,9 @@ MdbHandle *mdb = table->entry->mdb; int rows; + if (table->num_rows == 0) + return 0; + /* initialize */ if (!table->cur_pg_num) { table->cur_pg_num=1; > A small note about the num_pgs vs. number of indexes. The is > a holdover from a time when I mistakingly thought that this > fields represented the number of pages in the table. This is > clearly not the case, but instead it is the number of indexes > attached to the table. So, the references to num_pgs should > be cleaned up at some point (when I get to it :-) I have been subscribed to the list for a couple of weeks or so, so I did see your message about confusing indexes with pages a while ago. Also, even though the documentation said the two fields were indexes, the code used one as the page count, so it wasn't too hard to guess that the page count/index fields might be the wrong way around :) > BTW, I'm curious how helpful the documentation was to you. It was useful. I refer back to it fairly often. It's just a bit out of date in parts. Also, it could be organised better, I think. I don't have a problem with it as it is at the moment, but for the final release of mdbtools it would be a bit rough :) > I'm trying to put an API reference together for libmdb, but I > didn't know if there are any other big holes in it? Well, I'm not sure. I haven't looked at the API from the perspective of trying to write a useful program myself. Also, I don't have much experience with writing to db access APIs, so I'm not sure I would be the best person to comment on whether or not the API has holes in it :) -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ wo...@ki... | Fax: +27 21 761 9930 | Kingsley Technologies |
From: Brian B. <ca...@um...> - 2000-04-07 01:23:07
|
Thanks Carl. I'll commit it in a few. Brian On Thu, 6 Apr 2000, Carl Seutter wrote: > Here is the Postgres data types so that a Postgress schema can be > generated. There are a few that I could not quite match up. Hopefully, > someone with more Postgres knowledge will be able to fill them in. > > /* Postgres data types */ > char *mdb_postgres_types[] = > {"Postgres_Unknown 0x00", > "Bool", > "Int2", > "Int4", > "Int8", > "Money", > "Float4", > "Float8", > "Timestamp", > "Postgres_Unknown 0x09", > "Char", > "Postgres_Unknown 0x0b", > "Postgres_Unknown 0x0c", > "Postgres_Unknown 0x0d", > "Postgres_Unknown 0x0e", > "Serial"}; > > > These lines need to be added to function mdb_init_backends: > > backend = (MdbBackend *) g_malloc0(sizeof(MdbBackend)); > backend->types_table = mdb_postgres_types; > mdb_register_backend(backend, "postgres"); > > > _______________________________________________ > mdbtools-dev mailing list > mdb...@li... > http://lists.sourceforge.net/mailman/listinfo/mdbtools-dev > |
From: Carl S. <cgs...@wo...> - 2000-04-07 01:18:37
|
Here is the Postgres data types so that a Postgress schema can be generated. There are a few that I could not quite match up. Hopefully, someone with more Postgres knowledge will be able to fill them in. /* Postgres data types */ char *mdb_postgres_types[] = {"Postgres_Unknown 0x00", "Bool", "Int2", "Int4", "Int8", "Money", "Float4", "Float8", "Timestamp", "Postgres_Unknown 0x09", "Char", "Postgres_Unknown 0x0b", "Postgres_Unknown 0x0c", "Postgres_Unknown 0x0d", "Postgres_Unknown 0x0e", "Serial"}; These lines need to be added to function mdb_init_backends: backend = (MdbBackend *) g_malloc0(sizeof(MdbBackend)); backend->types_table = mdb_postgres_types; mdb_register_backend(backend, "postgres"); |
From: Brian B. <ca...@um...> - 2000-04-07 01:03:39
|
Hi, Thanks for this and the other patches. I've checked them all in. A small note about the num_pgs vs. number of indexes. The is a holdover from a time when I mistakingly thought that this fields represented the number of pages in the table. This is clearly not the case, but instead it is the number of indexes attached to the table. So, the references to num_pgs should be cleaned up at some point (when I get to it :-) BTW, I'm curious how helpful the documentation was to you. I'm trying to put an API reference together for libmdb, but I didn't know if there are any other big holes in it? Cheers, Brian On Wed, 5 Apr 2000, Michael Wood wrote: > Hi > > I've been playing around with the mdbtools, since the company I > work for has a large (currently about 18MB .mdb file) Access > database. I would love to be able to get all the data out of it > into something like PostgreSQL. > > The tools haven't been working very well for me. I was getting > segfaults in mdb_read_columns() for some tables. I had a look > at things using gdb and also the source code and the HACKERS > file and discovered that for one table (the first one mdb-schema > crashed on) mdb-schema seemed to be looking 8 characters too far > into the page for the columns. > > I eventually figured out (it took me a few days, but I wasn't > doing it fulltime and I am fairly new at this ;) that the number > of pages found by mdb_read_table() was one too many. I noticed > that the integer at position 27 was being used as the number of > pages and the integer at position 31 is supposedly (according > to the HACKERS file) the number of indexes in the table. > > For the table I was having trouble with, the second integer was > one smaller than the first, so I thought maybe they were the > wrong way around. I changed the constant 27 in mdb_read_table() > to 31 and tried mdb-schema again and it works perfectly for all > the tables in the database, including ALL the tables it was > previously crashing on! :) > |
From: Carl S. <cgs...@wo...> - 2000-04-07 00:38:18
|
I found an Oracle Migration tool from Access to Oracle. They mapped the datatypes a little different. Here is the way they mapped them: char *mdb_oracle_types[] = {"Oracle_Unknown 0x00", "NUMBER", "NUMBER", "NUMBER", "NUMBER", "NUMBER", "FLOAT", "FLOAT", "DATE", "Oracle_Unknown 0x09", "VARCHAR2", "BLOB", "CLOB", "Oracle_Unknown 0x0d", "Oracle_Unknown 0x0e", "NUMBER"}; |
From: Michael W. <wo...@ki...> - 2000-04-06 12:46:23
|
Hi prtable was segfaulting for me, while mdb-schema was working. This didn't make sense to me, because they both seemed to do the same thing. Then I figured out that prtable wasn't checking the object_type of the catalog entry. I had another object with the same name as the table I was testing with, and prtable was calling mdb_table_dump() with that object instead of the table. mdb_read_table() was getting very strange values, causing mdb_read_columns() to segfault. prtable works fine after changing: if (!strcmp(entry.object_name,argv[2])) { to: if (entry.object_type == MDB_TABLE && !strcmp(entry.object_name,argv[2])) { The call to mdb_read_catalog() above the loop seems to imply that it will only read MDB_TABLE catalog entries, but the object_type parameter is never used in mdb_read_catalog(). -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ wo...@ki... | Fax: +27 21 761 9930 | Kingsley Technologies |
From: Michael W. <wo...@ki...> - 2000-04-05 15:19:17
|
Hi mdb-export and prdata were segfaulting. The database I am trying to work with has in the past been replicated, so it has all those nasty s_Generation, s_GUID and s_Lineage fields in all the tables. It seems, mdb_col_to_string() was causing a segfault, because the OLE type (s_Lineage) wasn't handled. I just added a 'default: return ""; break;' in the switch, which stops the segfault. I haven't thought about what should actually be in there. Please alter as you see fit :) -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ wo...@ki... | Fax: +27 21 761 9930 | Kingsley Technologies |
From: Michael W. <wo...@ki...> - 2000-04-05 13:44:33
|
Hi I've been playing around with the mdbtools, since the company I work for has a large (currently about 18MB .mdb file) Access database. I would love to be able to get all the data out of it into something like PostgreSQL. The tools haven't been working very well for me. I was getting segfaults in mdb_read_columns() for some tables. I had a look at things using gdb and also the source code and the HACKERS file and discovered that for one table (the first one mdb-schema crashed on) mdb-schema seemed to be looking 8 characters too far into the page for the columns. I eventually figured out (it took me a few days, but I wasn't doing it fulltime and I am fairly new at this ;) that the number of pages found by mdb_read_table() was one too many. I noticed that the integer at position 27 was being used as the number of pages and the integer at position 31 is supposedly (according to the HACKERS file) the number of indexes in the table. For the table I was having trouble with, the second integer was one smaller than the first, so I thought maybe they were the wrong way around. I changed the constant 27 in mdb_read_table() to 31 and tried mdb-schema again and it works perfectly for all the tables in the database, including ALL the tables it was previously crashing on! :) Here's a simple patch: Index: HACKERS =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/HACKERS,v retrieving revision 1.8 diff -u -r1.8 HACKERS --- HACKERS 2000/03/22 02:07:34 1.8 +++ HACKERS 2000/04/05 13:34:37 @@ -115,14 +115,14 @@ | ???? | 2 bytes | ??? | | ???? | 2 bytes | number of columns in table | | ???? | 4 bytes | number of indexes for this table | -| ???? | 4 bytes | number of indexes for this table (repeat) | +| ???? | 4 bytes | number of pages for this table | | 0x00 | 1 byte | ??? | | ???? | 2 bytes | page number of first datapage for table | | ???? | 2 bytes | ??? | | ???? | 2 bytes | page number of first datapage for table | | 0x00 | 1 byte | ??? | +-------------------------------------------------------------------------+ -| Iterate for the 2 x number of indexes | +| Iterate for the 2 x number of indexes (pages?) | +-------------------------------------------------------------------------+ | ???? | 4 bytes | number of rows in table | | ???? | 4 bytes | number of rows in the index | Index: src/libmdb/table.c =================================================================== RCS file: /cvsroot/mdbtools/mdbtools/src/libmdb/table.c,v retrieving revision 1.10 diff -u -r1.10 table.c --- src/libmdb/table.c 2000/04/02 17:08:30 1.10 +++ src/libmdb/table.c 2000/04/05 13:34:37 @@ -42,7 +42,7 @@ table->num_rows = mdb_get_int32(mdb,12); table->num_cols = mdb_get_int16(mdb,25); - table->num_pgs = mdb_get_int32(mdb,27); + table->num_pgs = mdb_get_int32(mdb,31); table->first_data_pg = mdb_get_int16(mdb,36); return table; =================================================================== -- Michael Wood | Tel: +27 21 762 0276 | http://www.kingsley.co.za/ wo...@ki... | Fax: +27 21 761 9930 | Kingsley Technologies |
From: <kn...@gr...> - 2000-04-04 18:55:50
|
Since the diffs are almost 1/4 of the file, here's the whole thing. There were a couple "C" areas ('"' and '\') that didn't get correctly escaped and caused compilation errors. -- Karl -- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* this is inherited from mdb-export.c, modified to make arrays similar to those generated by parsecsv.c */ #include "mdbtools.h" main (int argc, char **argv) { int rows; int i, j, k; unsigned char buf [2048]; MdbHandle *mdb; MdbCatalogEntry entry; MdbTableDef *table; MdbColumn *col; /* doesn't handle tables > 256 columns. Can that happen? */ char *bound_values [256]; char delimiter [] = ", "; char quote_text = 1; int count; int started; char *c; if (argc < 2) { fprintf (stderr, "Usage: %s <file> <table>\n", argv [0]); exit (1); } mdb_init(); mdb = mdb_open (argv [1]); mdb_read_catalog (mdb, MDB_TABLE); for (i = 0; i < mdb->num_catalog; i++) { entry = g_array_index (mdb->catalog, MdbCatalogEntry, i); if (!strcmp (entry.object_name, argv [2])) { table = mdb_read_table (&entry); mdb_read_columns (table); mdb_rewind_table (table); for (j = 0; j < table->num_cols; j++) { bound_values [j] = (char *) malloc (256); bound_values [j] [0] = '\0'; mdb_bind_column (table, j + 1, bound_values [j]); } fprintf (stdout, "/******************************************************************/\n"); fprintf (stdout, "/* THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT IT!!!!!! */\n"); fprintf (stdout, "/******************************************************************/\n"); fprintf (stdout, "\n"); fprintf (stdout, "#include <stdio.h>\n"); fprintf (stdout, "#include \"types.h\"\n"); fprintf (stdout, "#include \"dump.h\"\n"); fprintf (stdout, "\n"); fprintf (stdout, "const %s %s_array [] = {\n", argv [2], argv [2]); count = 0; started = 0; while (mdb_fetch_row (table)) { if (started != 0) { fprintf (stdout, ",\n"); } started = 1; fprintf (stdout, "{\t\t\t\t/* %6d */\n\t", count); for (j = 0; j < table->num_cols; j++) { fprintf (stdout, "\t"); col = g_ptr_array_index (table->columns, j); if (quote_text && (col->col_type == MDB_TEXT || col->col_type == MDB_MEMO)) { fprintf (stdout, "\""); c = bound_values [j]; for (k = 0; k < strlen (bound_values [j]); k++) { if ((*c == '\"') || (*c == '\\')) { fprintf (stdout, "\\"); } fprintf (stdout, "%c", *c++); } fprintf (stdout, "\""); } else if (((col->col_type == MDB_LONGINT) || (col->col_type == MDB_INT)) && strlen (bound_values [j]) == 0) { fprintf (stdout, "0"); } else { fprintf (stdout, "%s", bound_values [j]); } if (j != table->num_cols - 1) { fprintf (stdout, "%s\n", delimiter); } else { fprintf (stdout, "\n"); } } fprintf (stdout, "}"); count++; } for (j = 0; j < table->num_cols; j++) { free (bound_values [j]); } } } mdb_free_handle (mdb); mdb_exit(); fprintf (stdout, "\n};\n"); fprintf (stdout, "\nconst int %s_array_length = %d;\n", argv [2], count); } |