Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
mariadb
Commits
97745efd
Commit
97745efd
authored
24 years ago
by
unknown
Browse files
Options
Download
Plain Diff
merge
sql/mysqld.cc: Auto merged sql/sql_select.cc: Auto merged
parents
3be2018a
e3bf73c1
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
408 additions
and
169 deletions
+408
-169
Docs/internals.texi
Docs/internals.texi
+59
-0
Docs/manual.texi
Docs/manual.texi
+275
-147
client/mysql.cc
client/mysql.cc
+18
-8
client/mysqlimport.c
client/mysqlimport.c
+1
-2
include/config-win.h
include/config-win.h
+2
-0
include/global.h
include/global.h
+1
-1
libmysql/libmysql.c
libmysql/libmysql.c
+4
-3
myisam/ChangeLog
myisam/ChangeLog
+4
-0
myisam/Makefile.am
myisam/Makefile.am
+1
-1
myisam/ft_stopwords.c
myisam/ft_stopwords.c
+1
-1
myisam/mi_delete_table.c
myisam/mi_delete_table.c
+7
-0
myisam/mi_rename.c
myisam/mi_rename.c
+8
-0
myisam/mi_rnext.c
myisam/mi_rnext.c
+1
-1
myisam/mi_rprev.c
myisam/mi_rprev.c
+1
-1
myisam/mi_search.c
myisam/mi_search.c
+1
-0
myisam/myisamdef.h
myisam/myisamdef.h
+2
-0
scripts/make_binary_distribution.sh
scripts/make_binary_distribution.sh
+1
-1
sql/ha_heap.cc
sql/ha_heap.cc
+15
-0
sql/ha_heap.h
sql/ha_heap.h
+4
-1
sql/handler.cc
sql/handler.cc
+2
-2
No files found.
Docs/internals.texi
View file @
97745efd
...
...
@@ -143,6 +143,65 @@ same tables.
and then we read the rows in the sorted order into a row buffer
(record
_
buffer) .
@node Coding guidelines
@chapter Coding guidelines
- We are using bitkeeper (www.bitkeeper.com) for source management.
- You should use the MySQL 3.23 or MySQL 4.0 source for all developments.
- If you have any questions about the MySQL source, you can post these
to developers@mysql.com and we will answer them.
Note that we will shortly change the name of this list to
internals@mysql.com, to more accurately reflect what should be
posted to this list.
- Try to write code in a lot of black boxes that can be reused or at
least have a clean interface
- Reuse code; There is already in MySQL a lot of algorithms for list handling,
queues, dynamic and hashed arrays, sorting...) that can be reused.
- Try to always write optimized code, so that you don't have to
go back and rewrite it a couple of months later. It's better to
spend 3 times as much time designing and writing and optimal function than
having to do it all over again later on.
- Avoid CPU wasteful code, even where it does not matter, so that
you will not develop sloppy coding habits.
- If you can write it in fewer lines, do it (as long as the code will not
be slower or much harder to read)
- do not check the same pointer for NULL more than once.
- Use long function and variable names in English; This makes your
code easier to read.
- Think assembly - make it easier for the compiler to optimize your code.
- Comment your code when you do something that someone else may think
is 'not trivial'.
- Use the my
_
functions like my
_
read/my
_
write/my
_
malloc() that you can
find in the mysys library instead of the direct system calls; This
will make your code easier to debug and more portable.
- use libstring functions instead of standard libc string functions
whenever possible
- Avoid using alloc (its REAL slow); For memory allocations that only
needs to live for the lifetime of one thread, on should use
sql
_
alloc() instead.
- Before doing big design decision, please first post a summary of
what you want to do, why you want to do it and how you plan to do
it. This way we can easily provide you with feedback and also
easily discuss is throughly if some other developer thinks there is better
way to do the same thing!
- Use my
_
var as opposed to myVar or MyVar (
_
rather than dancing SHIFT
to spearate words in identifiers)
- class names start with a capital
- structure types are typedefed to all caps identifier
- #defines are capitalized
- matching
{
are in the same column
- functions return 0 on success , non-zero on error, so you can do
if(a() || b() || c())
{
error("something went wrong");
}
- goto is ok if not abused
- avoid default variable initalizations, use LINT
_
INIT() if the
compiler complains after making sure that there is really no way
the variable can be used uninitialized
- Do not instantiate a class if you do not have to
- Use pointers rather than array indexing when operating on strings
@node Index
@unnumbered Index
...
...
This diff is collapsed.
Click to expand it.
Docs/manual.texi
View file @
97745efd
This diff is collapsed.
Click to expand it.
client/mysql.cc
View file @
97745efd
...
...
@@ -114,7 +114,7 @@ static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
no_rehash=0,skip_updates=0,safe_updates=0,one_database=0,
opt_compress=0,
vertical=0,skip_line_numbers=0,skip_column_names=0,opt_html=0,
no_named_cmds
=
0
;
no_named_cmds=
1; // we want this to be the default
static uint verbose=0,opt_silent=0,opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE;
...
...
@@ -160,7 +160,7 @@ typedef struct {
static COMMANDS commands[] = {
{ "help", 'h', com_help, 0, "Display this text" },
{
"?"
,
'
h
'
,
com_help
,
0
,
"Synonym for `help'"
},
{ "?", '
?
', com_help, 0, "Synonym for `help'" },
{ "clear", 'c', com_clear, 0, "Clear command"},
{ "connect",'r', com_connect,1,
"Reconnect to the server. Optional arguments are db and host" },
...
...
@@ -300,7 +300,7 @@ int main(int argc,char *argv[])
}
}
#endif
sprintf
(
buff
,
"Type '
%s' for help.
\n
"
,
no_named_cmds
?
"
\\
h"
:
"
help"
);
sprintf(buff, "Type '
help;' or '\\h' for
help
.\n
");
put_info(buff,INFO_INFO);
status.exit_status=read_lines(1); // read lines and execute them
mysql_end(0);
...
...
@@ -352,6 +352,7 @@ static struct option long_options[] =
{"database", required_argument, 0, 'D'},
{"debug-info", no_argument, 0, 'T'},
{"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET},
{"enable-named-commands", no_argument, 0, 'G'},
{"execute", required_argument, 0, 'e'},
{"force", no_argument, 0, 'f'},
{"help", no_argument, 0, '?'},
...
...
@@ -401,7 +402,7 @@ CHANGEABLE_VAR changeable_vars[] = {
static void usage(int version)
{
printf
(
"%s Ver 10.
8
Distrib %s, for %s (%s)
\n
"
,
printf("%s Ver 10.
10
Distrib %s, for %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version)
return;
...
...
@@ -426,11 +427,17 @@ static void usage(int version)
-D, --database=.. Database to use.\n\
--default-character-set=...\n\
Set the default character set.\n\
-G, --enable-named-commands\n\
Named commands are enabled. Opposite to -g.\n\
-e, --execute=... Execute command and quit. (Output like with --batch)\n\
-E, --vertical Print the output of a query (rows) vertically.\n\
-f, --force Continue even if we get an sql error.\n\
-g, --no-named-commands\n\
Named commands are disabled. Use
\\
* form only.
\n
\
Named commands are disabled. Use \\* form only, or\n\
use named commands only in the beginning of a line\n\
ending with a semicolon (;)\n\
Since version 10.9 the client now starts with this\n\
option ENABLED by default! Disable with '-G'\n\
-i, --ignore-space Ignore space after function names.\n\
-h, --host=... Connect to host.\n\
-H, --html Produce HTML output.\n\
...
...
@@ -486,7 +493,7 @@ static int get_options(int argc, char **argv)
bool tty_password=0;
set_all_changeable_vars(changeable_vars);
while
((
c
=
getopt_long
(
argc
,
argv
,
"?ABCD:LfgHinNoqrstTUvVwWEe:h:O:P:S:u:#::p::"
,
while ((c=getopt_long(argc,argv,"?ABCD:Lfg
G
HinNoqrstTUvVwWEe:h:O:P:S:u:#::p::",
long_options, &option_index)) != EOF)
{
switch(c) {
...
...
@@ -565,6 +572,7 @@ static int get_options(int argc, char **argv)
case 'E': vertical=1; break;
case 'w': wait_flag=1; break;
case 'A': no_rehash=1; break;
case 'G': no_named_cmds=0; break;
case 'g': no_named_cmds=1; break;
case 'H': opt_html=1; break;
case 'i': connect_flag|= CLIENT_IGNORE_SPACE; break;
...
...
@@ -1171,11 +1179,13 @@ com_help (String *buffer __attribute__((unused)),
reg1 int i;
put_info("\nMySQL commands:",INFO_INFO);
if (no_named_cmds)
put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO);
for (i = 0; commands[i].name; i++)
{
if (commands[i].func)
printf
(
"%s
\t
(
\\
%c)
\t
%s
\n
"
,
commands
[
i
].
name
,
commands
[
i
].
cmd_char
,
commands
[
i
].
doc
);
printf("%s\t(\\%c)\t%s\n", commands[i].name,
commands[i].cmd_char,
commands[i].doc);
}
if (connected)
printf("\nConnection id: %ld (Can be used with mysqladmin kill)\n\n",
...
...
This diff is collapsed.
Click to expand it.
client/mysqlimport.c
View file @
97745efd
...
...
@@ -25,7 +25,7 @@
** * *
** *************************
*/
#define IMPORT_VERSION "2.
3
"
#define IMPORT_VERSION "2.
4
"
#include <global.h>
#include <my_sys.h>
...
...
@@ -514,7 +514,6 @@ int main(int argc, char **argv)
exitcode
=
error
;
db_disconnect
(
current_host
,
sock
);
my_free
(
password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
current_user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
free_defaults
(
argv_to_free
);
my_end
(
0
);
return
(
exitcode
);
...
...
This diff is collapsed.
Click to expand it.
include/config-win.h
View file @
97745efd
...
...
@@ -250,6 +250,8 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_RINT
/* defined in this file */
#define NO_FCNTL_NONBLOCK
/* No FCNTL */
#define HAVE_ALLOCA
#define HAVE_STRPBRK
#define HAVE_STRSTR
#define HAVE_COMPRESS
#ifdef NOT_USED
...
...
This diff is collapsed.
Click to expand it.
include/global.h
View file @
97745efd
...
...
@@ -110,7 +110,7 @@
#endif
/* In Linux-alpha we have atomic.h if we are using gcc */
#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95))
#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95))
&& !defined(HAVE_ATOMIC_ADD)
#define HAVE_ATOMIC_ADD
#define HAVE_ATOMIC_SUB
#endif
...
...
This diff is collapsed.
Click to expand it.
libmysql/libmysql.c
View file @
97745efd
...
...
@@ -112,7 +112,8 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
*****************************************************************************/
static
int
connect2
(
File
s
,
const
struct
sockaddr
*
name
,
uint
namelen
,
uint
to
)
static
int
connect2
(
my_socket
s
,
const
struct
sockaddr
*
name
,
uint
namelen
,
uint
to
)
{
#if defined(__WIN__)
return
connect
(
s
,
(
struct
sockaddr
*
)
name
,
namelen
);
...
...
@@ -1138,7 +1139,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
uint
port
,
const
char
*
unix_socket
,
uint
client_flag
)
{
char
buff
[
100
],
charset_name_buff
[
16
],
*
end
,
*
host_info
,
*
charset_name
;
int
sock
;
my_socket
sock
;
uint32
ip_addr
;
struct
sockaddr_in
sock_addr
;
uint
pkt_length
;
...
...
@@ -1270,7 +1271,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
sprintf
(
host_info
=
buff
,
ER
(
CR_TCP_CONNECTION
),
host
);
DBUG_PRINT
(
"info"
,(
"Server name: '%s'. TCP sock: %d"
,
host
,
port
));
/* _WIN64 ; Assume that the (int) range is enough for socket() */
if
((
sock
=
(
in
t
)
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
SOCKET_ERROR
)
if
((
sock
=
(
my_socke
t
)
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
SOCKET_ERROR
)
{
net
->
last_errno
=
CR_IPSOCK_ERROR
;
sprintf
(
net
->
last_error
,
ER
(
net
->
last_errno
),
ERRNO
);
...
...
This diff is collapsed.
Click to expand it.
myisam/ChangeLog
View file @
97745efd
2000-08-23 Michael Widenius <monty@mysql.com>
* Fixed bug when comparing DECIMAL/NUMERIC key parts.
2000-08-17 Michael Widenius <monty@mysql.com>
* Add a new flag in share.staus so that we can quickly check if a table
...
...
This diff is collapsed.
Click to expand it.
myisam/Makefile.am
View file @
97745efd
...
...
@@ -43,7 +43,7 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
mi_rsamepos.c mi_panic.c mi_close.c mi_create.c
\
mi_range.c mi_dbug.c mi_checksum.c mi_log.c
\
mi_changed.c mi_static.c mi_delete_all.c
\
mi_delete_table.c mi_rename.c mi_check.c
\
mi_delete_table.c mi_rename.c mi_check.c
mi_debug.c
\
ft_parser.c ft_search.c ft_stopwords.c ft_static.c
\
ft_update.c sort.c
CLEANFILES
=
test
?.IS? isam.log mi_test_all
...
...
This diff is collapsed.
Click to expand it.
myisam/ft_stopwords.c
View file @
97745efd
...
...
@@ -48,7 +48,7 @@ int ft_init_stopwords(const char **sws)
for
(;
*
sws
;
sws
++
)
{
if
(
(
sw
.
len
=
strlen
(
sw
.
pos
=*
sws
))
<
MIN_WORD_LEN
)
continue
;
if
(
(
sw
.
len
=
(
uint
)
strlen
(
sw
.
pos
=*
sws
))
<
MIN_WORD_LEN
)
continue
;
if
(
!
tree_insert
(
stopwords3
,
&
sw
,
0
))
{
delete_tree
(
stopwords3
);
...
...
This diff is collapsed.
Click to expand it.
myisam/mi_delete_table.c
View file @
97745efd
...
...
@@ -30,6 +30,10 @@ int mi_delete_table(const char *name)
uint
raid_type
=
0
,
raid_chunks
=
0
;
#endif
DBUG_ENTER
(
"mi_delete_table"
);
#ifdef EXTRA_DEBUG
check_table_is_closed
(
name
,
"delete"
);
#endif
#ifdef USE_RAID
{
MI_INFO
*
info
;
...
...
@@ -39,7 +43,10 @@ int mi_delete_table(const char *name)
raid_chunks
=
info
->
s
->
base
.
raid_chunks
;
mi_close
(
info
);
}
#ifdef EXTRA_DEBUG
check_table_is_closed
(
name
,
"delete"
);
#endif
#endif
/* USE_RAID */
fn_format
(
from
,
name
,
""
,
MI_NAME_IEXT
,
4
);
if
(
my_delete
(
from
,
MYF
(
MY_WME
)))
...
...
This diff is collapsed.
Click to expand it.
myisam/mi_rename.c
View file @
97745efd
...
...
@@ -30,6 +30,11 @@ int mi_rename(const char *old_name, const char *new_name)
uint
raid_type
=
0
,
raid_chunks
=
0
;
#endif
DBUG_ENTER
(
"mi_rename"
);
#ifdef EXTRA_DEBUG
check_table_is_closed
(
old_name
,
"rename old_table"
);
check_table_is_closed
(
new_name
,
"rename new table2"
);
#endif
#ifdef USE_RAID
{
MI_INFO
*
info
;
...
...
@@ -39,7 +44,10 @@ int mi_rename(const char *old_name, const char *new_name)
raid_chunks
=
info
->
s
->
base
.
raid_chunks
;
mi_close
(
info
);
}
#ifdef EXTRA_DEBUG
check_table_is_closed
(
old_name
,
"rename raidcheck"
);
#endif
#endif
/* USE_RAID */
fn_format
(
from
,
old_name
,
""
,
MI_NAME_IEXT
,
4
);
fn_format
(
to
,
new_name
,
""
,
MI_NAME_IEXT
,
4
);
...
...
This diff is collapsed.
Click to expand it.
myisam/mi_rnext.c
View file @
97745efd
...
...
@@ -57,7 +57,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
/* Skip rows that are inserted by other threads since we got a lock */
if
((
error
=
_mi_search_next
(
info
,
info
->
s
->
keyinfo
+
inx
,
info
->
lastkey
,
info
->
lastkey_length
,
flag
,
SEARCH_BIGGER
,
info
->
s
->
state
.
key_root
[
inx
])))
break
;
}
...
...
This diff is collapsed.
Click to expand it.
myisam/mi_rprev.c
View file @
97745efd
...
...
@@ -58,7 +58,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
/* Skip rows that are inserted by other threads since we got a lock */
if
((
error
=
_mi_search_next
(
info
,
share
->
keyinfo
+
inx
,
info
->
lastkey
,
info
->
lastkey_length
,
flag
,
SEARCH_SMALLER
,
share
->
state
.
key_root
[
inx
])))
break
;
}
...
...
This diff is collapsed.
Click to expand it.
myisam/mi_search.c
View file @
97745efd
...
...
@@ -716,6 +716,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a,
{
alength
=
*
a
++
;
blength
=
*
b
++
;
end
=
a
+
alength
;
next_key_length
=
key_length
-
blength
-
1
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
myisam/myisamdef.h
View file @
97745efd
...
...
@@ -622,6 +622,8 @@ void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows);
int
_mi_rkey
(
MI_INFO
*
info
,
byte
*
buf
,
int
inx
,
const
byte
*
key
,
uint
key_len
,
enum
ha_rkey_function
search_flag
,
bool
raw_key
);
my_bool
check_table_is_closed
(
const
char
*
name
,
const
char
*
where
);
/* Functions needed by mi_check */
#ifdef __cplusplus
extern
"C"
{
...
...
This diff is collapsed.
Click to expand it.
scripts/make_binary_distribution.sh
View file @
97745efd
...
...
@@ -48,7 +48,7 @@ rm $BASE/include/Makefile*; rm $BASE/include/*.in
cp
-p
tests/
*
.res tests/
*
.tst tests/
*
.pl
$BASE
/tests
cp
-p
support-files/
*
$BASE
/support-files
cp
-p
libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so
*
libmysql/libmysqlclient.
*
mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a
$BASE
/lib
cp
-p
libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so
*
libmysql/libmysqlclient.
*
libmysql_r/.libs/libmysqlclient_a.a libmysql_r/.libs/libmysqlclient.so
*
libmysql_r/libmysqlclient.
*
mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a
$BASE
/lib
cp
-r
-p
sql/share/
*
$BASE
/share/mysql
;
rm
-f
$BASE
/share/mysql/Makefile
*
$BASE
/share/mysql/
*
/
*
.OLD
$BASE
/share/CVS
$BASE
/share/
*
/CVS
cp
-p
scripts/
*
$BASE
/bin
...
...
This diff is collapsed.
Click to expand it.
sql/ha_heap.cc
View file @
97745efd
...
...
@@ -251,6 +251,21 @@ int ha_heap::rename_table(const char * from, const char * to)
}
ha_rows
ha_heap
::
records_in_range
(
int
inx
,
const
byte
*
start_key
,
uint
start_key_len
,
enum
ha_rkey_function
start_search_flag
,
const
byte
*
end_key
,
uint
end_key_len
,
enum
ha_rkey_function
end_search_flag
)
{
KEY
*
pos
=
table
->
key_info
+
inx
;
if
(
start_key_len
!=
end_key_len
||
start_key_len
!=
pos
->
key_length
||
start_search_flag
!=
HA_READ_KEY_EXACT
||
end_search_flag
!=
HA_READ_KEY_EXACT
)
return
HA_POS_ERROR
;
// Can't only use exact keys
return
10
;
// Good guess
}
/* We can just delete the heap on creation */
int
ha_heap
::
create
(
const
char
*
name
,
TABLE
*
form
,
HA_CREATE_INFO
*
create_info
)
...
...
This diff is collapsed.
Click to expand it.
sql/ha_heap.h
View file @
97745efd
...
...
@@ -65,7 +65,10 @@ class ha_heap: public handler
int
reset
(
void
);
int
external_lock
(
THD
*
thd
,
int
lock_type
);
int
delete_all_rows
(
void
);
ha_rows
records_in_range
(
int
inx
,
const
byte
*
start_key
,
uint
start_key_len
,
enum
ha_rkey_function
start_search_flag
,
const
byte
*
end_key
,
uint
end_key_len
,
enum
ha_rkey_function
end_search_flag
);
int
delete_table
(
const
char
*
from
);
int
rename_table
(
const
char
*
from
,
const
char
*
to
);
int
create
(
const
char
*
name
,
TABLE
*
form
,
HA_CREATE_INFO
*
create_info
);
...
...
This diff is collapsed.
Click to expand it.
sql/handler.cc
View file @
97745efd
...
...
@@ -317,8 +317,8 @@ int handler::ha_open(const char *name, int mode, int test_if_locked)
}
if
(
!
error
)
{
if
(
!
(
ref
=
(
byte
*
)
my_malloc
(
ALIGN_SIZE
(
ref_length
)
*
2
,
MYF
(
0
)
)))
if
(
!
(
ref
=
(
byte
*
)
alloc_root
(
&
table
->
mem_root
,
ALIGN_SIZE
(
ref_length
)
*
2
)))
{
close
();
error
=
HA_ERR_OUT_OF_MEM
;
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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