MySQL  8.0.18
Source Code Documentation
sql_digest.h File Reference
#include <string.h>
#include <sys/types.h>
#include "my_inttypes.h"

Go to the source code of this file.

Classes

struct  sql_digest_storage
 Structure to store token count/array for a statement on which digest is to be calculated. More...
 

Macros

#define MAX_DIGEST_STORAGE_SIZE   (1024 * 1024)
 
#define DIGEST_HASH_TO_STRING(_hash, _str)
 Write SHA-256 hash value in a string to be used as DIGEST for the statement. More...
 
#define DIGEST_HASH_TO_STRING_LENGTH   64
 SHA-256 = 32 bytes of binary = 64 printable characters. More...
 
#define DIGEST_HASH_SIZE   32
 DIGEST hash size, in bytes. More...
 

Typedefs

typedef struct sql_digest_storage sql_digest_storage
 

Functions

ulong get_max_digest_length ()
 
void compute_digest_hash (const sql_digest_storage *digest_storage, unsigned char *hash)
 Compute a digest hash. More...
 
void compute_digest_text (const sql_digest_storage *digest_storage, String *digest_text)
 Compute a digest text. More...
 

Macro Definition Documentation

◆ DIGEST_HASH_SIZE

#define DIGEST_HASH_SIZE   32

DIGEST hash size, in bytes.

256 bits, for SHA256.

◆ DIGEST_HASH_TO_STRING

#define DIGEST_HASH_TO_STRING (   _hash,
  _str 
)
Value:
sprintf(_str, \
"%02x%02x%02x%02x%02x%02x%02x%02x" \
"%02x%02x%02x%02x%02x%02x%02x%02x" \
"%02x%02x%02x%02x%02x%02x%02x%02x" \
"%02x%02x%02x%02x%02x%02x%02x%02x", \
_hash[0], _hash[1], _hash[2], _hash[3], _hash[4], _hash[5], \
_hash[6], _hash[7], _hash[8], _hash[9], _hash[10], _hash[11], \
_hash[12], _hash[13], _hash[14], _hash[15], _hash[16], _hash[17], \
_hash[18], _hash[19], _hash[20], _hash[21], _hash[22], _hash[23], \
_hash[24], _hash[25], _hash[26], _hash[27], _hash[28], _hash[29], \
_hash[30], _hash[31])

Write SHA-256 hash value in a string to be used as DIGEST for the statement.

◆ DIGEST_HASH_TO_STRING_LENGTH

#define DIGEST_HASH_TO_STRING_LENGTH   64

SHA-256 = 32 bytes of binary = 64 printable characters.

◆ MAX_DIGEST_STORAGE_SIZE

#define MAX_DIGEST_STORAGE_SIZE   (1024 * 1024)

Typedef Documentation

◆ sql_digest_storage

Function Documentation

◆ compute_digest_hash()

void compute_digest_hash ( const sql_digest_storage digest_storage,
unsigned char *  hash 
)

Compute a digest hash.

Parameters
digest_storageThe digest
[out]hashThe computed digest hash. This parameter is a buffer of size DIGEST_HASH_SIZE.

◆ compute_digest_text()

void compute_digest_text ( const sql_digest_storage digest_storage,
String digest_text 
)

Compute a digest text.

A 'digest text' is a textual representation of a query, where:

  • comments are removed,
  • non significant spaces are removed,
  • literal values are replaced with a special '?' marker,
  • lists of values are collapsed using a shorter notation
    Parameters
    digest_storageThe digest
    [out]digest_textThe digest text

◆ get_max_digest_length()

ulong get_max_digest_length ( )