protocol.hrl 4.8 KB

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