Index: /trunk/ippdb/configure.ac
===================================================================
--- /trunk/ippdb/configure.ac	(revision 18795)
+++ /trunk/ippdb/configure.ac	(revision 18796)
@@ -7,5 +7,5 @@
 AC_PREREQ(2.61)
 
-AC_INIT([ippdb], [1.1.38], [pan-starrs.ifa.hawaii.edu])
+AC_INIT([ippdb], [1.1.39], [pan-starrs.ifa.hawaii.edu])
 AC_CONFIG_SRCDIR([ippdb.pc.in])
 
Index: /trunk/ippdb/src/ippdb.c
===================================================================
--- /trunk/ippdb/src/ippdb.c	(revision 18795)
+++ /trunk/ippdb/src/ippdb.c	(revision 18796)
@@ -23053,5 +23053,5 @@
 static void magicRunRowFree(magicRunRow *object);
 
-magicRunRow *magicRunRowAlloc(psS64 magic_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, psTime* registered, psS16 fault)
+magicRunRow *magicRunRowAlloc(psS64 magic_id, psS64 exp_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, psTime* registered, psS16 fault)
 {
     magicRunRow     *_object;
@@ -23061,4 +23061,5 @@
 
     _object->magic_id = magic_id;
+    _object->exp_id = exp_id;
     _object->state = psStringCopy(state);
     _object->workdir = psStringCopy(workdir);
@@ -23090,4 +23091,9 @@
         return false;
     }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Key", 0)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+        psFree(md);
+        return false;
+    }
     if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "Key", "64")) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item state");
@@ -23138,9 +23144,14 @@
 }
 
-bool magicRunInsert(psDB * dbh, psS64 magic_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, psTime* registered, psS16 fault)
+bool magicRunInsert(psDB * dbh, psS64 magic_id, psS64 exp_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *dvodb, psTime* registered, psS16 fault)
 {
     psMetadata *md = psMetadataAlloc();
     if (!psMetadataAdd(md, PS_LIST_TAIL, "magic_id", PS_DATA_S64, NULL, magic_id)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item magic_id");
+        psFree(md);
+        return false;
+    }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
         psFree(md);
         return false;
@@ -23204,5 +23215,5 @@
 bool magicRunInsertObject(psDB *dbh, magicRunRow *object)
 {
-    return magicRunInsert(dbh, object->magic_id, object->state, object->workdir, object->workdir_state, object->label, object->dvodb, object->registered, object->fault);
+    return magicRunInsert(dbh, object->magic_id, object->exp_id, object->state, object->workdir, object->workdir_state, object->label, object->dvodb, object->registered, object->fault);
 }
 
@@ -23282,4 +23293,9 @@
         return false;
     }
+    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+        psFree(md);
+        return false;
+    }
     if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) {
         psError(PS_ERR_UNKNOWN, false, "failed to add item state");
@@ -23331,4 +23347,9 @@
         return false;
     }
+    psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id");
+        return false;
+    }
     char* state = psMetadataLookupPtr(&status, md, "state");
     if (!status) {
@@ -23367,5 +23388,5 @@
     }
 
-    return magicRunRowAlloc(magic_id, state, workdir, workdir_state, label, dvodb, registered, fault);
+    return magicRunRowAlloc(magic_id, exp_id, state, workdir, workdir_state, label, dvodb, registered, fault);
 }
 psArray *magicRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
Index: /trunk/ippdb/src/ippdb.h
===================================================================
--- /trunk/ippdb/src/ippdb.h	(revision 18795)
+++ /trunk/ippdb/src/ippdb.h	(revision 18796)
@@ -10029,4 +10029,5 @@
 typedef struct {
     psS64           magic_id;
+    psS64           exp_id;
     char            *state;
     char            *workdir;
@@ -10045,4 +10046,5 @@
 magicRunRow *magicRunRowAlloc(
     psS64           magic_id,
+    psS64           exp_id,
     const char      *state,
     const char      *workdir,
@@ -10082,4 +10084,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           magic_id,
+    psS64           exp_id,
     const char      *state,
     const char      *workdir,
Index: /trunk/ippdb/tests/alloc.c
===================================================================
--- /trunk/ippdb/tests/alloc.c	(revision 18795)
+++ /trunk/ippdb/tests/alloc.c	(revision 18796)
@@ -2736,5 +2736,5 @@
         magicRunRow     *object;
 
-        object = magicRunRowAlloc(-64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16    );
+        object = magicRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16    );
 
         if (!object) {
@@ -2743,4 +2743,8 @@
 
         if (!object->magic_id == -64) {
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
+        if (!object->exp_id == -64) {
             psFree(object);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/insert.c
===================================================================
--- /trunk/ippdb/tests/insert.c	(revision 18795)
+++ /trunk/ippdb/tests/insert.c	(revision 18796)
@@ -658,5 +658,5 @@
         }
 
-        if (!magicRunInsert(dbh, -64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16)) {
+        if (!magicRunInsert(dbh, -64, -64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16)) {
             exit(EXIT_FAILURE);
         }
Index: /trunk/ippdb/tests/insertobject.c
===================================================================
--- /trunk/ippdb/tests/insertobject.c	(revision 18795)
+++ /trunk/ippdb/tests/insertobject.c	(revision 18796)
@@ -960,5 +960,5 @@
         }
 
-        object = magicRunRowAlloc(-64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16);
+        object = magicRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16);
         if (!object) {
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/metadatafromobject.c
===================================================================
--- /trunk/ippdb/tests/metadatafromobject.c	(revision 18795)
+++ /trunk/ippdb/tests/metadatafromobject.c	(revision 18796)
@@ -3007,5 +3007,5 @@
         bool            status;
 
-        object = magicRunRowAlloc(-64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16);
+        object = magicRunRowAlloc(-64, -64, "a string", "a string", "a string", "a string", "a string", "0001-01-01T00:00:00Z", -16);
         if (!object) {
             exit(EXIT_FAILURE);
@@ -3019,4 +3019,7 @@
         psFree(object);
 
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
             psFree(md);
             exit(EXIT_FAILURE);
Index: /trunk/ippdb/tests/objectfrommetadata.c
===================================================================
--- /trunk/ippdb/tests/objectfrommetadata.c	(revision 18795)
+++ /trunk/ippdb/tests/objectfrommetadata.c	(revision 18796)
@@ -4972,4 +4972,7 @@
             exit(EXIT_FAILURE);
         }
+            psFree(md);
+            exit(EXIT_FAILURE);
+        }
         if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) {
             psFree(md);
@@ -5007,4 +5010,7 @@
         psFree(md);
 
+            psFree(object);
+            exit(EXIT_FAILURE);
+        }
             psFree(object);
             exit(EXIT_FAILURE);
