protocol.hrl 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. %% MySQL/OTP – a MySQL driver for Erlang/OTP
  2. %% Copyright (C) 2014 Viktor Söderqvist
  3. %%
  4. %% This program is free software: you can redistribute it and/or modify
  5. %% it under the terms of the GNU General Public License as published by
  6. %% the Free Software Foundation, either version 3 of the License, or
  7. %% (at your option) any later version.
  8. %%
  9. %% This program is distributed in the hope that it will be useful,
  10. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. %% GNU General Public License for more details.
  13. %%
  14. %% You should have received a copy of the GNU General Public License
  15. %% along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. %% --- Status flags (bits) ---
  17. -define(SERVER_STATUS_IN_TRANS, 16#0001). %% a transaction is active
  18. -define(SERVER_STATUS_AUTOCOMMIT, 16#0002). %% auto-commit is enabled
  19. -define(SERVER_MORE_RESULTS_EXISTS, 16#0008).
  20. -define(SERVER_STATUS_NO_GOOD_INDEX_USED, 16#0010).
  21. -define(SERVER_STATUS_NO_INDEX_USED, 16#0020).
  22. -define(SERVER_STATUS_CURSOR_EXISTS, 16#0040). %% Used by Binary Protocol
  23. %% Resultset to signal that
  24. %% COM_STMT_FETCH has to be used
  25. %% to fetch the row-data.
  26. -define(SERVER_STATUS_LAST_ROW_SENT, 16#0080).
  27. -define(SERVER_STATUS_DB_DROPPED, 16#0100).
  28. -define(SERVER_STATUS_NO_BACKSLASH_ESCAPES, 16#0200).
  29. -define(SERVER_STATUS_METADATA_CHANGED, 16#0400).
  30. -define(SERVER_QUERY_WAS_SLOW, 16#0800).
  31. -define(SERVER_PS_OUT_PARAMS, 16#1000).
  32. -define(SERVER_STATUS_IN_TRANS_READONLY, 16#2000). %% in a read-only transaction
  33. -define(SERVER_SESSION_STATE_CHANGED, 16#4000). %% connection state information
  34. %% has changed
  35. %% Response packet tag (first byte)
  36. -define(OK, 0).
  37. -define(EOF, 16#fe).
  38. -define(ERROR, 16#ff).
  39. %% Character sets
  40. -define(UTF8, 16#21). %% utf8_general_ci
  41. %% --- Capability flags ---
  42. %% Server: supports the 4.1 protocol
  43. %% Client: uses the 4.1 protocol
  44. -define(CLIENT_PROTOCOL_41, 16#00000200).
  45. %% Server: can send status flags in EOF_Packet
  46. %% Client: expects status flags in EOF_Packet
  47. -define(CLIENT_TRANSACTIONS, 16#00002000).
  48. %% Server: supports Authentication::Native41
  49. %% Client: supports Authentication::Native41
  50. -define(CLIENT_SECURE_CONNECTION, 16#00008000).
  51. %% Server: can handle multiple statements per COM_QUERY and COM_STMT_PREPARE
  52. %% Client: may send multiple statements per COM_QUERY and COM_STMT_PREPARE
  53. %% Requires: CLIENT_PROTOCOL_41
  54. -define(CLIENT_MULTI_STATEMENTS, 16#00010000).
  55. %% Server: can send multiple resultsets for COM_QUERY
  56. %% Client: can handle multiple resultsets for COM_QUERY
  57. %% Requires: CLIENT_PROTOCOL_41
  58. -define(CLIENT_MULTI_RESULTS, 16#00020000).
  59. %% Server: sends extra data in Initial Handshake Packet and supports the
  60. %% pluggable authentication protocol.
  61. %% Client: supports auth plugins
  62. %% Requires: CLIENT_PROTOCOL_41
  63. -define(CLIENT_PLUGIN_AUTH, 16#00080000).
  64. %% --- Commands ---
  65. -define(COM_SLEEP, 16#00).
  66. -define(COM_QUIT, 16#01).
  67. -define(COM_INIT_DB, 16#02).
  68. -define(COM_QUERY, 16#03).
  69. -define(COM_FIELD_LIST, 16#04).
  70. -define(COM_CREATE_DB, 16#05).
  71. -define(COM_DROP_DB, 16#06).
  72. -define(COM_REFRESH, 16#07).
  73. -define(COM_SHUTDOWN, 16#08).
  74. -define(COM_STATISTICS, 16#09).
  75. -define(COM_PROCESS_INFO, 16#0a).
  76. -define(COM_CONNECT, 16#0b).
  77. -define(COM_PROCESS_KILL, 16#0c).
  78. -define(COM_DEBUG, 16#0d).
  79. -define(COM_PING, 16#0e).
  80. -define(COM_TIME, 16#0f).
  81. -define(COM_DELAYED_INSERT, 16#10).
  82. -define(COM_CHANGE_USER, 16#11).
  83. -define(COM_BINLOG_DUMP, 16#12).
  84. -define(COM_TABLE_DUMP, 16#13).
  85. -define(COM_CONNECT_OUT, 16#14).
  86. -define(COM_REGISTER_SLAVE, 16#15).
  87. -define(COM_STMT_PREPARE, 16#16).
  88. -define(COM_STMT_EXECUTE, 16#17).
  89. -define(COM_STMT_SEND_LONG_DATA, 16#18).
  90. -define(COM_STMT_CLOSE, 16#19).
  91. -define(COM_STMT_RESET, 16#1a).
  92. -define(COM_SET_OPTION, 16#1b).
  93. -define(COM_STMT_FETCH, 16#1c).
  94. %% --- Types ---
  95. -define(TYPE_DECIMAL, 16#00).
  96. -define(TYPE_TINY, 16#01).
  97. -define(TYPE_SHORT, 16#02).
  98. -define(TYPE_LONG, 16#03).
  99. -define(TYPE_FLOAT, 16#04).
  100. -define(TYPE_DOUBLE, 16#05).
  101. -define(TYPE_NULL, 16#06).
  102. -define(TYPE_TIMESTAMP, 16#07).
  103. -define(TYPE_LONGLONG, 16#08).
  104. -define(TYPE_INT24, 16#09).
  105. -define(TYPE_DATE, 16#0a).
  106. -define(TYPE_TIME, 16#0b).
  107. -define(TYPE_DATETIME, 16#0c).
  108. -define(TYPE_YEAR, 16#0d).
  109. -define(TYPE_VARCHAR, 16#0f).
  110. -define(TYPE_BIT, 16#10).
  111. -define(TYPE_NEWDECIMAL, 16#f6).
  112. -define(TYPE_ENUM, 16#f7).
  113. -define(TYPE_SET, 16#f8).
  114. -define(TYPE_TINY_BLOB, 16#f9).
  115. -define(TYPE_MEDIUM_BLOB, 16#fa).
  116. -define(TYPE_LONG_BLOB, 16#fb).
  117. -define(TYPE_BLOB, 16#fc).
  118. -define(TYPE_VAR_STRING, 16#fd).
  119. -define(TYPE_STRING, 16#fe).
  120. -define(TYPE_GEOMETRY, 16#ff).