Index: /trunk/glueforge/templates/psdb/Makefile.am
===================================================================
--- /trunk/glueforge/templates/psdb/Makefile.am	(revision 9418)
+++ /trunk/glueforge/templates/psdb/Makefile.am	(revision 9419)
@@ -61,16 +61,4 @@
     objectfrommetadata_h.tt \
     pkgconfig_pc_in.tt \
-    pop.tt \
-    pop_at.tt \
-    pop_c.tt \
-    pop_h.tt \
-    popfits.tt \
-    popfits_at.tt \
-    popfits_c.tt \
-    popfits_h.tt \
-    popobject.tt \
-    popobject_at.tt \
-    popobject_c.tt \
-    popobject_h.tt \
     printmetadata.tt \
     printmetadata_h.tt \
Index: /trunk/glueforge/templates/psdb/code.tt
===================================================================
--- /trunk/glueforge/templates/psdb/code.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/code.tt	(revision 9419)
@@ -31,8 +31,6 @@
 #include "[% pkg_name %].h"
 
-#define [% pkg_name FILTER upper %]_DEFAULT_INDEX_NAME "position"
 [% FOREACH table = tables -%]
 #define [% table.namespace FILTER upper %]_TABLE_NAME "[% table.name %]"
-#define [% table.namespace FILTER upper %]_INDEX_NAME [% pkg_name FILTER upper %]_DEFAULT_INDEX_NAME
 [% END -%]
 #define MAX_STRING_LENGTH 1024
@@ -50,10 +48,7 @@
 [% INCLUDE insert.tt %]
 [% INCLUDE delete.tt -%]
-[% INCLUDE pop.tt %]
 [% INCLUDE insertobject.tt %]
 [% INCLUDE insertobjects.tt %]
-[% INCLUDE popobject.tt %]
 [% INCLUDE insertfits.tt %]
-[% INCLUDE popfits.tt %]
 [% INCLUDE selectrowsfits.tt %]
 [% INCLUDE metadatafromobject.tt %]
Index: /trunk/glueforge/templates/psdb/config.pl
===================================================================
--- /trunk/glueforge/templates/psdb/config.pl	(revision 9418)
+++ /trunk/glueforge/templates/psdb/config.pl	(revision 9419)
@@ -19,9 +19,6 @@
     'droptable_c.tt'        => "$output/tests/droptable.c",
     'insert_c.tt'           => "$output/tests/insert.c",
-    'pop_c.tt'              => "$output/tests/pop.c",
     'insertobject_c.tt'     => "$output/tests/insertobject.c",
-    'popobject_c.tt'        => "$output/tests/popobject.c",
     'insertfits_c.tt'       => "$output/tests/insertfits.c",
-    'popfits_c.tt'          => "$output/tests/popfits.c",
     'selectrowsfits_c.tt'   => "$output/tests/selectrowsfits.c",
     'metadatafromobject_c.tt' => "$output/tests/metadatafromobject.c",
Index: /trunk/glueforge/templates/psdb/createtable.tt
===================================================================
--- /trunk/glueforge/templates/psdb/createtable.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/createtable.tt	(revision 9419)
@@ -5,9 +5,4 @@
 
     md = psMetadataAlloc();
-    if (!psMetadataAdd(md, PS_LIST_TAIL, [% table.namespace FILTER upper %]_INDEX_NAME, PS_DATA_S32, "AUTO_INCREMENT", 0.0)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to add item %s", [% table.namespace FILTER upper %]_INDEX_NAME);
-        psFree(md);
-        return false;
-    }
 [% FOREACH item = table.columns -%]
 [% IF item.comment;
Index: /trunk/glueforge/templates/psdb/header.tt
===================================================================
--- /trunk/glueforge/templates/psdb/header.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/header.tt	(revision 9419)
@@ -51,10 +51,7 @@
 [% INCLUDE insert_h.tt %]
 [% INCLUDE delete_h.tt %]
-[% INCLUDE pop_h.tt %]
 [% INCLUDE insertobject_h.tt %]
 [% INCLUDE insertobjects_h.tt %]
-[% INCLUDE popobject_h.tt %]
 [% INCLUDE insertfits_h.tt %]
-[% INCLUDE popfits_h.tt %]
 [% INCLUDE selectrowsfits_h.tt %]
 [% INCLUDE metadatafromobject_h.tt %]
Index: /trunk/glueforge/templates/psdb/insertfits_at.tt
===================================================================
--- /trunk/glueforge/templates/psdb/insertfits_at.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/insertfits_at.tt	(revision 9419)
@@ -6,5 +6,5 @@
 AT_CHECK([insert])
 # run popfis so there is afits file to read
-AT_CHECK([popfits])
+AT_CHECK([selectrowsfits])
 AT_CHECK([insertfits])
 AT_CHECK([dbcleanup])
Index: unk/glueforge/templates/psdb/pop.tt
===================================================================
--- /trunk/glueforge/templates/psdb/pop.tt	(revision 9418)
+++ 	(revision )
@@ -1,74 +1,0 @@
-[% USE format -%]
-[% indented = format('%-15s %s') -%]
-bool [% table.namespace %]Pop(psDB *dbh, 
-[%- SET i = 0 -%]
-[% FOREACH item = table.columns -%]
-[% IF i == 0 %][% i = 1 %][% ELSE %], [% END -%]
-[% IF item.type == "STR" -%]
-char **[% item.name -%]
-[% ELSE -%]
-[% item.ctype %] *[% item.name -%]
-[% END -%]
-[% END %])
-{
-    psArray         *rowSet;
-    psMetadata      *row;
-    psMetadata      *popped;
-    long            deleted;
-    bool            status;
-    int             rowID;
-
-    rowSet = psDBSelectRows(dbh, [% table.namespace FILTER upper %]_TABLE_NAME, NULL, 1);
-    if (!rowSet) {
-        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item %s", [% table.namespace FILTER upper %]_INDEX_NAME);
-        psFree(rowSet);
-        return NULL;
-    }
-
-    row = psArrayGet(rowSet, 0);
-    psMemIncrRefCounter(row);
-    if (!row) {
-        psError(PS_ERR_UNKNOWN, true, "database error or table is empty");
-        return NULL;
-    }
-    psFree(rowSet);
-
-    rowID = psMetadataLookupS32(&status, row, [% table.namespace FILTER upper %]_INDEX_NAME);
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item %s", [% table.namespace FILTER upper %]_INDEX_NAME);
-        psFree(row);
-        return NULL;
-    }
-
-    popped = psMetadataAlloc();
-    psMetadataAddS32(popped, PS_LIST_TAIL, [% table.namespace FILTER upper %]_INDEX_NAME, 0, NULL, rowID);
-
-    deleted = psDBDeleteRows(dbh, [% table.namespace FILTER upper %]_TABLE_NAME, popped, 0);
-    if (deleted != 1) {
-        psError(PS_ERR_UNKNOWN, false, "database failed to delete row");
-        psFree(popped);
-        psFree(row);
-        return NULL;
-    }
-
-    psFree(popped);
-
-[% FOREACH item = table.columns -%]
-[% IF item.type == "S32" or item.type == "F32" or item.type == "F64" -%]
-    *[% item.name %] = psMetadataLookup[% item.type %](&status, row, "[% item.name %]");
-[% ELSIF item.type == "STR" -%]
-    *[% item.name %] = psMetadataLookupPtr(&status, row, "[% item.name %]");
-[% ELSIF item.type == "BOOL" -%]
-    *[% item.name %] = psMetadataLookupBool(&status, row, "[% item.name %]");
-[% END -%]
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item [% item.name %]");
-        psFree(row);
-        return false;
-    }
-[% END -%]
-
-    psFree(row);
-
-    return true;
-}
Index: unk/glueforge/templates/psdb/pop_at.tt
===================================================================
--- /trunk/glueforge/templates/psdb/pop_at.tt	(revision 9418)
+++ 	(revision )
@@ -1,10 +1,0 @@
-AT_SETUP([[% table.namespace %]Pop()])
-AT_KEYWORDS([[% table.namespace %]Pop])
-
-AT_CHECK([dbsetup])
-# run insert so there is a row in the table
-AT_CHECK([insert])
-AT_CHECK([pop])
-AT_CHECK([dbcleanup])
-
-AT_CLEANUP
Index: unk/glueforge/templates/psdb/pop_c.tt
===================================================================
--- /trunk/glueforge/templates/psdb/pop_c.tt	(revision 9418)
+++ 	(revision )
@@ -1,43 +1,0 @@
-[% USE format -%]
-[% indented = format('%-15s %s') -%]
-#include <pslib.h>
-#include <[% pkg_name %].h>
-#include <stdlib.h>
-
-int main ()
-{
-[% FOREACH table = tables -%]
-    {
-        psDB            *dbh;
-[% FOREACH item = table.columns -%]
-[% IF item.type == "STR" -%]
-        [% indented("char", "$item.name[256]") %];
-[% ELSE-%]
-        [% indented("$item.ctype", "$item.name") %];
-[% END -%]
-[% END -%]
-
-        dbh = psDBInit("localhost", "test", NULL, "test");
-        if (!dbh) {
-            exit(EXIT_FAILURE);
-        }
-
-        if (![% table.namespace %]Pop(dbh, 
-[%- SET i = 0 -%]
-[% FOREACH item = table.columns -%]
-[% IF i == 0 %][% i = 1 %][% ELSE %], [% END -%]
-[% IF item.type == "STR" -%]
-(char **)&[% item.name -%]
-[% ELSE-%]
-&[% item.name -%]
-[% END -%]
-[% END %])) { 
-            exit(EXIT_FAILURE);
-        }
-
-        psDBCleanup(dbh);
-    }
-
-[% END -%]
-    exit(EXIT_SUCCESS);
-}
Index: unk/glueforge/templates/psdb/pop_h.tt
===================================================================
--- /trunk/glueforge/templates/psdb/pop_h.tt	(revision 9418)
+++ 	(revision )
@@ -1,19 +1,0 @@
-[% USE format -%]
-[% indented = format('%-15s %s') -%]
-/** Removes the last row from the database and returns it
- *
- * @return true on success
- */
-
-bool [% table.namespace %]Pop(
-    psDB            *dbh,               ///< Database handle
-[%- SET i = 0 -%]
-[% FOREACH item = table.columns -%]
-[% IF i == 0 %][% i = 1 %][% ELSE %],[% END %]
-[% IF item.type == "STR" -%]
-    [% indented("char", "**$item.name") -%]
-[% ELSE -%]
-    [% indented("$item.ctype", "*$item.name") -%]
-[% END -%]
-[% END %]
-);
Index: unk/glueforge/templates/psdb/popfits.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popfits.tt	(revision 9418)
+++ 	(revision )
@@ -1,24 +1,0 @@
-bool [% table.namespace %]PopFits(psDB *dbh, psFits *fits, unsigned long long limit)
-{
-    char            query[MAX_STRING_LENGTH];
-
-    if (![% table.namespace %]SelectRowsFits(dbh, fits, NULL, limit)) {
-        psError(PS_ERR_UNKNOWN, true, "database error or table is empty");
-        return false;
-    }
-
-    // remove limit rows from the end of the database
-    if (snprintf(query, MAX_STRING_LENGTH,
-                "DELETE FROM %s ORDER BY %s DESC LIMIT %lld",
-                [% table.namespace FILTER upper %]_TABLE_NAME, [% table.namespace FILTER upper %]_INDEX_NAME, limit) < 0) {
-        psError(PS_ERR_UNKNOWN, true, "query value attempted to exceed %d bytes", MAX_STRING_LENGTH);
-        return false;
-    }
-            
-    if (!p_psDBRunQuery(dbh, query)) {
-        psError(PS_ERR_UNKNOWN, false, "database query failed");
-        return false;
-    }
-
-    return true;
-}
Index: unk/glueforge/templates/psdb/popfits_at.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popfits_at.tt	(revision 9418)
+++ 	(revision )
@@ -1,13 +1,0 @@
-AT_SETUP([[% table.namespace %]PopFits()])
-AT_KEYWORDS([[% table.namespace %]PopFits])
-
-AT_CHECK([dbsetup])
-# run insert so there is a row in the table
-AT_CHECK([insert])
-AT_CHECK([popfits])
-AT_CHECK([dbcleanup])
-if [ test -f "blargh" ] ; then
-    rm -f "blargh"
-fi
-
-AT_CLEANUP
Index: unk/glueforge/templates/psdb/popfits_c.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popfits_c.tt	(revision 9418)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#include <pslib.h>
-#include <[% pkg_name %].h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#define TMP_FILENAME "./blargh"
-
-int main ()
-{
-[% FOREACH table = tables -%]
-    {
-        psDB            *dbh;
-        psFits          *fits;
-
-        dbh = psDBInit("localhost", "test", NULL, "test");
-        if (!dbh) {
-            exit(EXIT_FAILURE);
-        }
-
-        // allocate a temp
-        fits = psFitsOpen(TMP_FILENAME, "w");
-        if (!fits) {
-            exit(EXIT_FAILURE);
-        }
-
-        if (![% table.namespace %]PopFits(dbh, fits, 1)) {
-            exit(EXIT_FAILURE);
-        }
-
-        if (!psFitsClose(fits)) {
-            exit(EXIT_FAILURE);
-        }
-
-        psDBCleanup(dbh);
-    }
-
-[% END -%]
-    exit(EXIT_SUCCESS);
-}
Index: unk/glueforge/templates/psdb/popfits_h.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popfits_h.tt	(revision 9418)
+++ 	(revision )
@@ -1,13 +1,0 @@
-/** Removes the last limit row from the database and returns them in a binary FITS table.
- *
- * This function assumes an empty psFits object and will create a FITS table as
- * the first extension. 
- *
- * @return true on success
- */
-
-bool [% table.namespace %]PopFits(
-    psDB            *dbh,               ///< Database handle
-    psFits          *fits,              ///< psFits object
-    unsigned long long limit            ///< Maximum number of elements to return
-);
Index: unk/glueforge/templates/psdb/popobject.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popobject.tt	(revision 9418)
+++ 	(revision )
@@ -1,33 +1,0 @@
-[% USE format -%]
-[% indented = format('%-15s %s') -%]
-[% table.object_name %] *[% table.namespace %]PopObject(psDB *dbh)
-{
-[% FOREACH item = table.columns -%]
-[% IF item.type == "STR" -%]
-    [% indented("char", "$item.name[256]") %];
-[% ELSE-%]
-    [% indented("$item.ctype", "$item.name") %];
-[% END -%]
-[% END -%]
-
-    if (![% table.namespace %]Pop(dbh, 
-[%- SET i = 0 -%]
-[% FOREACH item = table.columns -%]
-[% IF i == 0 %][% i = 1 %][% ELSE %], [% END -%]
-[% IF item.type == "STR" -%]
-(char **)&[% item.name -%]
-[% ELSE-%]
-&[% item.name -%]
-[% END -%]
-[% END %])) {
-        psError(PS_ERR_UNKNOWN, false, "failed to pop a database row");
-        return NULL;
-    }
-
-    return [% table.object_name %]Alloc(
-[%- SET i = 0 -%]
-[% FOREACH item = table.columns -%]
-[% IF i == 0 -%][%- i = 1 -%][% ELSE %], [% END -%]
-[% item.name %]
-[%- END -%]);
-}
Index: unk/glueforge/templates/psdb/popobject_at.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popobject_at.tt	(revision 9418)
+++ 	(revision )
@@ -1,10 +1,0 @@
-AT_SETUP([[% table.namespace %]PopObject()])
-AT_KEYWORDS([[% table.namespace %]PopObject])
-
-AT_CHECK([dbsetup])
-# run insert so there is a row in the table
-AT_CHECK([insert])
-AT_CHECK([popobject])
-AT_CHECK([dbcleanup])
-
-AT_CLEANUP
Index: unk/glueforge/templates/psdb/popobject_c.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popobject_c.tt	(revision 9418)
+++ 	(revision )
@@ -1,30 +1,0 @@
-[% USE format -%]
-[% indented = format('%-15s %s') -%]
-#include <pslib.h>
-#include <[% pkg_name %].h>
-#include <stdlib.h>
-
-int main ()
-{
-[% FOREACH table = tables -%]
-    {
-        psDB            *dbh;
-        [% indented(table.object_name, "*object") %];
-
-        dbh = psDBInit("localhost", "test", NULL, "test");
-        if (!dbh) {
-            exit(EXIT_FAILURE);
-        }
-
-        object = [% table.namespace %]PopObject(dbh);
-        if (!object) {
-            exit(EXIT_FAILURE);
-        }
-
-        psFree(object);
-        psDBCleanup(dbh);
-    }
-
-[% END -%]
-    exit(EXIT_SUCCESS);
-}
Index: unk/glueforge/templates/psdb/popobject_h.tt
===================================================================
--- /trunk/glueforge/templates/psdb/popobject_h.tt	(revision 9418)
+++ 	(revision )
@@ -1,8 +1,0 @@
-/** Removes the last row from the database and returns it
- *
- * @return A new [% table.object_name %] on success or NULL on failure.
- */
-
-[% table.object_name %] *[% table.namespace %]PopObject(
-    psDB            *dbh                ///< Database handle
-);
Index: /trunk/glueforge/templates/psdb/printmetadata.tt
===================================================================
--- /trunk/glueforge/templates/psdb/printmetadata.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/printmetadata.tt	(revision 9419)
@@ -5,10 +5,4 @@
     psMetadata *clean = psMetadataCopy(NULL, md);
 
-    // don't bother to check the return status as the key we are trying to
-    // remove may or may not be there
-    // XXX someday psErr should be checked -- the only acceptable error is key
-    // not found
-    psMetadataRemoveKey(clean, [% pkg_name FILTER upper %]_DEFAULT_INDEX_NAME);
-    
     if (![% pkg_namespace %]PrintMetadataRaw(stream, clean, mdcf)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print metadata");
Index: /trunk/glueforge/templates/psdb/printmetadatas.tt
===================================================================
--- /trunk/glueforge/templates/psdb/printmetadatas.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/printmetadatas.tt	(revision 9419)
@@ -7,10 +7,4 @@
     for (long i = 0; i < psArrayLength(mds); i++) {
         psMetadata *md = psMetadataCopy(NULL, mds->data[i]);
-        // don't bother to check the return status as the key we are trying to
-        // remove may or may not be there 
-        // XXX someday psErr should be checked -- the only acceptable error
-        // is key not found
-
-        psMetadataRemoveKey(md, [% pkg_name FILTER upper %]_DEFAULT_INDEX_NAME);
         if (!psMetadataAddMetadata(output, PS_LIST_TAIL, mdname, PS_META_DUPLICATE_OK, NULL, md)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add a metadata item");
Index: /trunk/glueforge/templates/psdb/selectrowobjects.tt
===================================================================
--- /trunk/glueforge/templates/psdb/selectrowobjects.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/selectrowobjects.tt	(revision 9419)
@@ -8,13 +8,4 @@
     if (!rowSet) {
         return NULL;
-    }
-
-    // strip index column
-    for (i = 0; i < rowSet->n; i++) {
-        if (!psMetadataRemove((psMetadata *)(rowSet->data[i]), 0, [% table.namespace FILTER upper %]_INDEX_NAME)) {
-            psError(PS_ERR_UNKNOWN, true, "failed to remove item %s", [% table.namespace FILTER upper %]_INDEX_NAME);
-            psFree(rowSet);
-            return false;
-        }
     }
 
Index: /trunk/glueforge/templates/psdb/selectrowsfits.tt
===================================================================
--- /trunk/glueforge/templates/psdb/selectrowsfits.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/selectrowsfits.tt	(revision 9419)
@@ -2,18 +2,8 @@
 {
     psArray         *rowSet;
-    psU64           i;
 
     rowSet = psDBSelectRows(dbh, [% table.namespace FILTER upper %]_TABLE_NAME, where, limit);
     if (!rowSet) {
         return false;
-    }
-
-    // strip index column
-    for (i = 0; i < rowSet->n; i++) {
-        if (!psMetadataRemove((psMetadata *)rowSet->data[i], 0, [% table.namespace FILTER upper %]_INDEX_NAME)) {
-            psError(PS_ERR_UNKNOWN, true, "failed to remove item %s", [% table.namespace FILTER upper %]_INDEX_NAME);
-            psFree(rowSet);
-            return false;
-        }
     }
 
Index: /trunk/glueforge/templates/psdb/tests_makefile_am.tt
===================================================================
--- /trunk/glueforge/templates/psdb/tests_makefile_am.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/tests_makefile_am.tt	(revision 9419)
@@ -51,9 +51,6 @@
     droptable \
     insert \
-    pop \
     insertobject \
-    popobject \
     insertfits \
-    popfits \
     selectrowsfits \
     metadatafromobject \
Index: /trunk/glueforge/templates/psdb/testsuite_at.tt
===================================================================
--- /trunk/glueforge/templates/psdb/testsuite_at.tt	(revision 9418)
+++ /trunk/glueforge/templates/psdb/testsuite_at.tt	(revision 9419)
@@ -16,13 +16,7 @@
 [% INCLUDE insert_at.tt %]
 ###
-[% INCLUDE pop_at.tt %]
-###
 [% INCLUDE insertobject_at.tt %]
 ###
-[% INCLUDE popobject_at.tt %]
-###
 [% INCLUDE insertfits_at.tt %]
-###
-[% INCLUDE popfits_at.tt %]
 ###
 [% INCLUDE selectrowsfits_at.tt %]
