]> granicus.if.org Git - postgresql/commitdiff
Fix misplacement of savepointLevel test, per report from Chris K-L.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 3 Aug 2004 15:57:26 +0000 (15:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 3 Aug 2004 15:57:26 +0000 (15:57 +0000)
src/backend/access/transam/xact.c

index 601519e4e959f8bbd8754d6798d57f93fbddb833..4794c761c3a56cb53ce55d05e22f3872487b9e9d 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.176 2004/08/01 20:57:59 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.177 2004/08/03 15:57:26 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2520,19 +2520,10 @@ RollbackToSavepoint(List *options)
 
        Assert(PointerIsValid(name));
 
-       target = CurrentTransactionState;
-
-       while (target != NULL)
+       for (target = s; PointerIsValid(target); target = target->parent)
        {
                if (PointerIsValid(target->name) && strcmp(target->name, name) == 0)
                        break;
-               target = target->parent;
-
-               /* we don't cross savepoint level boundaries */
-               if (target->savepointLevel != s->savepointLevel)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
-                                        errmsg("no such savepoint")));
        }
 
        if (!PointerIsValid(target))
@@ -2540,6 +2531,12 @@ RollbackToSavepoint(List *options)
                                (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
                                 errmsg("no such savepoint")));
 
+       /* disallow crossing savepoint level boundaries */
+       if (target->savepointLevel != s->savepointLevel)
+               ereport(ERROR,
+                               (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
+                                errmsg("no such savepoint")));
+
        /*
         * Abort the current subtransaction, if needed.  We can't Cleanup the
         * savepoint yet, so signal CommitTransactionCommand to do it and