9
3

mysql_com.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /* Copyright (C) 2000 MySQL AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. /*
  13. ** Common definition between mysql server & client
  14. */
  15. #ifndef _mysql_com_h
  16. #define _mysql_com_h
  17. #define HOSTNAME_LENGTH 60
  18. #define SYSTEM_CHARSET_MBMAXLEN 3
  19. #define NAME_CHAR_LEN 64 /* Field/table name length */
  20. #define USERNAME_CHAR_LENGTH 16
  21. #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
  22. #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
  23. #define SERVER_VERSION_LENGTH 60
  24. #define SQLSTATE_LENGTH 5
  25. /*
  26. USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
  27. username and hostname parts of the user identifier with trailing zero in
  28. MySQL standard format:
  29. user_name_part@host_name_part\0
  30. */
  31. #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
  32. #define LOCAL_HOST "localhost"
  33. #define LOCAL_HOST_NAMEDPIPE "."
  34. #if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
  35. #define MYSQL_NAMEDPIPE "MySQL"
  36. #define MYSQL_SERVICENAME "MySQL"
  37. #endif /* __WIN__ */
  38. /*
  39. You should add new commands to the end of this list, otherwise old
  40. servers won't be able to handle them as 'unsupported'.
  41. */
  42. enum enum_server_command
  43. {
  44. COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
  45. COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
  46. COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
  47. COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
  48. COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
  49. COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
  50. COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
  51. /* don't forget to update const char *command_name[] in sql_parse.cc */
  52. /* Must be last */
  53. COM_END
  54. };
  55. /*
  56. Length of random string sent by server on handshake; this is also length of
  57. obfuscated password, recieved from client
  58. */
  59. #define SCRAMBLE_LENGTH 20
  60. #define SCRAMBLE_LENGTH_323 8
  61. /* length of password stored in the db: new passwords are preceeded with '*' */
  62. #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
  63. #define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
  64. #define NOT_NULL_FLAG 1 /* Field can't be NULL */
  65. #define PRI_KEY_FLAG 2 /* Field is part of a primary key */
  66. #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
  67. #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
  68. #define BLOB_FLAG 16 /* Field is a blob */
  69. #define UNSIGNED_FLAG 32 /* Field is unsigned */
  70. #define ZEROFILL_FLAG 64 /* Field is zerofill */
  71. #define BINARY_FLAG 128 /* Field is binary */
  72. /* The following are only sent to new clients */
  73. #define ENUM_FLAG 256 /* field is an enum */
  74. #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
  75. #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
  76. #define SET_FLAG 2048 /* field is a set */
  77. #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
  78. #define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
  79. #define NUM_FLAG 32768 /* Field is num (for clients) */
  80. #define PART_KEY_FLAG 16384 /* Intern; Part of some key */
  81. #define GROUP_FLAG 32768 /* Intern: Group field */
  82. #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
  83. #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
  84. #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
  85. #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
  86. #define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */
  87. #define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
  88. #define REFRESH_GRANT 1 /* Refresh grant tables */
  89. #define REFRESH_LOG 2 /* Start on new log file */
  90. #define REFRESH_TABLES 4 /* close all tables */
  91. #define REFRESH_HOSTS 8 /* Flush host cache */
  92. #define REFRESH_STATUS 16 /* Flush status variables */
  93. #define REFRESH_THREADS 32 /* Flush thread cache */
  94. #define REFRESH_SLAVE 64 /* Reset master info and restart slave
  95. thread */
  96. #define REFRESH_MASTER 128 /* Remove all bin logs in the index
  97. and truncate the index */
  98. /* The following can't be set with mysql_refresh() */
  99. #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
  100. #define REFRESH_FAST 32768 /* Intern flag */
  101. /* RESET (remove all queries) from query cache */
  102. #define REFRESH_QUERY_CACHE 65536
  103. #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
  104. #define REFRESH_DES_KEY_FILE 0x40000L
  105. #define REFRESH_USER_RESOURCES 0x80000L
  106. #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
  107. #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
  108. #define CLIENT_LONG_FLAG 4 /* Get all column flags */
  109. #define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
  110. #define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
  111. #define CLIENT_COMPRESS 32 /* Can use compression protocol */
  112. #define CLIENT_ODBC 64 /* Odbc client */
  113. #define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
  114. #define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
  115. #define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
  116. #define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
  117. #define CLIENT_SSL 2048 /* Switch to SSL after handshake */
  118. #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
  119. #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
  120. #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
  121. #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
  122. #define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
  123. #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
  124. #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
  125. #define CLIENT_REMEMBER_OPTIONS (1UL << 31)
  126. /* Gather all possible capabilites (flags) supported by the server */
  127. #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \
  128. CLIENT_FOUND_ROWS | \
  129. CLIENT_LONG_FLAG | \
  130. CLIENT_CONNECT_WITH_DB | \
  131. CLIENT_NO_SCHEMA | \
  132. CLIENT_COMPRESS | \
  133. CLIENT_ODBC | \
  134. CLIENT_LOCAL_FILES | \
  135. CLIENT_IGNORE_SPACE | \
  136. CLIENT_PROTOCOL_41 | \
  137. CLIENT_INTERACTIVE | \
  138. CLIENT_SSL | \
  139. CLIENT_IGNORE_SIGPIPE | \
  140. CLIENT_TRANSACTIONS | \
  141. CLIENT_RESERVED | \
  142. CLIENT_SECURE_CONNECTION | \
  143. CLIENT_MULTI_STATEMENTS | \
  144. CLIENT_MULTI_RESULTS | \
  145. CLIENT_SSL_VERIFY_SERVER_CERT | \
  146. CLIENT_REMEMBER_OPTIONS)
  147. /*
  148. Switch off the flags that are optional and depending on build flags
  149. If any of the optional flags is supported by the build it will be switched
  150. on before sending to the client during the connection handshake.
  151. */
  152. #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
  153. & ~CLIENT_COMPRESS) \
  154. & ~CLIENT_SSL_VERIFY_SERVER_CERT)
  155. #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
  156. #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
  157. #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
  158. #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
  159. #define SERVER_QUERY_NO_INDEX_USED 32
  160. /**
  161. The server was able to fulfill the clients request and opened a
  162. read-only non-scrollable cursor for a query. This flag comes
  163. in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
  164. */
  165. #define SERVER_STATUS_CURSOR_EXISTS 64
  166. /**
  167. This flag is sent when a read-only cursor is exhausted, in reply to
  168. COM_STMT_FETCH command.
  169. */
  170. #define SERVER_STATUS_LAST_ROW_SENT 128
  171. #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
  172. #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
  173. /**
  174. Sent to the client if after a prepared statement reprepare
  175. we discovered that the new statement returns a different
  176. number of result set columns.
  177. */
  178. #define SERVER_STATUS_METADATA_CHANGED 1024
  179. /**
  180. Server status flags that must be cleared when starting
  181. execution of a new SQL statement.
  182. Flags from this set are only added to the
  183. current server status by the execution engine, but
  184. never removed -- the execution engine expects them
  185. to disappear automagically by the next command.
  186. */
  187. #define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \
  188. SERVER_QUERY_NO_INDEX_USED|\
  189. SERVER_MORE_RESULTS_EXISTS|\
  190. SERVER_STATUS_METADATA_CHANGED)
  191. #define MYSQL_ERRMSG_SIZE 512
  192. #define NET_READ_TIMEOUT 30 /* Timeout on read */
  193. #define NET_WRITE_TIMEOUT 60 /* Timeout on write */
  194. #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
  195. #define ONLY_KILL_QUERY 1
  196. struct st_vio; /* Only C */
  197. typedef struct st_vio Vio;
  198. #define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
  199. #define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
  200. #define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
  201. #define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
  202. #define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
  203. #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
  204. #define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
  205. typedef struct st_net {
  206. #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
  207. Vio *vio;
  208. unsigned char *buff,*buff_end,*write_pos,*read_pos;
  209. my_socket fd; /* For Perl DBI/dbd */
  210. /*
  211. The following variable is set if we are doing several queries in one
  212. command ( as in LOAD TABLE ... FROM MASTER ),
  213. and do not want to confuse the client with OK at the wrong time
  214. */
  215. unsigned long remain_in_buf,length, buf_length, where_b;
  216. unsigned long max_packet,max_packet_size;
  217. unsigned int pkt_nr,compress_pkt_nr;
  218. unsigned int write_timeout, read_timeout, retry_count;
  219. int fcntl;
  220. unsigned int *return_status;
  221. unsigned char reading_or_writing;
  222. char save_char;
  223. my_bool unused0; /* Please remove with the next incompatible ABI change. */
  224. my_bool unused; /* Please remove with the next incompatible ABI change */
  225. my_bool compress;
  226. my_bool unused1; /* Please remove with the next incompatible ABI change. */
  227. /*
  228. Pointer to query object in query cache, do not equal NULL (0) for
  229. queries in cache that have not stored its results yet
  230. */
  231. #endif
  232. /*
  233. 'query_cache_query' should be accessed only via query cache
  234. functions and methods to maintain proper locking.
  235. */
  236. unsigned char *query_cache_query;
  237. unsigned int last_errno;
  238. unsigned char error;
  239. my_bool unused2; /* Please remove with the next incompatible ABI change. */
  240. my_bool return_errno;
  241. /** Client library error message buffer. Actually belongs to struct MYSQL. */
  242. char last_error[MYSQL_ERRMSG_SIZE];
  243. /** Client library sqlstate buffer. Set along with the error message. */
  244. char sqlstate[SQLSTATE_LENGTH+1];
  245. void *extension;
  246. } NET;
  247. #define packet_error (~(unsigned long) 0)
  248. enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
  249. MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
  250. MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
  251. MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
  252. MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
  253. MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
  254. MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
  255. MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
  256. MYSQL_TYPE_BIT,
  257. MYSQL_TYPE_NEWDECIMAL=246,
  258. MYSQL_TYPE_ENUM=247,
  259. MYSQL_TYPE_SET=248,
  260. MYSQL_TYPE_TINY_BLOB=249,
  261. MYSQL_TYPE_MEDIUM_BLOB=250,
  262. MYSQL_TYPE_LONG_BLOB=251,
  263. MYSQL_TYPE_BLOB=252,
  264. MYSQL_TYPE_VAR_STRING=253,
  265. MYSQL_TYPE_STRING=254,
  266. MYSQL_TYPE_GEOMETRY=255
  267. };
  268. /* For backward compatibility */
  269. #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
  270. #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
  271. #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
  272. #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
  273. #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
  274. #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
  275. #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
  276. #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
  277. #define FIELD_TYPE_NULL MYSQL_TYPE_NULL
  278. #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
  279. #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
  280. #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
  281. #define FIELD_TYPE_DATE MYSQL_TYPE_DATE
  282. #define FIELD_TYPE_TIME MYSQL_TYPE_TIME
  283. #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
  284. #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
  285. #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
  286. #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
  287. #define FIELD_TYPE_SET MYSQL_TYPE_SET
  288. #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
  289. #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
  290. #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
  291. #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
  292. #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
  293. #define FIELD_TYPE_STRING MYSQL_TYPE_STRING
  294. #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
  295. #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
  296. #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
  297. #define FIELD_TYPE_BIT MYSQL_TYPE_BIT
  298. /* Shutdown/kill enums and constants */
  299. /* Bits for THD::killable. */
  300. #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
  301. #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
  302. #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
  303. #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
  304. enum mysql_enum_shutdown_level {
  305. /*
  306. We want levels to be in growing order of hardness (because we use number
  307. comparisons). Note that DEFAULT does not respect the growing property, but
  308. it's ok.
  309. */
  310. SHUTDOWN_DEFAULT = 0,
  311. /* wait for existing connections to finish */
  312. SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
  313. /* wait for existing trans to finish */
  314. SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
  315. /* wait for existing updates to finish (=> no partial MyISAM update) */
  316. SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
  317. /* flush InnoDB buffers and other storage engines' buffers*/
  318. SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
  319. /* don't flush InnoDB buffers, flush other storage engines' buffers*/
  320. SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
  321. /* Now the 2 levels of the KILL command */
  322. #if MYSQL_VERSION_ID >= 50000
  323. KILL_QUERY= 254,
  324. #endif
  325. KILL_CONNECTION= 255
  326. };
  327. enum enum_cursor_type
  328. {
  329. CURSOR_TYPE_NO_CURSOR= 0,
  330. CURSOR_TYPE_READ_ONLY= 1,
  331. CURSOR_TYPE_FOR_UPDATE= 2,
  332. CURSOR_TYPE_SCROLLABLE= 4
  333. };
  334. /* options for mysql_set_option */
  335. enum enum_mysql_set_option
  336. {
  337. MYSQL_OPTION_MULTI_STATEMENTS_ON,
  338. MYSQL_OPTION_MULTI_STATEMENTS_OFF
  339. };
  340. #define net_new_transaction(net) ((net)->pkt_nr=0)
  341. #ifdef __cplusplus
  342. extern "C" {
  343. #endif
  344. my_bool my_net_init(NET *net, Vio* vio);
  345. void my_net_local_init(NET *net);
  346. void net_end(NET *net);
  347. void net_clear(NET *net, my_bool clear_buffer);
  348. my_bool net_realloc(NET *net, size_t length);
  349. my_bool net_flush(NET *net);
  350. my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
  351. my_bool net_write_command(NET *net,unsigned char command,
  352. const unsigned char *header, size_t head_len,
  353. const unsigned char *packet, size_t len);
  354. int net_real_write(NET *net,const unsigned char *packet, size_t len);
  355. unsigned long my_net_read(NET *net);
  356. #ifdef _global_h
  357. void my_net_set_write_timeout(NET *net, uint timeout);
  358. void my_net_set_read_timeout(NET *net, uint timeout);
  359. #endif
  360. /*
  361. The following function is not meant for normal usage
  362. Currently it's used internally by manager.c
  363. */
  364. struct sockaddr;
  365. int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
  366. unsigned int timeout);
  367. struct rand_struct {
  368. unsigned long seed1,seed2,max_value;
  369. double max_value_dbl;
  370. };
  371. #ifdef __cplusplus
  372. }
  373. #endif
  374. /* The following is for user defined functions */
  375. enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
  376. DECIMAL_RESULT};
  377. typedef struct st_udf_args
  378. {
  379. unsigned int arg_count; /* Number of arguments */
  380. enum Item_result *arg_type; /* Pointer to item_results */
  381. char **args; /* Pointer to argument */
  382. unsigned long *lengths; /* Length of string arguments */
  383. char *maybe_null; /* Set to 1 for all maybe_null args */
  384. char **attributes; /* Pointer to attribute name */
  385. unsigned long *attribute_lengths; /* Length of attribute arguments */
  386. void *extension;
  387. } UDF_ARGS;
  388. /* This holds information about the result */
  389. typedef struct st_udf_init
  390. {
  391. my_bool maybe_null; /* 1 if function can return NULL */
  392. unsigned int decimals; /* for real functions */
  393. unsigned long max_length; /* For string functions */
  394. char *ptr; /* free pointer for function data */
  395. my_bool const_item; /* 1 if function always returns the same value */
  396. void *extension;
  397. } UDF_INIT;
  398. /*
  399. TODO: add a notion for determinism of the UDF.
  400. See Item_udf_func::update_used_tables ()
  401. */
  402. /* Constants when using compression */
  403. #define NET_HEADER_SIZE 4 /* standard header size */
  404. #define COMP_HEADER_SIZE 3 /* compression header extra size */
  405. /* Prototypes to password functions */
  406. #ifdef __cplusplus
  407. extern "C" {
  408. #endif
  409. /*
  410. These functions are used for authentication by client and server and
  411. implemented in sql/password.c
  412. */
  413. void randominit(struct rand_struct *, unsigned long seed1,
  414. unsigned long seed2);
  415. double my_rnd(struct rand_struct *);
  416. void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
  417. void hash_password(unsigned long *to, const char *password, unsigned int password_len);
  418. void make_scrambled_password_323(char *to, const char *password);
  419. void scramble_323(char *to, const char *message, const char *password);
  420. my_bool check_scramble_323(const char *, const char *message,
  421. unsigned long *salt);
  422. void get_salt_from_password_323(unsigned long *res, const char *password);
  423. void make_password_from_salt_323(char *to, const unsigned long *salt);
  424. void make_scrambled_password(char *to, const char *password);
  425. void scramble(char *to, const char *message, const char *password);
  426. my_bool check_scramble(const char *reply, const char *message,
  427. const unsigned char *hash_stage2);
  428. void get_salt_from_password(unsigned char *res, const char *password);
  429. void make_password_from_salt(char *to, const unsigned char *hash_stage2);
  430. char *octet2hex(char *to, const char *str, unsigned int len);
  431. /* end of password.c */
  432. char *get_tty_password(const char *opt_message);
  433. const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
  434. /* Some other useful functions */
  435. my_bool my_thread_init(void);
  436. void my_thread_end(void);
  437. #ifdef _global_h
  438. ulong STDCALL net_field_length(uchar **packet);
  439. my_ulonglong net_field_length_ll(uchar **packet);
  440. uchar *net_store_length(uchar *pkg, ulonglong length);
  441. #endif
  442. #ifdef __cplusplus
  443. }
  444. #endif
  445. #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
  446. #define MYSQL_STMT_HEADER 4
  447. #define MYSQL_LONG_DATA_HEADER 6
  448. #endif