[lxc-devel] [lxd/master] snapshots: find max value currently used

brauner on Github lxc-bot at linuxcontainers.org
Thu Mar 9 14:34:32 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 464 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170309/45bc9e9a/attachment.bin>
-------------- next part --------------
From 12ba6aa5d1fb53dfa1036d6c14e1d5513dc87f7d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 9 Mar 2017 15:32:16 +0100
Subject: [PATCH] snapshots: find max value currently used

The MAX() statement consistently returns snap9 when it should actualy return
snap10 or greater.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_snapshot.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/container_snapshot.go b/lxd/container_snapshot.go
index 51d184e..5d8b6ea 100644
--- a/lxd/container_snapshot.go
+++ b/lxd/container_snapshot.go
@@ -64,7 +64,7 @@ func containerSnapshotsGet(d *Daemon, r *http.Request) Response {
 func nextSnapshot(d *Daemon, name string) int {
 	base := name + shared.SnapshotDelimiter + "snap"
 	length := len(base)
-	q := fmt.Sprintf("SELECT MAX(name) FROM containers WHERE type=? AND SUBSTR(name,1,?)=?")
+	q := fmt.Sprintf("SELECT name FROM containers WHERE type=? AND SUBSTR(name,1,?)=?")
 	var numstr string
 	inargs := []interface{}{cTypeSnapshot, length, base}
 	outfmt := []interface{}{numstr}


More information about the lxc-devel mailing list