Database Articles

  Home arrow Database Articles arrow Page 5 - Authentication Protocol Security
DATABASE ARTICLES

Authentication Protocol Security
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2007-08-17

    Table of Contents:
  • Authentication Protocol Security
  • Authenticating Handshake
  • Command Packet
  • Server Responses
  • OK Packet
  • Error Packet
  • Result Set Packets

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Authentication Protocol Security - OK Packet


    (Page 5 of 7 )

    An OK packet is sent to indicate that the server successfully completed the command. It is sent in response to the following commands:

    • COM_PING 
    • COM_QUERY if the query does not need to return a result set; for example, INSERT , UPDATE , or ALTER TABLE
    • COM_REFRESH
    • COM_REGISTER_SLAVE

    This type of packet is appropriate for commands that do not return a result set. Its format, however, permits sending some extra status information, such as the number of modified records, the value of the automatically generated primary key, or a custom status message in a string format. The structure of the packet body is documented in Table 4-8 .

    Table 4-8. Format of server’s OK packet

     

    Offset in the body

    Length

    Description

    0

    1

    A byte with the value of 0, indicating that the packet has no fields.

    1

    rows_len

    The number of records that the query has changed in the field length format described in the "Data Field" section, earlier in this chapter. Its length varies depending on the value. I will refer to its length as rows_lento express the subsequent offsets.

    Table 4-8. Format of server’s OK packet (continued) 

    Offset in the body

    Length

    Description

    1 + rows_len

    id_len

    The value of the generated auto-increment ID for the primary key. Set to 0 if not applicable in the context. The value is stored in the field length format of a data field. I will refer to the length of this value as id_len.

    1 + rows_len + id_len

    2

    Server status bit mask, low byte first. For details on different values, see the macros starting with STATUS_in include/mysql_com.h. In the protocol of version 4.0 and earlier, the status field is present only if it is a nonzero value. In the protocol of version 4.1 and later, it is reported unconditionally.

    3 + rows_len + id_len

    2

    Present only in the protocol of version 4.1 and later. Contains the number of warnings the last command has generated. For example, if the command was COM_QUERY with LOAD DATA INFILE, and some of the fields or lines could not be properly imported, a number of warnings will be generated. The number is stored with the low byte first.

    5 + rows_len + id_lenin version 4.1 and later protocol., 1 +rows_len + id_lenor 3 +rows_len + id_lenin the older protocol, depending on whether the server status bit mask was included.

    msg_len

    An optional field for the status message if one is present in the standard data field format with the field length followed by field value, which in this case is a character string.

    To send an OK packet from inside the server, you must call send_ok() . In version 4.1 and later, the function is declared in sql/protocol.h, and defined in sql/protocol.cc. In the earlier versions, it is declared in sql/mysql_priv.h and defined in sql/net_pkg.cc.

    More Database Articles Articles
    More By O'Reilly Media

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap