mysql_com.h 16.5 KB
Newer Older
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
1 2 3 4 5 6 7 8
/* Copyright (C) 2000 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
bk@work.mysql.com's avatar
bk@work.mysql.com committed
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
10 11 12 13 14 15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
16 17 18 19 20 21 22 23 24 25 26

/*
** Common definition between mysql server & client
*/

#ifndef _mysql_com_h
#define _mysql_com_h

#define NAME_LEN	64		/* Field/table name length */
#define HOSTNAME_LENGTH 60
#define USERNAME_LENGTH 16
27
#define SERVER_VERSION_LENGTH 60
28
#define SQLSTATE_LENGTH 5
bk@work.mysql.com's avatar
bk@work.mysql.com committed
29

30 31 32 33 34 35 36 37
/*
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
  username and hostname parts of the user identifier with trailing zero in
  MySQL standard format:
  user_name_part@host_name_part\0
*/
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2

bk@work.mysql.com's avatar
bk@work.mysql.com committed
38 39 40
#define LOCAL_HOST	"localhost"
#define LOCAL_HOST_NAMEDPIPE "."

peter@mysql.com's avatar
peter@mysql.com committed
41

bk@work.mysql.com's avatar
bk@work.mysql.com committed
42 43
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
#define MYSQL_NAMEDPIPE "MySQL"
44
#define MYSQL_SERVICENAME "MySQL"
bk@work.mysql.com's avatar
bk@work.mysql.com committed
45 46
#endif /* __WIN__ */

konstantin@mysql.com's avatar
konstantin@mysql.com committed
47 48 49 50 51
/*
  You should add new commands to the end of this list, otherwise old
  servers won't be able to handle them as 'unsupported'.
*/

52 53 54 55 56 57 58
enum enum_server_command
{
  COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
  COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
  COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
  COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
  COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
59
  COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
60
  COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
61 62 63 64
  /* don't forget to update const char *command_name[] in sql_parse.cc */

  /* Must be last */
  COM_END
65
};
bk@work.mysql.com's avatar
bk@work.mysql.com committed
66

peter@mysql.com's avatar
peter@mysql.com committed
67

68 69
/*
  Length of random string sent by server on handshake; this is also length of
70
  obfuscated password, recieved from client
71 72 73 74 75 76
*/
#define SCRAMBLE_LENGTH 20
#define SCRAMBLE_LENGTH_323 8
/* length of password stored in the db: new passwords are preceeded with '*' */
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
peter@mysql.com's avatar
peter@mysql.com committed
77 78


bk@work.mysql.com's avatar
bk@work.mysql.com committed
79 80 81 82 83 84 85
#define NOT_NULL_FLAG	1		/* Field can't be NULL */
#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
#define BLOB_FLAG	16		/* Field is a blob */
#define UNSIGNED_FLAG	32		/* Field is unsigned */
#define ZEROFILL_FLAG	64		/* Field is zerofill */
86
#define BINARY_FLAG	128		/* Field is binary   */
87

bk@work.mysql.com's avatar
bk@work.mysql.com committed
88 89 90 91 92
/* The following are only sent to new clients */
#define ENUM_FLAG	256		/* field is an enum */
#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
#define TIMESTAMP_FLAG	1024		/* Field is a timestamp */
#define SET_FLAG	2048		/* field is a set */
93
#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
94
#define NUM_FLAG	32768		/* Field is num (for clients) */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
95 96 97
#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
#define GROUP_FLAG	32768		/* Intern: Group field */
#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
98
#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
99 100
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
101 102 103 104 105 106

#define REFRESH_GRANT		1	/* Refresh grant tables */
#define REFRESH_LOG		2	/* Start on new log file */
#define REFRESH_TABLES		4	/* close all tables */
#define REFRESH_HOSTS		8	/* Flush host cache */
#define REFRESH_STATUS		16	/* Flush status variables */
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
107
#define REFRESH_THREADS		32	/* Flush thread cache */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
108 109 110 111 112 113 114 115 116
#define REFRESH_SLAVE           64      /* Reset master info and restart slave
					   thread */
#define REFRESH_MASTER          128     /* Remove all bin logs in the index
					   and truncate the index */

/* The following can't be set with mysql_refresh() */
#define REFRESH_READ_LOCK	16384	/* Lock tables for read */
#define REFRESH_FAST		32768	/* Intern flag */

117 118 119
/* RESET (remove all queries) from query cache */
#define REFRESH_QUERY_CACHE	65536
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
120
#define REFRESH_DES_KEY_FILE	0x40000L
121
#define REFRESH_USER_RESOURCES	0x80000L
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
122

bk@work.mysql.com's avatar
bk@work.mysql.com committed
123 124 125 126 127 128 129 130 131
#define CLIENT_LONG_PASSWORD	1	/* new more secure passwords */
#define CLIENT_FOUND_ROWS	2	/* Found instead of affected rows */
#define CLIENT_LONG_FLAG	4	/* Get all column flags */
#define CLIENT_CONNECT_WITH_DB	8	/* One can specify db on connect */
#define CLIENT_NO_SCHEMA	16	/* Don't allow database.table.column */
#define CLIENT_COMPRESS		32	/* Can use compression protocol */
#define CLIENT_ODBC		64	/* Odbc client */
#define CLIENT_LOCAL_FILES	128	/* Can use LOAD DATA LOCAL */
#define CLIENT_IGNORE_SPACE	256	/* Ignore spaces before '(' */
132
#define CLIENT_PROTOCOL_41	512	/* New 4.1 protocol */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
133
#define CLIENT_INTERACTIVE	1024	/* This is an interactive client */
134 135
#define CLIENT_SSL              2048	/* Switch to SSL after handshake */
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
136
#define CLIENT_TRANSACTIONS	8192	/* Client knows about transactions */
137 138
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
139
#define CLIENT_MULTI_STATEMENTS 65536   /* Enable/disable multi-stmt support */
140
#define CLIENT_MULTI_RESULTS    131072  /* Enable/disable multi-results */
141
#define CLIENT_REMEMBER_OPTIONS	(((ulong) 1) << 31)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
142

143 144 145
#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
#define SERVER_STATUS_MORE_RESULTS 4	/* More results on server */
146
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
147 148
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
#define SERVER_QUERY_NO_INDEX_USED      32
149
/*
150 151 152
  The server was able to fulfill the clients request and opened a
  read-only non-scrollable cursor for a query. This flag comes
  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
153 154 155
*/
#define SERVER_STATUS_CURSOR_EXISTS 64
/*
156 157
  This flag is sent when a read-only cursor is exhausted, in reply to
  COM_STMT_FETCH command.
158 159
*/
#define SERVER_STATUS_LAST_ROW_SENT 128
160
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
161
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
bk@work.mysql.com's avatar
bk@work.mysql.com committed
162

163
#define MYSQL_ERRMSG_SIZE	512
bk@work.mysql.com's avatar
bk@work.mysql.com committed
164 165 166 167
#define NET_READ_TIMEOUT	30		/* Timeout on read */
#define NET_WRITE_TIMEOUT	60		/* Timeout on write */
#define NET_WAIT_TIMEOUT	8*60*60		/* Wait for new query */

hf@genie.(none)'s avatar
SCRUM  
hf@genie.(none) committed
168 169
#define ONLY_KILL_QUERY         1

bk@work.mysql.com's avatar
bk@work.mysql.com committed
170 171 172
struct st_vio;					/* Only C */
typedef struct st_vio Vio;

173 174 175 176 177
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
178 179
#define MAX_CHAR_WIDTH		255	/* Max length for a CHAR colum */
#define MAX_BLOB_WIDTH		8192	/* Default width for blob */
180

bk@work.mysql.com's avatar
bk@work.mysql.com committed
181
typedef struct st_net {
hf@deer.(none)'s avatar
SCRUM  
hf@deer.(none) committed
182
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
183
  Vio* vio;
184
  unsigned char *buff,*buff_end,*write_pos,*read_pos;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
185
  my_socket fd;					/* For Perl DBI/dbd */
186
  unsigned long max_packet,max_packet_size;
187
  unsigned int pkt_nr,compress_pkt_nr;
188
  unsigned int write_timeout, read_timeout, retry_count;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
189
  int fcntl;
190
  my_bool compress;
191 192 193 194 195
  /*
    The following variable is set if we are doing several queries in one
    command ( as in LOAD TABLE ... FROM MASTER ),
    and do not want to confuse the client with OK at the wrong time
  */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
196 197 198 199
  unsigned long remain_in_buf,length, buf_length, where_b;
  unsigned int *return_status;
  unsigned char reading_or_writing;
  char save_char;
200 201
  my_bool no_send_ok;  /* For SPs and other things that do multiple stmts */
  my_bool no_send_eof; /* For SPs' first version read-only cursors */
202 203 204 205 206
  /*
    Set if OK packet is already sent, and we do not need to send error
    messages
  */
  my_bool no_send_error;
207 208 209
  /*
    Pointer to query object in query cache, do not equal NULL (0) for
    queries in cache that have not stored its results yet
bell@sanja.is.com.ua's avatar
bell@sanja.is.com.ua committed
210
  */
211
#endif
212
  char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
213 214
  unsigned int last_errno;
  unsigned char error;
215
  gptr query_cache_query;
216 217
  my_bool report_error; /* We should report error (we have unreported error) */
  my_bool return_errno;
bk@work.mysql.com's avatar
bk@work.mysql.com committed
218 219
} NET;

220
#define packet_error (~(unsigned long) 0)
bk@work.mysql.com's avatar
bk@work.mysql.com committed
221

222 223 224 225 226 227 228
enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
			MYSQL_TYPE_SHORT,  MYSQL_TYPE_LONG,
			MYSQL_TYPE_FLOAT,  MYSQL_TYPE_DOUBLE,
			MYSQL_TYPE_NULL,   MYSQL_TYPE_TIMESTAMP,
			MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
			MYSQL_TYPE_DATE,   MYSQL_TYPE_TIME,
			MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
229
			MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
ram@gw.mysql.r18.ru's avatar
ram@gw.mysql.r18.ru committed
230
			MYSQL_TYPE_BIT,
231
                        MYSQL_TYPE_NEWDECIMAL=246,
232 233 234 235 236 237 238 239 240 241
			MYSQL_TYPE_ENUM=247,
			MYSQL_TYPE_SET=248,
			MYSQL_TYPE_TINY_BLOB=249,
			MYSQL_TYPE_MEDIUM_BLOB=250,
			MYSQL_TYPE_LONG_BLOB=251,
			MYSQL_TYPE_BLOB=252,
			MYSQL_TYPE_VAR_STRING=253,
			MYSQL_TYPE_STRING=254,
			MYSQL_TYPE_GEOMETRY=255

bk@work.mysql.com's avatar
bk@work.mysql.com committed
242 243
};

244
/* For backward compatibility */
245
#define CLIENT_MULTI_QUERIES    CLIENT_MULTI_STATEMENTS    
246
#define FIELD_TYPE_DECIMAL     MYSQL_TYPE_DECIMAL
247
#define FIELD_TYPE_NEWDECIMAL  MYSQL_TYPE_NEWDECIMAL
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
#define FIELD_TYPE_TINY        MYSQL_TYPE_TINY
#define FIELD_TYPE_SHORT       MYSQL_TYPE_SHORT
#define FIELD_TYPE_LONG        MYSQL_TYPE_LONG
#define FIELD_TYPE_FLOAT       MYSQL_TYPE_FLOAT
#define FIELD_TYPE_DOUBLE      MYSQL_TYPE_DOUBLE
#define FIELD_TYPE_NULL        MYSQL_TYPE_NULL
#define FIELD_TYPE_TIMESTAMP   MYSQL_TYPE_TIMESTAMP
#define FIELD_TYPE_LONGLONG    MYSQL_TYPE_LONGLONG
#define FIELD_TYPE_INT24       MYSQL_TYPE_INT24
#define FIELD_TYPE_DATE        MYSQL_TYPE_DATE
#define FIELD_TYPE_TIME        MYSQL_TYPE_TIME
#define FIELD_TYPE_DATETIME    MYSQL_TYPE_DATETIME
#define FIELD_TYPE_YEAR        MYSQL_TYPE_YEAR
#define FIELD_TYPE_NEWDATE     MYSQL_TYPE_NEWDATE
#define FIELD_TYPE_ENUM        MYSQL_TYPE_ENUM
#define FIELD_TYPE_SET         MYSQL_TYPE_SET
#define FIELD_TYPE_TINY_BLOB   MYSQL_TYPE_TINY_BLOB
#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
266
#define FIELD_TYPE_LONG_BLOB   MYSQL_TYPE_LONG_BLOB
267 268 269 270
#define FIELD_TYPE_BLOB        MYSQL_TYPE_BLOB
#define FIELD_TYPE_VAR_STRING  MYSQL_TYPE_VAR_STRING
#define FIELD_TYPE_STRING      MYSQL_TYPE_STRING
#define FIELD_TYPE_CHAR        MYSQL_TYPE_TINY
271
#define FIELD_TYPE_INTERVAL    MYSQL_TYPE_ENUM
272
#define FIELD_TYPE_GEOMETRY    MYSQL_TYPE_GEOMETRY
ram@gw.mysql.r18.ru's avatar
ram@gw.mysql.r18.ru committed
273
#define FIELD_TYPE_BIT         MYSQL_TYPE_BIT
274

275 276 277 278

/* Shutdown/kill enums and constants */ 

/* Bits for THD::killable. */
guilhem@mysql.com's avatar
guilhem@mysql.com committed
279 280 281 282
#define MYSQL_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
#define MYSQL_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
#define MYSQL_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
283

guilhem@mysql.com's avatar
guilhem@mysql.com committed
284
enum mysql_enum_shutdown_level {
285
  /*
286 287 288
    We want levels to be in growing order of hardness (because we use number
    comparisons). Note that DEFAULT does not respect the growing property, but
    it's ok.
289
  */
290
  SHUTDOWN_DEFAULT = 0,
291
  /* wait for existing connections to finish */
292
  SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
293
  /* wait for existing trans to finish */
294
  SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
295
  /* wait for existing updates to finish (=> no partial MyISAM update) */
296
  SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
297
  /* flush InnoDB buffers and other storage engines' buffers*/
298
  SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
299
  /* don't flush InnoDB buffers, flush other storage engines' buffers*/
300
  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
301 302 303 304 305
  /* Now the 2 levels of the KILL command */
#if MYSQL_VERSION_ID >= 50000
  KILL_QUERY= 254,
#endif
  KILL_CONNECTION= 255
306 307
};

308 309 310 311 312 313 314 315 316 317

enum enum_cursor_type
{
  CURSOR_TYPE_NO_CURSOR= 0,
  CURSOR_TYPE_READ_ONLY= 1,
  CURSOR_TYPE_FOR_UPDATE= 2,
  CURSOR_TYPE_SCROLLABLE= 4
};


318 319 320 321 322 323 324
/* options for mysql_set_option */
enum enum_mysql_set_option
{
  MYSQL_OPTION_MULTI_STATEMENTS_ON,
  MYSQL_OPTION_MULTI_STATEMENTS_OFF
};

bk@work.mysql.com's avatar
bk@work.mysql.com committed
325 326
#define net_new_transaction(net) ((net)->pkt_nr=0)

327 328 329 330
#ifdef __cplusplus
extern "C" {
#endif

331
my_bool	my_net_init(NET *net, Vio* vio);
332
void	my_net_local_init(NET *net);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
333 334
void	net_end(NET *net);
void	net_clear(NET *net);
335 336 337 338 339 340
my_bool net_realloc(NET *net, unsigned long length);
my_bool	net_flush(NET *net);
my_bool	my_net_write(NET *net,const char *packet,unsigned long len);
my_bool	net_write_command(NET *net,unsigned char command,
			  const char *header, unsigned long head_len,
			  const char *packet, unsigned long len);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
341
int	net_real_write(NET *net,const char *packet,unsigned long len);
342
unsigned long my_net_read(NET *net);
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
343

344 345 346 347
/*
  The following function is not meant for normal usage
  Currently it's used internally by manager.c
*/
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
348
struct sockaddr;
monty@mashka.mysql.fi's avatar
monty@mashka.mysql.fi committed
349 350
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
	       unsigned int timeout);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
351 352 353 354 355 356

struct rand_struct {
  unsigned long seed1,seed2,max_value;
  double max_value_dbl;
};

357 358 359 360
#ifdef __cplusplus
}
#endif

bk@work.mysql.com's avatar
bk@work.mysql.com committed
361 362
  /* The following is for user defined functions */

mskold@mysql.com's avatar
Merge  
mskold@mysql.com committed
363
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
364
                  DECIMAL_RESULT};
bk@work.mysql.com's avatar
bk@work.mysql.com committed
365 366 367 368 369 370 371 372

typedef struct st_udf_args
{
  unsigned int arg_count;		/* Number of arguments */
  enum Item_result *arg_type;		/* Pointer to item_results */
  char **args;				/* Pointer to argument */
  unsigned long *lengths;		/* Length of string arguments */
  char *maybe_null;			/* Set to 1 for all maybe_null args */
373 374
  char **attributes;                    /* Pointer to attribute name */
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
375 376 377 378 379 380 381 382
} UDF_ARGS;

  /* This holds information about the result */

typedef struct st_udf_init
{
  my_bool maybe_null;			/* 1 if function can return NULL */
  unsigned int decimals;		/* for real functions */
383
  unsigned long max_length;		/* For string functions */
bk@work.mysql.com's avatar
bk@work.mysql.com committed
384 385 386 387 388 389 390 391 392 393 394 395 396
  char	  *ptr;				/* free pointer for function data */
  my_bool const_item;			/* 0 if result is independent of arguments */
} UDF_INIT;

  /* Constants when using compression */
#define NET_HEADER_SIZE 4		/* standard header size */
#define COMP_HEADER_SIZE 3		/* compression header extra size */

  /* Prototypes to password functions */

#ifdef __cplusplus
extern "C" {
#endif
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
397

398 399 400 401 402 403 404
/*
  These functions are used for authentication by client and server and
  implemented in sql/password.c
*/

void randominit(struct rand_struct *, unsigned long seed1,
                unsigned long seed2);
405
double my_rnd(struct rand_struct *);
406
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
407

408
void hash_password(unsigned long *to, const char *password, unsigned int password_len);
409
void make_scrambled_password_323(char *to, const char *password);
410
void scramble_323(char *to, const char *message, const char *password);
411
my_bool check_scramble_323(const char *, const char *message,
412
                           unsigned long *salt);
413 414 415 416
void get_salt_from_password_323(unsigned long *res, const char *password);
void make_password_from_salt_323(char *to, const unsigned long *salt);

void make_scrambled_password(char *to, const char *password);
417
void scramble(char *to, const char *message, const char *password);
418 419 420 421
my_bool check_scramble(const char *reply, const char *message,
                       const unsigned char *hash_stage2);
void get_salt_from_password(unsigned char *res, const char *password);
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
monty@mysql.com's avatar
monty@mysql.com committed
422
char *octet2hex(char *to, const char *str, unsigned int len);
423 424 425

/* end of password.c */

426
char *get_tty_password(const char *opt_message);
427
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
428 429 430

/* Some other useful functions */

monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
431
my_bool my_thread_init(void);
432
void my_thread_end(void);
bk@work.mysql.com's avatar
bk@work.mysql.com committed
433

hf@deer.mysql.r18.ru's avatar
SCRUM  
hf@deer.mysql.r18.ru committed
434 435
#ifdef _global_h
ulong STDCALL net_field_length(uchar **packet);
hf@deer.mysql.r18.ru's avatar
SCRUM  
hf@deer.mysql.r18.ru committed
436
my_ulonglong net_field_length_ll(uchar **packet);
hf@deer.(none)'s avatar
SCRUM  
hf@deer.(none) committed
437
char *net_store_length(char *pkg, ulonglong length);
hf@deer.mysql.r18.ru's avatar
SCRUM  
hf@deer.mysql.r18.ru committed
438 439
#endif

tonu@hundin.mysql.fi's avatar
tonu@hundin.mysql.fi committed
440 441 442 443
#ifdef __cplusplus
}
#endif

bk@work.mysql.com's avatar
bk@work.mysql.com committed
444
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
venu@myvenu.com's avatar
venu@myvenu.com committed
445
#define MYSQL_STMT_HEADER       4
446
#define MYSQL_LONG_DATA_HEADER  6
bk@work.mysql.com's avatar
bk@work.mysql.com committed
447 448

#endif