protocol.hrl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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(ERROR, 16#ff).
  22. %% Character sets
  23. -define(UTF8, 16#21). %% utf8_general_ci
  24. %% --- Capability flags ---
  25. %% Server: supports schema-name in Handshake Response Packet
  26. %% Client: Handshake Response Packet contains a schema-name
  27. -define(CLIENT_CONNECT_WITH_DB, 16#00000008).
  28. %% Server: supports the 4.1 protocol
  29. %% Client: uses the 4.1 protocol
  30. -define(CLIENT_PROTOCOL_41, 16#00000200).
  31. %% Server: can send status flags in EOF_Packet
  32. %% Client: expects status flags in EOF_Packet
  33. -define(CLIENT_TRANSACTIONS, 16#00002000).
  34. %% Server: supports Authentication::Native41
  35. %% Client: supports Authentication::Native41
  36. -define(CLIENT_SECURE_CONNECTION, 16#00008000).
  37. %% Server: can handle multiple statements per COM_QUERY and COM_STMT_PREPARE
  38. %% Client: may send multiple statements per COM_QUERY and COM_STMT_PREPARE
  39. %% Requires: CLIENT_PROTOCOL_41
  40. -define(CLIENT_MULTI_STATEMENTS, 16#00010000).
  41. %% Server: can send multiple resultsets for COM_QUERY
  42. %% Client: can handle multiple resultsets for COM_QUERY
  43. %% Requires: CLIENT_PROTOCOL_41
  44. -define(CLIENT_MULTI_RESULTS, 16#00020000).
  45. %% Server: sends extra data in Initial Handshake Packet and supports the
  46. %% pluggable authentication protocol.
  47. %% Client: supports auth plugins
  48. %% Requires: CLIENT_PROTOCOL_41
  49. -define(CLIENT_PLUGIN_AUTH, 16#00080000).
  50. %% --- Commands ---
  51. -define(COM_SLEEP, 16#00).
  52. -define(COM_QUIT, 16#01).
  53. -define(COM_INIT_DB, 16#02).
  54. -define(COM_QUERY, 16#03).
  55. -define(COM_FIELD_LIST, 16#04).
  56. -define(COM_CREATE_DB, 16#05).
  57. -define(COM_DROP_DB, 16#06).
  58. -define(COM_REFRESH, 16#07).
  59. -define(COM_SHUTDOWN, 16#08).
  60. -define(COM_STATISTICS, 16#09).
  61. -define(COM_PROCESS_INFO, 16#0a).
  62. -define(COM_CONNECT, 16#0b).
  63. -define(COM_PROCESS_KILL, 16#0c).
  64. -define(COM_DEBUG, 16#0d).
  65. -define(COM_PING, 16#0e).
  66. -define(COM_TIME, 16#0f).
  67. -define(COM_DELAYED_INSERT, 16#10).
  68. -define(COM_CHANGE_USER, 16#11).
  69. -define(COM_BINLOG_DUMP, 16#12).
  70. -define(COM_TABLE_DUMP, 16#13).
  71. -define(COM_CONNECT_OUT, 16#14).
  72. -define(COM_REGISTER_SLAVE, 16#15).
  73. -define(COM_STMT_PREPARE, 16#16).
  74. -define(COM_STMT_EXECUTE, 16#17).
  75. -define(COM_STMT_SEND_LONG_DATA, 16#18).
  76. -define(COM_STMT_CLOSE, 16#19).
  77. -define(COM_STMT_RESET, 16#1a).
  78. -define(COM_SET_OPTION, 16#1b).
  79. -define(COM_STMT_FETCH, 16#1c).
  80. %% --- Types ---
  81. -define(TYPE_DECIMAL, 16#00).
  82. -define(TYPE_TINY, 16#01).
  83. -define(TYPE_SHORT, 16#02).
  84. -define(TYPE_LONG, 16#03).
  85. -define(TYPE_FLOAT, 16#04).
  86. -define(TYPE_DOUBLE, 16#05).
  87. -define(TYPE_NULL, 16#06).
  88. -define(TYPE_TIMESTAMP, 16#07).
  89. -define(TYPE_LONGLONG, 16#08).
  90. -define(TYPE_INT24, 16#09).
  91. -define(TYPE_DATE, 16#0a).
  92. -define(TYPE_TIME, 16#0b).
  93. -define(TYPE_DATETIME, 16#0c).
  94. -define(TYPE_YEAR, 16#0d).
  95. -define(TYPE_VARCHAR, 16#0f).
  96. -define(TYPE_BIT, 16#10).
  97. -define(TYPE_NEWDECIMAL, 16#f6).
  98. -define(TYPE_ENUM, 16#f7).
  99. -define(TYPE_SET, 16#f8).
  100. -define(TYPE_TINY_BLOB, 16#f9).
  101. -define(TYPE_MEDIUM_BLOB, 16#fa).
  102. -define(TYPE_LONG_BLOB, 16#fb).
  103. -define(TYPE_BLOB, 16#fc).
  104. -define(TYPE_VAR_STRING, 16#fd).
  105. -define(TYPE_STRING, 16#fe).
  106. -define(TYPE_GEOMETRY, 16#ff).