1/*
2   Copyright (c) 2004, 2021, Oracle and/or its affiliates.
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License, version 2.0,
6   as published by the Free Software Foundation.
7
8   This program is also distributed with certain software (including
9   but not limited to OpenSSL) that is licensed under separate terms,
10   as designated in a particular file or component or in included license
11   documentation.  The authors of MySQL hereby grant you an additional
12   permission to link the program and your derivative works with the
13   separately licensed software that they have included with MySQL.
14
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License, version 2.0, for more details.
19
20   You should have received a copy of the GNU General Public License
21   along with this program; if not, write to the Free Software
22   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23*/
24
25#ifndef NDB_VERSION_H
26#define NDB_VERSION_H
27
28#include <ndb_types.h>
29#include <mysql_version.h>
30
31/*
32  Creates a composite version number from major, minor and build
33  ex: NDB_MAKE_VERSION(5,1,47) => 0x00050147
34*/
35#define NDB_MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8)  | ((C) << 0))
36
37/*
38  Creates a stringified version from major, minor and build
39  ex: NDB_MAKE_STRING_VERSION(7,0,22) => "7.0.22"
40*/
41#define NDB_MAKE_QUOTED_VERSION(A,B,C) #A "." #B "." #C
42#define NDB_MAKE_STRING_VERSION(A,B,C) NDB_MAKE_QUOTED_VERSION(A,B,C)
43
44/* NDB version numbers and status  */
45#define NDB_VERSION_MAJOR @NDB_VERSION_MAJOR@
46#define NDB_VERSION_MINOR @NDB_VERSION_MINOR@
47#define NDB_VERSION_BUILD @NDB_VERSION_BUILD@
48#define NDB_VERSION_STATUS "@NDB_VERSION_STATUS@"
49
50/* Composite version number for NDB */
51#define NDB_VERSION_D \
52  NDB_MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD)
53
54/* Version string for NDB, ex: "ndb-7.0.22" */
55#define NDB_NDB_VERSION_STRING \
56  "ndb-" NDB_MAKE_STRING_VERSION(NDB_VERSION_MAJOR, \
57                                 NDB_VERSION_MINOR, \
58                                 NDB_VERSION_BUILD) NDB_VERSION_STATUS
59
60/*
61  The version number of the MySQL Server that NDB is built
62  with. Extracted from MYSQL_VERSION_ID
63*/
64#define NDB_MYSQL_VERSION_MAJOR ((MYSQL_VERSION_ID / 10000) % 100)
65#define NDB_MYSQL_VERSION_MINOR ((MYSQL_VERSION_ID /100) % 100)
66#define NDB_MYSQL_VERSION_BUILD (MYSQL_VERSION_ID % 100)
67
68/* Composite version number for MYSQL Server */
69#define NDB_MYSQL_VERSION_D \
70  NDB_MAKE_VERSION(NDB_MYSQL_VERSION_MAJOR, \
71                   NDB_MYSQL_VERSION_MINOR, \
72                   NDB_MYSQL_VERSION_BUILD)
73
74#define NDB_VERSION_STRING_BUF_SZ 100
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80void ndbPrintVersion();
81
82Uint32 ndbMakeVersion(Uint32 major, Uint32 minor, Uint32 build);
83
84Uint32 ndbGetMajor(Uint32 version);
85
86Uint32 ndbGetMinor(Uint32 version);
87
88Uint32 ndbGetBuild(Uint32 version);
89
90const char* ndbGetVersionString(Uint32 version, Uint32 mysql_version, const char * status,
91                                char *buf, unsigned sz);
92const char* ndbGetOwnVersionString();
93
94Uint32 ndbGetOwnVersion();
95
96#ifdef __cplusplus
97}
98#endif
99
100#define NDB_VERSION_STRING ndbGetOwnVersionString()
101
102#define NDB_VERSION ndbGetOwnVersion()
103
104/**
105 * This is updated each time a version of backup/lcp format is changed
106 *   when it's updated, it's set to version that made the change
107 */
108#define NDB_BACKUP_VERSION NDB_MAKE_VERSION(6,3,11)
109
110/**
111 * From which version do we support rowid
112 */
113#define NDBD_ROWID_VERSION (NDB_MAKE_VERSION(5,1,6))
114#define NDBD_INCL_NODECONF_VERSION_4 NDB_MAKE_VERSION(4,1,17)
115#define NDBD_INCL_NODECONF_VERSION_5 NDB_MAKE_VERSION(5,0,18)
116#define NDBD_FRAGID_VERSION (NDB_MAKE_VERSION(5,1,6))
117#define NDBD_DICT_LOCK_VERSION_5 NDB_MAKE_VERSION(5,0,23)
118#define NDBD_DICT_LOCK_VERSION_5_1 NDB_MAKE_VERSION(5,1,12)
119
120#define NDBD_UPDATE_FRAG_DIST_KEY_50 NDB_MAKE_VERSION(5,0,26)
121#define NDBD_UPDATE_FRAG_DIST_KEY_51 NDB_MAKE_VERSION(5,1,12)
122
123#define NDBD_QMGR_SINGLEUSER_VERSION_5 NDB_MAKE_VERSION(5,0,25)
124
125#define NDBD_SPLIT_VERSION NDB_MAKE_VERSION(6,1,0)
126#define NDBD_NODE_VERSION_REP NDB_MAKE_VERSION(6,1,1)
127
128#define NDBD_255_NODES_VERSION NDB_MAKE_VERSION(5,1,4)
129
130#define NDBD_MICRO_GCP_62 NDB_MAKE_VERSION(6,2,5)
131#define NDBD_MICRO_GCP_63 NDB_MAKE_VERSION(6,3,2)
132#define NDBD_RAW_LCP MAKE_VERSION(6,3,11)
133#define NDBD_LONG_TCKEYREQ NDB_MAKE_VERSION(6,4,0)
134#define NDBD_LONG_LQHKEYREQ MAKE_VERSION(6,4,0)
135#define NDBD_MAX_RECVBYTESIZE_32K MAKE_VERSION(6,3,18)
136#define NDBD_LONG_SCANTABREQ NDB_MAKE_VERSION(6,4,0)
137#define NDBD_LONG_SCANFRAGREQ MAKE_VERSION(6,4,0)
138#define NDBD_MT_LQH_VERSION MAKE_VERSION(6,4,0)
139
140#define NDBD_SCHEMA_TRANS_VERSION NDB_MAKE_VERSION(6,4,0)
141
142static
143inline
144int
145ndb_check_micro_gcp(Uint32 version)
146{
147  if (version == NDB_VERSION_D)
148    return 1;
149  {
150    const Uint32 major = (version >> 16) & 0xFF;
151    const Uint32 minor = (version >>  8) & 0xFF;
152    if (major >= 6)
153    {
154      if (minor == 2)
155        return version >= NDBD_MICRO_GCP_62;
156      return version >= NDBD_MICRO_GCP_63;
157    }
158  }
159  return 0;
160}
161
162#define NDBD_PREPARE_COPY_FRAG_VERSION NDB_MAKE_VERSION(6,2,1)
163#define NDBD_PREPARE_COPY_FRAG_V2_51 NDB_MAKE_VERSION(5,1,23)
164#define NDBD_PREPARE_COPY_FRAG_V2_62 NDB_MAKE_VERSION(6,2,8)
165#define NDBD_PREPARE_COPY_FRAG_V2_63 NDB_MAKE_VERSION(6,3,6)
166
167/**
168 * 0 = NO PREP COPY FRAG SUPPORT
169 * 1 = NO MAX PAGE SUPPORT
170 * 2 = LATEST VERSION
171 */
172static
173inline
174int
175ndb_check_prep_copy_frag_version(Uint32 version)
176{
177  const Uint32 major = (version >> 16) & 0xFF;
178  const Uint32 minor = (version >>  8) & 0xFF;
179
180  if (version == NDB_VERSION_D)
181    return 2;
182
183  if (major >= 6)
184  {
185    if (minor == 2)
186    {
187      if (version >= NDBD_PREPARE_COPY_FRAG_V2_62)
188        return 2;
189      if (version >= NDBD_PREPARE_COPY_FRAG_VERSION)
190        return 1;
191      return 0;
192    }
193    else if (minor == 3)
194    {
195      if (version >= NDBD_PREPARE_COPY_FRAG_V2_63)
196        return 2;
197      return 1;
198    }
199    return 2;
200  }
201  else if (major == 5 && minor == 1)
202  {
203    if (version >= NDBD_PREPARE_COPY_FRAG_V2_51)
204      return 2;
205  }
206
207  return 0;
208}
209
210#define NDBD_PNR NDB_MAKE_VERSION(6,3,8)
211
212static
213inline
214int
215ndb_pnr(Uint32 version)
216{
217  return
218    version == NDB_VERSION_D || version >= NDBD_PNR;
219}
220
221#define NDBD_SUMA_DICT_LOCK_62 NDB_MAKE_VERSION(6,2,14)
222#define NDBD_SUMA_DICT_LOCK_63 NDB_MAKE_VERSION(6,3,11)
223
224static
225inline
226int
227ndbd_suma_dictlock_startme(Uint32 x)
228{
229  if (x >= NDB_VERSION_D)
230    return 1;
231
232  {
233    const Uint32 major = (x >> 16) & 0xFF;
234    const Uint32 minor = (x >>  8) & 0xFF;
235
236    if (major >= 6)
237    {
238      if (minor == 2)
239      return x >= NDBD_SUMA_DICT_LOCK_62;
240    }
241
242    return x >= NDBD_SUMA_DICT_LOCK_63;
243  }
244}
245
246#define NDBD_LONG_LIST_TABLES_CONF_62 NDB_MAKE_VERSION(6,2,16)
247#define NDBD_LONG_LIST_TABLES_CONF_63 NDB_MAKE_VERSION(6,3,15)
248
249static
250inline
251int
252ndbd_LIST_TABLES_CONF_long_signal(Uint32 x)
253{
254  if (x >= NDB_VERSION_D)
255    return 1;
256
257  {
258    const Uint32 major = (x >> 16) & 0xFF;
259    const Uint32 minor = (x >>  8) & 0xFF;
260
261    if (major >= 6)
262    {
263      if (minor == 2)
264        return x >= NDBD_LONG_LIST_TABLES_CONF_62;
265    }
266
267    return x >= NDBD_LONG_LIST_TABLES_CONF_63;
268  }
269}
270
271#if NOT_YET
272#define NDBD_FIRE_TRIG_ORD_TRANSID_63 NDB_MAKE_VERSION(6,3,9)
273#define NDBD_FIRE_TRIG_ORD_TRANSID_62 NDB_MAKE_VERSION(6,2,12)
274#endif
275
276static
277inline
278int
279ndb_fire_trig_ord_transid(Uint32 version)
280{
281  if (version >= NDB_VERSION_D)
282    return 1;
283
284#if NOT_YET
285  const Uint32 major = (version >> 16) & 0xFF;
286  const Uint32 minor = (version >>  8) & 0xFF;
287  if (major >= 6)
288  {
289    if (minor == 2)
290    {
291      return version >= NDBD_FIRE_TRIG_ORD_TRANSID_62;
292    }
293
294    return version >= NDBD_FIRE_TRIG_ORD_TRANSID_63;
295  }
296#endif
297
298  return 0;
299}
300
301#define NDBD_SCAN_DISTKEY NDB_MAKE_VERSION(6,4,0)
302
303static
304inline
305int
306ndb_scan_distributionkey(Uint32 version)
307{
308  return version >= NDBD_SCAN_DISTKEY;
309}
310
311#define NDBD_FILTER_INSTANCE_63 NDB_MAKE_VERSION(6,3,16)
312#define NDBD_COPY_GCI_RESTART_NR NDB_MAKE_VERSION(6,3,18)
313
314#define NDBD_SUMA_DICTLOCK_HANDOVER NDB_MAKE_VERSION(6,4,0)
315
316static
317inline
318int
319ndbd_suma_dictlock_handover(Uint32 x)
320{
321  return (x >= NDBD_SUMA_DICTLOCK_HANDOVER);
322}
323
324#define NDBD_API_TAKE_OVERTCCONF_60 NDB_MAKE_VERSION(5,2,4)
325#define NDBD_API_TAKE_OVERTCCONF_62 NDB_MAKE_VERSION(6,2,17)
326#define NDBD_API_TAKE_OVERTCCONF_63 NDB_MAKE_VERSION(6,3,19)
327
328#define NDBD_DELAYED_COPY_ACTIVEREQ_63 NDB_MAKE_VERSION(6,3,29)
329#define NDBD_DELAYED_COPY_ACTIVEREQ_70 NDB_MAKE_VERSION(7,0,10)
330
331static
332inline
333int
334ndb_takeovertc(Uint32 x)
335{
336  if (x >= NDB_VERSION_D)
337    return 1;
338
339  {
340    const Uint32 major = (x >> 16) & 0xFF;
341    const Uint32 minor = (x >>  8) & 0xFF;
342
343    if (major >= 6)
344    {
345      if (minor == 2)
346        return x >= NDBD_API_TAKE_OVERTCCONF_62;
347    }
348
349    return x >= NDBD_API_TAKE_OVERTCCONF_63;
350  }
351}
352
353static
354inline
355int
356ndb_delayed_copy_active_req(Uint32 x)
357{
358  if (x >= NDB_VERSION_D)
359    return 1;
360
361  {
362    const Uint32 major = (x >> 16) & 0xFF;
363
364    if (major == 6)
365    {
366      return x >= NDBD_DELAYED_COPY_ACTIVEREQ_63;
367    }
368    else
369    {
370      return x >= NDBD_DELAYED_COPY_ACTIVEREQ_70;
371    }
372  }
373}
374
375#define NDBD_SUMA_NOTSTARTED_REF_63 NDB_MAKE_VERSION(6,3,29)
376#define NDBD_SUMA_NOTSTARTED_REF_70 NDB_MAKE_VERSION(7,0,10)
377
378static
379inline
380int
381ndb_suma_not_started_ref(Uint32 x)
382{
383  if (x >= NDB_VERSION_D)
384    return 1;
385
386  {
387    const Uint32 major = (x >> 16) & 0xFF;
388
389    if (major == 6)
390    {
391      return x >= NDBD_SUMA_NOTSTARTED_REF_63;
392    }
393    else
394    {
395      return x >= NDBD_SUMA_NOTSTARTED_REF_70;
396    }
397  }
398}
399
400#define NDBD_UNLOCK_OP_SUPPORTED NDB_MAKE_VERSION(7,0,12)
401
402#define NDBD_ROUTE_EXEC_FRAG NDB_MAKE_VERSION(7,0,13)
403
404static
405inline
406int
407ndb_route_exec_frag(Uint32 x)
408{
409  if (x >= NDB_VERSION_D)
410    return 1;
411
412  return x >= NDBD_ROUTE_EXEC_FRAG;
413}
414
415#define NDBD_NATIVE_DEFAULT_SUPPORT_70 NDB_MAKE_VERSION(7,0,15)
416#define NDBD_NATIVE_DEFAULT_SUPPORT_71 NDB_MAKE_VERSION(7,1,4)
417
418static
419inline
420int
421ndb_native_default_support(Uint32 x)
422{
423  const Uint32 major = (x >> 16) & 0xFF;
424  const Uint32 minor = (x >>  8) & 0xFF;
425
426  if (major == 7 && minor == 0)
427    return x >= NDBD_NATIVE_DEFAULT_SUPPORT_70;
428
429  return x >= NDBD_NATIVE_DEFAULT_SUPPORT_71;
430}
431
432#define NDBD_HB_ORDER_VERSION_63 NDB_MAKE_VERSION(6,3,35)
433#define NDBD_HB_ORDER_VERSION_70 NDB_MAKE_VERSION(7,0,16)
434#define NDBD_HB_ORDER_VERSION_71 NDB_MAKE_VERSION(7,1,5)
435
436static
437inline
438int
439ndb_check_hb_order_version(Uint32 x)
440{
441  {
442    const Uint32 major = (x >> 16) & 0xFF;
443    const Uint32 minor = (x >>  8) & 0xFF;
444
445    if (major == 6 && minor == 3)
446    {
447      return x >= NDBD_HB_ORDER_VERSION_63;
448    }
449    if (major == 7 && minor == 0)
450    {
451      return x >= NDBD_HB_ORDER_VERSION_70;
452    }
453    return x >= NDBD_HB_ORDER_VERSION_71;
454  }
455}
456
457#define NDBD_SYNCH_SP_70 NDB_MAKE_VERSION(7,0,17)
458#define NDBD_SYNCH_SP_71 NDB_MAKE_VERSION(7,1,6)
459
460static
461inline
462int
463ndb_wait_sp(Uint32 x)
464{
465  {
466    const Uint32 major = (x >> 16) & 0xFF;
467    const Uint32 minor = (x >>  8) & 0xFF;
468
469    if (major == 7 && minor == 0)
470    {
471      return x >= NDBD_SYNCH_SP_70;
472    }
473    return x >= NDBD_SYNCH_SP_71;
474  }
475}
476
477#define NDBD_DIH_GET_TABINFO_70 NDB_MAKE_VERSION(7,0,17)
478#define NDBD_DIH_GET_TABINFO_71 NDB_MAKE_VERSION(7,1,6)
479
480static
481inline
482int
483ndb_dih_get_tabinfo(Uint32 x)
484{
485  {
486    const Uint32 major = (x >> 16) & 0xFF;
487    const Uint32 minor = (x >>  8) & 0xFF;
488
489    if (major == 7 && minor == 0)
490    {
491      return x >= NDBD_DIH_GET_TABINFO_70;
492    }
493    return x >= NDBD_DIH_GET_TABINFO_71;
494  }
495}
496
497#define NDBD_SUMA_STOP_ME_63 NDB_MAKE_VERSION(6,3,37)
498#define NDBD_SUMA_STOP_ME_70 NDB_MAKE_VERSION(7,0,18)
499#define NDBD_SUMA_STOP_ME_71 NDB_MAKE_VERSION(7,1,7)
500
501static
502inline
503int
504ndbd_suma_stop_me(Uint32 x)
505{
506  {
507    const Uint32 major = (x >> 16) & 0xFF;
508    const Uint32 minor = (x >>  8) & 0xFF;
509
510    if (major == 6)
511    {
512      return x >= NDBD_SUMA_STOP_ME_63;
513    }
514    if (major == 7 && minor == 0)
515    {
516      return x >= NDBD_SUMA_STOP_ME_70;
517    }
518    return x >= NDBD_SUMA_STOP_ME_71;
519  }
520}
521
522#define NDBD_DIH_SUB_GCP_COMPLETE_ACK_63 NDB_MAKE_VERSION(6,3,39)
523#define NDBD_DIH_SUB_GCP_COMPLETE_ACK_70 NDB_MAKE_VERSION(7,0,20)
524#define NDBD_DIH_SUB_GCP_COMPLETE_ACK_71 NDB_MAKE_VERSION(7,1,9)
525
526static
527inline
528int
529ndbd_dih_sub_gcp_complete_ack(Uint32 x)
530{
531  {
532    const Uint32 major = (x >> 16) & 0xFF;
533    const Uint32 minor = (x >>  8) & 0xFF;
534
535    if (major == 6)
536    {
537      return x >= NDBD_DIH_SUB_GCP_COMPLETE_ACK_63;
538    }
539    if (major == 7 && minor == 0)
540    {
541      return x >= NDBD_DIH_SUB_GCP_COMPLETE_ACK_70;
542    }
543    return x >= NDBD_DIH_SUB_GCP_COMPLETE_ACK_71;
544  }
545}
546
547/**
548 * After this version, TC/BACKUP/SUMA does not use ScanFragReq::setAttrLen
549 *   when sending long SCAN_FRAGREQ
550 */
551#define NDBD_LONG_SCAN_FRAGREQ_70 NDB_MAKE_VERSION(7,0,20)
552#define NDBD_LONG_SCAN_FRAGREQ_71 NDB_MAKE_VERSION(7,1,9)
553
554#define NDBD_FAIL_REP_SOURCE_NODE_63 NDB_MAKE_VERSION(6,3,40)
555#define NDBD_FAIL_REP_SOURCE_NODE_70 NDB_MAKE_VERSION(7,0,21)
556#define NDBD_FAIL_REP_SOURCE_NODE_71 NDB_MAKE_VERSION(7,1,10)
557
558static
559inline
560int
561ndbd_fail_rep_source_node(Uint32 x)
562{
563  {
564    const Uint32 major = (x >> 16) & 0xFF;
565    const Uint32 minor = (x >>  8) & 0xFF;
566
567    if (major == 6)
568    {
569      return x >= NDBD_FAIL_REP_SOURCE_NODE_63;
570    }
571    if (major == 7 && minor == 0)
572    {
573      return x >= NDBD_FAIL_REP_SOURCE_NODE_70;
574    }
575    return x >= NDBD_FAIL_REP_SOURCE_NODE_71;
576  }
577}
578
579
580#define NDBD_SYNC_REQ_SUPPORT_70 NDB_MAKE_VERSION(7,0,20)
581#define NDBD_SYNC_REQ_SUPPORT_71 NDB_MAKE_VERSION(7,1,9)
582
583static
584inline
585int
586ndbd_sync_req_support(Uint32 x)
587{
588  const Uint32 major = (x >> 16) & 0xFF;
589  const Uint32 minor = (x >>  8) & 0xFF;
590
591  if (major == 7 && minor == 0)
592    return x >= NDBD_SYNC_REQ_SUPPORT_70;
593
594  return x >= NDBD_SYNC_REQ_SUPPORT_71;
595}
596
597/**
598 * Does not support CopyFragReq::CFR_NON_TRANSACTIONAL
599 */
600#define NDBD_NON_TRANS_COPY_FRAG_REQ_70 NDB_MAKE_VERSION(7,0,22)
601#define NDBD_NON_TRANS_COPY_FRAG_REQ_71 NDB_MAKE_VERSION(7,1,11)
602
603static
604inline
605int
606ndbd_non_trans_copy_frag_req(Uint32 x)
607{
608  const Uint32 major = (x >> 16) & 0xFF;
609  const Uint32 minor = (x >>  8) & 0xFF;
610
611  if (major == 7 && minor == 0)
612    return x >= NDBD_NON_TRANS_COPY_FRAG_REQ_70;
613
614  return x >= NDBD_NON_TRANS_COPY_FRAG_REQ_71;
615}
616
617#define NDBD_PING_REQ_70 NDB_MAKE_VERSION(7,0,24)
618#define NDBD_PING_REQ_71 NDB_MAKE_VERSION(7,1,13)
619
620static
621inline
622int
623ndbd_connectivity_check(Uint32 x)
624{
625  const Uint32 major = (x >> 16) & 0xFF;
626  const Uint32 minor = (x >>  8) & 0xFF;
627
628  if (major == 7 && minor == 0)
629    return x >= NDBD_PING_REQ_70;
630
631  return x >= NDBD_PING_REQ_71;
632}
633
634#define NDBD_DEFERRED_UNIQUE_CONSTRAINTS_70 NDB_MAKE_VERSION(7,0,25)
635#define NDBD_DEFERRED_UNIQUE_CONSTRAINTS_71 NDB_MAKE_VERSION(7,1,14)
636
637static
638inline
639int
640ndbd_deferred_unique_constraints(Uint32 x)
641{
642  const Uint32 major = (x >> 16) & 0xFF;
643  const Uint32 minor = (x >>  8) & 0xFF;
644
645  if (major == 7 && minor == 0)
646    return x >= NDBD_DEFERRED_UNIQUE_CONSTRAINTS_70;
647
648  return x >= NDBD_DEFERRED_UNIQUE_CONSTRAINTS_71;
649}
650
651#define NDBD_TUP_EXTRABITS_70 NDB_MAKE_VERSION(7,0,25)
652#define NDBD_TUP_EXTRABITS_71 NDB_MAKE_VERSION(7,1,14)
653#define NDBD_TUP_EXTRABITS_72 NDB_MAKE_VERSION(7,2,1)
654
655static
656inline
657int
658ndb_tup_extrabits(Uint32 x)
659{
660  {
661    const Uint32 major = (x >> 16) & 0xFF;
662    const Uint32 minor = (x >>  8) & 0xFF;
663
664    if (major == 7 && minor < 2)
665    {
666      if (minor == 0)
667        return x >= NDBD_TUP_EXTRABITS_70;
668      else if (minor == 1)
669        return x >= NDBD_TUP_EXTRABITS_71;
670    }
671    return x >= NDBD_TUP_EXTRABITS_72;
672  }
673}
674
675#define NDBD_REFRESH_TUPLE_70 NDB_MAKE_VERSION(7,0,26)
676#define NDBD_REFRESH_TUPLE_71 NDB_MAKE_VERSION(7,1,15)
677#define NDBD_REFRESH_TUPLE_72 NDB_MAKE_VERSION(7,2,1)
678
679static
680inline
681int
682ndb_refresh_tuple(Uint32 x)
683{
684  {
685    const Uint32 major = (x >> 16) & 0xFF;
686    const Uint32 minor = (x >>  8) & 0xFF;
687
688    if (major == 7 && minor < 2)
689    {
690      if (minor == 0)
691        return x >= NDBD_REFRESH_TUPLE_70;
692      else if (minor == 1)
693        return x >= NDBD_REFRESH_TUPLE_71;
694    }
695    return x >= NDBD_REFRESH_TUPLE_72;
696  }
697}
698
699#define NDBD_GET_CONFIG_SUPPORT_70 NDB_MAKE_VERSION(7,0,27)
700#define NDBD_GET_CONFIG_SUPPORT_71 NDB_MAKE_VERSION(7,1,16)
701
702static
703inline
704int
705ndbd_get_config_supported(Uint32 x)
706{
707  const Uint32 major = (x >> 16) & 0xFF;
708  const Uint32 minor = (x >>  8) & 0xFF;
709
710  if (major == 7 && minor == 0)
711    return x >= NDBD_GET_CONFIG_SUPPORT_70;
712
713  return x >= NDBD_GET_CONFIG_SUPPORT_71;
714}
715
716#define NDBD_CONFIGURABLE_LOG_PARTS_70 NDB_MAKE_VERSION(7,0,29)
717#define NDBD_CONFIGURABLE_LOG_PARTS_71 NDB_MAKE_VERSION(7,1,18)
718#define NDBD_CONFIGURABLE_LOG_PARTS_72 NDB_MAKE_VERSION(7,2,3)
719
720static
721inline
722int
723ndb_configurable_log_parts(Uint32 x)
724{
725  const Uint32 major = (x >> 16) & 0xFF;
726  const Uint32 minor = (x >>  8) & 0xFF;
727
728  if (major == 7 && minor < 2)
729  {
730    if (minor == 0)
731      return x >= NDBD_CONFIGURABLE_LOG_PARTS_70;
732    else if (minor == 1)
733      return x >= NDBD_CONFIGURABLE_LOG_PARTS_71;
734  }
735  return x >= NDBD_CONFIGURABLE_LOG_PARTS_72;
736}
737
738#define NDBD_128_INSTANCES_ADDRESS_70 NDB_MAKE_VERSION(7,0,31)
739#define NDBD_128_INSTANCES_ADDRESS_71 NDB_MAKE_VERSION(7,1,20)
740#define NDBD_128_INSTANCES_ADDRESS_72 NDB_MAKE_VERSION(7,2,5)
741
742static
743inline
744int
745ndbd_128_instances_address(Uint32 x)
746{
747  const Uint32 major = (x >> 16) & 0xFF;
748  const Uint32 minor = (x >>  8) & 0xFF;
749
750  if (major == 7 && minor < 2)
751  {
752    if (minor == 0)
753      return x >= NDBD_128_INSTANCES_ADDRESS_70;
754    else if (minor == 1)
755      return x >= NDBD_128_INSTANCES_ADDRESS_71;
756  }
757  return x >= NDBD_128_INSTANCES_ADDRESS_72;
758}
759
760#define NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_70 NDB_MAKE_VERSION(7,0,34)
761#define NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_71 NDB_MAKE_VERSION(7,1,23)
762#define NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_72 NDB_MAKE_VERSION(7,2,7)
763
764static
765inline
766int
767ndbd_scan_tabreq_implicit_parallelism(Uint32 x)
768{
769  const Uint32 major = (x >> 16) & 0xFF;
770  const Uint32 minor = (x >>  8) & 0xFF;
771
772  if (major == 7 && minor < 2)
773  {
774    if (minor == 0)
775      return x >= NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_70;
776    else if (minor == 1)
777      return x >= NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_71;
778  }
779  return x >= NDBD_SCAN_TABREQ_IMPLICIT_PARALLELISM_72;
780}
781
782#define NDBD_FIXED_LOOKUP_QUERY_ABORT_72 NDB_MAKE_VERSION(7,2,5)
783
784static
785inline
786int
787ndbd_fixed_lookup_query_abort(Uint32 x)
788{
789  const Uint32 major = (x >> 16) & 0xFF;
790  const Uint32 minor = (x >>  8) & 0xFF;
791
792  if (major == 7 && minor < 2)
793  {
794    // Only experimental support of SPJ pre 7.2.0.
795    // Assume we support 'fixed-abort' as we want it tested.
796    return 1;
797  }
798  return x >= NDBD_FIXED_LOOKUP_QUERY_ABORT_72;
799}
800
801/**
802 * NOTE1:
803 *   Even though pushed join support wasn't GA intil 7.2.4
804 *   we claim support for it in all 7.2.x versions.
805 * NOTE2:
806 *   By a mistake this online upgrade check was not
807 *   added until version 7.2.6
808 */
809#define NDBD_JOIN_PUSHDOWN NDB_MAKE_VERSION(7,2,0)
810
811static
812inline
813int
814ndb_join_pushdown(Uint32 x)
815{
816  return x >= NDBD_JOIN_PUSHDOWN;
817}
818
819/**
820 * DICT did not have a function for receiving GET_TABINFOREF signals
821 * (see Bug#14647210).
822 */
823#define NDBD_DICT_GET_TABINFOREF_IMPLEMENTED NDB_MAKE_VERSION(7, 2, 9)
824
825inline
826int
827ndbd_dict_get_tabinforef_implemented(Uint32 x)
828{
829  return x >= NDBD_DICT_GET_TABINFOREF_IMPLEMENTED;
830}
831
832/**
833 * Dbtc::execFIRE_TRIG_ORD can receive long signals.
834 */
835#define NDBD_LONG_FIRE_TRIG_ORD NDB_MAKE_VERSION(7,3,2)
836
837#define NDBD_MULTI_TC_INSTANCE_TAKEOVER_72 NDB_MAKE_VERSION(7,2,17)
838#define NDBD_MULTI_TC_INSTANCE_TAKEOVER_73 NDB_MAKE_VERSION(7,3,6)
839
840static
841inline
842int
843ndbd_long_fire_trig_ord(Uint32 x)
844{
845  return x >= NDBD_LONG_FIRE_TRIG_ORD;
846}
847
848static
849inline
850int
851ndbd_multi_tc_instance_takeover(Uint32 x)
852{
853  const Uint32 major = (x >> 16) & 0xFF;
854  const Uint32 minor = (x >>  8) & 0xFF;
855
856  if (major < 7)
857  {
858    return 0;
859  }
860  else if (major == 7)
861  {
862    if (minor < 2)
863    {
864      return 0;
865    }
866    else if (minor == 2)
867    {
868      return x >= NDBD_MULTI_TC_INSTANCE_TAKEOVER_72;
869    }
870    else if (minor == 3)
871    {
872      return x >= NDBD_MULTI_TC_INSTANCE_TAKEOVER_73;
873    }
874  }
875  return 1;
876}
877
878/**
879 * Support for more parallel fragment LCPs
880 */
881#define NDBD_EXTRA_PARALLEL_FRAG_LCP NDB_MAKE_VERSION(7,4,1)
882
883/**
884 * Support for PAUSE LCPs
885 */
886#define NDBD_SUPPORT_PAUSE_LCP NDB_MAKE_VERSION(7,4,3)
887
888/**
889 * Support for Node Recovery Status module, including sending
890 * END_TOREP.
891 */
892#define NDBD_NODE_RECOVERY_STATUS_VERSION NDB_MAKE_VERSION(7,4,3)
893
894/**
895 * Support for removing EMPTY_LCP_REQ protocol in master takeover
896 */
897#define NDBD_EMPTY_LCP_NOT_NEEDED NDB_MAKE_VERSION(7,4,3)
898
899/**
900 * Support for multiple take over threads per node group in parallel
901 * in master node.
902 */
903#define NDBD_SUPPORT_PARALLEL_SYNCH NDB_MAKE_VERSION(7,4,3)
904
905#define NDBD_ISOLATE_ORD_72 NDB_MAKE_VERSION(7,2,19)
906#define NDBD_ISOLATE_ORD_73 NDB_MAKE_VERSION(7,3,8)
907#define NDBD_ISOLATE_ORD_74 NDB_MAKE_VERSION(7,4,3)
908
909
910static
911inline
912int
913ndbd_isolate_ord(Uint32 x)
914{
915  const Uint32 major = (x >> 16) & 0xFF;
916  const Uint32 minor = (x >>  8) & 0xFF;
917
918  if (major < 7)
919  {
920    return 0;
921  }
922  else if (major == 7)
923  {
924    if (minor < 2)
925    {
926      return 0;
927    }
928    else if (minor == 2)
929    {
930      return x >= NDBD_ISOLATE_ORD_72;
931    }
932    else if (minor == 3)
933    {
934      return x >= NDBD_ISOLATE_ORD_73;
935    }
936    else if (minor == 4)
937    {
938      return x >= NDBD_ISOLATE_ORD_74;
939    }
940  }
941  return 1;
942}
943
944#endif
945