protocol.hrl 4.2 KB

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