diff --git a/Docs/Manual_style_guidelines.txt b/Docs/Manual_style_guidelines.txt new file mode 100644 index 00000000000..9616fa6fae4 --- /dev/null +++ b/Docs/Manual_style_guidelines.txt @@ -0,0 +1,140 @@ +MySQL Manual style guidelines + +Paul DuBois + +The following list of guidelines contains items that I've been jotting +down over time as style questions have come up in relation to the +MySQL manual. I wouldn't say they're exactly "official", but they +do reflect current working practice. Arjen asked me to post this +on the list some time ago so that it can be discussed with a view +to adding it (or something like it) to the source tree. So here it is! + +MySQL Reference Manual Style Guidelines + +The manual is written in UK English, not American English. This means: + +colour, not color +behaviour, not behavior +authorise, not authorize +optimise, not optimize +etc. + +Write MySQL, not @strong{MySQL} (the manual used to use the latter, but no +more). + +Write Unix, not UNIX. + +Use uppercase for SQL keywords, functions names, etc., when writing +SQL statement examples. + +To write a list of items, add commas after all items preceding the last one: +Correct: Features, products, and services +Incorrect: Features, products and services + +How to pluralize keywords that are enclosed in @code: +Correct: @code{SELECT}s +Incorrect: @code{SELECTs} or @code{SELECT}'s or @code{SELECT}:s + +Use "its" and "it's" correctly. These words are exceptions to +the normal use of "'s" to indicate possession: + +it's = it is (e.g., "one of the strengths of MySQL is that it's fast") +its = possession (e.g., "MySQL is fast, which is one of its strengths") + +"a lot" is two words. "alot" is rebarbative. + +Write lowercase, not lower case +Write uppercase, not upper case +Write lettercase, not letter case + +Write "web site" (two words), not "website", and "web page" rather +than "webpage". + +The word "data" is problematic. It's commonly used both in plural and in +singular form. The manual uses it as plural, which means you use "data are" +rather than "data is". It's unfortunate that no matter which form we use, it +will look incorrect to some people. But we can at least be internally +consistent. + +Write "press Enter", not "hit Return" or "hit Enter". + +When reproducing program output, reproduce it exactly, even if it contains +typos. Don't "fix" it. (If the output is produced by a MySQL program, then +fix the source for the program to write the output correctly without the +typo, then update the manual to match.) + +Use "okay" rather than "ok" or "Ok" or "OK" in sentences. +Exceptions: +- When describing instructions for a GUI with buttons that say +"OK", then use "OK". That is, use the label that the GUI uses. +- When showing the output from a program, show the output exactly; +don't change "ok" to "okay", etc. + +Write "Open Source", not "open source". + +To put something in quotes, do it ``like this,'' not "like this" +or 'like this.' In the latter two cases, the quotes will come +out looking rotten in printed formats. +Exception: quotes in code examples should be written using whatever +contention the program language requires. + +Table types should be written using @code{}; write @code{MyISAM}, not +MyISAM. + +When possible, use table names that are singular, not plural. +For example, use "item" rather than "items", or "person" rather than +"people". Sometimes you can add "_list" (as in "item_list") to make it +more clear that the name refers to a collection of items. + +Some commonly occurring misspelling: + +Correct Incorrect +--------------------------- +publicly publically +statically staticly +dynamically dynamicly +automatically automaticly + +There is no hyphen after "ly" words. Write statically linked, not +statically-linked. + +To refer to ASCII codes, use ASCII n, not ASCII(n), unless you're +referring to the ASCII() function, which case you use @code{ASCII()}. + +ASCII 13 indicates ASCII character code 13 +@code{ASCII(13)} indicates a function call + +backup is a noun or adjective (as in "a backup file"), back up is a verb +(as in "to back up a database") +rollback is a noun or adjective (as in "a rollback operation"), roll back +is a verb (as in "roll back a transaction") + +core dump is a noun or a verb (as in "a core dump file" or "a program +core dumps when it fails"). In the latter case, however, it's better say +say "a program dumps core when it fails"). + +Write character set names in @code{}, e.g., @code{latin1}, @code{win1251}. + +To prevent problems with various output formats, there should be no link +titles in a @uref{}. So @uref{url} is allowed, @uref{url,blabla} is not. +Use this format: + @uref{url} (WWW) +Not this format: + @uref{url, WWW} +Similarly for FTP sites. + +URLs ending in a domain name or directory should have a "/" at the end. +(For example, the URLs for all mirror sites should be written that way.) + +Privilege names are written using @strong and lowercase, as in "the +@strong{process} privilege". Column names in the grant tables are +written using @code and the lettercase found in the table definition, +as in "the @code{Process_priv} column". + +Write "e-mail", not "email". Exceptions are the @email{} construct, and +the Email attribute name in X509 certificate strings. + +Write thread-safe, transaction-safe, replication-safe, not thread safe, +transaction safe, replication safe. + +Write wildcard, not wild card or wild-card. diff --git a/Docs/manual.texi b/Docs/manual.texi index a4df5830480..dd14d95a29f 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -1774,8 +1774,8 @@ client library, so it is convenient and easy to use. @xref{libmysqld}. @item Version 4.0 further increases @emph{the speed of MySQL Server} in a number of areas, -such as bulk @code{INSERT}s, searching on packed indices, creation of -@code{FULLTEXT} indices as well as @code{COUNT(DISTINCT)}. +such as bulk @code{INSERT}s, searching on packed indexes, creation of +@code{FULLTEXT} indexes as well as @code{COUNT(DISTINCT)}. @item The table handler @code{InnoDB} is now offered as a feature of the @@ -4938,6 +4938,29 @@ same time. @xref{DELETE}. PostgreSQL currently offers the following advantages over MySQL Server: +Note that because we know the MySQL road map, we have included in the +following table the version when MySQL Server should support this feature. +Unfortunately we couldn't do this for previous comparison, because we +don't know the PostgreSQL roadmap. + +@multitable @columnfractions .30 .30 +@item @strong{Feature} @tab @strong{MySQL version} +@item Subselects @tab 4.1 +@item Foreign keys @tab 4.1 +@item Views @tab 5.0 +@item Stored procedures @tab 5.0 +@item Triggers @tab 5.0 +@item Unions @tab 4.0 +@item Full join @tab 4.1 +@item Constraints @tab 4.1 or 5.0 +@item Cursors @tab 4.1 or 5.0 +@item R-trees @tab 4.1 (for MyISAM tables) +@item Inherited tables @tab Not planned +@item Extensible type system @tab Not planned +@end multitable + +Other reasons someone may consider for using PostgreSQL: + @itemize @bullet @item Standard usage in PostgreSQL is closer to ANSI SQL in some cases. @@ -4945,6 +4968,10 @@ Standard usage in PostgreSQL is closer to ANSI SQL in some cases. @item One can speed up PostgreSQL by coding things as stored procedures. +@item +For geographical data, R-trees make PostgreSQL better than MySQL Server. +(note: MySQL version 4.1 will have R-trees for MyISAM tables). + @item The PostgreSQL optimiser can do some optimisation that the current MySQL optimiser can't do. Most notable is doing joins when you don't have the @@ -10540,7 +10567,7 @@ you back a string that looks like "000514676700", with a format of xxyyyyyymmss where xx and ss are always 0's, yyyyyy is a unique system id and mm is the id of the CPU Planar. A chart of these values can be found at -@uref{http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm}. +@uref{http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm}. This will give you a machine type and a machine model you can use to determine what type of cpu you have. @@ -14112,8 +14139,8 @@ Read the default keys used by @code{DES_ENCRYPT()} and @code{DES_DECRYPT()} from this file. @item --enable-locking -Enable system locking. Note that if you use this option on a system -which a not fully working lockd() (as on Linux) you will easily get +Enable system locking. Note that if you use this option on a system on +which @code{lockd} does not fully work (as on Linux), you will easily get mysqld to deadlock. @item --enable-named-pipe @@ -14539,8 +14566,7 @@ will automatically be directed to the new running server! If you need to do this more permanently, you should create an option file for each server. @xref{Option files}. In your startup script that -is executed at boot time (mysql.server?) you should specify for both -servers: +is executed at boot time you should specify for both servers: @code{safe_mysqld --default-file=path-to-option-file} @@ -16710,10 +16736,11 @@ request. @item Database privilege changes take effect at the next @code{USE db_name} command. -@end itemize -Global privilege changes and password changes take effect the next time the -client connects. +@item +Global privilege changes and password changes take effect the next time +the client connects. +@end itemize @node Default privileges, Adding users, Privilege changes, User Account Management @@ -17457,19 +17484,19 @@ If you are using a Veritas file system, you can do: @enumerate @item -Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK} +From a client (or Perl), execute: @code{FLUSH TABLES WITH READ LOCK}. @item -Fork a shell or execute in another client @code{mount vxfs snapshot}. +From another shell, execute: @code{mount vxfs snapshot}. @item -Execute in the first client @code{UNLOCK TABLES} +From the first client, execute: @code{UNLOCK TABLES}. @item -Copy files from snapshot +Copy files from snapshot. @item -Unmount snapshot +Unmount snapshot. @end enumerate @@ -17484,9 +17511,9 @@ Unmount snapshot BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory' @end example -Make a copy of all the table files to the backup directory that are the -minimum needed to restore it. Currenlty only works for @code{MyISAM} -tables. For @code{MyISAM} table, copies @file{.frm} (definition) and +Copies to the backup directory the minimum number of table files needed +to restore the table. Currently only works for @code{MyISAM} tables. +For @code{MyISAM} tables, copies @file{.frm} (definition) and @file{.MYD} (data) files. The index file can be rebuilt from those two. Before using this command, please see @ref{Backup}. @@ -17584,7 +17611,7 @@ The different check types stand for the following: @item @code{EXTENDED} @tab Do a full key lookup for all keys for each row. This ensures that the table is 100 % consistent, but will take a long time! @end multitable -For dynamic sized @code{MyISAM} tables a started check will always +For dynamically sized @code{MyISAM} tables a started check will always do a @code{MEDIUM} check. For static size rows we skip the row scan for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted. @@ -17594,7 +17621,8 @@ You can combine check options as in: CHECK TABLE test_table FAST QUICK; @end example -Which only would do a quick check on the table if it wasn't closed properly. +Which would simply do a quick check on the table to see whether it was +closed properly. @strong{Note:} that in some case @code{CHECK TABLE} will change the table! This happens if the table is marked as 'corrupted' or 'not @@ -17978,8 +18006,8 @@ If you have lots of memory, you should increase the size of @code{sort_buffer_size}! @item -o or --safe-recover Uses an old recovery method (reads through all rows in order and updates -all index trees based on the found rows); this is a magnitude slower -than @code{-r}, but can handle a couple of very unlikely cases that +all index trees based on the found rows); this is an order of magnitude +slower than @code{-r}, but can handle a couple of very unlikely cases that @code{-r} cannot handle. This recovery method also uses much less disk space than @code{-r}. Normally one should always first repair with @code{-r}, and only if this fails use @code{-o}. @@ -18396,8 +18424,8 @@ shell> myisamchk -r tbl_name @end example You can optimise a table in the same way using the SQL @code{OPTIMIZE TABLE} -statement. @code{OPTIMIZE TABLE} does a repair of the table, a key -analyses and also sorts the index tree to give faster key lookups. +statement. @code{OPTIMIZE TABLE} does a repair of the table and a key +analysis, and also sorts the index tree to give faster key lookups. There is also no possibility of unwanted interaction between a utility and the server, because the server does all the work when you use @code{OPTIMIZE TABLE}. @xref{OPTIMIZE TABLE}. @@ -18791,8 +18819,8 @@ What percentage of the data file is unused. @item Blocks/Record Average number of blocks per record (that is, how many links a fragmented -record is composed of). This is always 1 for fixed-format tables. This value -should stay as close to 1.0 as possible. If it gets too big, you can +record is composed of). This is always 1.0 for fixed-format tables. This +value should stay as close to 1.0 as possible. If it gets too big, you can reorganise the table with @code{myisamchk}. @xref{Optimisation}. @@ -19517,6 +19545,10 @@ or @samp{M} to indicate kilobytes or megabytes. For example, @code{16M} indicates 16 megabytes. The case of suffix letters does not matter; @code{16M} and @code{16m} are equivalent: +@c FIX 2002-04-29 arjen / paul +@c FIX Below should be a @multitable just like SHOW STATUS. +@c FIX Has to wait till after O'Reilly printed edition is out the door. + @cindex variables, values @itemize @item @code{ansi_mode}. @@ -19701,10 +19733,10 @@ Index blocks are buffered and are shared by all threads. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common. If you, however, make this too big -(more than 50% of your total memory?) your system may start to page and -become extremely slow. Remember that because MySQL does not cache -data read, that you will have to leave some room for the OS filesystem -cache. +(for instance more than 50% of your total memory) your system may start +to page and become extremely slow. Remember that because MySQL does not +cache data reads, you will have to leave some room for the OS +filesystem cache. You can check the performance of the key buffer by doing @code{show status} and examine the variables @code{Key_read_requests}, @@ -19826,9 +19858,9 @@ The buffer that is allocated when sorting the index when doing a @code{ALTER TABLE}. @item @code{myisam_max_extra_sort_file_size}. -If the creating of the temporary file for fast index creation would be -this much bigger than using the key cache, then prefer the key cache -method. This is mainly used to force long character keys in large +If the temporary file used for fast index creation would be bigger than +using the key cache by the amount specified here, then prefer the key +cache method. This is mainly used to force long character keys in large tables to use the slower key cache method to create the index. @strong{NOTE} that this parameter is given in megabytes! @@ -20045,11 +20077,11 @@ one extra connection for a client with the @strong{process} privilege to ensure that you should always be able to login and check the system (assuming you are not giving this privilege to all your users). -Some frequently states in @code{mysqladmin processlist} +Some states commonly seen in @code{mysqladmin processlist} @itemize @bullet @item @code{Checking table} -The thread doing an [automatic ?] checking of the table. +The thread is performing [automatic] checking of the table. @item @code{Closing tables} Means that the thread is flushing the changed table data to disk and closing the used tables. This should be a fast operation. If not, then @@ -20431,7 +20463,7 @@ The @code{configure} program uses this comment to include the character set into the MySQL library automatically. The strxfrm_multiply and mbmaxlen lines will be explained in -the following sections. Only include them if you the string +the following sections. Only include these if you need the string collating functions or the multi-byte character set functions, respectively. @@ -20857,7 +20889,7 @@ or mysqld_multi [OPTIONS] @{start|stop|report@} [GNR-GNR,GNR,GNR-GNR,...] The GNR above means the group number. You can start, stop or report any GNR, or several of them at the same time. (See --example) The GNRs -list can be comma separated, or a dash combined, of which the latter +list can be comma separated or combined with a dash, of which the latter means that all the GNRs between GNR1-GNR2 will be affected. Without GNR argument all the found groups will be either started, stopped, or reported. Note that you must not have any white spaces in the GNR @@ -20954,7 +20986,7 @@ release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys @end example The above test should be successful, or you may encounter problems. @item -Beware of the dangers starting multiple @code{mysqlds} in the same data +Beware of the dangers starting multiple @code{mysqld}s in the same data directory. Use separate data directories, unless you @strong{know} what you are doing! @item @@ -23278,7 +23310,7 @@ your databases and have not configured replication before. You will need to shutdown your master server briefly to complete the steps outlined below. -While the above method is the most straightforward way to set up a slave, +While this method is the most straightforward way to set up a slave, it is not the only one. For example, if you already have a snapshot of the master, and the master already has server id set and binary logging enabled, you can @@ -23451,7 +23483,7 @@ the new privileges into effect. Temporary tables starting in 3.23.29 are replicated properly with the exception of the case when you shut down slave server ( not just slave thread), you have some temporary tables open, and they are used in subsequent updates. -To deal with this problem, to shut down the slave, do @code{SLAVE STOP}, then +To deal with this problem shutting down the slave, do @code{SLAVE STOP}, check @code{Slave_open_temp_tables} variable to see if it is 0, then issue @code{mysqladmin shutdown}. If the number is not 0, restart the slave thread with @code{SLAVE START} and see @@ -23621,8 +23653,7 @@ slaves. In Versions 3.23.26 and later, you should use Because the user could issue the @code{FLUSH LOGS} command, we need to know which log is currently active and which ones have been rotated out and in what sequence. This information is stored in the binary log index file. -The default is @file{`hostname`.index}. You can use this option if you want to -be a rebel. +The default is @file{`hostname`.index}. You should not need to change this. Example: @code{log-bin-index=db.index} @@ -23713,8 +23744,7 @@ Example: @code{master-ssl-key=SSL/master-cert.pem} @item @code{master-info-file=filename} @tab The location of the file that remembers where we left off on the master during the replication process. The default is @file{master.info} in the data -directory. Sasha: The only reason I see for ever changing the default -is the desire to be rebellious. +directory. You should not need to change this. Example: @code{master-info-file=master.info} @@ -23971,7 +24001,7 @@ intuitive way to describe this operation. @tab Available starting in Version 3.23.28. Deletes all the replication logs that are listed in the log index as being prior to the specified log, and removes them from the -log index, so that the given log now becomes first. Example: +log index, so that the given log now becomes the first. Example: @example PURGE MASTER LOGS TO 'mysql-bin.010' @@ -24032,7 +24062,7 @@ later @end itemize Afterwards, follow the instructions for the case when you have a snapshot and -have records the log name and offset. You can use the same snapshot to set up +have recorded the log name and offset. You can use the same snapshot to set up several slaves. As long as the binary logs of the master are left intact, you can wait as long as several days or in some cases maybe a month to set up a slave once you have the snapshot of the master. In theory the waiting gap can @@ -24308,9 +24338,9 @@ the slaves of the master change in case of failure. Some suggestions: @item To tell a slave to change the master use the @code{CHANGE MASTER TO} command. @item -A good way to keep your applications informed where the master is by -having a dynamic DNS entry for the master. With @strong{bind} you can -use @code{nsupdate} to dynamically update your DNS. +A good way to keep your applications informed as to the location of the +master is by having a dynamic DNS entry for the master. +With @code{bind} you can use @file{nsupdate} to dynamically update your DNS. @item You should run your slaves with the @code{log-bin} option and without @code{log-slave-updates}. This way the slave will be ready to become a @@ -24405,10 +24435,10 @@ bug report. Ideally, we would like to have a test case in the format found in case like that, you can expect a patch within a day or two in most cases, although, of course, you mileage may vary depending on a number of factors. -Second best option is a just program with easily configurable connection -arguments for the master and the slave that will demonstrate the problem on our -systems. You can write one in Perl or in C, depending on which language you -know better. +The second best option is to write a simple program with easily configurable +connection arguments for the master and the slave that will demonstrate +the problem on our systems. You can write one in Perl or in C, depending +on which language you know better. If you have one of the above ways to demonstrate the bug, use @code{mysqlbug} to prepare a bug report and send it to @@ -25568,7 +25598,7 @@ SELECT * FROM t1 WHERE key_part1=1 ORDER BY key_part1 DESC,key_part2 DESC Some cases where MySQL can NOT use indexes to resolve the @code{ORDER BY}: (Note that MySQL will still use indexes to find the rows that -matches the where clause): +matches the @code{WHERE} clause): @itemize @bullet @item @@ -25576,7 +25606,7 @@ You are doing an @code{ORDER BY} on different keys: @code{SELECT * FROM t1 ORDER BY key1,key2} @item -You are doing an @code{ORDER BY} on not following key parts. +You are doing an @code{ORDER BY} using non-consecutive key parts. @code{SELECT * FROM t1 WHERE key2=constant ORDER BY key_part2} @@ -25698,8 +25728,8 @@ will abort the query (If you are not using @code{SQL_CALC_FOUND_ROWS}). @code{LIMIT 0} will always quickly return an empty set. This is useful to check the query and to get the column types of the result columns. @item -The size of temporary tables uses the @code{LIMIT #} to calculate how much -space is needed to resolve the query. +When the server uses temporary tables to resolve the query, the +@code{LIMIT #} is used to calculate how much space is required. @end itemize @@ -26003,7 +26033,7 @@ is integrated in @code{mysqld}. Use @code{AUTO_INCREMENT} columns to make unique values. @item Use @code{OPTIMIZE TABLE} once in a while to avoid fragmentation when -using dynamic table format. @xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}. +using a dynamic table format. @xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}. @item Use @code{HEAP} tables to get more speed when possible. @xref{Table @@ -48958,16 +48988,18 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @item Query cache disabled in mysqldump. @item +Fixed problem on Windows 98 that made sending of results very slow. +@item Boolean fulltext search weighting scheme changed to something more reasonable. @item -Fixed bug in boolean fulltext search, that caused MySQL to ignore queries of +Fixed bug in boolean fulltext search that caused MySQL to ignore queries of @code{ft_min_word_len} characters. @item -Boolean fulltext search now supports "phrase searches". +Boolean fulltext search now supports ``phrase searches''. @item New configure option @code{--without-query-cache}. @item -Memory allocation strategy for 'root memory' changed. Block size now grows +Memory allocation strategy for ``root memory'' changed. Block size now grows with number of allocated blocks. @item @code{INET_NTOA()} now returns @code{NULL} if you give it an argument that diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 86507bc0b31..7945407ccae 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -614,8 +614,8 @@ int main(int argc, char **argv) if (dbConnect(current_host, current_user, opt_password)) exit(EX_MYSQLERR); - if (opt_auto_repair && - init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64)) + if (opt_auto_repair && + my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64)) { first_error = 1; goto end; diff --git a/client/mysqldump.c b/client/mysqldump.c index eae5700a553..7e05e777acd 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -35,7 +35,7 @@ ** and adapted to mysqldump 05/11/01 by Jani Tolonen */ -#define DUMP_VERSION "9.01" +#define DUMP_VERSION "9.02" #include #include @@ -201,8 +201,7 @@ static struct my_option my_long_options[] = 0, 0}, {"result-file", 'r', "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\n\\r' (newline + carriage return).", - (gptr*) &md_result_file, (gptr*) &md_result_file, 0, GET_STR, REQUIRED_ARG, - 0, 0, 0, 0, 0, 0}, + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -366,9 +365,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_xml = 1; opt_disable_keys=0; break; - default: - fprintf(stderr,"%s: Illegal option character '%c'\n",my_progname,opterr); - /* Fall throught */ case 'I': case '?': usage(); diff --git a/client/mysqltest.c b/client/mysqltest.c index a007c7778e0..a161b9352d4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2360,7 +2360,7 @@ int main(int argc, char** argv) file_stack_end = file_stack + MAX_INCLUDE_DEPTH; cur_file = file_stack; lineno = lineno_stack; - init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, + my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, INIT_Q_LINES); memset(block_stack, 0, sizeof(block_stack)); block_stack_end = block_stack + BLOCK_STACK_DEPTH; diff --git a/extra/mysql_install.c b/extra/mysql_install.c index 1fa62f35b7e..d02c054d4eb 100644 --- a/extra/mysql_install.c +++ b/extra/mysql_install.c @@ -135,7 +135,7 @@ static int init_question_widget(QUESTION_WIDGET* w, const char* question, } w->question = question; w->default_ind = default_ind; - if (init_dynamic_array(&w->answers,sizeof(char*), + if (my_init_dynamic_array(&w->answers,sizeof(char*), ANSWERS_CHUNCK,ANSWERS_CHUNCK)) die("Out of memory"); return 0; diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 6c2ddf66027..7c33bd51dbe 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -230,9 +230,9 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf) static void init_sym_table() { char buf[512]; - if(init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE, + if(my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE, INC_SYM_TABLE)) - die("Failed in init_dynamic_array() -- looks like out of memory problem"); + die("Failed in my_init_dynamic_array() -- looks like out of memory problem"); while(fgets(buf, sizeof(buf), fp_sym)) { diff --git a/fs/database.c b/fs/database.c index 4a328c41618..0ff12e433ee 100644 --- a/fs/database.c +++ b/fs/database.c @@ -243,7 +243,7 @@ int db_show_field(char *b,const char *database,const char *table, const char *fi if (!(database[0] && table[0] && field[0])) DBUG_RETURN(-1); - init_dynamic_array(&field_array, sizeof(buff), 4096, 1024); + my_init_dynamic_array(&field_array, sizeof(buff), 4096, 1024); if (mysql_select_db(sock,database)) { @@ -593,7 +593,7 @@ gptr db_load_functions() int i=0; struct func_st func; DBUG_ENTER("db_load_functions"); - init_dynamic_array(&functions_array, sizeof(struct func_st), 4096, 1024); + my_init_dynamic_array(&functions_array, sizeof(struct func_st), 4096, 1024); while(functions[i]) { strcpy(func.type_s, functions[i]); /* Type in string: "table"` */ strcpy(func.filename, functions[i+1]); /* Name like it appears on FS: "count" */ diff --git a/include/my_sys.h b/include/my_sys.h index 175f7a86789..3ff35763bce 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -651,9 +651,9 @@ extern my_bool real_open_cached_file(IO_CACHE *cache); extern void close_cached_file(IO_CACHE *cache); File create_temp_file(char *to, const char *dir, const char *pfx, int mode, myf MyFlags); -#define init_dynamic_array(A,B,C,D) _init_dynamic_array(A,B,C,D CALLER_INFO) -#define init_dynamic_array_ci(A,B,C,D) _init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) -extern my_bool _init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, +#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) +#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) +extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, uint init_alloc,uint alloc_increment CALLER_INFO_PROTO); extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index baa6f5a72f2..feee3451f51 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -848,13 +848,13 @@ static void mysql_read_default_options(struct st_mysql_options *options, options->client_flag&= CLIENT_LOCAL_FILES; break; case 23: /* replication probe */ - options->rpl_probe = 1; + options->rpl_probe= 1; break; case 24: /* enable-reads-from-master */ - options->rpl_parse = 1; + options->no_master_reads= 0; break; case 25: /* repl-parse-query */ - options->no_master_reads = 0; + options->rpl_parse= 1; break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 24b585985c0..c3883ed0961 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -481,15 +481,15 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) continue; end=ftsi.pos+ftsi.len; - while (ft_simple_get_word((byte **)&ftsi.pos,(byte *)end,&word)) + while (ft_simple_get_word((byte **) &ftsi.pos,(byte *) end, &word)) { int a, b, c; for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2) { ftbw=(FTB_WORD *)(ftb->list[c]); - if (_mi_compare_text(ftb->charset, word.pos,word.len, - (uchar*) ftbw->word+1,ftbw->len-1, - (ftbw->flags&FTB_FLAG_TRUNC) ) >0) + if (_mi_compare_text(ftb->charset, word.pos, word.len, + (uchar*) ftbw->word+1, ftbw->len-1, + (my_bool) (ftbw->flags&FTB_FLAG_TRUNC)) >0) b=c; else a=c; @@ -498,8 +498,8 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) { ftbw=(FTB_WORD *)(ftb->list[c]); if (_mi_compare_text(ftb->charset, word.pos,word.len, - (uchar*) ftbw->word+1,ftbw->len-1, - (ftbw->flags&FTB_FLAG_TRUNC) )) + (uchar*) ftbw->word+1,ftbw->len-1, + (my_bool) (ftbw->flags&FTB_FLAG_TRUNC))) break; if (ftbw->docid[1] == docid) continue; diff --git a/myisam/sort.c b/myisam/sort.c index 66a8254732a..bec77b231b8 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -122,7 +122,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, if ((sort_keys=(uchar **)my_malloc(keys*(sort_length+sizeof(char*))+ HA_FT_MAXLEN, MYF(0)))) { - if (init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, + if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, maxbuffer/2)) my_free((gptr) sort_keys,MYF(0)); else diff --git a/mysys/array.c b/mysys/array.c index 2420213d454..2a0723fbd69 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -28,7 +28,7 @@ even if space allocation failed */ -my_bool _init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, +my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, uint init_alloc, uint alloc_increment CALLER_INFO_PROTO) { diff --git a/mysys/charset.c b/mysys/charset.c index 93e8b697904..1001b76f417 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -122,7 +122,7 @@ static my_bool read_charset_index(CS_ID ***charsets, myf myflags) fb.buf[0] = '\0'; fb.p = fb.buf; - if (init_dynamic_array(&cs, sizeof(CS_ID *), 32, 32)) + if (my_init_dynamic_array(&cs, sizeof(CS_ID *), 32, 32)) return TRUE; while (!get_word(&fb, buf) && !get_word(&fb, num_buf)) @@ -180,7 +180,7 @@ static my_bool init_available_charsets(myf myflags) pthread_mutex_lock(&THR_LOCK_charset); if (!cs_info_table.buffer) /* If not initialized */ { - init_dynamic_array(&cs_info_table, sizeof(CHARSET_INFO*), 16, 8); + my_init_dynamic_array(&cs_info_table, sizeof(CHARSET_INFO*), 16, 8); error = read_charset_index(&available_charsets, myflags); } charset_initialized=1; diff --git a/mysys/default.c b/mysys/default.c index d3c1b3815eb..12d7d2e4ed0 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -123,7 +123,7 @@ void load_defaults(const char *conf_file, const char **groups, for (; *groups ; groups++) group.count++; - if (init_dynamic_array(&args, sizeof(char*),*argc, 32)) + if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32)) goto err; if (forced_default_file) { diff --git a/mysys/hash.c b/mysys/hash.c index b3769d1dfb2..eaea6d7503f 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -44,7 +44,7 @@ my_bool _hash_init(HASH *hash,uint size,uint key_offset,uint key_length, DBUG_PRINT("enter",("hash: %lx size: %d",hash,size)); hash->records=0; - if (init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) + if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) { hash->free=0; /* Allow call to hash_free */ DBUG_RETURN(TRUE); diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 0bd542d2bd9..8e6fdbbbec5 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -105,6 +105,8 @@ static long thread_id=0; my_bool my_thread_init(void) { struct st_my_thread_var *tmp; + my_bool error=0; + #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self()); #endif @@ -117,16 +119,14 @@ my_bool my_thread_init(void) { #ifdef EXTRA_DEBUG fprintf(stderr,"my_thread_init() called more than once in thread %ld\n", - pthread_self()); + pthread_self()); #endif - pthread_mutex_unlock(&THR_LOCK_lock); - return 0; /* Safequard */ + goto end; } - if (!(tmp=(struct st_my_thread_var *) - calloc(1, sizeof(struct st_my_thread_var)))) + if (!(tmp= (struct st_my_thread_var *) calloc(1, sizeof(*tmp)))) { - pthread_mutex_unlock(&THR_LOCK_lock); - return 1; + error= 1; + goto end; } pthread_setspecific(THR_KEY_mysys,tmp); @@ -146,7 +146,7 @@ end: #if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) pthread_mutex_unlock(&THR_LOCK_lock); #endif - return 0; + return error; } void my_thread_end(void) diff --git a/mysys/raid.cc b/mysys/raid.cc index 72d3b2074be..6196e1f1aa6 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -94,7 +94,7 @@ extern "C" { void init_raid(void) { /* Allocate memory for global file to raid map */ - init_dynamic_array(&RaidFd::_raid_map, sizeof(RaidFd*), 4096, 1024); + my_init_dynamic_array(&RaidFd::_raid_map, sizeof(RaidFd*), 4096, 1024); } void end_raid(void) { diff --git a/sql/log.cc b/sql/log.cc index 40cafeeaad1..f0012a94f5d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -531,14 +531,14 @@ int MYSQL_LOG::purge_logs(THD* thd, const char* to_log) error = LOG_INFO_MEM; goto err; } - if (init_dynamic_array(&logs_to_purge, sizeof(char*), 1024, 1024)) + if (my_init_dynamic_array(&logs_to_purge, sizeof(char*), 1024, 1024)) { error = LOG_INFO_MEM; goto err; } logs_to_purge_inited = 1; - if (init_dynamic_array(&logs_to_keep, sizeof(char*), 1024, 1024)) + if (my_init_dynamic_array(&logs_to_keep, sizeof(char*), 1024, 1024)) { error = LOG_INFO_MEM; goto err; diff --git a/sql/slave.cc b/sql/slave.cc index 0af3823c1e0..b473d8ab1e3 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -246,9 +246,10 @@ err: } /* called from get_options() in mysqld.cc on start-up */ -void init_slave_skip_errors(char* arg) + +void init_slave_skip_errors(const char* arg) { - char* p; + const char *p; my_bool last_was_digit = 0; if (bitmap_init(&slave_error_mask,MAX_SLAVE_ERROR,0)) { @@ -275,8 +276,11 @@ void init_slave_skip_errors(char* arg) } } -// we assume we have a run lock on rli and that the both slave thread -// are not running +/* + We assume we have a run lock on rli and that the both slave thread + are not running +*/ + int purge_relay_logs(RELAY_LOG_INFO* rli, bool just_reset, const char** errmsg) { DBUG_ENTER("purge_relay_logs"); @@ -514,7 +518,7 @@ void init_table_rule_hash(HASH* h, bool* h_inited) void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) { - init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, + my_init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, TABLE_RULE_ARR_SIZE); *a_inited = 1; } diff --git a/sql/slave.h b/sql/slave.h index 75e3e81e57f..34df17f2851 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -333,7 +333,7 @@ typedef struct st_table_rule_ent #define SLAVE_FORCE_ALL 4 int init_slave(); -void init_slave_skip_errors(char* arg); +void init_slave_skip_errors(const char* arg); int flush_master_info(MASTER_INFO* mi); int flush_relay_log_info(RELAY_LOG_INFO* rli); int register_slave_on_master(MYSQL* mysql); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 104b431bdbb..1c9e269fde9 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -163,7 +163,7 @@ int acl_init(bool dont_read_acl_tables) init_sql_alloc(&mem,1024,0); init_read_record(&read_record_info,thd,table= tables[0].table,NULL,1,0); - VOID(init_dynamic_array(&acl_hosts,sizeof(ACL_HOST),20,50)); + VOID(my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST),20,50)); while (!(read_record_info.read_record(&read_record_info))) { ACL_HOST host; @@ -187,7 +187,7 @@ int acl_init(bool dont_read_acl_tables) freeze_size(&acl_hosts); init_read_record(&read_record_info,thd,table=tables[1].table,NULL,1,0); - VOID(init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100)); + VOID(my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100)); if (table->field[2]->field_length == 8 && protocol_version == PROTOCOL_VERSION) { @@ -273,7 +273,7 @@ int acl_init(bool dont_read_acl_tables) freeze_size(&acl_users); init_read_record(&read_record_info,thd,table=tables[2].table,NULL,1,0); - VOID(init_dynamic_array(&acl_dbs,sizeof(ACL_DB),50,100)); + VOID(my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB),50,100)); while (!(read_record_info.read_record(&read_record_info))) { ACL_DB db; @@ -846,7 +846,7 @@ int wild_case_compare(const char *str,const char *wildstr) static void init_check_host(void) { DBUG_ENTER("init_check_host"); - VOID(init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip), + VOID(my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip), acl_users.elements,1)); VOID(hash_init(&acl_check_hosts,acl_users.elements,0,0, (hash_get_key) check_get_key,0,HASH_CASE_INSENSITIVE)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 88854396ae3..4d6c4ba1bb9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -195,6 +195,7 @@ send_fields(THD *thd,List &list,uint flag) Item *item; char buff[80]; CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->convert_set; + DBUG_ENTER("send_fields"); String tmp((char*) buff,sizeof(buff)),*res,*packet= &thd->packet; @@ -255,11 +256,11 @@ send_fields(THD *thd,List &list,uint flag) if (my_net_write(&thd->net, (char*) packet->ptr(),packet->length())) break; /* purecov: inspected */ } - send_eof(&thd->net); - return 0; + send_eof(&thd->net,1); + DBUG_RETURN(0); err: send_error(&thd->net,ER_OUT_OF_RESOURCES); /* purecov: inspected */ - return 1; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f5a5a684fc0..9d1037a9dc7 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -182,7 +182,9 @@ cleanup: thd->lock=0; } if (deleted) - query_cache_invalidate3(thd, table_list, 1); + { + query_cache_invalidate3(thd, table_list, 1); + } delete select; if (error >= 0) // Fatal error send_error(&thd->net,thd->killed ? ER_SERVER_SHUTDOWN: 0); @@ -470,7 +472,9 @@ bool multi_delete::send_eof() VOID(ha_autocommit_or_rollback(thd,error > 0)); } if (deleted) + { query_cache_invalidate3(thd, delete_tables, 1); + } ::send_ok(&thd->net,deleted); return 0; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 69fc7c00955..6cc4f258c65 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -311,7 +311,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, } thd->proc_info="end"; if (info.copied || info.deleted) + { query_cache_invalidate3(thd, table_list, 1); + } table->time_stamp=save_time_stamp; // Restore auto timestamp ptr table->next_number_field=0; thd->count_cuted_fields=0; @@ -1330,7 +1332,9 @@ void select_insert::send_error(uint errcode,const char *err) table->file->activate_all_index(thd); ha_rollback_stmt(thd); if (info.copied || info.deleted) + { query_cache_invalidate3(thd, table, 1); + } } @@ -1343,8 +1347,9 @@ bool select_insert::send_eof() if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error) error=error2; if (info.copied || info.deleted) + { query_cache_invalidate3(thd, table, 1); - + } if (error) { table->file->print_error(error,MYF(0)); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 18f256d9edb..d8dcb3a4ea7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1610,7 +1610,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, join_tab[i].table->map); } } - if (init_dynamic_array(keyuse,sizeof(KEYUSE),20,64)) + if (my_init_dynamic_array(keyuse,sizeof(KEYUSE),20,64)) return TRUE; /* fill keyuse with found key parts */ for (KEY_FIELD *field=key_fields ; field != end ; field++) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index db520af61c1..f8a0d169d5a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -324,7 +324,9 @@ int mysql_update(THD *thd, thd->lock=0; } if (updated) + { query_cache_invalidate3(thd, table_list, 1); + } delete select; if (error >= 0) @@ -788,8 +790,9 @@ bool multi_update::send_eof() sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated, (long) thd->cuted_fields); if (updated) + { query_cache_invalidate3(thd, update_tables, 1); - + } ::send_ok(&thd->net, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, thd->insert_id_used ? thd->insert_id() : 0L,buff); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 63bfb217b52..79227bcc3f9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1237,11 +1237,11 @@ alter_list_item: lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); lex->simple_alter=0; } - | RENAME opt_to table_alias table_ident + | RENAME opt_to table_ident { LEX *lex=Lex; - lex->select->db=$4->db.str; - lex->name= $4->table.str; + lex->select->db=$3->db.str; + lex->name= $3->table.str; lex->simple_alter=0; } | create_table_options { Lex->simple_alter=0; } @@ -1268,6 +1268,7 @@ opt_place: opt_to: /* empty */ {} | TO_SYM {} + | EQ {} | AS {}; slave: diff --git a/sql/uniques.cc b/sql/uniques.cc index 6b05618bcc7..3a26f610dc5 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -55,7 +55,7 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, my_b_clear(&file); init_tree(&tree, max_in_memory_size / 16, 0, size, comp_func, 0, NULL, comp_func_fixed_arg); /* If the following fail's the next add will also fail */ - init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16); + my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16); max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size); open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME)); diff --git a/vio/vio.c b/vio/vio.c index 62814e50240..67cb7ec95cd 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -96,7 +96,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) sprintf(vio->desc, (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"), vio->sd); -#if !defined(___WIN__) && !defined(__EMX__) +#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) vio->fcntl_mode = fcntl(sd, F_GETFL); #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ diff --git a/vio/viosocket.c b/vio/viosocket.c index 14b4305b95a..85e239f29ac 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -87,7 +87,7 @@ int vio_write(Vio * vio, const gptr buf, int size) int r; DBUG_ENTER("vio_write"); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); -#ifdef __WIN__ +#if defined( __WIN__) if ( vio->type == VIO_TYPE_NAMEDPIPE) { DWORD length; @@ -95,7 +95,7 @@ int vio_write(Vio * vio, const gptr buf, int size) DBUG_RETURN(-1); DBUG_RETURN(length); } - r = send(vio->sd, buf, size,0); + r = send(vio->sd, buf, size, 0); #else r = write(vio->sd, buf, size); #endif /* __WIN__ */