Commit f0c252e6 authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

merged

parents 86d88318 735efdbf
Loading
Loading
Loading
Loading
+204 −5
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ This is a manual about @strong{MySQL} internals.
@menu
@end menu

@node caching
@node caching,,,
@chapter How MySQL handles caching

@strong{MySQL} has the following caches:
@@ -89,7 +89,7 @@ found rows are cached in a join cache. One SELECT query can use many
join caches in the worst case.
@end itemize

@node flush tables
@node flush tables,,,
@chapter How MySQL handles flush tables

@itemize @bullet
@@ -134,7 +134,7 @@ After this it will give other threads a chance to open the same tables.

@end itemize

@node Filesort
@node Filesort,,,
@chapter How MySQL does sorting (filesort)

@itemize @bullet
@@ -174,7 +174,7 @@ and then we read the rows in the sorted order into a row buffer

@end itemize

@node Coding guidelines
@node Coding guidelines,,,
@chapter Coding guidelines

@itemize @bullet
@@ -289,7 +289,7 @@ Use pointers rather than array indexing when operating on strings.

@end itemize

@node mysys functions
@node mysys functions,,,
@chapter mysys functions

Functions i mysys: (For flags se my_sys.h)
@@ -433,6 +433,205 @@ Functions i mysys: (For flags se my_sys.h)
 void end_key_cache _A((void));
	- End key-cacheing.

@node protocol,,,
@chapter MySQL client/server protocol

Raw packet without compression
============================== 	
-------------------------------------------------
| Packet Length	| Packet no 	| Data		|
| 3 Bytes	| 1 Byte 	| n Bytes	|
-------------------------------------------------

3 Byte packet length
  The length is calculated with int3store
  See include/global.h for details.
  The max packetsize can be 16 MB.
1 Byte packet no

If no compression is used the first 4 bytes of each paket
is the header of the paket.
The packet number is incremented for each sent packet. The first
packet starts with 0		

n Byte data 

The packet length can be recalculated with:
length = byte1 + (256 * byte2) + (256 * 256 * byte3)
		
Raw packet with compression
=========================== 	
-----------------------------------------------------
| Packet Length	| Packet no | Uncomp. Packet Length |
| 3 Bytes	| 1 Byte    | 3 Bytes		    |
-----------------------------------------------------

3 Byte packet length
  The length is calculated with int3store
  See include/global.h for details.
  The max packetsize can be 16 MB.
1 Byte packet no
3 Byte uncompressed packet length

If compression is used the first 7 bytes of each paket
is the header of the paket.
		
Basic packets
==============
OK-packet	
	For details see sql/net_pkg.cc
	function send_ok
	-------------------------------------------------
	| Header	| No of Rows 	| Affected Rows |
	| 		| 1 Byte 	| 1-8 Byte	|
	-------------------------------------------------
	| ID (last_insert_id)	| Status | Length 	|
	| 1-8 Byte		| 2 Byte | 1-8 Byte	|
	-------------------------------------------------
	| Messagetext					|
	| n Byte					|
	-------------------------------------------------

	Header
	1 byte number of rows ? (always 0 ?)
	1-8 bytes affected rows
	1-8 byte id (last_insert_id) 
	2 byte Status (usually 0)
	If the OK-packege includes a message:
	1-8 bytes length of message
	n bytes messagetext

Error-packet	
	-------------------------------------------------
	| Header	| Statuscode	| Error no	|
	| 		| 1 Byte 	| 2 Byte	|
	-------------------------------------------------
	| Messagetext			       | 0x00	|
	| n Byte			       | 1 Byte |
	-------------------------------------------------
	
	Header
	1 byte status code (0xFF = ERROR)
	2 byte error number (is only sent to new 3.23 clients.
	n byte errortext
	1 byte 0x00



The communication
=================

> Packet from server to client
< Paket from client tor server

	Login
	------
		> 1. packet	
		Header
		1 byte protocolversion
		n byte serverversion
		1 byte 0x00
		4 byte threadnumber 
		8 byte crypt seed 
		1 byte 0x00
		2 byte CLIENT_xxx options (see include/mysql_com.h
			that is supported by the server
		1 byte number of current server charset
		2 byte server status variables (SERVER_STATUS_xxx flags)
		13 byte 0x00 (not used yet).

		< 2. packet	
		Header
		2 byte CLIENT_xxx options
		3 byte max_allowed_packet for the client
		n byte username
		1 byte 0x00
		8 byte crypted password
		1 byte 0x00
		n byte databasename
		1 byte 0x00 

		> 3. packet	
		OK-packet


	Command
	--------
		< 1. packet	
		Header
		1 byte command type (e.g.0x03 = query)
		n byte query

	Result set (after command)
	--------------------------
		> 2. packet	
		Header
		1-8 byte field_count (packed with net_store_length())
		
		If field_count == 0 (command): 
		1-8 byte affected rows
		1-8 byte insert id
		2 bytes server_status (SERVER_STATUS_xx) 		
		
		If field_count == NULL_LENGTH (251)
		LOAD DATA LOCAL INFILE

		If field_count > 0 Result Set:

		> n packets	
		Header Info
		Column description: 5 data object /column
		(See code in unpack_fields())
		
		Columninfo for each column:
			1 data block table_name
			    1 byte length of block
			    n byte data
			1 data block field_name
			    1 byte length of block...
			    n byte data
			1 data block display length of field
			    1 byte length of block
			    3 bytes display length of filed
			1 data block type field of type (enum_field_types)
			    1 byte length of block
			    1 bytexs field of type
			1 data block flags
			    1 byte length of block
			    2 byte flags for the columns (NOT_NULL_FLAG, ZEROFILL_FLAG....)
			    1 byte decimals

		if table definition:
			1 data block default value

		Actual result (one packet per row):
		4 byte header
		1-8 byte length of data
		n data
		
 
Fieldtype Codes:
================

		display_length 	|enum_field_type	|flags
		----------------------------------------------------
Blob		03 FF FF 00	|01 FC			|03 90 00 00
Mediumblob	03 FF FF FF	|01 FC			|03 90 00 00
Tinyblob	03 FF 00 00	|01 FC			|03 90 00 00
Text		03 FF FF 00	|01 FC			|03 10 00 00
Mediumtext	03 FF FF FF	|01 FC			|03 10 00 00
Tinytext	03 FF 00 00	|01 FC			|03 10 00 00
Integer		03 0B 00 00	|01 03			|03 03 42 00
Mediumint	03 09 00 00 	|01 09			|03 00 00 00
Smallint	03 06 00 00	|01 02			|03 00 00 00
Tinyint		03 04 00 00	|01 01			|03 00 00 00
Varchar		03 XX 00 00	|01 FD			|03 00 00 00
Enum		03 05 00 00	|01 FE			|03 00 01 00
Datetime	03 13 00 00	|01 0C			|03 00 00 00
Timestamp	03 0E 00 00	|01 07			|03 61 04 00
Time		03 08 00 00	|01 0B			|03 00 00 00
Date		03 0A 00 00	|01 0A			|03 00 00 00


@c The Index was empty, and ugly, so I removed it. (jcole, Sep 7, 2000)

+15 −15
Original line number Diff line number Diff line
@@ -956,14 +956,9 @@ How MySQL Compares to @code{mSQL}
How MySQL Compares to PostgreSQL
* MySQL-PostgreSQL goals::      
* MySQL-PostgreSQL features::   
* MySQL-PostgreSQL benchmarks::  
MySQL and PostgreSQL development goals
* MySQL-PostgreSQL features::   
* MySQL-PostgreSQL benchmarks::  
* MySQL-PostgreSQL goals::      MySQL and PostgreSQL development strategies
* MySQL-PostgreSQL features::   Featurevise Comparison of MySQL and PostgreSQL
* MySQL-PostgreSQL benchmarks::  Benchmarking MySQL and PostgreSQL
MySQL Internals
@@ -2614,6 +2609,10 @@ M2D, a @strong{MySQL} Administration client for Windows. M2D supports
administration of @strong{MySQL} databases, creation of new databases and 
tables, editing, and more.
@item @uref{http://dlabs.4t2.com}
Dexter, a small server written in Perl which can be used as a proxy server for
@strong{MySQL} or as a database extender.
@item @uref{http://www.scibit.com/Products/Software/Utils/Mascon.asp}
Mascon is a powerful Win32 GUI for administering MySQL databases.
@@ -9020,10 +9019,11 @@ course. For example, using @code{mysqld-opt} under NT will not allow
named pipe connections.  You should use either @code{mysqld-nt} or
@code{mysqld-max-nt}.)
If @code{mysqld} doesn't start, please check whether or not the
@file{\mysql\data\mysql.err} file contains any reason for this.  You can also
try to start the server with @code{mysqld --standalone};  In this case, you may
get some useful information on the screen that may help solve the problem.
If @code{mysqld} doesn't start, please check the
@file{\mysql\data\mysql.err} file to see if the server wrote any message
there to indicate the cause of the problem.  You can also try to start
the server with @code{mysqld --standalone};  In this case, you may get
some useful information on the screen that may help solve the problem.
The last option is to start @code{mysqld} with @code{--standalone
--debug}.  In this case @code{mysqld} will write a log file
@@ -9055,9 +9055,9 @@ or
C:\> C:\mysql\bin\mysqld-max-nt --install
@end example
(You can also use @code{mysqld} binaries that don't end with
@code{-nt.exe} on NT, but those cannot be started as a service or use
named pipes.)
(Under Windows NT, you can actually install any of the server binaries
as a service, but only those having names that end with @code{-nt.exe}
provide support for named pipes.)
You can start and stop the @strong{MySQL} service with these commands:
+2 −0
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ Created 1/20/1994 Heikki Tuuri
#ifndef univ_i
#define univ_i

#undef UNIV_INTEL_X86

#if (defined(_WIN32) || defined(_WIN64)) && !defined(MYSQL_SERVER)
#define __WIN__
#include <windows.h>
+3 −5
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ while test $# -gt 0; do
    --mysqld=*)
       TMP=`$ECHO "$1" | $SED -e "s;--mysqld-=;"`
       EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $TMP"
       EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $TMP"
       ;;
    --gcov )
      if [ x$BINARY_DIST = x1 ] ; then
@@ -385,10 +386,8 @@ report_stats () {
	$ECHO ""
        $ECHO "The log files in $MYSQL_TEST_DIR/var/log may give you some hint"
	$ECHO "of what when wrong."
	$ECHO ""
	$ECHO "Please follow the instructions outlined at"
	$ECHO "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
	$ECHO "to find the reason to this problem and how to report this."
	$ECHO "If you want to report this error, please read first the documentation at"
        $ECHO "http://www.mysql.com/doc/M/y/MySQL_test_suite.html"
    fi
}

@@ -475,7 +474,6 @@ start_master()
	    --pid-file=$MASTER_MYPID \
	    --socket=$MASTER_MYSOCK \
            --log=$MASTER_MYLOG --default-character-set=latin1 \
	    --core \
	    --tmpdir=$MYSQL_TMP_DIR \
	    --language=english \
            --innodb_data_file_path=ibdata1:50M \
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
# Bug when using comparions of strings and integers.
#

drop table if exists t1;
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
Loading