Tarantool development patches archive
 help / color / mirror / Atom feed
From: Chris Sosnin <k.sosnin@tarantool.org>
To: tarantool-patches@dev.tarantool.org, kyukhin@tarantool.org
Subject: [Tarantool-patches] [PATCH 1/2] box: allow schema upgrades within a release
Date: Fri, 24 Apr 2020 13:14:24 +0300	[thread overview]
Message-ID: <ab82029decee53a89e0a730beb59e2348da49066.1587722860.git.k.sosnin@tarantool.org> (raw)
In-Reply-To: <cover.1587722860.git.k.sosnin@tarantool.org>

To avoid cases when a user has an incorrectly upgraded schema, we
introduce new versioning, which can be used to perform upgrades
within a single release.

Closes #4804
Needed for #4666
---
 src/box/lua/upgrade.lua | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 075cc236e..bd9a881b0 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -27,17 +27,23 @@ local mkversion = {}
 mkversion.__index = mkversion
 setmetatable(mkversion, {__call = function(c, ...) return c.new(...) end})
 
-function mkversion.new(major, minor, patch)
+function mkversion.new(major, minor, patch, build)
     local self = setmetatable({}, mkversion)
     self.major = major
     self.minor = minor
     self.patch = patch
+    self.build = build or 0
     self.id = bit.bor(bit.lshift(bit.bor(bit.lshift(major, 8), minor), 8), patch)
+    self.id = bit.bor(bit.lshift(self.id, 8), self.build)
     return self
 end
 
 function mkversion.__tostring(self)
-    return string.format('%s.%s.%s', self.major, self.minor, self.patch)
+    local s = string.format('%s.%s.%s', self.major, self.minor, self.patch)
+    if self.build ~= 0 then
+        s = s .. string.format('.%s', self.build)
+    end
+    return s
 end
 
 function mkversion.__eq(lhs, rhs)
@@ -982,8 +988,9 @@ local function get_version()
     local major = version[2]
     local minor = version[3]
     local patch = version[4] or 0
+    local build = version[5] or 0
 
-    return mkversion(major, minor, patch)
+    return mkversion(major, minor, patch, build)
 end
 
 local function upgrade(options)
@@ -1025,7 +1032,8 @@ local function upgrade(options)
         box.space._schema:replace({'version',
                                    handler.version.major,
                                    handler.version.minor,
-                                   handler.version.patch})
+                                   handler.version.patch,
+                                   handler.version.build})
         ::continue::
     end
 end
-- 
2.21.1 (Apple Git-122.3)

  reply	other threads:[~2020-04-24 10:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 10:14 [Tarantool-patches] [PATCH 0/2] fix assertion fault in SELECT * FROM "_vfunc" Chris Sosnin
2020-04-24 10:14 ` Chris Sosnin [this message]
2020-04-24 10:14 ` [Tarantool-patches] [PATCH 2/2] sql: " Chris Sosnin
  -- strict thread matches above, loose matches on Subject: below --
2020-03-19  9:14 [Tarantool-patches] [PATCH 0/2] " Chris Sosnin
2020-03-19  9:14 ` [Tarantool-patches] [PATCH 1/2] box: allow schema upgrades within a release Chris Sosnin
2020-03-22 19:43   ` Vladislav Shpilevoy
2020-03-25 19:10     ` Chris Sosnin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab82029decee53a89e0a730beb59e2348da49066.1587722860.git.k.sosnin@tarantool.org \
    --to=k.sosnin@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/2] box: allow schema upgrades within a release' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox