diff --git a/ChangeLog b/ChangeLog index 109fec1..3a51823 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Sat Mar 13 09:27:23 EST 2004 Brian Bruns + * doc/faq.html: fix typos, add question on write support + * doc/install.sgml: clarify yacc requirement + * doc/mdb-ver.txt: add -M to options + * doc/mdb-sql.txt: add BUGS sections + * src/libmdb/data.c: fix bug in call to mdb_get_double (Jeff Smith) + * src/libmdb/write.c: move declaration to top of function in crack_row3 (Jeff Smith), check for null in mdb_pack_row[3-4] (me) + * src/libmdb/index.c: fix hard coded index size in compressed index handling + * src/sql/lexer.l: missing ] in NUMBER (Jeff Smith) + * src/sql/mdbsql.c: temp_fill called with wrong value (Jeff Smith) + * src/odbc/odbc.c: fix typo, incorrect pointer dereference (Jeff Smith), change value to SQLSMALLINT * in type_info + Sat Mar 6 18:10:20 EST 2004 Brian Bruns * include/mdbsql.h: * src/libmdb/worktable.c: diff --git a/doc/faq.html b/doc/faq.html index 2ebba23..839a8fc 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -24,7 +24,9 @@
1.9 How do I help?
-1.10 What's this postcard thing? +1.10 What's this postcard thing? +
+1.11 When will MDB Tools support writing?

@@ -64,7 +66,7 @@ MDB Tools supports Jet version 3.0 and 4.0 databases. It does not, and probably
  • Add support for adding rows to existing tables and an mdb-import tool.
  • Add full write support to libmdb and libmdbsql.
  • Extract queries, table properties, VBA script, forms.
  • -
  • mdb-check database consistancy checker and recovery tool.
  • +
  • mdb-check database consistency checker and recovery tool.
  • Add joins.
  • Ability to add tables.
  • @@ -96,7 +98,10 @@ We are currently looking for corrupted Access databases to help with developing

    1.10 What's this postcard thing?
    -I, like many free software others, enjoy getting postcards from where users live. If you're a happy MDB Tools user (or even a disgruntled one, doesn't really matter) and want to drop me a postcard with a picture of the place you live, email me for my snail-mail address. Come one, you know you want to! +I, like many free software others, enjoy getting postcards from where users live. If you're a happy MDB Tools user (or even a disgruntled one, doesn't really matter) and want to drop me a postcard with a picture of the place you live, email me for my snail-mail address. Come on, you know you want to! +
    +
    1.11 When will MDB Tools support writing?
    +Writing to MDB files is a quite a bit more complicated than simply reading. Some preliminary support is available in the CVS version, this includes under-the-covers things like building rows, adding rows to tables, tracing the index chain to the row, and some work on index writes. These are the nuts and bolts of write support; the big thing left is the allocation of new pages and splitting full pages on inserts. When will this be done? I don't commit to timelines, but the next release (0.6) will have some usable, though not complete, write support.
    diff --git a/doc/install.sgml b/doc/install.sgml index e71e9b1..df043f6 100644 --- a/doc/install.sgml +++ b/doc/install.sgml @@ -2,8 +2,8 @@ ]> - $Date: 2004/02/08 18:41:07 $ - $Revision: 1.3 $ + $Date: 2004/03/13 15:07:19 $ + $Revision: 1.4 $ <productname>MDB Tools</productname> Installation Guide A Guide to Installing and Configuring MDB Tools @@ -34,9 +34,9 @@ This guide is intended to provide help with installing and configuring the A few technical notes. This guide is written in SGML DocBook format, specifications for which are found in the DocBook book. It was converted to HTML with OpenJade. The document you are reading is version -$Revision: 1.3 $ +$Revision: 1.4 $ , dated -$Date: 2004/02/08 18:41:07 $ (CVS control number $Id: install.sgml,v 1.3 2004/02/08 18:41:07 brianb Exp $). The most recent version can be found on the MDB Tools +$Date: 2004/03/13 15:07:19 $ (CVS control number $Id: install.sgml,v 1.4 2004/03/13 15:07:19 brianb Exp $). The most recent version can be found on the MDB Tools web site. @@ -183,7 +183,7 @@ The following matrix lists all requirements and which features they affect. An Supports history in mdb-sql, will compile without history if not found. - bison + bison/yacc X X diff --git a/doc/mdb-sql.txt b/doc/mdb-sql.txt index 20584be..8dcfd99 100644 --- a/doc/mdb-sql.txt +++ b/doc/mdb-sql.txt @@ -65,3 +65,4 @@ AUTHORS The mdb-sql utility was written by Brian Bruns BUGS + The supported SQL syntax is a very limited subset and deficient in several ways. diff --git a/doc/mdb-ver.txt b/doc/mdb-ver.txt index 9f99da9..08bf4e8 100644 --- a/doc/mdb-ver.txt +++ b/doc/mdb-ver.txt @@ -10,6 +10,8 @@ DESCRIPTION OPTIONS + -M Prints the version of MDB Tools itself instead of the MDB file. + NOTES Access changed its format between Jet 3 used in Access 97 and Jet 4 used for Access 2000 and XP. The nature of the changes included moving the page size from 2K to 4K and added support for unicode. MDB Tools actively supports both formats. diff --git a/src/libmdb/data.c b/src/libmdb/data.c index f82e361..5eef7ef 100644 --- a/src/libmdb/data.c +++ b/src/libmdb/data.c @@ -1073,7 +1073,7 @@ char *mdb_col_to_string(MdbHandle *mdb, unsigned char *buf, int start, int datat return text; break; case MDB_SDATETIME: - td = mdb_get_double(mdb, start); + td = mdb_get_double(mdb->pg_buf, start); if (td > 1) { t = (long int)((td - 25569.0) * 86400.0); } else { diff --git a/src/libmdb/index.c b/src/libmdb/index.c index f200278..39ec6b0 100644 --- a/src/libmdb/index.c +++ b/src/libmdb/index.c @@ -571,6 +571,7 @@ mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 int passed = 0; int idx_sz; int idx_start = 0; + MdbColumn *col; ipg = mdb_index_read_bottom_pg(mdb, idx, chain); @@ -608,8 +609,10 @@ mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 *row = mdb->pg_buf[ipg->offset + ipg->len - 1]; *pg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 4); //printf("row = %d pg = %lu ipg->pg = %lu offset = %lu len = %d\n", *row, *pg, ipg->pg, ipg->offset, ipg->len); - idx_sz = 4; - if (ipg->len - 4 < idx_sz) { + col=g_ptr_array_index(idx->table->columns,idx->key_col_num[0]-1); + idx_sz = mdb_col_fixed_size(col); + /* handle compressed indexes, single key indexes only? */ + if (idx->num_keys==1 && idx_sz>0 && ipg->len - 4 < idx_sz) { //printf("short index found\n"); //buffer_dump(ipg->cache_value, 0, idx_sz); memcpy(&ipg->cache_value[idx_sz - (ipg->len - 4)], &mdb->pg_buf[ipg->offset], ipg->len); diff --git a/src/libmdb/write.c b/src/libmdb/write.c index db86d84..43b836c 100644 --- a/src/libmdb/write.c +++ b/src/libmdb/write.c @@ -215,7 +215,7 @@ mdb_crack_row3(MdbTableDef *table, int row_start, int row_end, MdbField *fields) int byte_num, bit_num; int num_of_jumps = 0, jumps_used = 0; int eod, len; /* end of data */ - int row_pos; + int row_pos, col_ptr; if (mdb_get_option(MDB_DEBUG_ROW)) { buffer_dump(mdb->pg_buf, row_start, row_end+1); @@ -283,7 +283,7 @@ mdb_crack_row3(MdbTableDef *table, int row_start, int row_end, MdbField *fields) } /* if fixed columns add up to more than 256, we need a jump */ - int col_ptr = row_end - bitmask_sz - num_of_jumps - 1; + col_ptr = row_end - bitmask_sz - num_of_jumps - 1; if (col_start >= 256) { num_of_jumps++; jumps_used++; @@ -406,8 +406,10 @@ mdb_pack_row4(MdbTableDef *table, unsigned char *row_buffer, int num_fields, Mdb if (!fields[i].is_fixed) { var_cols++; fields[i].offset = pos; - memcpy(&row_buffer[pos], fields[i].value, fields[i].siz); - pos += fields[i].siz; + if (! fields[i].is_null) { + memcpy(&row_buffer[pos], fields[i].value, fields[i].siz); + pos += fields[i].siz; + } } } /* EOD */ @@ -451,8 +453,10 @@ mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, int num_fields, Mdb if (!fields[i].is_fixed) { var_cols++; fields[i].offset = pos; - memcpy(&row_buffer[pos], fields[i].value, fields[i].siz); - pos += fields[i].siz; + if (! fields[i].is_null) { + memcpy(&row_buffer[pos], fields[i].value, fields[i].siz); + pos += fields[i].siz; + } } } /* EOD */ diff --git a/src/odbc/Makefile.am b/src/odbc/Makefile.am index 6c026d8..cfc4739 100644 --- a/src/odbc/Makefile.am +++ b/src/odbc/Makefile.am @@ -7,7 +7,7 @@ MDBSOURCES = backend.c index.c money.c catalog.c kkd.c sargs.c \ map.c props.c worktable.c options.c \ write.c stats.c iconv.c -bin_PROGRAMS = unittest +bin_PROGRAMS = unittest unittest2 lib_LTLIBRARIES = libmdbodbc.la AM_CPPFLAGS = -I ../../include $(GLIB_CFLAGS) libmdbodbc_la_SOURCES= odbc.c connectparams.c diff --git a/src/odbc/odbc.c b/src/odbc/odbc.c index af42352..2626fc0 100644 --- a/src/odbc/odbc.c +++ b/src/odbc/odbc.c @@ -32,7 +32,7 @@ #include "connectparams.h" -static char software_version[] = "$Id: odbc.c,v 1.14 2004/03/06 23:59:54 brianb Exp $"; +static char software_version[] = "$Id: odbc.c,v 1.15 2004/03/13 15:07:19 brianb Exp $"; static void *no_unused_var_warn[] = {software_version, no_unused_var_warn}; @@ -68,16 +68,16 @@ typedef struct { SQLSMALLINT nullable; SQLSMALLINT case_sensitive; SQLSMALLINT searchable; - SQLSMALLINT unsigned_attribute; + SQLSMALLINT *unsigned_attribute; SQLSMALLINT fixed_prec_scale; SQLSMALLINT auto_unique_value; SQLCHAR *local_type_name; SQLSMALLINT minimum_scale; SQLSMALLINT maximum_scale; SQLSMALLINT sql_data_type; - SQLSMALLINT sql_datetime_sub; - SQLSMALLINT num_prec_radix; - SQLSMALLINT interval_precision; + SQLSMALLINT *sql_datetime_sub; + SQLSMALLINT *num_prec_radix; + SQLSMALLINT *interval_precision; } TypeInfo; TypeInfo type_info[] = { @@ -429,6 +429,7 @@ SQLRETURN SQL_API SQLAllocHandle( return _SQLAllocEnv(OutputHandle); break; } + return SQL_ERROR; } static SQLRETURN SQL_API _SQLAllocConnect( SQLHENV henv, @@ -696,7 +697,7 @@ SQLRETURN SQL_API SQLColAttributes( case SQL_COLUMN_LABEL: namelen = MIN(cbDescMax,strlen(sqlcol->name)); strncpy(rgbDesc, sqlcol->name, namelen); - *((char *)&rgbDesc[namelen])='\0'; + ((char *)rgbDesc)[namelen]='\0'; break; case SQL_COLUMN_TYPE: *pfDesc = SQL_CHAR; @@ -1266,8 +1267,8 @@ SQLRETURN SQL_API SQLGetTypeInfo( MdbHandle *mdb = sql->mdb; unsigned char *new_pg; int row_size; - unsigned char *row_buffer[MDB_PGSIZE]; - unsigned char *tmpstr[MDB_BIND_SIZE]; + unsigned char row_buffer[MDB_PGSIZE]; + unsigned char tmpstr[MDB_BIND_SIZE]; int i, tmpsiz; MdbField fields[NUM_TYPE_INFO_COLS]; @@ -1315,7 +1316,7 @@ SQLRETURN SQL_API SQLGetTypeInfo( mdb_fill_temp_field(&fields[6],&type_info[i].nullable, sizeof(SQLSMALLINT), 0,0,0,1); mdb_fill_temp_field(&fields[7],&type_info[i].case_sensitive, sizeof(SQLSMALLINT), 0,0,0,1); mdb_fill_temp_field(&fields[8],&type_info[i].searchable, sizeof(SQLSMALLINT), 0,0,0,1); - mdb_fill_temp_field(&fields[9],&type_info[i].unsigned_attribute, sizeof(SQLSMALLINT), 0,0,0,1); + mdb_fill_temp_field(&fields[9],type_info[i].unsigned_attribute, sizeof(SQLSMALLINT), 0,type_info[i].unsigned_attribute ? 0 : 1,0,1); mdb_fill_temp_field(&fields[10],&type_info[i].fixed_prec_scale, sizeof(SQLSMALLINT), 0,0,0,1); mdb_fill_temp_field(&fields[11],&type_info[i].auto_unique_value, sizeof(SQLSMALLINT), 0,0,0,1); tmpsiz = mdb_ascii2unicode(mdb, type_info[i].local_type_name, 0, 100, tmpstr); @@ -1323,9 +1324,9 @@ SQLRETURN SQL_API SQLGetTypeInfo( mdb_fill_temp_field(&fields[13],&type_info[i].minimum_scale, sizeof(SQLSMALLINT), 0,0,0,1); mdb_fill_temp_field(&fields[14],&type_info[i].maximum_scale, sizeof(SQLSMALLINT), 0,0,0,1); mdb_fill_temp_field(&fields[15],&type_info[i].sql_data_type, sizeof(SQLSMALLINT), 0,0,0,1); - mdb_fill_temp_field(&fields[16],&type_info[i].sql_datetime_sub, sizeof(SQLSMALLINT), 0,0,0,1); - mdb_fill_temp_field(&fields[17],&type_info[i].num_prec_radix, sizeof(SQLSMALLINT), 0,0,0,1); - mdb_fill_temp_field(&fields[18],&type_info[i].interval_precision, sizeof(SQLSMALLINT), 0,0,0,1); + mdb_fill_temp_field(&fields[16],type_info[i].sql_datetime_sub, sizeof(SQLSMALLINT), 0,type_info[i].sql_datetime_sub ? 0 : 1,0,1); + mdb_fill_temp_field(&fields[17],type_info[i].num_prec_radix, sizeof(SQLSMALLINT), 0,type_info[i].num_prec_radix ? 0 : 1,0,1); + mdb_fill_temp_field(&fields[18],type_info[i].interval_precision, sizeof(SQLSMALLINT), 0,type_info[i].interval_precision ? 0 : 1,0,1); row_size = mdb_pack_row(ttable, row_buffer, NUM_TYPE_INFO_COLS, fields); mdb_add_row_to_pg(ttable,row_buffer, row_size); @@ -1522,6 +1523,8 @@ char quote_char; } *d='\0'; strcpy(stmt->query,tmp); + + return 0; } static int _odbc_get_string_size(int size, char *str) @@ -1534,6 +1537,7 @@ static int _odbc_get_string_size(int size, char *str) } else { return size; } + return 0; } static int _odbc_get_server_type(int clt_type) { @@ -1551,6 +1555,7 @@ static int _odbc_get_server_type(int clt_type) default: break; } + return 0; } static SQLSMALLINT _odbc_get_client_type(int srv_type) { @@ -1580,5 +1585,6 @@ static SQLSMALLINT _odbc_get_client_type(int srv_type) // fprintf(stderr,"Unknown type %d\n",srv_type); break; } + return -1; } diff --git a/src/sql/lexer.l b/src/sql/lexer.l index 911be6c..ac277a3 100644 --- a/src/sql/lexer.l +++ b/src/sql/lexer.l @@ -51,7 +51,7 @@ like { return LIKE; } [A-z][A-z0-9_#@]* { yylval.name = strdup(yytext); return NAME; } '[A-z0-9 !@#$%^&*()-_+={}[\];:",.<>/?`~|\\]*' { yylval.name = strdup(yytext); return STRING; } -(-*[0-9]+|([0-9]*\.[0-9+)([eE][-+]?[0-9]+)?) { +(-*[0-9]+|([0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?) { yylval.name = strdup(yytext); return NUMBER; } ~?(\/?[A-z0-9\.]+)+ { yylval.name = strdup(yytext); return PATH; } diff --git a/src/sql/mdbsql.c b/src/sql/mdbsql.c index a57a0bc..9a0ff7a 100644 --- a/src/sql/mdbsql.c +++ b/src/sql/mdbsql.c @@ -652,7 +652,7 @@ void mdb_sql_describe_table(MdbSQL *sql) sprintf(tmpstr,"%d",col->col_size); tmpsiz = mdb_ascii2unicode(mdb, tmpstr, 0, 100, col_size); - mdb_fill_temp_field(&fields[2],tmpstr, tmpsiz, 0,0,0,2); + mdb_fill_temp_field(&fields[2],col_size, tmpsiz, 0,0,0,2); row_size = mdb_pack_row(ttable, row_buffer, 3, fields); mdb_add_row_to_pg(ttable,row_buffer, row_size);