Skip to content

Commit 354e485

Browse files
committed
References lp:1208030 - realised the need to add flags parameter to preordered() call.
1 parent 71361e9 commit 354e485

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

wsrep_api.h

+35-18
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,24 @@ extern "C" {
5656

5757
/*!
5858
* Writeset flags
59+
*
60+
* COMMIT the writeset and all preceding writesets must be committed
61+
* ROLLBACK all preceding writesets in a transaction must be rolled back
62+
* PA_UNSAFE the writeset cannot be applied in parallel
63+
* ISOLATION the writeset must be applied AND committed in isolation
64+
* COMMUTATIVE the order in which the writeset is applied does not matter
65+
* NATIVE the writeset contains another writeset in this provider format
66+
*
67+
* Note that some of the flags are mutually exclusive (e.g. COMMIT and
68+
* ROLLBACK).
5969
*/
60-
#define WSREP_FLAG_PA_SAFE ( 1ULL << 0 )
61-
#define WSREP_FLAG_COMMUTATIVE ( 1ULL << 1 )
70+
#define WSREP_FLAG_COMMIT ( 1ULL << 0 )
71+
#define WSREP_FLAG_ROLLBACK ( 1ULL << 1 )
72+
#define WSREP_FLAG_PA_UNSAFE ( 1ULL << 3 )
73+
#define WSREP_FLAG_ISOLATION ( 1ULL << 2 )
74+
#define WSREP_FLAG_COMMUTATIVE ( 1ULL << 4 )
75+
#define WSREP_FLAG_NATIVE ( 1ULL << 5 )
76+
6277

6378
typedef uint64_t wsrep_trx_id_t; //!< application transaction ID
6479
typedef uint64_t wsrep_conn_id_t; //!< application connection ID
@@ -698,21 +713,21 @@ struct wsrep_ {
698713
enum wsrep_key_type type,
699714
wsrep_bool_t copy);
700715

701-
/*!
702-
* @brief Appends data to transaction writeset
703-
*
704-
* This method can be called any time before commit and it
705-
* appends a number of data buffers to transaction writeset.
706-
*
707-
* Both copy and unordered flags can be ignored by provider.
708-
*
709-
* @param wsrep provider handle
710-
* @param ws_handle writeset handle
711-
* @param data array of data buffers
712-
* @param count buffer count
713-
* @param type type of data
714-
* @param copy can be set to FALSE if data persists through commit.
715-
*/
716+
/*!
717+
* @brief Appends data to transaction writeset
718+
*
719+
* This method can be called any time before commit and it
720+
* appends a number of data buffers to transaction writeset.
721+
*
722+
* Both copy and unordered flags can be ignored by provider.
723+
*
724+
* @param wsrep provider handle
725+
* @param ws_handle writeset handle
726+
* @param data array of data buffers
727+
* @param count buffer count
728+
* @param type type of data
729+
* @param copy can be set to FALSE if data persists through commit.
730+
*/
716731
wsrep_status_t (*append_data)(wsrep_t* wsrep,
717732
wsrep_ws_handle_t* ws_handle,
718733
const struct wsrep_buf* data,
@@ -806,7 +821,8 @@ struct wsrep_ {
806821
* processing. Note: commits always happend in wsrep order.
807822
* @param data an array of data buffers.
808823
* @param count length of data buffer array.
809-
* @param copy whether provider needs to make a copy of event
824+
* @param flags WSREP_FLAG_... flags
825+
* @param copy whether provider needs to make a copy of event.
810826
*
811827
* @retval WSREP_OK cluster commit succeeded
812828
* @retval WSREP_CONN_FAIL must close client connection
@@ -817,6 +833,7 @@ struct wsrep_ {
817833
int pa_range,
818834
const struct wsrep_buf* data,
819835
int count,
836+
uint64_t flags,
820837
wsrep_bool_t copy);
821838

822839
/*!

wsrep_dummy.c

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static wsrep_status_t dummy_preordered(
211211
int pa_range __attribute__((unused)),
212212
const struct wsrep_buf* data __attribute__((unused)),
213213
int count __attribute__((unused)),
214+
uint64_t flags __attribute__((unused)),
214215
wsrep_bool_t copy __attribute__((unused)))
215216
{
216217
WSREP_DBUG_ENTER(w);

wsrep_gtid.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
* Read GTID from string
2828
* @return length of GTID string representation or -EINVAL in case of error
2929
*/
30-
ssize_t
30+
int
3131
wsrep_gtid_scan(const char* str, size_t str_len, wsrep_gtid_t* gtid)
3232
{
33-
size_t offset;
33+
unsigned int offset;
3434
char* endptr;
3535

3636
if ((offset = wsrep_uuid_scan(str, str_len, &gtid->uuid)) > 0 &&
@@ -56,10 +56,10 @@ wsrep_gtid_scan(const char* str, size_t str_len, wsrep_gtid_t* gtid)
5656
* @return length of GTID stirng representation of -EMSGSIZE if string is too
5757
* short
5858
*/
59-
ssize_t
59+
int
6060
wsrep_gtid_print(const wsrep_gtid_t* gtid, char* str, size_t str_len)
6161
{
62-
size_t offset, ret;
62+
unsigned int offset, ret;
6363
if ((offset = wsrep_uuid_print(&gtid->uuid, str, str_len)) > 0)
6464
{
6565
ret = snprintf(str + offset, str_len - offset,

wsrep_uuid.c

+13-7
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,27 @@
2626
* Read UUID from string
2727
* @return length of UUID string representation or -EINVAL in case of error
2828
*/
29-
ssize_t
29+
int
3030
wsrep_uuid_scan (const char* str, size_t str_len, wsrep_uuid_t* uuid)
3131
{
32-
size_t uuid_len = 0;
33-
size_t uuid_offt = 0;
32+
unsigned int uuid_len = 0;
33+
unsigned int uuid_offt = 0;
3434

3535
while (uuid_len + 1 < str_len) {
36-
if ((4 == uuid_offt || 6 == uuid_offt || 8 == uuid_offt ||
37-
10 == uuid_offt) && str[uuid_len] == '-') {
36+
/* We are skipping potential '-' after uuid_offt == 4, 6, 8, 10
37+
* which means
38+
* (uuid_offt >> 1) == 2, 3, 4, 5,
39+
* which in turn means
40+
* (uuid_offt >> 1) - 2 <= 3
41+
* since it is always >= 0, because uuid_offt is unsigned */
42+
if (((uuid_offt >> 1) - 2) <= 3 && str[uuid_len] == '-') {
3843
// skip dashes after 4th, 6th, 8th and 10th positions
3944
uuid_len += 1;
4045
continue;
4146
}
47+
4248
if (isxdigit(str[uuid_len]) && isxdigit(str[uuid_len + 1])) {
43-
// got hex digit
49+
// got hex digit, scan another byte to uuid, increment uuid_offt
4450
sscanf (str + uuid_len, "%2hhx", uuid->uuid + uuid_offt);
4551
uuid_len += 2;
4652
uuid_offt += 1;
@@ -61,7 +67,7 @@ wsrep_uuid_scan (const char* str, size_t str_len, wsrep_uuid_t* uuid)
6167
* @return length of UUID string representation or -EMSGSIZE if string is too
6268
* short
6369
*/
64-
ssize_t
70+
int
6571
wsrep_uuid_print (const wsrep_uuid_t* uuid, char* str, size_t str_len)
6672
{
6773
if (str_len > 36) {

0 commit comments

Comments
 (0)