mysqld.cc
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:130k
- (void*) thd)))
- {
- DBUG_PRINT("error",
- ("Can't create thread to handle request (error %d)",
- error));
- (void) pthread_mutex_lock(&LOCK_thread_count);
- thread_count--;
- thd->killed=1; // Safety
- (void) pthread_mutex_unlock(&LOCK_thread_count);
- net_printf(net,ER_CANT_CREATE_THREAD,error);
- (void) pthread_mutex_lock(&LOCK_thread_count);
- close_connection(net,0,0);
- delete thd;
- (void) pthread_mutex_unlock(&LOCK_thread_count);
- DBUG_VOID_RETURN;
- }
- }
- }
- DBUG_PRINT("info",(("Thread %d created"), thd->thread_id));
- DBUG_VOID_RETURN;
- }
- /* Handle new connections and spawn new process to handle them */
- pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
- {
- my_socket sock,new_sock;
- uint error_count=0;
- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
- int ip_flags=0,socket_flags=0,flags;
- Vio *vio_tmp;
- DBUG_ENTER("handle_connections_sockets");
- LINT_INIT(new_sock);
- (void) my_pthread_getprio(pthread_self()); // For debugging
- FD_ZERO(&clientFDs);
- if (ip_sock != INVALID_SOCKET)
- {
- FD_SET(ip_sock,&clientFDs);
- #ifdef HAVE_FCNTL
- ip_flags = fcntl(ip_sock, F_GETFL, 0);
- #endif
- }
- #ifdef HAVE_SYS_UN_H
- FD_SET(unix_sock,&clientFDs);
- socket_flags=fcntl(unix_sock, F_GETFL, 0);
- #endif
- DBUG_PRINT("general",("Waiting for connections."));
- while (!abort_loop)
- {
- readFDs=clientFDs;
- #ifdef HPUX
- if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0)
- continue;
- #else
- if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
- {
- if (errno != EINTR)
- {
- if (!select_errors++ && !abort_loop) /* purecov: inspected */
- sql_print_error("mysqld: Got error %d from select",errno); /* purecov: inspected */
- }
- continue;
- }
- #endif /* HPUX */
- if (abort_loop)
- break;
- /*
- ** Is this a new connection request
- */
- #ifdef HAVE_SYS_UN_H
- if (FD_ISSET(unix_sock,&readFDs))
- {
- sock = unix_sock;
- flags= socket_flags;
- }
- else
- #endif
- {
- sock = ip_sock;
- flags= ip_flags;
- }
- #if !defined(NO_FCNTL_NONBLOCK)
- if (!(test_flags & TEST_BLOCKING))
- {
- #if defined(O_NONBLOCK)
- fcntl(sock, F_SETFL, flags | O_NONBLOCK);
- #elif defined(O_NDELAY)
- fcntl(sock, F_SETFL, flags | O_NDELAY);
- #endif
- }
- #endif /* NO_FCNTL_NONBLOCK */
- for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
- {
- size_socket length=sizeof(struct sockaddr_in);
- new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr),
- &length);
- if (new_sock != INVALID_SOCKET || (errno != EINTR && errno != EAGAIN))
- break;
- #if !defined(NO_FCNTL_NONBLOCK)
- if (!(test_flags & TEST_BLOCKING))
- {
- if (retry == MAX_ACCEPT_RETRY - 1)
- fcntl(sock, F_SETFL, flags); // Try without O_NONBLOCK
- }
- #endif
- }
- #if !defined(NO_FCNTL_NONBLOCK)
- if (!(test_flags & TEST_BLOCKING))
- fcntl(sock, F_SETFL, flags);
- #endif
- if (new_sock < 0)
- {
- if ((error_count++ & 255) == 0) // This can happen often
- sql_perror("Error in accept");
- if (errno == ENFILE || errno == EMFILE)
- sleep(1); // Give other threads some time
- continue;
- }
- #ifdef HAVE_LIBWRAP
- {
- if (sock == ip_sock)
- {
- struct request_info req;
- signal(SIGCHLD, SIG_DFL);
- request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, new_sock, NULL);
- fromhost(&req);
- if (!hosts_access(&req))
- {
- // This may be stupid but refuse() includes an exit(0)
- // which we surely don't want...
- // clean_exit() - same stupid thing ...
- syslog(deny_severity, "refused connect from %s", eval_client(&req));
- if (req.sink)
- ((void (*)(int))req.sink)(req.fd);
- // C++ sucks (the gibberish in front just translates the supplied
- // sink function pointer in the req structure from a void (*sink)();
- // to a void(*sink)(int) if you omit the cast, the C++ compiler
- // will cry...
- (void) shutdown(new_sock,2); // This looks fine to me...
- (void) closesocket(new_sock);
- continue;
- }
- }
- }
- #endif /* HAVE_LIBWRAP */
- {
- size_socket dummyLen;
- struct sockaddr dummy;
- dummyLen = sizeof(struct sockaddr);
- if (getsockname(new_sock,&dummy, &dummyLen) < 0)
- {
- sql_perror("Error on new connection socket");
- (void) shutdown(new_sock,2);
- (void) closesocket(new_sock);
- continue;
- }
- }
- /*
- ** Don't allow too many connections
- */
- if (!(thd= new THD))
- {
- (void) shutdown(new_sock,2); VOID(closesocket(new_sock));
- continue;
- }
- if (!(vio_tmp=vio_new(new_sock,
- sock == unix_sock ? VIO_TYPE_SOCKET :
- VIO_TYPE_TCPIP,
- sock == unix_sock)) ||
- my_net_init(&thd->net,vio_tmp))
- {
- if (vio_tmp)
- vio_delete(vio_tmp);
- else
- {
- (void) shutdown(new_sock,2);
- (void) closesocket(new_sock);
- }
- delete thd;
- continue;
- }
- if (sock == unix_sock)
- thd->host=(char*) localhost;
- create_new_thread(thd);
- }
- #ifdef __NT__
- pthread_mutex_lock(&LOCK_thread_count);
- handler_count--;
- pthread_mutex_unlock(&LOCK_thread_count);
- pthread_cond_signal(&COND_handler_count);
- #endif
- DBUG_RETURN(0);
- }
- #ifdef __NT__
- pthread_handler_decl(handle_connections_namedpipes,arg)
- {
- HANDLE hConnectedPipe;
- BOOL fConnected;
- THD *thd;
- my_thread_init();
- DBUG_ENTER("handle_connections_namedpipes");
- (void) my_pthread_getprio(pthread_self()); // For debugging
- DBUG_PRINT("general",("Waiting for named pipe connections."));
- while (!abort_loop)
- {
- /* wait for named pipe connection */
- fConnected = ConnectNamedPipe( hPipe, NULL );
- if (abort_loop)
- break;
- if ( !fConnected )
- fConnected = GetLastError() == ERROR_PIPE_CONNECTED;
- if ( !fConnected )
- {
- CloseHandle( hPipe );
- if ((hPipe = CreateNamedPipe(szPipeName,
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_BYTE |
- PIPE_READMODE_BYTE |
- PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES,
- (int) net_buffer_length,
- (int) net_buffer_length,
- NMPWAIT_USE_DEFAULT_WAIT,
- &saPipeSecurity )) ==
- INVALID_HANDLE_VALUE )
- {
- sql_perror("Can't create new named pipe!");
- break; // Abort
- }
- }
- hConnectedPipe = hPipe;
- /* create new pipe for new connection */
- if ((hPipe = CreateNamedPipe(szPipeName,
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_BYTE |
- PIPE_READMODE_BYTE |
- PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES,
- (int) net_buffer_length,
- (int) net_buffer_length,
- NMPWAIT_USE_DEFAULT_WAIT,
- &saPipeSecurity)) ==
- INVALID_HANDLE_VALUE)
- {
- sql_perror("Can't create new named pipe!");
- hPipe=hConnectedPipe;
- continue; // We have to try again
- }
- if ( !(thd = new THD))
- {
- DisconnectNamedPipe( hConnectedPipe );
- CloseHandle( hConnectedPipe );
- continue;
- }
- if (!(thd->net.vio = vio_new_win32pipe(hConnectedPipe)) ||
- my_net_init(&thd->net, thd->net.vio))
- {
- close_connection(&thd->net,ER_OUT_OF_RESOURCES);
- delete thd;
- continue;
- }
- /* host name is unknown */
- thd->host = my_strdup(localhost,MYF(0)); /* Host is unknown */
- create_new_thread(thd);
- }
- pthread_mutex_lock(&LOCK_thread_count);
- handler_count--;
- pthread_cond_signal(&COND_handler_count);
- pthread_mutex_unlock(&LOCK_thread_count);
- DBUG_RETURN(0);
- }
- #endif /* __NT__ */
- /******************************************************************************
- ** handle start options
- ******************************************************************************/
- enum options {
- OPT_ISAM_LOG=256, OPT_SKIP_NEW,
- OPT_SKIP_GRANT, OPT_SKIP_LOCK,
- OPT_ENABLE_LOCK, OPT_USE_LOCKING,
- OPT_SOCKET, OPT_UPDATE_LOG,
- OPT_BIN_LOG, OPT_SKIP_RESOLVE,
- OPT_SKIP_NETWORKING, OPT_BIN_LOG_INDEX,
- OPT_BIND_ADDRESS, OPT_PID_FILE,
- OPT_SKIP_PRIOR, OPT_BIG_TABLES,
- OPT_STANDALONE, OPT_ONE_THREAD,
- OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES,
- OPT_SKIP_HOST_CACHE, OPT_LONG_FORMAT,
- OPT_FLUSH, OPT_SAFE,
- OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB,
- OPT_TABLE_TYPE, OPT_INIT_FILE,
- OPT_DELAY_KEY_WRITE, OPT_SLOW_QUERY_LOG,
- OPT_SKIP_DELAY_KEY_WRITE, OPT_CHARSETS_DIR,
- OPT_BDB_HOME, OPT_BDB_LOG,
- OPT_BDB_TMP, OPT_BDB_NOSYNC,
- OPT_BDB_LOCK, OPT_BDB_SKIP,
- OPT_BDB_NO_RECOVER, OPT_BDB_SHARED,
- OPT_MASTER_HOST, OPT_MASTER_USER,
- OPT_MASTER_PASSWORD, OPT_MASTER_PORT,
- OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY,
- OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB,
- OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES,
- OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB,
- OPT_WANT_CORE, OPT_SKIP_CONCURRENT_INSERT,
- OPT_MEMLOCK, OPT_MYISAM_RECOVER,
- OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID,
- OPT_SKIP_SLAVE_START, OPT_SKIP_INNOBASE,
- OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE,
- OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
- OPT_REPLICATE_WILD_IGNORE_TABLE,
- OPT_DISCONNECT_SLAVE_EVENT_COUNT,
- OPT_ABORT_SLAVE_EVENT_COUNT,
- OPT_INNOBASE_DATA_HOME_DIR,
- OPT_INNOBASE_DATA_FILE_PATH,
- OPT_INNOBASE_LOG_GROUP_HOME_DIR,
- OPT_INNOBASE_LOG_ARCH_DIR,
- OPT_INNOBASE_LOG_ARCHIVE,
- OPT_INNOBASE_FLUSH_LOG_AT_TRX_COMMIT,
- OPT_SAFE_SHOW_DB,
- OPT_GEMINI_SKIP, OPT_INNOBASE_SKIP,
- OPT_TEMP_POOL
- };
- static struct option long_options[] = {
- {"ansi", no_argument, 0, 'a'},
- {"basedir", required_argument, 0, 'b'},
- #ifdef HAVE_BERKELEY_DB
- {"bdb-home", required_argument, 0, (int) OPT_BDB_HOME},
- {"bdb-lock-detect", required_argument, 0, (int) OPT_BDB_LOCK},
- {"bdb-logdir", required_argument, 0, (int) OPT_BDB_LOG},
- {"bdb-no-recover", no_argument, 0, (int) OPT_BDB_NO_RECOVER},
- {"bdb-no-sync", no_argument, 0, (int) OPT_BDB_NOSYNC},
- {"bdb-shared-data", no_argument, 0, (int) OPT_BDB_SHARED},
- {"bdb-tmpdir", required_argument, 0, (int) OPT_BDB_TMP},
- #endif
- {"big-tables", no_argument, 0, (int) OPT_BIG_TABLES},
- {"binlog-do-db", required_argument, 0, (int) OPT_BINLOG_DO_DB},
- {"binlog-ignore-db", required_argument, 0, (int) OPT_BINLOG_IGNORE_DB},
- {"bind-address", required_argument, 0, (int) OPT_BIND_ADDRESS},
- {"bootstrap", no_argument, 0, (int) OPT_BOOTSTRAP},
- #ifdef __WIN__
- {"console", no_argument, 0, (int) OPT_CONSOLE},
- #endif
- {"core-file", no_argument, 0, (int) OPT_WANT_CORE},
- {"chroot", required_argument, 0, 'r'},
- {"character-sets-dir", required_argument, 0, (int) OPT_CHARSETS_DIR},
- {"datadir", required_argument, 0, 'h'},
- #ifndef DBUG_OFF
- {"debug", optional_argument, 0, '#'},
- #endif
- {"default-character-set", required_argument, 0, 'C'},
- {"default-table-type", required_argument, 0, (int) OPT_TABLE_TYPE},
- {"delay-key-write-for-all-tables",
- no_argument, 0, (int) OPT_DELAY_KEY_WRITE},
- {"enable-locking", no_argument, 0, (int) OPT_ENABLE_LOCK},
- {"exit-info", optional_argument, 0, 'T'},
- {"flush", no_argument, 0, (int) OPT_FLUSH},
- /* We must always support this option to make scripts like mysqltest easier
- to do */
- {"innobase_data_file_path", required_argument, 0,
- OPT_INNOBASE_DATA_FILE_PATH},
- #ifdef HAVE_INNOBASE_DB
- {"innobase_data_home_dir", required_argument, 0,
- OPT_INNOBASE_DATA_HOME_DIR},
- {"innobase_log_group_home_dir", required_argument, 0,
- OPT_INNOBASE_LOG_GROUP_HOME_DIR},
- {"innobase_log_arch_dir", required_argument, 0,
- OPT_INNOBASE_LOG_ARCH_DIR},
- {"innobase_log_archive", optional_argument, 0,
- OPT_INNOBASE_LOG_ARCHIVE},
- {"innobase_flush_log_at_trx_commit", optional_argument, 0,
- OPT_INNOBASE_FLUSH_LOG_AT_TRX_COMMIT},
- #endif
- {"help", no_argument, 0, '?'},
- {"init-file", required_argument, 0, (int) OPT_INIT_FILE},
- {"log", optional_argument, 0, 'l'},
- {"language", required_argument, 0, 'L'},
- {"log-bin", optional_argument, 0, (int) OPT_BIN_LOG},
- {"log-bin-index", required_argument, 0, (int) OPT_BIN_LOG_INDEX},
- {"log-isam", optional_argument, 0, (int) OPT_ISAM_LOG},
- {"log-update", optional_argument, 0, (int) OPT_UPDATE_LOG},
- {"log-slow-queries", optional_argument, 0, (int) OPT_SLOW_QUERY_LOG},
- {"log-long-format", no_argument, 0, (int) OPT_LONG_FORMAT},
- {"log-slave-updates", no_argument, 0, (int) OPT_LOG_SLAVE_UPDATES},
- {"low-priority-updates", no_argument, 0, (int) OPT_LOW_PRIORITY_UPDATES},
- {"master-host", required_argument, 0, (int) OPT_MASTER_HOST},
- {"master-user", required_argument, 0, (int) OPT_MASTER_USER},
- {"master-password", required_argument, 0, (int) OPT_MASTER_PASSWORD},
- {"master-port", required_argument, 0, (int) OPT_MASTER_PORT},
- {"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY},
- {"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE},
- {"myisam-recover", optional_argument, 0, (int) OPT_MYISAM_RECOVER},
- {"memlock", no_argument, 0, (int) OPT_MEMLOCK},
- // needs to be available for the test case to pass in non-debugging mode
- // is a no-op
- {"disconnect-slave-event-count", required_argument, 0,
- (int) OPT_DISCONNECT_SLAVE_EVENT_COUNT},
- {"abort-slave-event-count", required_argument, 0,
- (int) OPT_ABORT_SLAVE_EVENT_COUNT},
- #if !defined(DBUG_OFF) && defined(SAFEMALLOC)
- {"safemalloc-mem-limit", required_argument, 0, (int)
- OPT_SAFEMALLOC_MEM_LIMIT},
- #endif
- {"new", no_argument, 0, 'n'},
- {"old-protocol", no_argument, 0, 'o'},
- #ifdef ONE_THREAD
- {"one-thread", no_argument, 0, (int) OPT_ONE_THREAD},
- #endif
- {"pid-file", required_argument, 0, (int) OPT_PID_FILE},
- {"port", required_argument, 0, 'P'},
- {"replicate-do-db", required_argument, 0, (int) OPT_REPLICATE_DO_DB},
- {"replicate-do-table", required_argument, 0,
- (int) OPT_REPLICATE_DO_TABLE},
- {"replicate-wild-do-table", required_argument, 0,
- (int) OPT_REPLICATE_WILD_DO_TABLE},
- {"replicate-ignore-db", required_argument, 0,
- (int) OPT_REPLICATE_IGNORE_DB},
- {"replicate-ignore-table", required_argument, 0,
- (int) OPT_REPLICATE_IGNORE_TABLE},
- {"replicate-wild-ignore-table", required_argument, 0,
- (int) OPT_REPLICATE_WILD_IGNORE_TABLE},
- {"replicate-rewrite-db", required_argument, 0,
- (int) OPT_REPLICATE_REWRITE_DB},
- {"safe-mode", no_argument, 0, (int) OPT_SAFE},
- {"safe-show-database", no_argument, 0, (int) OPT_SAFE_SHOW_DB},
- {"socket", required_argument, 0, (int) OPT_SOCKET},
- {"server-id", required_argument, 0, (int) OPT_SERVER_ID},
- {"set-variable", required_argument, 0, 'O'},
- {"skip-bdb", no_argument, 0, (int) OPT_BDB_SKIP},
- {"skip-innobase", no_argument, 0, (int) OPT_INNOBASE_SKIP},
- {"skip-gemini", no_argument, 0, (int) OPT_GEMINI_SKIP},
- {"skip-concurrent-insert", no_argument, 0, (int) OPT_SKIP_CONCURRENT_INSERT},
- {"skip-delay-key-write", no_argument, 0, (int) OPT_SKIP_DELAY_KEY_WRITE},
- {"skip-grant-tables", no_argument, 0, (int) OPT_SKIP_GRANT},
- {"skip-locking", no_argument, 0, (int) OPT_SKIP_LOCK},
- {"skip-host-cache", no_argument, 0, (int) OPT_SKIP_HOST_CACHE},
- {"skip-name-resolve", no_argument, 0, (int) OPT_SKIP_RESOLVE},
- {"skip-new", no_argument, 0, (int) OPT_SKIP_NEW},
- {"skip-show-database", no_argument, 0, (int) OPT_SKIP_SHOW_DB},
- {"skip-slave-start", no_argument, 0, (int) OPT_SKIP_SLAVE_START},
- {"skip-networking", no_argument, 0, (int) OPT_SKIP_NETWORKING},
- {"skip-thread-priority", no_argument, 0, (int) OPT_SKIP_PRIOR},
- {"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME},
- #include "sslopt-longopts.h"
- #ifdef __WIN__
- {"standalone", no_argument, 0, (int) OPT_STANDALONE},
- #endif
- {"temp-pool", no_argument, 0, (int) OPT_TEMP_POOL},
- {"tmpdir", required_argument, 0, 't'},
- {"use-locking", no_argument, 0, (int) OPT_USE_LOCKING},
- #ifdef USE_SYMDIR
- {"use-symbolic-links", no_argument, 0, 's'},
- #endif
- {"user", required_argument, 0, 'u'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
- };
- CHANGEABLE_VAR changeable_vars[] = {
- { "back_log", (long*) &back_log,
- 50, 1, 65535, 0, 1 },
- #ifdef HAVE_BERKELEY_DB
- { "bdb_cache_size", (long*) &berkeley_cache_size,
- KEY_CACHE_SIZE, 20*1024, (long) ~0, 0, IO_SIZE },
- {"bdb_log_buffer_size", (long*) &berkeley_log_buffer_size, 0, 256*1024L,
- ~0L, 0, 1024},
- { "bdb_max_lock", (long*) &berkeley_max_lock,
- 10000, 0, (long) ~0, 0, 1 },
- /* QQ: The following should be removed soon! */
- { "bdb_lock_max", (long*) &berkeley_max_lock,
- 10000, 0, (long) ~0, 0, 1 },
- #endif
- { "binlog_cache_size", (long*) &binlog_cache_size,
- 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE },
- { "connect_timeout", (long*) &connect_timeout,
- CONNECT_TIMEOUT, 2, 65535, 0, 1 },
- { "delayed_insert_timeout", (long*) &delayed_insert_timeout,
- DELAYED_WAIT_TIMEOUT, 1, ~0L, 0, 1 },
- { "delayed_insert_limit", (long*) &delayed_insert_limit,
- DELAYED_LIMIT, 1, ~0L, 0, 1 },
- { "delayed_queue_size", (long*) &delayed_queue_size,
- DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1 },
- { "flush_time", (long*) &flush_time,
- FLUSH_TIME, 0, ~0L, 0, 1 },
- #ifdef HAVE_INNOBASE_DB
- {"innobase_mirrored_log_groups",
- (long*) &innobase_mirrored_log_groups, 1, 1, 10, 0, 1},
- {"innobase_log_files_in_group",
- (long*) &innobase_log_files_in_group, 2, 2, 100, 0, 1},
- {"innobase_log_file_size",
- (long*) &innobase_log_file_size, 5*1024*1024L, 1*1024*1024L,
- ~0L, 0, 1024*1024L},
- {"innobase_log_buffer_size",
- (long*) &innobase_log_buffer_size, 1024*1024L, 256*1024L,
- ~0L, 0, 1024},
- {"innobase_buffer_pool_size",
- (long*) &innobase_buffer_pool_size, 8*1024*1024L, 1024*1024L,
- ~0L, 0, 1024*1024L},
- {"innobase_additional_mem_pool_size",
- (long*) &innobase_additional_mem_pool_size, 1*1024*1024L, 512*1024L,
- ~0L, 0, 1024},
- {"innobase_file_io_threads",
- (long*) &innobase_file_io_threads, 9, 4, 64, 0, 1},
- {"innobase_lock_wait_timeout",
- (long*) &innobase_lock_wait_timeout, 1024 * 1024 * 1024, 1,
- 1024 * 1024 * 1024, 0, 1},
- #endif
- { "interactive_timeout", (long*) &net_interactive_timeout,
- NET_WAIT_TIMEOUT, 1, 31*24*60*60, 0, 1 },
- { "join_buffer_size", (long*) &join_buff_size,
- 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE },
- { "key_buffer_size", (long*) &keybuff_size,
- KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE },
- { "long_query_time", (long*) &long_query_time,
- 10, 1, ~0L, 0, 1 },
- { "lower_case_table_names", (long*) &lower_case_table_names,
- IF_WIN(1,0), 0, 1, 0, 1 },
- { "max_allowed_packet", (long*) &max_allowed_packet,
- 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024 },
- { "max_binlog_cache_size", (long*) &max_binlog_cache_size,
- ~0L, IO_SIZE, ~0L, 0, IO_SIZE },
- { "max_binlog_size", (long*) &max_binlog_size,
- 1024*1024L*1024L, 1024, 1024*1024L*1024L, 0, 1 },
- { "max_connections", (long*) &max_connections,
- 100, 1, 16384, 0, 1 },
- { "max_connect_errors", (long*) &max_connect_errors,
- MAX_CONNECT_ERRORS, 1, ~0L, 0, 1 },
- { "max_delayed_threads", (long*) &max_insert_delayed_threads,
- 20, 1, 16384, 0, 1 },
- { "max_heap_table_size", (long*) &max_heap_table_size,
- 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024 },
- { "max_join_size", (long*) &max_join_size,
- ~0L, 1, ~0L, 0, 1 },
- { "max_sort_length", (long*) &max_item_sort_length,
- 1024, 4, 8192*1024L, 0, 1 },
- { "max_tmp_tables", (long*) &max_tmp_tables,
- 32, 1, ~0L, 0, 1 },
- { "max_user_connections", (long*) &max_user_connections,
- 0, 1, ~0L, 0, 1 },
- { "max_write_lock_count", (long*) &max_write_lock_count,
- ~0L, 1, ~0L, 0, 1 },
- { "myisam_sort_buffer_size", (long*) &myisam_sort_buffer_size,
- 8192*1024, 4, ~0L, 0, 1 },
- { "net_buffer_length", (long*) &net_buffer_length,
- 16384, 1024, 1024*1024L, MALLOC_OVERHEAD, 1024 },
- { "net_retry_count", (long*) &mysqld_net_retry_count,
- MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1 },
- { "net_read_timeout", (long*) &net_read_timeout,
- NET_READ_TIMEOUT, 1, 65535, 0, 1 },
- { "net_write_timeout", (long*) &net_write_timeout,
- NET_WRITE_TIMEOUT, 1, 65535, 0, 1 },
- { "open_files_limit", (long*) &open_files_limit,
- 0, 0, 65535, 0, 1},
- { "query_buffer_size", (long*) &query_buff_size,
- 0, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE },
- { "record_buffer", (long*) &my_default_record_cache_size,
- 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE },
- { "slow_launch_time", (long*) &slow_launch_time,
- 2L, 0L, ~0L, 0, 1 },
- { "sort_buffer", (long*) &sortbuff_size,
- MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD, 1 },
- { "table_cache", (long*) &table_cache_size,
- 64, 1, 16384, 0, 1 },
- { "thread_concurrency", (long*) &concurrency,
- DEFAULT_CONCURRENCY, 1, 512, 0, 1 },
- { "thread_cache_size", (long*) &thread_cache_size,
- 0, 0, 16384, 0, 1 },
- { "tmp_table_size", (long*) &tmp_table_size,
- 1024*1024L, 1024, ~0L, MALLOC_OVERHEAD, 1 },
- { "thread_stack", (long*) &thread_stack,
- DEFAULT_THREAD_STACK, 1024*32, ~0L, 0, 1024 },
- { "wait_timeout", (long*) &net_wait_timeout,
- NET_WAIT_TIMEOUT, 1, ~0L, 0, 1 },
- { NullS, (long*) 0, 0, 0, 0, 0, 0}
- };
- struct show_var_st init_vars[]= {
- {"ansi_mode", (char*) &opt_ansi_mode, SHOW_BOOL},
- {"back_log", (char*) &back_log, SHOW_LONG},
- {"basedir", mysql_home, SHOW_CHAR},
- #ifdef HAVE_BERKELEY_DB
- {"bdb_cache_size", (char*) &berkeley_cache_size, SHOW_LONG},
- {"bdb_log_buffer_size", (char*) &berkeley_log_buffer_size, SHOW_LONG},
- {"bdb_home", (char*) &berkeley_home, SHOW_CHAR_PTR},
- {"bdb_max_lock", (char*) &berkeley_max_lock, SHOW_LONG},
- {"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR},
- {"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL},
- {"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR},
- {"bdb_version", (char*) DB_VERSION_STRING, SHOW_CHAR},
- #endif
- {"binlog_cache_size", (char*) &binlog_cache_size, SHOW_LONG},
- {"character_set", default_charset, SHOW_CHAR},
- {"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
- {"concurrent_insert", (char*) &myisam_concurrent_insert, SHOW_MY_BOOL},
- {"connect_timeout", (char*) &connect_timeout, SHOW_LONG},
- {"datadir", mysql_real_data_home, SHOW_CHAR},
- {"delay_key_write", (char*) &myisam_delay_key_write, SHOW_MY_BOOL},
- {"delayed_insert_limit", (char*) &delayed_insert_limit, SHOW_LONG},
- {"delayed_insert_timeout", (char*) &delayed_insert_timeout, SHOW_LONG},
- {"delayed_queue_size", (char*) &delayed_queue_size, SHOW_LONG},
- {"flush", (char*) &myisam_flush, SHOW_MY_BOOL},
- {"flush_time", (char*) &flush_time, SHOW_LONG},
- {"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
- {"have_gemini", (char*) &have_gemini, SHOW_HAVE},
- {"have_innobase", (char*) &have_innobase, SHOW_HAVE},
- {"have_isam", (char*) &have_isam, SHOW_HAVE},
- {"have_raid", (char*) &have_raid, SHOW_HAVE},
- {"have_ssl", (char*) &have_ssl, SHOW_HAVE},
- {"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
- #ifdef HAVE_INNOBASE_DB
- {"innobase_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR},
- {"innobase_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
- {"innobase_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_MY_BOOL},
- {"innobase_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
- {"innobase_log_archive", (char*) &innobase_log_archive, SHOW_MY_BOOL},
- {"innobase_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
- #endif
- {"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG},
- {"join_buffer_size", (char*) &join_buff_size, SHOW_LONG},
- {"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
- {"language", language, SHOW_CHAR},
- {"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
- #ifdef HAVE_MLOCKALL
- {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
- #endif
- {"log", (char*) &opt_log, SHOW_BOOL},
- {"log_update", (char*) &opt_update_log, SHOW_BOOL},
- {"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_BOOL},
- {"long_query_time", (char*) &long_query_time, SHOW_LONG},
- {"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG},
- {"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG},
- {"max_binlog_cache_size", (char*) &max_binlog_cache_size, SHOW_LONG},
- {"max_binlog_size", (char*) &max_binlog_size, SHOW_LONG},
- {"max_connections", (char*) &max_connections, SHOW_LONG},
- {"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG},
- {"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG},
- {"max_heap_table_size", (char*) &max_heap_table_size, SHOW_LONG},
- {"max_join_size", (char*) &max_join_size, SHOW_LONG},
- {"max_sort_length", (char*) &max_item_sort_length, SHOW_LONG},
- {"max_user_connections", (char*) &max_user_connections, SHOW_LONG},
- {"max_tmp_tables", (char*) &max_tmp_tables, SHOW_LONG},
- {"max_write_lock_count", (char*) &max_write_lock_count, SHOW_LONG},
- {"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
- {"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG},
- {"net_buffer_length", (char*) &net_buffer_length, SHOW_LONG},
- {"net_read_timeout", (char*) &net_read_timeout, SHOW_LONG},
- {"net_retry_count", (char*) &mysqld_net_retry_count, SHOW_LONG},
- {"net_write_timeout", (char*) &net_write_timeout, SHOW_LONG},
- {"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
- {"pid_file", (char*) pidfile_name, SHOW_CHAR},
- {"port", (char*) &mysql_port, SHOW_INT},
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG},
- {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
- {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL},
- {"server_id", (char*) &server_id, SHOW_LONG},
- {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
- {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
- {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
- {"slow_launch_time", (char*) &slow_launch_time, SHOW_LONG},
- {"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR},
- {"sort_buffer", (char*) &sortbuff_size, SHOW_LONG},
- {"table_cache", (char*) &table_cache_size, SHOW_LONG},
- {"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
- {"thread_cache_size", (char*) &thread_cache_size, SHOW_LONG},
- #ifdef HAVE_THR_SETCONCURRENCY
- {"thread_concurrency", (char*) &concurrency, SHOW_LONG},
- #endif
- {"thread_stack", (char*) &thread_stack, SHOW_LONG},
- #ifdef HAVE_TZNAME
- {"timezone", time_zone, SHOW_CHAR},
- #endif
- {"tmp_table_size", (char*) &tmp_table_size, SHOW_LONG},
- {"tmpdir", (char*) &mysql_tmpdir, SHOW_CHAR_PTR},
- {"version", server_version, SHOW_CHAR},
- {"wait_timeout", (char*) &net_wait_timeout, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}
- };
- struct show_var_st status_vars[]= {
- {"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
- {"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
- {"Bytes_received", (char*) &bytes_received, SHOW_LONG},
- {"Bytes_sent", (char*) &bytes_sent, SHOW_LONG},
- {"Connections", (char*) &thread_id, SHOW_LONG_CONST},
- {"Created_tmp_disk_tables", (char*) &created_tmp_disk_tables,SHOW_LONG},
- {"Created_tmp_tables", (char*) &created_tmp_tables, SHOW_LONG},
- {"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_delete", (char*) &ha_delete_count, SHOW_LONG},
- {"Handler_read_first", (char*) &ha_read_first_count, SHOW_LONG},
- {"Handler_read_key", (char*) &ha_read_key_count, SHOW_LONG},
- {"Handler_read_next", (char*) &ha_read_next_count, SHOW_LONG},
- {"Handler_read_prev", (char*) &ha_read_prev_count, SHOW_LONG},
- {"Handler_read_rnd", (char*) &ha_read_rnd_count, SHOW_LONG},
- {"Handler_read_rnd_next", (char*) &ha_read_rnd_next_count, SHOW_LONG},
- {"Handler_update", (char*) &ha_update_count, SHOW_LONG},
- {"Handler_write", (char*) &ha_write_count, SHOW_LONG},
- {"Key_blocks_used", (char*) &_my_blocks_used, SHOW_LONG_CONST},
- {"Key_read_requests", (char*) &_my_cache_r_requests, SHOW_LONG},
- {"Key_reads", (char*) &_my_cache_read, SHOW_LONG},
- {"Key_write_requests", (char*) &_my_cache_w_requests, SHOW_LONG},
- {"Key_writes", (char*) &_my_cache_write, SHOW_LONG},
- {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
- {"Not_flushed_key_blocks", (char*) &_my_blocks_changed, SHOW_LONG_CONST},
- {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST},
- {"Open_tables", (char*) 0, SHOW_OPENTABLES},
- {"Open_files", (char*) &my_file_opened, SHOW_INT_CONST},
- {"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST},
- {"Opened_tables", (char*) &opened_tables, SHOW_LONG},
- {"Questions", (char*) 0, SHOW_QUESTION},
- {"Select_full_join", (char*) &select_full_join_count, SHOW_LONG},
- {"Select_full_range_join", (char*) &select_full_range_join_count, SHOW_LONG},
- {"Select_range", (char*) &select_range_count, SHOW_LONG},
- {"Select_range_check", (char*) &select_range_check_count, SHOW_LONG},
- {"Select_scan", (char*) &select_scan_count, SHOW_LONG},
- {"Slave_running", (char*) &slave_running, SHOW_BOOL},
- {"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
- {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
- {"Slow_queries", (char*) &long_query_count, SHOW_LONG},
- {"Sort_merge_passes", (char*) &filesort_merge_passes, SHOW_LONG},
- {"Sort_range", (char*) &filesort_range_count, SHOW_LONG},
- {"Sort_rows", (char*) &filesort_rows, SHOW_LONG},
- {"Sort_scan", (char*) &filesort_scan_count, SHOW_LONG},
- {"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG},
- {"Table_locks_waited", (char*) &locks_waited, SHOW_LONG},
- {"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_CONST},
- {"Threads_created", (char*) &thread_created, SHOW_LONG_CONST},
- {"Threads_connected", (char*) &thread_count, SHOW_INT_CONST},
- {"Threads_running", (char*) &thread_running, SHOW_INT_CONST},
- {"Uptime", (char*) 0, SHOW_STARTTIME},
- {NullS, NullS, SHOW_LONG}
- };
- static void print_version(void)
- {
- printf("%s Ver %s for %s on %sn",my_progname,
- server_version,SYSTEM_TYPE,MACHINE_TYPE);
- }
- static void use_help(void)
- {
- print_version();
- printf("Use '--help' or '--no-defaults --help' for a list of available optionsn");
- }
- static void usage(void)
- {
- print_version();
- puts("Copyright (C) 2000 MySQL AB & MySQL Finland AB, by Monty and others");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
- puts("and you are welcome to modify and redistribute it under the GPL licensen");
- puts("Starts the MySQL servern");
- printf("Usage: %s [OPTIONS]n", my_progname);
- puts("n
- --ansi Use ANSI SQL syntax instead of MySQL syntaxn
- -b, --basedir=path Path to installation directory. All paths aren
- usually resolved relative to thisn
- --big-tables Allow big result sets by saving all temporary setsn
- on file (Solves most 'table full' errors)n
- --bind-address=IP Ip address to bind ton
- --bootstrap Used by mysql installation scriptsn
- --character-sets-dir=...n
- Directory where character sets aren
- --chroot=path Chroot mysqld daemon during startupn
- --core-file Write core on errorsn
- -h, --datadir=path Path to the database root");
- #ifndef DBUG_OFF
- printf("
- -#, --debug[=...] Debug log. Default is '%s'n",default_dbug_option);
- #endif
- puts("
- --default-character-set=charsetn
- Set the default character setn
- --default-table-type=typen
- Set the default table type for tablesn
- --delay-key-write-for-all-tablesn
- Don't flush key buffers between writes for any MyISAMn
- tablen
- --enable-locking Enable system lockingn
- -T, --exit-info Used for debugging; Use at your own risk!n
- --flush Flush tables to disk between SQL commandsn
- -?, --help Display this help and exitn
- --init-file=file Read SQL commands from this file at startupn
- -L, --language=... Client error messages in given language. May ben
- given as a full pathn
- -l, --log[=file] Log connections and queries to filen
- --log-bin[=file] Log queries in new binary format (for replication)n
- --log-bin-index=file File that holds the names for last binary log filesn
- --log-update[=file] Log updates to file.# where # is a unique numbern
- if not given.n
- --log-isam[=file] Log all MyISAM changes to filen
- --log-long-format Log some extra information to update logn
- --low-priority-updates INSERT/DELETE/UPDATE has lower priority than selectsn
- --log-slow-queries=[file]n
- Log slow queries to this log file. Defaults loggingn
- to hostname-slow.logn
- --pid-file=path Pid file used by safe_mysqldn
- --myisam-recover[=option[,option...]] where options is one of DEAULT,n
- BACKUP or FORCE.n
- --memlock Lock mysqld in memoryn
- -n, --new Use very new possible 'unsafe' functionsn
- -o, --old-protocol Use the old (3.20) protocoln
- -P, --port=... Port number to use for connectionn");
- #ifdef ONE_THREAD
- puts("
- --one-thread Only use one thread (for debugging under Linux)n");
- #endif
- puts("
- -O, --set-variable var=optionn
- Give a variable an value. --help lists variablesn
- -Sg, --skip-grant-tablesn
- Start without grant tables. This gives all usersn
- FULL ACCESS to all tables!n
- --safe-mode Skip some optimize stages (for testing)n
- --skip-concurrent-insertn
- Don't use concurrent insert with MyISAMn
- --skip-delay-key-writen
- Ignore the delay_key_write option for all tablesn
- --skip-locking Don't use system locking. To use isamchk one hasn
- to shut down the server.n
- --skip-name-resolve Don't resolve hostnames.n
- All hostnames are IP's or 'localhost'n
- --skip-networking Don't allow connection with TCP/IP.n
- --skip-new Don't use new, possible wrong routines.n
- --skip-host-cache Don't cache host namesn");
- /* We have to break the string here because of VC++ limits */
- puts("
- --skip-show-database Don't allow 'SHOW DATABASE' commandsn
- --skip-thread-priorityn
- Don't give threads different priorities.n
- --socket=... Socket file to use for connectionn
- -t, --tmpdir=path Path for temporary filesn
- --temp-pool Use a pool of temporary filesn
- -u, --user=user_name Run mysqld daemon as usern
- -V, --version output version information and exit");
- #ifdef __WIN__
- puts("NT and Win32 specific options:n
- --console Don't remove the console windown
- --install Install mysqld as a service (NT)n
- --remove Remove mysqld from the service list (NT)n
- --standalone Dummy option to start as a standalone program (NT)n
- ");
- #endif
- #ifdef HAVE_BERKELEY_DB
- puts("
- --bdb-home= directory Berkeley home direcoryn
- --bdb-lock-detect=# Berkeley lock detectn
- (DEFAULT, OLDEST, RANDOM or YOUNGEST, # sec)n
- --bdb-logdir=directory Berkeley DB log file directoryn
- --bdb-no-sync Don't synchronously flush logsn
- --bdb-no-recover Don't try to recover Berkeley DB tables on startn
- --bdb-shared-data Start Berkeley DB in multi-process moden
- --bdb-tmpdir=directory Berkeley DB tempfile namen
- --skip-bdb Don't use berkeley db (will save memory)n
- ");
- #endif /* HAVE_BERKELEY_DB */
- #ifdef HAVE_INNOBASE_DB
- puts("
- --innobase_data_home_dir=dir The common part for innobase table spacesn
- --innobase_data_file_path=dir Path to individual files and their sizesn
- --innobase_flush_log_at_trx_commit[=#]
- Set to 0 if you don't want to flush logsn
- --innobase_log_arch_dir=dir Where full logs should be archivedn
- --innobase_log_archive[=#] Set to 1 if you want to have logs archivedn
- --innobase_log_group_home_dir=dir Path to Innobase log files.
- --skip-innobase Don't use innobase (will save memory)n
- ");
- #endif /* HAVE_INNOBASE_DB */
- print_defaults("my",load_default_groups);
- puts("");
- #include "sslopt-usage.h"
- fix_paths();
- set_ports();
- printf("
- To see what values a running MySQL server is using, typen
- 'mysqladmin variables' instead of 'mysqld --help'.n
- The default values (after parsing the command line arguments) are:nn");
- printf("basedir: %sn",mysql_home);
- printf("datadir: %sn",mysql_real_data_home);
- printf("tmpdir: %sn",mysql_tmpdir);
- printf("language: %sn",language);
- #ifndef __WIN__
- printf("pid file: %sn",pidfile_name);
- #endif
- if (opt_logname)
- printf("logfile: %sn",opt_logname);
- if (opt_update_logname)
- printf("update log: %sn",opt_update_logname);
- if (opt_bin_log)
- {
- printf("binary log: %sn",opt_bin_logname ? opt_bin_logname : "");
- printf("binary log index: %sn",
- opt_binlog_index_name ? opt_binlog_index_name : "");
- }
- if (opt_slow_logname)
- printf("update log: %sn",opt_slow_logname);
- printf("TCP port: %dn",mysql_port);
- #if defined(HAVE_SYS_UN_H)
- printf("Unix socket: %sn",mysql_unix_port);
- #endif
- if (my_disable_locking)
- puts("nsystem locking is not in use");
- if (opt_noacl)
- puts("nGrant tables are not used. All users have full access rights");
- printf("nPossible variables for option --set-variable (-O) are:n");
- for (uint i=0 ; changeable_vars[i].name ; i++)
- printf("%-20s current value: %lun",
- changeable_vars[i].name,
- (ulong) *changeable_vars[i].varptr);
- }
- static void set_options(void)
- {
- set_all_changeable_vars( changeable_vars );
- #if !defined( my_pthread_setprio ) && !defined( HAVE_PTHREAD_SETSCHEDPARAM )
- opt_specialflag |= SPECIAL_NO_PRIOR;
- #endif
- (void) strmov( default_charset, MYSQL_CHARSET);
- (void) strmov( language, LANGUAGE);
- (void) strmov( mysql_real_data_home, get_relative_path(DATADIR));
- #ifdef __WIN__
- /* Allow Win32 users to move MySQL anywhere */
- {
- char prg_dev[LIBLEN];
- my_path(prg_dev,my_progname,"mysql/bin");
- strcat(prg_dev,"/../"); // Remove 'bin' to get base dir
- cleanup_dirname(mysql_home,prg_dev);
- }
- #else
- const char *tmpenv;
- if ( !(tmpenv = getenv("MY_BASEDIR_VERSION")))
- tmpenv = DEFAULT_MYSQL_HOME;
- (void) strmov( mysql_home, tmpenv );
- #endif
- #if defined( HAVE_mit_thread ) || defined( __WIN__ ) || defined( HAVE_LINUXTHREADS )
- my_disable_locking = 1;
- #endif
- my_bind_addr = htonl( INADDR_ANY );
- }
- /* Initiates DEBUG - but no debugging here ! */
- static void get_options(int argc,char **argv)
- {
- int c,option_index=0;
- myisam_delay_key_write=1; // Allow use of this
- while ((c=getopt_long(argc,argv,"ab:C:h:#::T::?l::L:O:P:sS::t:u:noVvI?",
- long_options, &option_index)) != EOF)
- {
- switch(c) {
- #ifndef DBUG_OFF
- case '#':
- DBUG_PUSH(optarg ? optarg : default_dbug_option);
- opt_endinfo=1; /* unireg: memory allocation */
- break;
- #endif
- case 'a':
- opt_ansi_mode=1;
- thd_startup_options|=OPTION_ANSI_MODE;
- break;
- case 'b':
- strmov(mysql_home,optarg);
- break;
- case 'l':
- opt_log=1;
- opt_logname=optarg; // Use hostname.log if null
- break;
- case 'h':
- strmov(mysql_real_data_home,optarg);
- break;
- case 'L':
- strmov(language,optarg);
- break;
- case 'n':
- opt_specialflag|= SPECIAL_NEW_FUNC;
- break;
- case 'o':
- protocol_version=PROTOCOL_VERSION-1;
- break;
- case 'O':
- if (set_changeable_var(optarg, changeable_vars))
- {
- use_help();
- exit(1);
- }
- break;
- case 'P':
- mysql_port= (unsigned int) atoi(optarg);
- break;
- #if !defined(DBUG_OFF) && defined(SAFEMALLOC)
- case OPT_SAFEMALLOC_MEM_LIMIT:
- safemalloc_mem_limit = atoi(optarg);
- break;
- #endif
- case OPT_SOCKET:
- mysql_unix_port= optarg;
- break;
- case 'r':
- mysqld_chroot=optarg;
- break;
- #ifdef USE_SYMDIR
- case 's':
- my_use_symdir=1; /* Use internal symbolic links */
- break;
- #endif
- case 't':
- mysql_tmpdir=optarg;
- break;
- case OPT_TEMP_POOL:
- use_temp_pool=1;
- break;
- case 'u':
- mysqld_user=optarg;
- break;
- case 'v':
- case 'V':
- print_version();
- exit(0);
- case 'I':
- case '?':
- usage();
- exit(0);
- case 'T':
- test_flags= optarg ? (uint) atoi(optarg) : 0;
- opt_endinfo=1;
- break;
- case 'S':
- if (!optarg)
- opt_specialflag|= SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE;
- else if (!strcmp(optarg,"l"))
- my_disable_locking=1;
- else if (!strcmp(optarg,"g"))
- opt_noacl=1;
- else
- {
- fprintf(stderr,"%s: Unrecognized option: %sn",my_progname,optarg);
- use_help();
- exit(1);
- }
- break;
- case (int) OPT_BIG_TABLES:
- thd_startup_options|=OPTION_BIG_TABLES;
- break;
- case (int) OPT_ISAM_LOG:
- opt_myisam_log=1;
- if (optarg)
- myisam_log_filename=optarg;
- break;
- case (int) OPT_UPDATE_LOG:
- opt_update_log=1;
- opt_update_logname=optarg; // Use hostname.# if null
- break;
- case (int) OPT_BIN_LOG_INDEX:
- opt_binlog_index_name = optarg;
- break;
- case (int) OPT_BIN_LOG:
- opt_bin_log=1;
- x_free(opt_bin_logname);
- if (optarg && optarg[0])
- opt_bin_logname=my_strdup(optarg,MYF(0));
- break;
- // needs to be handled (as no-op) in non-debugging mode for test suite
- case (int)OPT_DISCONNECT_SLAVE_EVENT_COUNT:
- #ifndef DBUG_OFF
- disconnect_slave_event_count = atoi(optarg);
- #endif
- break;
- case (int)OPT_ABORT_SLAVE_EVENT_COUNT:
- #ifndef DBUG_OFF
- abort_slave_event_count = atoi(optarg);
- #endif
- break;
- case (int) OPT_LOG_SLAVE_UPDATES:
- opt_log_slave_updates = 1;
- break;
- case (int)OPT_REPLICATE_IGNORE_DB:
- {
- i_string *db = new i_string(optarg);
- replicate_ignore_db.push_back(db);
- break;
- }
- case (int)OPT_REPLICATE_DO_DB:
- {
- i_string *db = new i_string(optarg);
- replicate_do_db.push_back(db);
- break;
- }
- case (int)OPT_REPLICATE_REWRITE_DB:
- {
- char* key = optarg,*p, *val;
- p = strstr(optarg, "->");
- if (!p)
- {
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - missing '->'!n");
- exit(1);
- }
- val = p--;
- while(isspace(*p) && p > optarg) *p-- = 0;
- if(p == optarg)
- {
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - empty FROM db!n");
- exit(1);
- }
- *val = 0;
- val += 2;
- while(*val && isspace(*val)) *val++;
- if (!*val)
- {
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - empty TO db!n");
- exit(1);
- }
- i_string_pair* db_pair = new i_string_pair(key, val);
- replicate_rewrite_db.push_back(db_pair);
- break;
- }
- case (int)OPT_BINLOG_IGNORE_DB:
- {
- i_string *db = new i_string(optarg);
- binlog_ignore_db.push_back(db);
- break;
- }
- case (int)OPT_BINLOG_DO_DB:
- {
- i_string *db = new i_string(optarg);
- binlog_do_db.push_back(db);
- break;
- }
- case (int)OPT_REPLICATE_DO_TABLE:
- {
- if (!do_table_inited)
- init_table_rule_hash(&replicate_do_table, &do_table_inited);
- if(add_table_rule(&replicate_do_table, optarg))
- {
- fprintf(stderr, "Could not add do table rule '%s'!n", optarg);
- exit(1);
- }
- table_rules_on = 1;
- break;
- }
- case (int)OPT_REPLICATE_WILD_DO_TABLE:
- {
- if (!wild_do_table_inited)
- init_table_rule_array(&replicate_wild_do_table,
- &wild_do_table_inited);
- if(add_wild_table_rule(&replicate_wild_do_table, optarg))
- {
- fprintf(stderr, "Could not add do table rule '%s'!n", optarg);
- exit(1);
- }
- table_rules_on = 1;
- break;
- }
- case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
- {
- if (!wild_ignore_table_inited)
- init_table_rule_array(&replicate_wild_ignore_table,
- &wild_ignore_table_inited);
- if(add_wild_table_rule(&replicate_wild_ignore_table, optarg))
- {
- fprintf(stderr, "Could not add ignore table rule '%s'!n", optarg);
- exit(1);
- }
- table_rules_on = 1;
- break;
- }
- case (int)OPT_REPLICATE_IGNORE_TABLE:
- {
- if (!ignore_table_inited)
- init_table_rule_hash(&replicate_ignore_table, &ignore_table_inited);
- if(add_table_rule(&replicate_ignore_table, optarg))
- {
- fprintf(stderr, "Could not add ignore table rule '%s'!n", optarg);
- exit(1);
- }
- table_rules_on = 1;
- break;
- }
- case (int) OPT_SQL_BIN_UPDATE_SAME:
- opt_sql_bin_update = 1;
- break;
- case (int) OPT_SLOW_QUERY_LOG:
- opt_slow_log=1;
- opt_slow_logname=optarg;
- break;
- case (int)OPT_SKIP_SLAVE_START:
- opt_skip_slave_start = 1;
- break;
- case (int) OPT_SKIP_NEW:
- opt_specialflag|= SPECIAL_NO_NEW_FUNC;
- default_table_type=DB_TYPE_ISAM;
- myisam_delay_key_write=0;
- myisam_concurrent_insert=0;
- myisam_recover_options= HA_RECOVER_NONE;
- ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED;
- break;
- case (int) OPT_SAFE:
- opt_specialflag|= SPECIAL_SAFE_MODE;
- myisam_delay_key_write=0;
- myisam_recover_options= HA_RECOVER_NONE; // To be changed
- ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED;
- break;
- case (int) OPT_SKIP_CONCURRENT_INSERT:
- myisam_concurrent_insert=0;
- break;
- case (int) OPT_SKIP_PRIOR:
- opt_specialflag|= SPECIAL_NO_PRIOR;
- break;
- case (int) OPT_SKIP_GRANT:
- opt_noacl=1;
- break;
- case (int) OPT_SKIP_LOCK:
- my_disable_locking=1;
- break;
- case (int) OPT_SKIP_HOST_CACHE:
- opt_specialflag|= SPECIAL_NO_HOST_CACHE;
- break;
- case (int) OPT_ENABLE_LOCK:
- my_disable_locking=0;
- break;
- case (int) OPT_USE_LOCKING:
- my_disable_locking=0;
- break;
- case (int) OPT_SKIP_RESOLVE:
- opt_specialflag|=SPECIAL_NO_RESOLVE;
- break;
- case (int) OPT_LONG_FORMAT:
- opt_specialflag|=SPECIAL_LONG_LOG_FORMAT;
- break;
- case (int) OPT_SKIP_NETWORKING:
- opt_disable_networking=1;
- mysql_port=0;
- break;
- case (int) OPT_SKIP_SHOW_DB:
- opt_skip_show_db=1;
- opt_specialflag|=SPECIAL_SKIP_SHOW_DB;
- mysql_port=0;
- break;
- case (int) OPT_MEMLOCK:
- locked_in_memory=1;
- break;
- case (int) OPT_ONE_THREAD:
- test_flags |= TEST_NO_THREADS;
- break;
- case (int) OPT_WANT_CORE:
- test_flags |= TEST_CORE_ON_SIGNAL;
- break;
- case (int) OPT_BIND_ADDRESS:
- if (optarg && isdigit(optarg[0]))
- {
- my_bind_addr = (ulong) inet_addr(optarg);
- }
- else
- {
- struct hostent *ent;
- if (!optarg || !optarg[0])
- ent=gethostbyname(optarg);
- else
- {
- char myhostname[255];
- if (gethostname(myhostname,sizeof(myhostname)) < 0)
- {
- sql_perror("Can't start server: cannot get my own hostname!");
- exit(1);
- }
- ent=gethostbyname(myhostname);
- }
- if (!ent)
- {
- sql_perror("Can't start server: cannot resolve hostname!");
- exit(1);
- }
- my_bind_addr = (ulong) ((in_addr*)ent->h_addr_list[0])->s_addr;
- }
- break;
- case (int) OPT_PID_FILE:
- strmov(pidfile_name,optarg);
- break;
- case (int) OPT_INIT_FILE:
- opt_init_file=optarg;
- break;
- #ifdef __WIN__
- case (int) OPT_STANDALONE: /* Dummy option for NT */
- break;
- case (int) OPT_CONSOLE:
- opt_console=1;
- break;
- #endif
- case (int) OPT_FLUSH:
- nisam_flush=myisam_flush=1;
- flush_time=0; // No auto flush
- break;
- case OPT_LOW_PRIORITY_UPDATES:
- thd_startup_options|=OPTION_LOW_PRIORITY_UPDATES;
- low_priority_updates=1;
- break;
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
- case OPT_TABLE_TYPE:
- {
- int type;
- if ((type=find_type(optarg, &ha_table_typelib, 2)) <= 0)
- {
- fprintf(stderr,"Unknown table type: %sn",optarg);
- exit(1);
- }
- default_table_type= (enum db_type) type;
- break;
- }
- case OPT_SERVER_ID:
- server_id = atoi(optarg);
- server_id_supplied = 1;
- break;
- case OPT_DELAY_KEY_WRITE:
- ha_open_options|=HA_OPEN_DELAY_KEY_WRITE;
- myisam_delay_key_write=1;
- break;
- case OPT_SKIP_DELAY_KEY_WRITE:
- myisam_delay_key_write=0;
- break;
- case 'C':
- strmov(default_charset,optarg);
- break;
- case OPT_CHARSETS_DIR:
- strmov(mysql_charsets_dir, optarg);
- charsets_dir = mysql_charsets_dir;
- break;
- #include "sslopt-case.h"
- #ifdef HAVE_BERKELEY_DB
- case OPT_BDB_LOG:
- berkeley_logdir=optarg;
- break;
- case OPT_BDB_HOME:
- berkeley_home=optarg;
- break;
- case OPT_BDB_NOSYNC:
- berkeley_env_flags|=DB_TXN_NOSYNC;
- break;
- case OPT_BDB_NO_RECOVER:
- berkeley_init_flags&= ~(DB_RECOVER);
- break;
- case OPT_BDB_TMP:
- berkeley_tmpdir=optarg;
- break;
- case OPT_BDB_LOCK:
- {
- int type;
- if ((type=find_type(optarg, &berkeley_lock_typelib, 2)) > 0)
- berkeley_lock_type=berkeley_lock_types[type-1];
- else
- {
- if (test_if_int(optarg,(uint) strlen(optarg)))
- berkeley_lock_scan_time=atoi(optarg);
- else
- {
- fprintf(stderr,"Unknown lock type: %sn",optarg);
- exit(1);
- }
- }
- break;
- }
- case OPT_BDB_SHARED:
- berkeley_init_flags&= ~(DB_PRIVATE);
- berkeley_shared_data=1;
- break;
- #endif /* HAVE_BERKELEY_DB */
- case OPT_BDB_SKIP:
- #ifdef HAVE_BERKELEY_DB
- berkeley_skip=1;
- have_berkeley_db=SHOW_OPTION_DISABLED;
- #endif
- break;
- case OPT_GEMINI_SKIP:
- #ifdef HAVE_GEMINI_DB
- gemini_skip=1;
- have_gemini=SHOW_OPTION_DISABLED;
- #endif
- break;
- case OPT_INNOBASE_SKIP:
- #ifdef HAVE_INNOBASE_DB
- innobase_skip=1;
- have_innobase=SHOW_OPTION_DISABLED;
- #endif
- break;
- case OPT_INNOBASE_DATA_FILE_PATH:
- #ifdef HAVE_INNOBASE_DB
- innobase_data_file_path=optarg;
- #endif
- break;
- #ifdef HAVE_INNOBASE_DB
- case OPT_INNOBASE_DATA_HOME_DIR:
- innobase_data_home_dir=optarg;
- break;
- case OPT_INNOBASE_LOG_GROUP_HOME_DIR:
- innobase_log_group_home_dir=optarg;
- break;
- case OPT_INNOBASE_LOG_ARCH_DIR:
- innobase_log_arch_dir=optarg;
- break;
- case OPT_INNOBASE_LOG_ARCHIVE:
- innobase_log_archive= optarg ? test(atoi(optarg)) : 1;
- break;
- case OPT_INNOBASE_FLUSH_LOG_AT_TRX_COMMIT:
- innobase_flush_log_at_trx_commit= optarg ? test(atoi(optarg)) : 1;
- break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
- if (!optarg || !optarg[0])
- {
- myisam_recover_options= HA_RECOVER_DEFAULT;
- myisam_recover_options_str= myisam_recover_typelib.type_names[0];
- }
- else
- {
- myisam_recover_options_str=optarg;
- if ((myisam_recover_options=
- find_bit_type(optarg, &myisam_recover_typelib)) == ~(ulong) 0)
- {
- fprintf(stderr, "Unknown option to myisam-recover: %sn",optarg);
- exit(1);
- }
- }
- ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
- break;
- }
- case OPT_MASTER_HOST:
- master_host=optarg;
- break;
- case OPT_MASTER_USER:
- master_user=optarg;
- break;
- case OPT_MASTER_PASSWORD:
- master_password=optarg;
- break;
- case OPT_MASTER_INFO_FILE:
- master_info_file=optarg;
- break;
- case OPT_MASTER_PORT:
- master_port= atoi(optarg);
- break;
- case OPT_MASTER_CONNECT_RETRY:
- master_connect_retry= atoi(optarg);
- break;
- case (int) OPT_SAFE_SHOW_DB:
- opt_safe_show_db=1;
- break;
- default:
- fprintf(stderr,"%s: Unrecognized option: %cn",my_progname,c);
- use_help();
- exit(1);
- }
- }
- // Skipp empty arguments (from shell)
- while (argc != optind && !argv[optind][0])
- optind++;
- if (argc != optind)
- {
- fprintf(stderr,"%s: Too many parametersn",my_progname);
- use_help();
- exit(1);
- }
- fix_paths();
- default_table_type_name=ha_table_typelib.type_names[default_table_type-1];
- }
- #ifdef __WIN__
- #ifndef KEY_SERVICE_PARAMETERS
- #define KEY_SERVICE_PARAMETERS "SYSTEM\CurrentControlSet\Services\MySql\Parameters"
- #endif
- #define COPY_KEY_VALUE(value) if (copy_key_value(hParametersKey,&(value),lpszValue)) return 1
- #define CHECK_KEY_TYPE(type,name) if ( type != dwKeyValueType ) { key_type_error(hParametersKey,name); return 1; }
- #define SET_CHANGEABLE_VARVAL(varname) if (set_varval(hParametersKey,varname,szKeyValueName,dwKeyValueType,lpdwValue)) return 1;
- static void key_type_error(HKEY hParametersKey,const char *szKeyValueName)
- {
- TCHAR szErrorMsg[512];
- RegCloseKey( hParametersKey );
- strxmov(szErrorMsg,TEXT("Value ""),
- szKeyValueName,
- TEXT("" of registry key "" KEY_SERVICE_PARAMETERS "" has wrong typen"),NullS);
- fprintf(stderr, szErrorMsg); /* not unicode compatible */
- }
- static bool copy_key_value(HKEY hParametersKey, char **var, const char *value)
- {
- if (!(*var=my_strdup(value,MYF(MY_WME))))
- {
- RegCloseKey(hParametersKey);
- fprintf(stderr, "Couldn't allocate memory for registry key valuen");
- return 1;
- }
- return 0;
- }
- static bool set_varval(HKEY hParametersKey,const char *var,
- const char *szKeyValueName, DWORD dwKeyValueType,
- LPDWORD lpdwValue)
- {
- CHECK_KEY_TYPE(dwKeyValueType, szKeyValueName );
- if (set_changeable_varval(var, *lpdwValue, changeable_vars))
- {
- TCHAR szErrorMsg [ 512 ];
- RegCloseKey( hParametersKey );
- strxmov(szErrorMsg,
- TEXT("Value ""),
- szKeyValueName,
- TEXT("" of registry key "" KEY_SERVICE_PARAMETERS "" is invalidn"),NullS);
- fprintf( stderr, szErrorMsg ); /* not unicode compatible */
- return 1;
- }
- return 0;
- }
- static int get_service_parameters()
- {
- DWORD dwLastError;
- HKEY hParametersKey;
- DWORD dwIndex;
- TCHAR szKeyValueName [ 256 ];
- DWORD dwKeyValueName;
- DWORD dwKeyValueType;
- BYTE bKeyValueBuffer [ 512 ];
- DWORD dwKeyValueBuffer;
- LPDWORD lpdwValue = (LPDWORD) &bKeyValueBuffer[0];
- LPCTSTR lpszValue = (LPCTSTR) &bKeyValueBuffer[0];
- /* open parameters of service */
- dwLastError = (DWORD) RegOpenKeyEx( HKEY_LOCAL_MACHINE,
- TEXT(KEY_SERVICE_PARAMETERS), 0,
- KEY_READ, &hParametersKey );
- if ( dwLastError == ERROR_FILE_NOT_FOUND ) /* no parameters available */
- return 0;
- if ( dwLastError != ERROR_SUCCESS )
- {
- fprintf(stderr,"Can't open registry key "" KEY_SERVICE_PARAMETERS "" for readingn" );
- return 1;
- }
- /* enumerate all values of key */
- dwIndex = 0;
- dwKeyValueName = sizeof( szKeyValueName ) / sizeof( TCHAR );
- dwKeyValueBuffer = sizeof( bKeyValueBuffer );
- while ( (dwLastError = (DWORD) RegEnumValue(hParametersKey, dwIndex,
- szKeyValueName, &dwKeyValueName,
- NULL, &dwKeyValueType,
- &bKeyValueBuffer[0],
- &dwKeyValueBuffer))
- != ERROR_NO_MORE_ITEMS )
- {
- /* check if error occured */
- if ( dwLastError != ERROR_SUCCESS )
- {
- RegCloseKey( hParametersKey );
- fprintf( stderr, "Can't enumerate values of registry key "" KEY_SERVICE_PARAMETERS ""n" );
- return 1;
- }
- if ( lstrcmp(szKeyValueName, TEXT("BaseDir")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName);
- strmov( mysql_home, lpszValue ); /* not unicode compatible */
- }
- else if ( lstrcmp(szKeyValueName, TEXT("BindAddress")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName);
- my_bind_addr = (ulong) inet_addr( lpszValue );
- if ( my_bind_addr == (ulong) INADDR_NONE )
- {
- struct hostent* ent;
- if ( !(*lpszValue) )
- {
- char szHostName [ 256 ];
- if ( gethostname(szHostName, sizeof(szHostName)) == SOCKET_ERROR )
- {
- RegCloseKey( hParametersKey );
- fprintf( stderr, "Can't get my own hostnamen" );
- return 1;
- }
- ent = gethostbyname( szHostName );
- }
- else ent = gethostbyname( lpszValue );
- if ( !ent )
- {
- RegCloseKey( hParametersKey );
- fprintf( stderr, "Can't resolve hostname!n" );
- return 1;
- }
- my_bind_addr = (ulong) ((in_addr*)ent->h_addr_list[0])->s_addr;
- }
- }
- else if ( lstrcmp(szKeyValueName, TEXT("BigTables")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName);
- if ( *lpdwValue )
- thd_startup_options |= OPTION_BIG_TABLES;
- else
- thd_startup_options &= ~((ulong)OPTION_BIG_TABLES);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("DataDir")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- strmov( mysql_real_data_home, lpszValue ); /* not unicode compatible */
- }
- else if ( lstrcmp(szKeyValueName, TEXT("Locking")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- my_disable_locking = !(*lpdwValue);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("LogFile")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- opt_log = 1;
- COPY_KEY_VALUE( opt_logname );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("UpdateLogFile")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- opt_update_log = 1;
- COPY_KEY_VALUE( opt_update_logname );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("BinaryLogFile")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- opt_bin_log = 1;
- COPY_KEY_VALUE( opt_bin_logname );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("BinaryLogIndexFile")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- opt_bin_log = 1;
- COPY_KEY_VALUE( opt_binlog_index_name );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ISAMLogFile")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- COPY_KEY_VALUE( myisam_log_filename );
- opt_myisam_log=1;
- }
- else if ( lstrcmp(szKeyValueName, TEXT("LongLogFormat")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- if ( *lpdwValue )
- opt_specialflag |= SPECIAL_LONG_LOG_FORMAT;
- else
- opt_specialflag &= ~((ulong)SPECIAL_LONG_LOG_FORMAT);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("LowPriorityUpdates")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- if ( *lpdwValue )
- {
- thd_startup_options |= OPTION_LOW_PRIORITY_UPDATES;
- low_priority_updates = 1;
- }
- else
- {
- thd_startup_options &= ~((ulong)OPTION_LOW_PRIORITY_UPDATES);
- low_priority_updates = 0;
- }
- }
- else if ( lstrcmp(szKeyValueName, TEXT("Port")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- mysql_port = (unsigned int) *lpdwValue;
- }
- else if ( lstrcmp(szKeyValueName, TEXT("OldProtocol")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- protocol_version = *lpdwValue ? PROTOCOL_VERSION - 1 : PROTOCOL_VERSION;
- }
- else if ( lstrcmp(szKeyValueName, TEXT("HostnameResolving")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- if ( !*lpdwValue )
- opt_specialflag |= SPECIAL_NO_RESOLVE;
- else
- opt_specialflag &= ~((ulong)SPECIAL_NO_RESOLVE);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("Networking")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- opt_disable_networking = !(*lpdwValue);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ShowDatabase")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- opt_skip_show_db = !(*lpdwValue);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("HostnameCaching")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- if ( !*lpdwValue )
- opt_specialflag |= SPECIAL_NO_HOST_CACHE;
- else
- opt_specialflag &= ~((ulong)SPECIAL_NO_HOST_CACHE);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ThreadPriority")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- if ( !(*lpdwValue) )
- opt_specialflag |= SPECIAL_NO_PRIOR;
- else
- opt_specialflag &= ~((ulong)SPECIAL_NO_PRIOR);
- }
- else if ( lstrcmp(szKeyValueName, TEXT("NamedPipe")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- COPY_KEY_VALUE( mysql_unix_port );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("TempDir")) == 0 )
- {
- CHECK_KEY_TYPE( REG_SZ, szKeyValueName );
- COPY_KEY_VALUE( mysql_tmpdir );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("FlushTables")) == 0 )
- {
- CHECK_KEY_TYPE( REG_DWORD, szKeyValueName );
- nisam_flush = myisam_flush= *lpdwValue ? 1 : 0;
- }
- else if ( lstrcmp(szKeyValueName, TEXT("BackLog")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "back_log" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ConnectTimeout")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "connect_timeout" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("JoinBufferSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "join_buffer" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("KeyBufferSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "key_buffer" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("LongQueryTime")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "long_query_time" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxAllowedPacket")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_allowed_packet" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxConnections")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_connections" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxUserConnections")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_user_connections" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxConnectErrors")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_connect_errors" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxInsertDelayedThreads")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_delayed_threads" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxJoinSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_join_size" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxSortLength")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_sort_length" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("NetBufferLength")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "net_buffer_length" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("RecordBufferSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "record_buffer" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("SortBufferSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "sort_buffer" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("TableCacheSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "table_cache" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("TmpTableSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "tmp_table_size" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ThreadStackSize")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "thread_stack" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("WaitTimeout")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "wait_timeout" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("DelayedInsertTimeout"))
- == 0 )
- {
- SET_CHANGEABLE_VARVAL( "delayed_insert_timeout" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("DelayedInsertLimit")) ==
- 0 )
- {
- SET_CHANGEABLE_VARVAL( "delayed_insert_limit" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("DelayedQueueSize")) == 0
- )
- {
- SET_CHANGEABLE_VARVAL( "delayed_queue_size" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("FlushTime")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "flush_time" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("InteractiveTimeout")) ==
- 0 )
- {
- SET_CHANGEABLE_VARVAL( "interactive_timeout" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("LowerCaseTableNames"))
- == 0 )
- {
- SET_CHANGEABLE_VARVAL( "lower_case_table_names" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxHeapTableSize")) == 0
- )
- {
- SET_CHANGEABLE_VARVAL( "max_heap_table_size" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxTmpTables")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_tmp_tables" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("MaxWriteLockCount")) ==
- 0 )
- {
- SET_CHANGEABLE_VARVAL( "max_write_lock_count" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("NetRetryCount")) == 0 )
- {
- SET_CHANGEABLE_VARVAL( "net_retry_count" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("QueryBufferSize")) == 0
- )
- {
- SET_CHANGEABLE_VARVAL( "query_buffer_size" );
- }
- else if ( lstrcmp(szKeyValueName, TEXT("ThreadConcurrency")) ==
- 0 )
- {
- SET_CHANGEABLE_VARVAL( "thread_concurrency" );
- }
- else
- {
- TCHAR szErrorMsg [ 512 ];
- RegCloseKey( hParametersKey );
- lstrcpy( szErrorMsg, TEXT("Value "") );
- lstrcat( szErrorMsg, szKeyValueName );
- lstrcat( szErrorMsg, TEXT("" of registry key "" KEY_SERVICE_PARAMETERS "" is not defined by MySQLn") );
- fprintf( stderr, szErrorMsg ); /* not unicode compatible */
- return 1;
- }
- dwIndex++;
- dwKeyValueName = sizeof( szKeyValueName ) / sizeof( TCHAR );
- dwKeyValueBuffer = sizeof( bKeyValueBuffer );
- }
- RegCloseKey( hParametersKey );
- /* paths are fixed by method get_options() */
- return 0;
- }
- #endif
- static char *get_relative_path(const char *path)
- {
- if (test_if_hard_path(path) &&
- is_prefix(path,DEFAULT_MYSQL_HOME) &&
- strcmp(DEFAULT_MYSQL_HOME,FN_ROOTDIR))
- {
- path+=(uint) strlen(DEFAULT_MYSQL_HOME);
- while (*path == FN_LIBCHAR)
- path++;
- }
- return (char*) path;
- }
- static void fix_paths(void)
- {
- (void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks
- convert_dirname(mysql_home);
- convert_dirname(mysql_real_data_home);
- convert_dirname(language);
- (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
- (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
- (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
- char buff[FN_REFLEN],*sharedir=get_relative_path(SHAREDIR);
- if (test_if_hard_path(sharedir))
- strmov(buff,sharedir); /* purecov: tested */
- else
- strxmov(buff,mysql_home,sharedir,NullS);
- convert_dirname(buff);
- (void) my_load_path(language,language,buff);
- /* If --character-sets-dir isn't given, use shared library dir */
- if (charsets_dir != mysql_charsets_dir)
- {
- strmov(strmov(mysql_charsets_dir,buff),CHARSET_DIR);
- charsets_dir=mysql_charsets_dir;
- }
- /* Add '/' to TMPDIR if needed */
- char *tmp= (char*) my_malloc(FN_REFLEN,MYF(MY_FAE));
- if (tmp)
- {
- strmov(tmp,mysql_tmpdir);
- mysql_tmpdir=tmp;
- convert_dirname(mysql_tmpdir);
- mysql_tmpdir=(char*) my_realloc(mysql_tmpdir,(uint) strlen(mysql_tmpdir)+1,
- MYF(MY_HOLD_ON_ERROR));
- }
- }
- #ifdef SET_RLIMIT_NOFILE
- static uint set_maximum_open_files(uint max_file_limit)
- {
- struct rlimit rlimit;
- ulong old_cur;
- if (!getrlimit(RLIMIT_NOFILE,&rlimit))
- {
- old_cur=rlimit.rlim_cur;
- if (rlimit.rlim_cur >= max_file_limit) // Nothing to do
- return rlimit.rlim_cur; /* purecov: inspected */
- rlimit.rlim_cur=rlimit.rlim_max=max_file_limit;
- if (setrlimit(RLIMIT_NOFILE,&rlimit))
- {
- sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %ld",
- old_cur); /* purecov: inspected */
- max_file_limit=old_cur;
- }
- else
- {
- (void) getrlimit(RLIMIT_NOFILE,&rlimit);
- if ((uint) rlimit.rlim_cur != max_file_limit)
- sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld",
- (ulong) rlimit.rlim_cur); /* purecov: inspected */
- max_file_limit=rlimit.rlim_cur;
- }
- }
- return max_file_limit;
- }
- #endif
- /*
- Return a bitfield from a string of substrings separated by ','
- returns ~(ulong) 0 on error.
- */
- static ulong find_bit_type(const char *x, TYPELIB *bit_lib)
- {
- bool found_end;
- int found_count;
- const char *end,*i,*j;
- const char **array, *pos;
- ulong found,found_int,bit;
- DBUG_ENTER("find_bit_type");
- DBUG_PRINT("enter",("x: '%s'",x));
- found=0;
- found_end= 0;
- pos=(my_string) x;
- do
- {
- if (!*(end=strcend(pos,','))) /* Let end point at fieldend */
- {
- while (end > pos && end[-1] == ' ')
- end--; /* Skipp end-space */
- found_end=1;
- }
- found_int=0; found_count=0;
- for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
- {
- j=pos;
- while (j != end)
- {
- if (toupper(*i++) != toupper(*j++))
- goto skipp;
- }
- found_int=bit;
- if (! *i)
- {
- found_count=1;
- break;
- }
- else if (j != pos) // Half field found
- {
- found_count++; // Could be one of two values
- }
- skipp: ;
- }
- if (found_count != 1)
- DBUG_RETURN(~(ulong) 0); // No unique value
- found|=found_int;
- pos=end+1;
- } while (! found_end);
- DBUG_PRINT("exit",("bit-field: %ld",(ulong) found));
- DBUG_RETURN(found);
- } /* find_bit_type */
- /*****************************************************************************
- ** Instantiate templates
- *****************************************************************************/
- #ifdef __GNUC__
- /* Used templates */
- template class I_List<THD>;
- template class I_List_iterator<THD>;
- template class I_List<i_string>;
- template class I_List<i_string_pair>;
- #endif