Skip to content
/ server Public

Commit 0ca9ce8

Browse files
changed return type to bool
1 parent b7e70e4 commit 0ca9ce8

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

include/my_sys.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#ifndef _my_sys_h
1818
#define _my_sys_h
1919

20+
#ifndef __cplusplus
21+
#include <stdbool.h>
22+
#endif
23+
2024
#include <m_string.h>
2125
#include <mysql/psi/mysql_memory.h>
2226

@@ -1107,7 +1111,7 @@ int my_msync(int, void *, size_t, int);
11071111
void my_uuid_init(ulong seed1, ulong seed2);
11081112
void my_uuid(uchar *guid);
11091113
void my_uuid_end(void);
1110-
int my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec);
1114+
bool my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec);
11111115
static inline void my_uuid2str(const uchar *guid, char *s, int with_separators)
11121116
{
11131117
int i;

mysys/my_uuid.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
identifier.
4040
*/
4141

42+
#include <stdbool.h>
4243
#include "mysys_priv.h"
4344
#include <my_rnd.h>
4445
#include <m_string.h>
@@ -234,8 +235,8 @@ void my_uuid_end()
234235
@param[out] usec Microseconds part
235236
236237
@return
237-
@retval 1 Success
238-
@retval 0 UUID version doesn't contain timestamp or timestamp invalid
238+
@retval false Success
239+
@retval true UUID version doesn't contain timestamp or timestamp invalid
239240
240241
UUIDv1 format (RFC 4122, big-endian):
241242
Bytes 0-3: time_low (32 bits, low part of timestamp)
@@ -247,7 +248,7 @@ void my_uuid_end()
247248
Bytes 0-5: Unix timestamp in milliseconds (48 bits)
248249
Bytes 6-7: version (4 bits) + sub-millisecond precision (12 bits)
249250
*/
250-
int my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec)
251+
bool my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec)
251252
{
252253
uint version= (uchar) uuid[6] >> 4;
253254
ulonglong ts;
@@ -259,7 +260,7 @@ int my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec)
259260
ts= mi_uint6korr(uuid);
260261
*seconds= ts / 1000;
261262
*usec= (ts % 1000) * 1000;
262-
return 1;
263+
return false;
263264

264265
case 1:
265266
/*
@@ -275,15 +276,15 @@ int my_uuid_extract_ts(const char *uuid, my_time_t *seconds, ulong *usec)
275276

276277
/* Timestamp before Unix epoch (1970-01-01) */
277278
if (ts < UUID_TIME_OFFSET)
278-
return 0;
279+
return true;
279280

280281
ts= (ts - UUID_TIME_OFFSET) / 10; /* Convert to microseconds */
281282
*seconds= ts / 1000000;
282283
*usec= ts % 1000000;
283-
return 1;
284+
return false;
284285

285286
default:
286287
/* Other versions (e.g., v4) don't contain timestamps */
287-
return 0;
288+
return true;
288289
}
289290
}

plugin/type_uuid/item_uuidfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool Item_func_uuid_timestamp::get_timestamp(my_time_t *sec, ulong *usec)
4747
Type_handler_uuid_new::Fbt_null uuid(args[0]);
4848
if (uuid.is_null())
4949
return true;
50-
return !my_uuid_extract_ts(uuid.to_lex_cstring().str, sec, usec);
50+
return my_uuid_extract_ts(uuid.to_lex_cstring().str, sec, usec);
5151
}
5252

5353

0 commit comments

Comments
 (0)