protocol.hrl 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. %% Response packet tag (first byte)
  19. -define(OK, 0).
  20. -define(EOF, 16#fe).
  21. -define(MORE_DATA, 16#01).
  22. -define(ERROR, 16#ff).
  23. %% Character sets
  24. -define(UTF8MB3, 16#21). %% utf8_general_ci
  25. -define(UTF8MB4, 16#2d). %% utf8mb4_general_ci
  26. %% --- Capability flags ---
  27. %% Use the improved version of Old Password Authentication.
  28. %% Assumed to be set since 4.1.1.
  29. -define(CLIENT_LONG_PASSWORD, 16#00000001).
  30. %% Server: sends found rows instead of affected rows in EOF_Packet
  31. -define(CLIENT_FOUND_ROWS, 16#00000002).
  32. %% Server: supports schema-name in Handshake Response Packet
  33. %% Client: Handshake Response Packet contains a schema-name
  34. -define(CLIENT_CONNECT_WITH_DB, 16#00000008).
  35. %% Server: supports the 4.1 protocol
  36. %% Client: uses the 4.1 protocol
  37. -define(CLIENT_PROTOCOL_41, 16#00000200).
  38. %% Client: supports SSL
  39. -define(CLIENT_SSL, 16#00000800).
  40. %% Server: can send status flags in EOF_Packet
  41. %% Client: expects status flags in EOF_Packet
  42. -define(CLIENT_TRANSACTIONS, 16#00002000).
  43. %% Server: supports Authentication::Native41
  44. %% Client: supports Authentication::Native41
  45. -define(CLIENT_SECURE_CONNECTION, 16#00008000).
  46. %% Server: can handle multiple statements per COM_QUERY and COM_STMT_PREPARE
  47. %% Client: may send multiple statements per COM_QUERY and COM_STMT_PREPARE
  48. %% Requires: CLIENT_PROTOCOL_41
  49. -define(CLIENT_MULTI_STATEMENTS, 16#00010000).
  50. %% Server: can send multiple resultsets for COM_QUERY
  51. %% Client: can handle multiple resultsets for COM_QUERY
  52. %% Requires: CLIENT_PROTOCOL_41
  53. -define(CLIENT_MULTI_RESULTS, 16#00020000).
  54. %% Server: can send multiple resultsets for COM_STMT_EXECUTE
  55. %% Client: can handle multiple resultsets for COM_STMT_EXECUTE
  56. %% Requires: CLIENT_PROTOCOL_41
  57. -define(CLIENT_PS_MULTI_RESULTS, 16#00040000).
  58. %% Server: sends extra data in Initial Handshake Packet and supports the
  59. %% pluggable authentication protocol.
  60. %% Client: supports auth plugins
  61. %% Requires: CLIENT_PROTOCOL_41
  62. -define(CLIENT_PLUGIN_AUTH, 16#00080000).
  63. %% --- Commands ---
  64. -define(COM_SLEEP, 16#00).
  65. -define(COM_QUIT, 16#01).
  66. -define(COM_INIT_DB, 16#02).
  67. -define(COM_QUERY, 16#03).
  68. -define(COM_FIELD_LIST, 16#04).
  69. -define(COM_CREATE_DB, 16#05).
  70. -define(COM_DROP_DB, 16#06).
  71. -define(COM_REFRESH, 16#07).
  72. -define(COM_SHUTDOWN, 16#08).
  73. -define(COM_STATISTICS, 16#09).
  74. -define(COM_PROCESS_INFO, 16#0a).
  75. -define(COM_CONNECT, 16#0b).
  76. -define(COM_PROCESS_KILL, 16#0c).
  77. -define(COM_DEBUG, 16#0d).
  78. -define(COM_PING, 16#0e).
  79. -define(COM_TIME, 16#0f).
  80. -define(COM_DELAYED_INSERT, 16#10).
  81. -define(COM_CHANGE_USER, 16#11).
  82. -define(COM_BINLOG_DUMP, 16#12).
  83. -define(COM_TABLE_DUMP, 16#13).
  84. -define(COM_CONNECT_OUT, 16#14).
  85. -define(COM_REGISTER_SLAVE, 16#15).
  86. -define(COM_STMT_PREPARE, 16#16).
  87. -define(COM_STMT_EXECUTE, 16#17).
  88. -define(COM_STMT_SEND_LONG_DATA, 16#18).
  89. -define(COM_STMT_CLOSE, 16#19).
  90. -define(COM_STMT_RESET, 16#1a).
  91. -define(COM_SET_OPTION, 16#1b).
  92. -define(COM_STMT_FETCH, 16#1c).
  93. -define(COM_RESET_CONNECTION, 16#1f).
  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_JSON, 16#f5).
  112. -define(TYPE_NEWDECIMAL, 16#f6).
  113. -define(TYPE_ENUM, 16#f7).
  114. -define(TYPE_SET, 16#f8).
  115. -define(TYPE_TINY_BLOB, 16#f9).
  116. -define(TYPE_MEDIUM_BLOB, 16#fa).
  117. -define(TYPE_LONG_BLOB, 16#fb).
  118. -define(TYPE_BLOB, 16#fc).
  119. -define(TYPE_VAR_STRING, 16#fd).
  120. -define(TYPE_STRING, 16#fe).
  121. -define(TYPE_GEOMETRY, 16#ff).
  122. %% --- Field flags ---
  123. -define(UNSIGNED_FLAG, 32).