Commit b581f17b authored by monty@donna.mysql.com's avatar monty@donna.mysql.com
Browse files

Fixes for MERGE TABLES and HEAP tables

parent 7e543b4d
Loading
Loading
Loading
Loading
+108 −27
Original line number Diff line number Diff line
@@ -195,8 +195,8 @@ Installing a MySQL binary distribution
System-specific issues
* Binary notes-Linux::          Linux notes
* Binary notes-HP-UX::          HP-UX notes
* Binary notes-Linux::          Linux notes for binary distribution
* Binary notes-HP-UX::          HP-UX notes for binary distribution
Installing a MySQL source distribution
@@ -259,6 +259,7 @@ Windows notes
* Windows and SSH::             Connecting to a remote @strong{MySQL} from Windows with SSH
* Windows symbolic links::      Splitting data across different disks under Win32
* Windows compiling::           Compiling MySQL clients on Windows.
* Windows and BDB tables.::     
* Windows vs Unix::             @strong{MySQL}-Windows compared to Unix @strong{MySQL}
Post-installation setup and testing
@@ -4568,8 +4569,8 @@ files.
@subsection System-specific issues
@menu
* Binary notes-Linux::          Linux notes
* Binary notes-HP-UX::          HP-UX notes
* Binary notes-Linux::          Linux notes for binary distribution
* Binary notes-HP-UX::          HP-UX notes for binary distribution
@end menu
The following sections indicate some of the issues that have been observed
@@ -4577,7 +4578,7 @@ on particular systems when installing @strong{MySQL} from a binary
distribution.
@node Binary notes-Linux, Binary notes-HP-UX, Binary install system issues, Binary install system issues
@subsubsection Linux notes
@subsubsection Linux notes for binary distribution
@strong{MySQL} needs at least Linux 2.0.
@@ -4653,7 +4654,7 @@ and clients on the same machine. We hope that the @code{Linux 2.4}
kernel will fix this problem in the future.
@node Binary notes-HP-UX,  , Binary notes-Linux, Binary install system issues
@subsubsection HP-UX notes
@subsubsection HP-UX notes for binary distribution
Some of the binary distributions of @strong{MySQL} for HP-UX is
distributed as an HP depot file and as a tar file.  To use the depot
@@ -7203,6 +7204,7 @@ is also described in the @file{README} file that comes with the
* Windows and SSH::             Connecting to a remote @strong{MySQL} from Windows with SSH
* Windows symbolic links::      Splitting data across different disks under Win32
* Windows compiling::           Compiling MySQL clients on Windows.
* Windows and BDB tables.::     
* Windows vs Unix::             @strong{MySQL}-Windows compared to Unix @strong{MySQL}
@end menu
@@ -7511,7 +7513,7 @@ should create the file @file{C:\mysql\data\foo.sym} that should contains the
text @code{D:\data\foo}.  After this, all tables created in the database
@code{foo} will be created in @file{D:\data\foo}.
@node Windows compiling, Windows vs Unix, Windows symbolic links, Windows
@node Windows compiling, Windows and BDB tables., Windows symbolic links, Windows
@subsection Compiling MySQL clients on Windows.
In your source files, you should include @file{windows.h} before you include
@@ -7531,7 +7533,17 @@ with the static @file{mysqlclient.lib} library.
Note that as the mysqlclient libraries are compiled as threaded libraries,
you should also compile your code to be multi-threaded!
@node Windows vs Unix,  , Windows compiling, Windows
@node Windows and BDB tables., Windows vs Unix, Windows compiling, Windows
@subsection Windows and BDB tables.
We are working on removing the requirement that one must have a primary
key in a BDB table; As soon as this is fixed we will throughly test the
BDB interface by running the @strong{MySQL} benchmark + our internal
test suite on it.  When the above is done we will start release binary
distributions (for windows and Unix) of @strong{MySQL} that will include
support for BDB tables.
@node Windows vs Unix,  , Windows and BDB tables., Windows
@subsection MySQL-Windows compared to Unix MySQL
@strong{MySQL}-Windows has by now proven itself to be very stable. This version
@@ -16445,6 +16457,7 @@ or PASSWORD = "string"
or	DELAY_KEY_WRITE = @{0 | 1@}
or      ROW_FORMAT= @{ default | dynamic | static | compressed @}
or	RAID_TYPE= @{1 | STRIPED | RAID0 @} RAID_CHUNKS=#  RAID_CHUNKSIZE=#;
or	UNION = (table_name,[table_name...])
select_statement:
	[IGNORE | REPLACE] SELECT ...  (Some legal select statement)
@@ -16742,8 +16755,14 @@ If you specify @code{RAID_TYPE=STRIPED} for a @code{MyISAM} table,
to the data file, the @code{RAID} handler will map the first
@code{RAID_CHUNKSIZE} *1024 bytes to the first file, the next
@code{RAID_CHUNKSIZE} *1024 bytes to the next file and so on.
@end itemize
@code{UNION} is used when you want to use a collection of identical
tables as one. This only works with MERGE tables. @xref{MERGE}.
For the moment you need to have @code{SELECT}, @code{UPDATE} and
@code{DELETE} privileges on the tables you map to a @code{MERGE} table.
All mapped tables must be in the same database as the @code{MERGE} table.
@end itemize
@node Silent column changes,  , CREATE TABLE, CREATE TABLE
@subsection Silent column specification changes
@@ -20633,9 +20652,10 @@ missing is a way from the SQL prompt to say which tables are part of the
@code{MERGE} table.
A @code{MERGE} table is a collection of identical @code{MyISAM} tables
that can be used as one.  You can only @code{SELECT} from the collection
of tables. If you @code{DROP} the @code{MERGE} table, you are only
dropping the @code{MERGE} specification.
that can be used as one.  You can only @code{SELECT}, @code{DELETE} and
@code{UPDATE} from the collection of tables.  If you @code{DROP} the
@code{MERGE} table, you are only dropping the @code{MERGE}
specification.
With identical tables we mean that all tables are created with identical
column information.  Some of the tables can be compressed with
@@ -20646,7 +20666,10 @@ definition file and a @code{.MRG} table list file. The @code{.MRG} just
contains a list of the index files (@code{.MYI} files) that should
be used as one.
@code{MERGE} tables helps you solve the following problems:
For the moment you need to have @code{SELECT}, @code{UPDATE} and
@code{DELETE} privileges on the tables you map to a @code{MERGE} table.
@code{MERGE} tables can help you solve the following problems:
@itemize @bullet
@item
@@ -20671,13 +20694,22 @@ are mapped to a @code{MERGE} file than trying to repair a real big file.
Instant mapping of many files as one;  A @code{MERGE} table uses the
index of the individual tables;  It doesn't need an index of its one.
This makes @code{MERGE} table collections VERY fast to make or remap.
@item
If you have a set of tables which you join to a big tables on demand or
batch, you should instead create a @code{MERGE} table on them on demand.
This is much faster and will save a lot of disk space.
@item
Go around the file size limit for the operating system.
@end itemize
The disadvantages with @code{MERGE} tables are:
@itemize @bullet
@item
@code{MERGE} tables are read-only.
You can't use @code{INSERT} on @code{MERGE} tables, as @strong{MySQL} can't know
in which of the tables we should insert the row.
@item
You can only use identical @code{MyISAM} tables for a @code{MERGE} table.
@item
@code{MERGE} tables uses more file descriptors: If you are using a
@strong{MERGE} that maps over 10 tables and 10 users are using this, you
@@ -20703,18 +20735,15 @@ CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a)) TYPE=MERGE;
CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a)) TYPE=MERGE UNION=(t1,t2);
@end example
Note that we didn't create an @code{UNIQUE} or @code{PRIMARY KEY} in the
@code{total} table as the key isn't going to be unique in the @code{total}
table.
(We plan to in the future add the information in the @code{MERGE} handler
that unique keys are not necessarily unique in the @code{MERGE} table.)
Now you have to use tool (editor, unix command...) to insert the file
names into the 'total' table:
Note that you can also manipulate the @code{.MRG} file directly from
the outside of the @code{MySQL} server:
@example
shell> cd /mysql-data-directory/current-database
@@ -20737,13 +20766,11 @@ mysql> select * from total;
+---+---------+
@end example
To remap a @code{MERGE} table you must either @code{DROP} it and recreate it
or change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the
@code{MERGE} table to force the handler to read the new definition file.
You can also put full paths to the index files in the @code{.MRG} file;  If
you don't do this, the @code{MERGE} handler assumes that the index files
are in the same directory as the @code{.MRG} file.
To remap a @code{MERGE} table you must either @code{DROP} it and
recreate it, use @code{ALTER TABLE} with a new @code{UNION}
specification or change the @code{.MRG} file and issue a @code{FLUSH
TABLE} on the @code{MERGE} table and all underlying tables to force the
handler to read the new definition file.
@node ISAM, HEAP, MERGE, Table types
@section ISAM tables
@@ -28799,6 +28826,48 @@ string to a time. This would be great if the source was a text file, but
is plain stupid when the source is an ODBC connection that reports
exact types for each column.
@end itemize
@item Word
To retrieve data from @strong{MySQL}to Word/Excel documents, you need to
use the @code{MyODBC} driver and the Add-in Microsoft Query help.
For example, create a db with a table with 2 columns text.
@itemize @bullet
@item
Insert rows using the mysql client command line tool.
@item
Create a DSN file using the MyODBC driver e.g. my for the db above.
@item 
Open the Word application.
@item
Create a blank new documentation.
@item
Using the tool bar called Database, press the button insert database.
@item
Press the button Get Data.
@item
At the right hand of the screen Get Data, press the button Ms Query.
@item
In the Ms Query create a New Data Source using the DSN file my.
@item
Select the new query.
@item
Select the columns that you want.
@item
Make a filter if you want.
@item
Make a Sort if you want.
@item
Select Return Data to Microsoft Word.
@item
Click Finish.
@item
Click Insert data and select the records.
@item
Click OK and you see the rows in your Word document.
@end itemize 
@item odbcadmin
Test program for ODBC.
@item Delphi
@@ -36224,6 +36293,11 @@ though, so 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.25
@itemize @bullet
@item
@code{HEAP} tables didn't use keys properly. (Bug from 3.23.23)
@item
Added better support for @code{MERGE} tables (keys, mapping, creation,
documentation...). @xref{MERGE}.
@item
Fixed bug in mysqldump from 3.23 which caused that some @code{CHAR} columns
wheren't quoted.
@item
@@ -40304,6 +40378,8 @@ Fixed @code{DISTINCT} with calculated columns.
@itemize @bullet
@item
For the moment @code{MATCH} only works with @code{SELECT} statements.
@item
You cannot build in another directory when using
MIT-pthreads. Because this requires changes to MIT-pthreads, we are not
likely to fix this.
@@ -40391,6 +40467,9 @@ the error value 'empty string', with numeric value 0.
@item
If you execute a @code{PROCEDURE} on a query with returns an empty set then
in some cases the @code{PROCEDURE} will not transform the columns.
@item
Creation of a table of type @code{MERGE} doesn't check if the underlaying
tables are of compatible types.
@end itemize
The following is known bugs in earlier versions of @strong{MySQL}:
@@ -40464,6 +40543,8 @@ Allow users to change startup options.
@item
Subqueries. @code{select id from t where grp in (select grp from g where u > 100)}
@item
Add range checking to @code{MERGE} tables.
@item
Port of @strong{MySQL} to BeOS.
@item
Add a temporary key buffer cache during @code{insert/delete/update} so that we
+5 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@

/* Return error-text for system error messages and nisam messages */

#define PERROR_VERSION "2.2"
#define PERROR_VERSION "2.3"

#include <global.h>
#include <my_sys.h>
@@ -59,9 +59,11 @@ static HA_ERRORS ha_errlist[]=
  { 136,"No more room in index file" },
  { 137,"No more records (read after end of file)" },
  { 138,"Unsupported extension used for table" },
  { 139,"Too big row (>= 24 M)"},
  { 139,"Too big row (>= 16 M)"},
  { 140,"Wrong create options"},
  { 141,"Dupplicate unique on write or update"},
  { 141,"Duplicate unique on write or update"},
  { 142,"Unknown character set used"},
  { 143,"Conflicting table definition between MERGE and mapped table"},
  { 0,NullS },
};

+2 −1
Original line number Diff line number Diff line
@@ -83,7 +83,8 @@ extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx);
extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec);
extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
extern int myrg_create(const char *name,const char **table_names);
extern int myrg_create(const char *name,const char **table_names,
		       my_bool fix_names);
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function);
extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
				    const byte *start_key,uint start_key_len,
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ void delete_queue(QUEUE *queue);
void queue_insert(QUEUE *queue,byte *element);
byte *queue_remove(QUEUE *queue,uint idx);
void _downheap(QUEUE *queue,uint idx);
#define is_queue_inited(queue) ((queue)->root != 0)

#ifdef	__cplusplus
}
+2 −2
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ register char ***argv;
	/* Fall through */
      case 'I':
      case '?':
	printf("%s  Ver 3.1 for %s at %s\n",my_progname,SYSTEM_TYPE,
	printf("%s  Ver 3.2 for %s at %s\n",my_progname,SYSTEM_TYPE,
	       MACHINE_TYPE);
	puts("TCX Datakonsult AB, by Monty, for your professional use\n");
	if (version)
@@ -325,7 +325,7 @@ static int examine_log(my_string file_name, char **table_names)

  init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0));
  bzero((gptr) com_count,sizeof(com_count));
  init_tree(&tree,0,sizeof(file_info),(qsort_cmp) file_info_compare,0,
  init_tree(&tree,0,sizeof(file_info),(qsort_cmp) file_info_compare,1,
	    (void(*)(void*)) file_info_free);
  VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD))));

Loading