1/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#ifndef SQL_DIGEST_STREAM_H
17#define SQL_DIGEST_STREAM_H
18
19#include "sql_digest.h"
20
21/**
22 State data storage for @c digest_start, @c digest_add_token.
23 This structure extends the @c sql_digest_storage structure
24 with temporary state used only during parsing.
25*/
26struct sql_digest_state
27{
28 /**
29 Index, in the digest token array, of the last identifier seen.
30 Reduce rules used in the digest computation can not
31 apply to tokens seen before an identifier.
32 @sa digest_add_token
33 */
34 int m_last_id_index;
35 sql_digest_storage m_digest_storage;
36
37 inline void reset(unsigned char *token_array, uint length)
38 {
39 m_last_id_index= 0;
40 m_digest_storage.reset(token_array, length);
41 }
42
43 inline bool is_empty()
44 {
45 return m_digest_storage.is_empty();
46 }
47};
48typedef struct sql_digest_state sql_digest_state;
49
50#endif
51
52