@@ -484,6 +484,34 @@ local function get_version_suffix(suffix_candidate)
484484 return nil
485485end
486486
487+ local function get_commits_since_from_version_part (commits_since_candidate )
488+ if commits_since_candidate == nil then
489+ return 0
490+ end
491+
492+ local ok , val = pcall (tonumber , commits_since_candidate )
493+ if ok then
494+ return val
495+ else
496+ -- It may be unknown suffix instead.
497+ -- Since suffix already unknown, there is no way to properly compare versions.
498+ return 0
499+ end
500+ end
501+
502+ local function get_commits_since (suffix , commits_since_candidate_1 , commits_since_candidate_2 )
503+ -- x.x.x.-candidate_1-candidate_2
504+
505+ if suffix ~= nil then
506+ -- X.Y.Z-suffix-N
507+ return get_commits_since_from_version_part (commits_since_candidate_2 )
508+ else
509+ -- X.Y.Z-N
510+ -- Possibly X.Y.Z-suffix-N with unknown suffix
511+ return get_commits_since_from_version_part (commits_since_candidate_1 )
512+ end
513+ end
514+
487515utils .get_version_suffix = get_version_suffix
488516
489517
@@ -517,18 +545,20 @@ utils.get_version_suffix_weight = get_version_suffix_weight
517545
518546
519547local function is_version_ge (major , minor ,
520- patch , suffix ,
548+ patch , suffix , commits_since ,
521549 major_to_compare , minor_to_compare ,
522- patch_to_compare , suffix_to_compare )
550+ patch_to_compare , suffix_to_compare , commits_since_to_compare )
523551 major = major or 0
524552 minor = minor or 0
525553 patch = patch or 0
526554 local suffix_weight = get_version_suffix_weight (suffix )
555+ commits_since = commits_since or 0
527556
528557 major_to_compare = major_to_compare or 0
529558 minor_to_compare = minor_to_compare or 0
530559 patch_to_compare = patch_to_compare or 0
531560 local suffix_weight_to_compare = get_version_suffix_weight (suffix_to_compare )
561+ commits_since_to_compare = commits_since_to_compare or 0
532562
533563 if major > major_to_compare then return true end
534564 if major < major_to_compare then return false end
@@ -542,33 +572,36 @@ local function is_version_ge(major, minor,
542572 if suffix_weight > suffix_weight_to_compare then return true end
543573 if suffix_weight < suffix_weight_to_compare then return false end
544574
575+ if commits_since > commits_since_to_compare then return true end
576+ if commits_since < commits_since_to_compare then return false end
577+
545578 return true
546579end
547580
548581utils .is_version_ge = is_version_ge
549582
550583
551584local function is_version_in_range (major , minor ,
552- patch , suffix ,
585+ patch , suffix , commits_since ,
553586 major_left_side , minor_left_side ,
554- patch_left_side , suffix_left_side ,
587+ patch_left_side , suffix_left_side , commits_since_left_side ,
555588 major_right_side , minor_right_side ,
556- patch_right_side , suffix_right_side )
589+ patch_right_side , suffix_right_side , commits_since_right_side )
557590 return is_version_ge (major , minor ,
558- patch , suffix ,
591+ patch , suffix , commits_since ,
559592 major_left_side , minor_left_side ,
560- patch_left_side , suffix_left_side )
593+ patch_left_side , suffix_left_side , commits_since_left_side )
561594 and is_version_ge (major_right_side , minor_right_side ,
562- patch_right_side , suffix_right_side ,
595+ patch_right_side , suffix_right_side , commits_since_right_side ,
563596 major , minor ,
564- patch , suffix )
597+ patch , suffix , commits_since )
565598end
566599
567600utils .is_version_in_range = is_version_in_range
568601
569602
570603local function get_tarantool_version ()
571- local version_parts = rawget (_G , ' _TARANTOOL' ):split (' -' , 1 )
604+ local version_parts = rawget (_G , ' _TARANTOOL' ):split (' -' , 3 )
572605
573606 local major_minor_patch_parts = version_parts [1 ]:split (' .' , 2 )
574607 local major = tonumber (major_minor_patch_parts [1 ])
@@ -577,17 +610,20 @@ local function get_tarantool_version()
577610
578611 local suffix = get_version_suffix (version_parts [2 ])
579612
580- return major , minor , patch , suffix
613+ local commits_since = get_commits_since (suffix , version_parts [2 ], version_parts [3 ])
614+
615+ return major , minor , patch , suffix , commits_since
581616end
582617
583618utils .get_tarantool_version = get_tarantool_version
584619
585620
586- local function tarantool_version_at_least (wanted_major , wanted_minor , wanted_patch )
587- local major , minor , patch , suffix = get_tarantool_version ()
621+ local function tarantool_version_at_least (wanted_major , wanted_minor ,
622+ wanted_patch , wanted_suffix , wanted_commits_since )
623+ local major , minor , patch , suffix , commits_since = get_tarantool_version ()
588624
589- return is_version_ge (major , minor , patch , suffix ,
590- wanted_major , wanted_minor , wanted_patch , nil )
625+ return is_version_ge (major , minor , patch , suffix , commits_since ,
626+ wanted_major , wanted_minor , wanted_patch , wanted_suffix , wanted_commits_since )
591627end
592628
593629utils .tarantool_version_at_least = tarantool_version_at_least
@@ -596,49 +632,49 @@ utils.tarantool_version_at_least = tarantool_version_at_least
596632local enabled_tarantool_features = {}
597633
598634local function determine_enabled_features ()
599- local major , minor , patch , suffix = get_tarantool_version ()
635+ local major , minor , patch , suffix , commits_since = get_tarantool_version ()
600636
601637 -- since Tarantool 2.3.1
602- enabled_tarantool_features .fieldpaths = is_version_ge (major , minor , patch , suffix ,
603- 2 , 3 , 1 , nil )
638+ enabled_tarantool_features .fieldpaths = is_version_ge (major , minor , patch , suffix , commits_since ,
639+ 2 , 3 , 1 , nil , nil )
604640
605641 -- Full support (Lua type, space format type and indexes) for decimal type
606642 -- is since Tarantool 2.3.1 [1]
607643 --
608644 -- [1] https://github.com/tarantool/tarantool/commit/485439e33196e26d120e622175f88b4edc7a5aa1
609- enabled_tarantool_features .decimals = is_version_ge (major , minor , patch , suffix ,
610- 2 , 3 , 1 , nil )
645+ enabled_tarantool_features .decimals = is_version_ge (major , minor , patch , suffix , commits_since ,
646+ 2 , 3 , 1 , nil , nil )
611647
612648 -- Full support (Lua type, space format type and indexes) for uuid type
613649 -- is since Tarantool 2.4.1 [1]
614650 --
615651 -- [1] https://github.com/tarantool/tarantool/commit/b238def8065d20070dcdc50b54c2536f1de4c7c7
616- enabled_tarantool_features .uuids = is_version_ge (major , minor , patch , suffix ,
617- 2 , 4 , 1 , nil )
652+ enabled_tarantool_features .uuids = is_version_ge (major , minor , patch , suffix , commits_since ,
653+ 2 , 4 , 1 , nil , nil )
618654
619655 -- Full support (Lua type, space format type and indexes) for datetime type
620656 -- is since Tarantool 2.10.0-beta2 [1]
621657 --
622658 -- [1] https://github.com/tarantool/tarantool/commit/3bd870261c462416c29226414fe0a2d79aba0c74
623- enabled_tarantool_features .datetimes = is_version_ge (major , minor , patch , suffix ,
624- 2 , 10 , 0 , ' beta2' )
659+ enabled_tarantool_features .datetimes = is_version_ge (major , minor , patch , suffix , commits_since ,
660+ 2 , 10 , 0 , ' beta2' , nil )
625661
626662 -- Full support (Lua type, space format type and indexes) for datetime type
627663 -- is since Tarantool 2.10.0-rc1 [1]
628664 --
629665 -- [1] https://github.com/tarantool/tarantool/commit/38f0c904af4882756c6dc802f1895117d3deae6a
630- enabled_tarantool_features .intervals = is_version_ge (major , minor , patch , suffix ,
631- 2 , 10 , 0 , ' rc1' )
666+ enabled_tarantool_features .intervals = is_version_ge (major , minor , patch , suffix , commits_since ,
667+ 2 , 10 , 0 , ' rc1' , nil )
632668
633669 -- since Tarantool 2.6.3 / 2.7.2 / 2.8.1
634- enabled_tarantool_features .jsonpath_indexes = is_version_ge (major , minor , patch , suffix ,
635- 2 , 8 , 1 , nil )
636- or is_version_in_range (major , minor , patch , suffix ,
637- 2 , 7 , 2 , nil ,
638- 2 , 7 , math.huge , nil )
639- or is_version_in_range (major , minor , patch , suffix ,
640- 2 , 6 , 3 , nil ,
641- 2 , 6 , math.huge , nil )
670+ enabled_tarantool_features .jsonpath_indexes = is_version_ge (major , minor , patch , suffix , commits_since ,
671+ 2 , 8 , 1 , nil , nil )
672+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
673+ 2 , 7 , 2 , nil , nil ,
674+ 2 , 7 , math.huge , nil , nil )
675+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
676+ 2 , 6 , 3 , nil , nil ,
677+ 2 , 6 , math.huge , nil , nil )
642678
643679 -- The merger module was implemented in 2.2.1, see [1].
644680 -- However it had the critical problem [2], which leads to
@@ -648,52 +684,56 @@ local function determine_enabled_features()
648684 --
649685 -- [1]: https://github.com/tarantool/tarantool/issues/3276
650686 -- [2]: https://github.com/tarantool/tarantool/issues/4954
651- enabled_tarantool_features .builtin_merger = is_version_ge (major , minor , patch , suffix ,
652- 2 , 6 , 0 , nil )
653- or is_version_in_range (major , minor , patch , suffix ,
654- 2 , 5 , 1 , nil ,
655- 2 , 5 , math.huge , nil )
656- or is_version_in_range (major , minor , patch , suffix ,
657- 2 , 4 , 2 , nil ,
658- 2 , 4 , math.huge , nil )
659- or is_version_in_range (major , minor , patch , suffix ,
660- 2 , 3 , 3 , nil ,
661- 2 , 3 , math.huge , nil )
687+ enabled_tarantool_features .builtin_merger = is_version_ge (major , minor , patch , suffix , commits_since ,
688+ 2 , 6 , 0 , nil , nil )
689+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
690+ 2 , 5 , 1 , nil , nil ,
691+ 2 , 5 , math.huge , nil , nil )
692+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
693+ 2 , 4 , 2 , nil , nil ,
694+ 2 , 4 , math.huge , nil , nil )
695+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
696+ 2 , 3 , 3 , nil , nil ,
697+ 2 , 3 , math.huge , nil , nil )
662698
663699 -- The external merger module leans on a set of relatively
664700 -- new APIs in tarantool. So it works only on tarantool
665701 -- versions, which offer those APIs.
666702 --
667703 -- See README of the module:
668704 -- https://github.com/tarantool/tuple-merger
669- enabled_tarantool_features .external_merger = is_version_ge (major , minor , patch , suffix ,
670- 2 , 7 , 0 , nil )
671- or is_version_in_range (major , minor , patch , suffix ,
672- 2 , 6 , 1 , nil ,
673- 2 , 6 , math.huge , nil )
674- or is_version_in_range (major , minor , patch , suffix ,
675- 2 , 5 , 2 , nil ,
676- 2 , 5 , math.huge , nil )
677- or is_version_in_range (major , minor , patch , suffix ,
678- 2 , 4 , 3 , nil ,
679- 2 , 4 , math.huge , nil )
680- or is_version_in_range (major , minor , patch , suffix ,
681- 1 , 10 , 8 , nil ,
682- 1 , 10 , math.huge , nil )
683-
684- enabled_tarantool_features .netbox_skip_header_option = is_version_ge (major , minor , patch , suffix ,
685- 2 , 2 , 0 , nil )
705+ enabled_tarantool_features .external_merger = is_version_ge (major , minor , patch , suffix , commits_since ,
706+ 2 , 7 , 0 , nil , nil )
707+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
708+ 2 , 6 , 1 , nil , nil ,
709+ 2 , 6 , math.huge , nil , nil )
710+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
711+ 2 , 5 , 2 , nil , nil ,
712+ 2 , 5 , math.huge , nil , nil )
713+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
714+ 2 , 4 , 3 , nil , nil ,
715+ 2 , 4 , math.huge , nil , nil )
716+ or is_version_in_range (major , minor , patch , suffix , commits_since ,
717+ 1 , 10 , 8 , nil , nil ,
718+ 1 , 10 , math.huge , nil , nil )
719+
720+ enabled_tarantool_features .netbox_skip_header_option = is_version_ge (major , minor , patch , suffix , commits_since ,
721+ 2 , 2 , 0 , nil , nil )
686722
687723 -- https://github.com/tarantool/tarantool/commit/11f2d999a92e45ee41b8c8d0014d8a09290fef7b
688- enabled_tarantool_features .box_watch = is_version_ge (major , minor , patch , suffix ,
689- 2 , 10 , 0 , ' beta2' )
724+ enabled_tarantool_features .box_watch = is_version_ge (major , minor , patch , suffix , commits_since ,
725+ 2 , 10 , 0 , ' beta2' , nil )
690726
691- enabled_tarantool_features .tarantool_3 = is_version_ge (major , minor , patch , suffix ,
692- 3 , 0 , 0 , nil )
727+ enabled_tarantool_features .tarantool_3 = is_version_ge (major , minor , patch , suffix , commits_since ,
728+ 3 , 0 , 0 , nil , nil )
693729end
694730
695731determine_enabled_features ()
696732
733+ local function feature_in_list (feature_to_check , list_of_features )
734+
735+ end
736+
697737for feature_name , feature_enabled in pairs (enabled_tarantool_features ) do
698738 local util_name
699739 if feature_name == ' tarantool_3' then
0 commit comments