Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ed68d5a3
Commit
ed68d5a3
authored
Mar 14, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Massive cleanups to internals.texi.
Docs/internals.texi: Massive cleanups.
parent
bc49942f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
272 additions
and
210 deletions
+272
-210
Docs/internals.texi
Docs/internals.texi
+272
-210
No files found.
Docs/internals.texi
View file @
ed68d5a3
\input
texinfo @c -*-texinfo-*-
@c Copyright
1998
TcX AB, Detron HB and Monty Program KB
@c Copyright
2002 MySQL AB,
TcX AB, Detron HB and Monty Program KB
@c
@c
%**start of header
@setfilename internals.info
@c We want the types in the same index
@c @synindex tp fn cp
@synindex cp fn
@iftex
@c Well this is normal in Europe. Maybe this should go into the include.texi?
@afourpaper
@end iftex
@c Get version and other info
@include include.texi
@ifclear tex-debug
@c This removes the black squares in the right margin
@finalout
@end ifclear
@c Set background for HTML
@set
_
body
_
tags BGCOLOR=#FFFFFF TEXT=#000000 LINK=#101090 VLINK=#7030B0
@settitle @strong
{
MySQL
}
i
nternals Manual for version @value
{
mysql
_
version
}
.
@setchapternewpage o
ff
@settitle @strong
{
MySQL
}
I
nternals Manual for version @value
{
mysql
_
version
}
.
@setchapternewpage o
dd
@paragraphindent 0
@c
%**end of header
@ifinfo
...
...
@@ -35,67 +39,77 @@ END-INFO-DIR-ENTRY
@sp 10
@center @titlefont
{
@strong
{
MySQL
}
Internals Manual
}
@sp 10
@center Copyright @copyright
{}
1998 TcX AB, Detron HB and Monty Program KB
@center Copyright @copyright
{}
1998-2002 MySQL AB
@page
@end titlepage
@node Top,
Introduction
, (dir), (dir)
@node Top,
caching
, (dir), (dir)
@ifinfo
This is a manual about @strong
{
MySQL
}
internals.
@end ifinfo
@menu
* caching:: How MySQL Handles Caching
* flush tables:: How MySQL Handles @code
{
FLUSH TABLES
}
* filesort:: How MySQL Does Sorting (@code
{
filesort
}
)
* coding guidelines:: Coding Guidelines
* mysys functions:: Functions In The @code
{
mysys
}
Library
* DBUG:: DBUG Tags To Use
* protocol:: MySQL Client/Server Protocol
@end menu
@node caching,,,
@chapter How MySQL handles caching
@node caching, flush tables, Top, Top
@chapter How MySQL Handles Caching
@strong
{
MySQL
}
has the following caches:
(Note that the some of the filename have a wrong spelling of cache. :)
@
itemize @bullet
@
table @strong
@item Key
c
ache
@item Key
C
ache
A shared cache for all B-tree index blocks in the different NISAM
files. Uses hashing and reverse linked lists for quick caching of the
last used blocks and quick flushing of changed entries for a specific
table. (@file
{
mysys/mf
_
keycash.c
}
)
@item Record
c
ache
@item Record
C
ache
This is used for quick scanning of all records in a table.
(@file
{
mysys/mf
_
iocash.c
}
and @file
{
isam/
_
cash.c
}
)
@item Table
c
ache
@item Table
C
ache
This holds the last used tables. (@file
{
sql/sql
_
base.cc
}
)
@item Hostname
c
ache
@item Hostname
C
ache
For quick lookup (with reverse name resolving). Is a must when one has a
slow DNS.
(@file
{
sql/hostname.cc
}
)
@item Privilege
c
ache
@item Privilege
C
ache
To allow quick change between databases the last used privileges are
cached for each user/database combination.
(@file
{
sql/sql
_
acl.cc
}
)
@item Heap
table c
ache
Many use of
GROUP BY or DISTINCT caches all found
rows in a HEAP table (this is a very quick in-memory table with hash index
)
@item Heap
Table C
ache
Many use of
@code
{
GROUP BY
}
or @code
{
DISTINCT
}
caches all found rows in
a @code
{
HEAP
}
table. (This is a very quick in-memory table with hash index.
)
@item Join
row cache.
For every full join in a
SELECT statement (a full join here means there
were no keys that one could use to find the next table in a list), the
found rows are cached in a join cache. One SELECT query can use many
join caches in the worst case.
@end
itemiz
e
@item Join
Row Cache
For every full join in a
@code
{
SELECT
}
statement (a full join here means
there were no keys that one could use to find the next table in a list),
the found rows are cached in a join cache. One @code
{
SELECT
}
query can
use many
join caches in the worst case.
@end
tabl
e
@node flush tables,,,
@chapter How MySQL handles flush tables
@node flush tables, filesort, caching, Top
@chapter How MySQL Handles @code
{
FLUSH TABLES
}
@itemize @bullet
@item
Flush tables is handled in @
cod
e
{
sql/sql
_
base.cc::close
_
cached
_
tables()
}
.
Flush tables is handled in @
fil
e
{
sql/sql
_
base.cc::close
_
cached
_
tables()
}
.
@item
The idea of flush tables is to force all tables to be closed. This
...
...
@@ -109,8 +123,8 @@ all tables)!
When one does a @code
{
FLUSH TABLES
}
, the variable @code
{
refresh
_
version
}
will be incremented. Every time a thread releases a table it checks if
the refresh version of the table (updated at open) is the same as
the current
refresh
_
version
. If not it will close it and broadcast
a signal on
COND
_
refresh
(to wait any thread that is waiting for
the current
@code
{
refresh
_
version
}
. If not it will close it and broadcast
a signal on
@code
{
COND
_
refresh
}
(to wait any thread that is waiting for
all instanses of a table to be closed).
@item
...
...
@@ -119,8 +133,8 @@ The current @code{refresh_version} is also compared to the open
refresh version is different the thread will free all locks, reopen the
table and try to get the locks again; This is just to quickly get all
tables to use the newest version. This is handled by
@
cod
e
{
sql/lock.cc::mysql
_
lock
_
tables()
}
and
@
cod
e
{
sql/sql
_
base.cc::wait
_
for
_
tables()
}
.
@
fil
e
{
sql/lock.cc::mysql
_
lock
_
tables()
}
and
@
fil
e
{
sql/sql
_
base.cc::wait
_
for
_
tables()
}
.
@item
When all tables has been closed @code
{
FLUSH TABLES
}
will return an ok
...
...
@@ -134,8 +148,8 @@ After this it will give other threads a chance to open the same tables.
@end itemize
@node
Filesort,,,
@chapter How MySQL
does sorting (filesort
)
@node
filesort, coding guidelines, flush tables, Top
@chapter How MySQL
Does Sorting (@code
{
filesort
}
)
@itemize @bullet
...
...
@@ -146,7 +160,7 @@ Read all rows according to key or by table scanning.
Store the sort-key in a buffer (@code
{
sort
_
buffer
}
).
@item
When the buffer gets full, run a
qsort
on it and store the result
When the buffer gets full, run a
@code
{
qsort
}
on it and store the result
in a temporary file. Save a pointer to the sorted block.
@item
...
...
@@ -174,8 +188,9 @@ and then we read the rows in the sorted order into a row buffer
@end itemize
@node Coding guidelines,,,
@chapter Coding guidelines
@node coding guidelines, mysys functions, filesort, Top
@chapter Coding Guidelines
@itemize @bullet
...
...
@@ -225,23 +240,23 @@ Don't use two commands on the same line.
Do not check the same pointer for @code
{
NULL
}
more than once.
@item
Use long function and variable names in English
;
This makes your code
Use long function and variable names in English
.
This makes your code
easier to read.
@item
Use
my
_
var as opposed to myVar or MyVar (@samp
{_}
rather than dancing SHIFT
to seperate words in identifiers).
Use
@code
{
my
_
var
}
as opposed to @code
{
myVar
}
or @code
{
MyVar
}
(@samp
{_}
rather than dancing SHIFT
to seperate words in identifiers).
@item
Think assembly - make it easier for the compiler to optimize your code.
@item
Comment your code when you do something that someone else may think
is not
''
trivial''.
is not
``
trivial''.
@item
Use @code
{
libstring
}
functions (in the
strings
directory)
instead of standard
libc
string functions whenever possible.
Use @code
{
libstring
}
functions (in the
@file
{
strings
}
directory)
instead of standard
@code
{
libc
}
string functions whenever possible.
@item
Avoid using @code
{
malloc()
}
(its REAL slow); For memory allocations
...
...
@@ -268,26 +283,25 @@ Any @code{#define}'s are in all-caps.
Matching @samp
{
@
{}
are in the same column.
@item
Put the @samp
{
@
{}
after a 'switch' on the same line
Put the @samp
{
@
{}
after a @code
{
switch
}
on the same line, as this gives
better overall indentation for the switch statement:
@example
switch (arg)
{
@end example
Because this gives better overall indentation for the switch statement.
@item
In all other cases, @
{
and @
}
should be on their own line, except
if there is nothing inside @
{
@
}
.
In all other cases, @
samp
{
@
{}
and @samp
{
@
}
}
should be on their own line, except
if there is nothing inside @
samp
{
@
{}
and @samp
{
@
}
}
.
@item
Have a space after
'if'
Have a space after
@code
{
if
}
@item
Put a space after
','
for function arguments
Put a space after
@samp
{
,
}
for function arguments
@item
Functions return
0
on success, and non-zero on error, so you can do:
Functions return
@samp
{
0
}
on success, and non-zero on error, so you can do:
@example
if(a() || b() || c())
{
error("something went wrong");
}
...
...
@@ -335,113 +349,110 @@ Suggested mode in emacs:
(setq c-default-style "MY")
@end example
@node mysys functions,,,
@chapter mysys functions
Functions i mysys: (For flags se my
_
sys.h)
int my
_
copy
_
A((const char *from,const char *to,myf MyFlags));
- Copy file
int my
_
delete
_
A((const char *name,myf MyFlags));
- Delete file
int my
_
getwd
_
A((string buf,uint size,myf MyFlags));
int my
_
setwd
_
A((const char *dir,myf MyFlags));
- Get and set working directory
string my
_
tempnam
_
A((const char *pfx,myf MyFlags));
- Make a uniq temp file name by using dir and adding something after
pfx to make name uniq. Name is made by adding a uniq 6 length-string
and TMP
_
EXT after pfx.
Returns pointer to malloced area for filename. Should be freed by
free().
File my
_
open
_
A((const char *FileName,int Flags,myf MyFlags));
File my
_
create
_
A((const char *FileName,int CreateFlags,
int AccsesFlags, myf MyFlags));
int my
_
close
_
A((File Filedes,myf MyFlags));
uint my
_
read
_
A((File Filedes,byte *Buffer,uint Count,myf MyFlags));
uint my
_
write
_
A((File Filedes,const byte *Buffer,uint Count,
myf MyFlags));
ulong my
_
seek
_
A((File fd,ulong pos,int whence,myf MyFlags));
ulong my
_
tell
_
A((File fd,myf MyFlags));
- Use instead of open,open-with-create-flag, close read and write
to get automatic error-messages (flag: MYF
_
WME) and only have
to test for != 0 if error (flag: MY
_
NABP).
int my
_
rename
_
A((const char *from,const char *to,myf MyFlags));
- Rename file
FILE *my
_
fopen
_
A((const char *FileName,int Flags,myf MyFlags));
FILE *my
_
fdopen
_
A((File Filedes,int Flags,myf MyFlags));
int my
_
fclose
_
A((FILE *fd,myf MyFlags));
uint my
_
fread
_
A((FILE *stream,byte *Buffer,uint Count,myf MyFlags));
uint my
_
fwrite
_
A((FILE *stream,const byte *Buffer,uint Count,
myf MyFlags));
ulong my
_
fseek
_
A((FILE *stream,ulong pos,int whence,myf MyFlags));
ulong my
_
ftell
_
A((FILE *stream,myf MyFlags));
- Same read-interface for streams as for files
gptr
_
mymalloc
_
A((uint uSize,const char *sFile,
uint uLine, myf MyFlag));
gptr
_
myrealloc
_
A((string pPtr,uint uSize,const char *sFile,
uint uLine, myf MyFlag));
void
_
myfree
_
A((gptr pPtr,const char *sFile,uint uLine));
int
_
sanity
_
A((const char *sFile,unsigned int uLine));
gptr
_
myget
_
copy
_
of
_
memory
_
A((const byte *from,uint length,
const char *sFile, uint uLine,
myf MyFlag));
- malloc(size,myflag) is mapped to this functions if not compiled
with -DSAFEMALLOC
void TERMINATE
_
A((void));
- Writes malloc-info on stdout if compiled with -DSAFEMALLOC.
int my
_
chsize
_
A((File fd,ulong newlength,myf MyFlags));
- Change size of file
void my
_
error
_
D((int nr,myf MyFlags, ...));
- Writes message using error number (se mysys/errors.h) on
stdout or curses if MYSYS
_
PROGRAM
_
USES
_
CURSES() is called.
void my
_
message
_
A((const char *str,myf MyFlags));
- Writes message-string on
stdout or curses if MYSYS
_
PROGRAM
_
USES
_
CURSES() is called.
void my
_
init
_
A((void ));
- Start each program (in main) with this.
void my
_
end
_
A((int infoflag));
- Gives info about program.
- If infoflag
&
MY
_
CHECK
_
ERROR prints if some files are left open
- If infoflag
&
MY
_
GIVE
_
INFO prints timing info and malloc info
about prog.
int my
_
redel
_
A((const char *from, const char *to, int MyFlags));
- Delete from before rename of to to from. Copyes state from old
file to new file. If MY
_
COPY
_
TIME is set sets old time.
int my
_
copystat
_
A((const char *from, const char *to, int MyFlags));
- Copye state from old file to new file.
If MY
_
COPY
_
TIME is set sets copy also time.
string my
_
filename
_
A((File fd));
- Give filename of open file.
int dirname
_
A((string to,const char *name));
- Copy name of directory from filename.
int test
_
if
_
hard
_
path
_
A((const char *dir
_
name));
- Test if dirname is a hard path (Starts from root)
void convert
_
dirname
_
A((string name));
- Convert dirname acording to system.
- In MSDOS changes all caracters to capitals and changes '/' to
'
\'
string fn
_
ext
_
A((const char *name));
- Returns pointer to extension in filename
string fn
_
format
_
A((string to,const char *name,const char *dsk,
const char *form,int flag));
@node mysys functions, DBUG, coding guidelines, Top
@chapter Functions In The @code
{
mysys
}
Library
Functions in @code
{
mysys
}
: (For flags see @file
{
my
_
sys.h
}
)
@table @code
@item int my
_
copy
_
A((const char *from, const char *to, myf MyFlags));
Copy file from @code
{
from
}
to @code
{
to
}
.
@item int my
_
delete
_
A((const char *name, myf MyFlags));
Delete file @code
{
name
}
.
@item int my
_
getwd
_
A((string buf, uint size, myf MyFlags));
@item int my
_
setwd
_
A((const char *dir, myf MyFlags));
Get and set working directory.
@item string my
_
tempnam
_
A((const char *pfx, myf MyFlags));
Make a unique temporary file name by using dir and adding something after
@code
{
pfx
}
to make name unique. The file name is made by adding a unique
six character string and @code
{
TMP
_
EXT
}
after @code
{
pfx
}
.
Returns pointer to @code
{
malloc()
}
'ed area for filename. Should be freed by
@code
{
free()
}
.
@item File my
_
open
_
A((const char *FileName,int Flags,myf MyFlags));
@item File my
_
create
_
A((const char *FileName, int CreateFlags, int AccsesFlags, myf MyFlags));
@item int my
_
close
_
A((File Filedes, myf MyFlags));
@item uint my
_
read
_
A((File Filedes, byte *Buffer, uint Count, myf MyFlags));
@item uint my
_
write
_
A((File Filedes, const byte *Buffer, uint Count, myf MyFlags));
@item ulong my
_
seek
_
A((File fd,ulong pos,int whence,myf MyFlags));
@item ulong my
_
tell
_
A((File fd,myf MyFlags));
Use instead of open, open-with-create-flag, close, read, and write
to get automatic error messages (flag @code
{
MYF
_
WME
}
) and only have
to test for != 0 if error (flag @code
{
MY
_
NABP
}
).
@item int my
_
rename
_
A((const char *from, const char *to, myf MyFlags));
Rename file from @code
{
from
}
to @code
{
to
}
.
@item FILE *my
_
fopen
_
A((const char *FileName,int Flags,myf MyFlags));
@item FILE *my
_
fdopen
_
A((File Filedes,int Flags,myf MyFlags));
@item int my
_
fclose
_
A((FILE *fd,myf MyFlags));
@item uint my
_
fread
_
A((FILE *stream,byte *Buffer,uint Count,myf MyFlags));
@item uint my
_
fwrite
_
A((FILE *stream,const byte *Buffer,uint Count, myf MyFlags));
@item ulong my
_
fseek
_
A((FILE *stream,ulong pos,int whence,myf MyFlags));
@item ulong my
_
ftell
_
A((FILE *stream,myf MyFlags));
Same read-interface for streams as for files.
@item gptr
_
mymalloc
_
A((uint uSize,const char *sFile,uint uLine, myf MyFlag));
@item gptr
_
myrealloc
_
A((string pPtr,uint uSize,const char *sFile,uint uLine, myf MyFlag));
@item void
_
myfree
_
A((gptr pPtr,const char *sFile,uint uLine));
@item int
_
sanity
_
A((const char *sFile,unsigned int uLine));
@item gptr
_
myget
_
copy
_
of
_
memory
_
A((const byte *from,uint length,const char *sFile, uint uLine,myf MyFlag));
@code
{
malloc(size,myflag)
}
is mapped to these functions if not compiled
with @code
{
-DSAFEMALLOC
}
.
@item void TERMINATE
_
A((void));
Writes @code
{
malloc()
}
info on @code
{
stdout
}
if compiled with
@code
{
-DSAFEMALLOC
}
.
@item int my
_
chsize
_
A((File fd, ulong newlength, myf MyFlags));
Change size of file @code
{
fd
}
to @code
{
newlength
}
.
@item void my
_
error
_
D((int nr, myf MyFlags, ...));
Writes message using error number (see @file
{
mysys/errors.h
}
) on @code
{
stdout
}
,
or using curses, if @code
{
MYSYS
_
PROGRAM
_
USES
_
CURSES()
}
has been called.
@item void my
_
message
_
A((const char *str, myf MyFlags));
Writes @code
{
str
}
on @code
{
stdout
}
, or using curses, if
@code
{
MYSYS
_
PROGRAM
_
USES
_
CURSES()
}
has been called.
@item void my
_
init
_
A((void ));
Start each program (in @code
{
main()
}
) with this.
@item void my
_
end
_
A((int infoflag));
Gives info about program.
If @code
{
infoflag
&
MY
_
CHECK
_
ERROR
}
, prints if some files are left open.
If @code
{
infoflag
&
MY
_
GIVE
_
INFO
}
, prints timing info and malloc info
about program.
@item int my
_
redel
_
A((const char *from, const char *to, int MyFlags));
Delete @code
{
from
}
before rename of @code
{
to
}
to @code
{
from
}
. Copies state
from old file to new file. If @code
{
MY
_
COPY
_
TIME
}
is set, sets old time.
@item int my
_
copystat
_
A((const char *from, const char *to, int MyFlags));
Copy state from old file to new file. If @code
{
MY
_
COPY
_
TIME
}
is set,
sets old time.
@item string my
_
filename
_
A((File fd));
Returns filename of open file.
@item int dirname
_
A((string to, const char *name));
Copy name of directory from filename.
@item int test
_
if
_
hard
_
path
_
A((const char *dir
_
name));
Test if @code
{
dir
_
name
}
is a hard path (starts from root).
@item void convert
_
dirname
_
A((string name));
Convert dirname according to system.
In MSDOS, changes all characters to capitals and changes @samp
{
/
}
to @samp
{
\}
.
@item string fn
_
ext
_
A((const char *name));
Returns pointer to extension in filename.
@item string fn
_
format
_
A((string to,const char *name,const char *dsk,const char *form,int flag));
format a filename with replace of library and extension and
converts between different systems.
params to and name may be identicall
...
...
@@ -455,60 +466,93 @@ Functions i mysys: (For flags se my_sys.h)
"open(fn
_
format(temp
_
buffe,name,"","",4),...)" to unpack home and
convert filename to system-form.
string fn
_
same
_
A((string toname,const char *name,int flag));
- Copys directory and extension from name to toname if neaded.
copy can be forced by same flags that in fn
_
format.
@item string fn
_
same
_
A((string toname, const char *name, int flag));
Copys directory and extension from @code
{
name
}
to @code
{
toname
}
if neaded.
Copying can be forced by same flags used in @code
{
fn
_
format()
}
.
@item int wild
_
compare
_
A((const char *str, const char *wildstr));
Compare if @code
{
str
}
matches @code
{
wildstr
}
. @code
{
wildstr
}
can contain
@samp
{
*
}
and @samp
{
?
}
as wildcard characters.
Returns 0 if @code
{
str
}
and @code
{
wildstr
}
match.
int wild
_
compare
_
A((const char *str,const char *wildstr));
- Compare if str matches wildstr. Wildstr can contain "*" and "?"
as match-characters.
Returns 0 if match.
@item void get
_
date
_
A((string to, int timeflag));
Get current date in a form ready for printing.
void get
_
date
_
A((string to,int timeflag));
- Get current date in a form ready for printing.
@item void soundex
_
A((string out
_
pntr, string in
_
pntr))
Makes @code
{
in
_
pntr
}
to a 5 char long string. All words that sound
alike have the same string.
void soundex
_
A((string out
_
pntr, string in
_
pntr))
- Makes in
_
pntr to a 5 chars long string. All words that sounds
alike have the same string.
@item int init
_
key
_
cache
_
A((ulong use
_
mem, ulong leave
_
this
_
much
_
mem));
Use caching of keys in MISAM, PISAM, and ISAM.
@code
{
KEY
_
CACHE
_
SIZE
}
is a good size.
Remember to lock databases for optimal caching.
int init
_
key
_
cache
_
A((ulong use
_
mem,ulong leave
_
this
_
much
_
mem));
- Use cacheing of keys in MISAM, PISAM, and ISAM.
KEY
_
CACHE
_
SIZE is a good size.
- Remember to lock databases for optimal cacheing
@item void end
_
key
_
cache
_
A((void));
End key caching.
void end
_
key
_
cache
_
A((void));
- End key-cacheing.
@node DBUG,
,,
@chapter
The DBUG tags to use:
@node DBUG,
protocol, mysys functions, Top
@chapter
DBUG Tags To Use
Here is some of the tags we now use:
(We should probably add a couple of new ones)
"enter" Arguments to the function.
"exit" Results from the function.
"info" is something that may be interesting.
"warning" is when something doesn't go the usual route or may be wrong.
"error" when something went wrong.
"loop" write in a loop, that is probably only useful when debugging
the loop. These should normally be deleted when on is
satisfied with the code and it has been in real use for a while.
@table @code
@item enter
Arguments to the function.
@item exit
Results from the function.
@item info
Something that may be interesting.
@item warning
When something doesn't go the usual route or may be wrong.
@item error
When something went wrong.
@item loop
Write in a loop, that is probably only useful when debugging
the loop. These should normally be deleted when one is
satisfied with the code and it has been in real use for a while.
@end table
Some specific to mysqld, because we want to watch these carefully:
"trans" Starting/stopping transactions.
"quit" 'info' when mysqld is preparing to die.
"query" Print query
@table @code
@item trans
Starting/stopping transactions.
@item quit
@code
{
info
}
when mysqld is preparing to die.
@item query
Print query.
@end table
@node protocol,,,
@chapter MySQL client/server protocol
Raw packet without compression
==============================
@node protocol, , DBUG, Top
@chapter MySQL Client/Server Protocol
@menu
* raw packet without compression::
* raw packet with compression::
* basic packets::
* communication::
* fieldtype codes::
@end menu
@node raw packet without compression, raw packet with compression, protocol, protocol
@section Raw Packet Without Compression
@example
-------------------------------------------------
| Packet Length | Packet no | Data |
| 3 Bytes | 1 Byte | n Bytes |
-------------------------------------------------
@end example
3 Byte packet length
The length is calculated with int3store
...
...
@@ -526,12 +570,15 @@ n Byte data
The packet length can be recalculated with:
length = byte1 + (256 * byte2) + (256 * 256 * byte3)
Raw packet with compression
===========================
@node raw packet with compression, basic packets, raw packet without compression, protocol
@section Raw Packet With Compression
@example
-----------------------------------------------------
| Packet Length | Packet no | Uncomp. Packet Length |
| 3 Bytes | 1 Byte | 3 Bytes |
-----------------------------------------------------
@end example
3 Byte packet length
The length is calculated with int3store
...
...
@@ -540,14 +587,23 @@ Raw packet with compression
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.
If compression is used the first 7 bytes of each packet
is the header of the packet.
@node basic packets, communication, raw packet with compression, protocol
@section Basic Packets
@menu
* ok packet::
* error packet::
@end menu
@node ok packet, error packet, basic packets, basic packets
@subsection OK Packet
Basic packets
==============
OK-packet
For details see sql/net
_
pkg.cc
function send
_
ok
@example
-------------------------------------------------
| Header | No of Rows | Affected Rows |
| | 1 Byte | 1-8 Byte |
...
...
@@ -558,6 +614,7 @@ OK-packet
| Messagetext |
| n Byte |
-------------------------------------------------
@end example
Header
1 byte number of rows ? (always 0 ?)
...
...
@@ -568,7 +625,11 @@ OK-packet
1-8 bytes length of message
n bytes messagetext
Error-packet
@node error packet, , ok packet, basic packets
@subsection Error Packet
@example
-------------------------------------------------
| Header | Statuscode | Error no |
| | 1 Byte | 2 Byte |
...
...
@@ -576,6 +637,7 @@ Error-packet
| Messagetext | 0x00 |
| n Byte | 1 Byte |
-------------------------------------------------
@end example
Header
1 byte status code (0xFF = ERROR)
...
...
@@ -584,9 +646,8 @@ Error-packet
1 byte 0x00
The communication
=================
@node communication, fieldtype codes, basic packets, protocol
@section Communication
> Packet from server to client
< Paket from client tor server
...
...
@@ -677,9 +738,10 @@ The communication
n data
Fieldtype Codes:
================
@node fieldtype codes, , communication, protocol
@section Fieldtype Codes
@example
display
_
length |enum
_
field
_
type |flags
----------------------------------------------------
Blob 03 FF FF 00 |01 FC |03 90 00 00
...
...
@@ -698,7 +760,7 @@ 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
@end example
@c The Index was empty, and ugly, so I removed it. (jcole, Sep 7, 2000)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment