Index: trunk/psLib/test/dataIO/tst_psDB.c
===================================================================
--- trunk/psLib/test/dataIO/tst_psDB.c	(revision 3963)
+++ trunk/psLib/test/dataIO/tst_psDB.c	(revision 4044)
@@ -9,6 +9,6 @@
  *  @author Aaron Culliney, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-18 23:41:06 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-28 01:02:08 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -35,17 +35,20 @@
 #define F64_1 2.7182818
 #define F64_2 1.23456789
+#define B_1 TRUE
+#define B_2 FALSE
 
 static psDB *_init_psDB( void );
 static psMetadata *_get_CreateTableMetadata( void );
-static psMetadata *_get_RowMetadataValues(const char *val0, psS32 val1, psF32 val2, psF64 val3);
+static psMetadata *_get_RowMetadataValues(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4);
 static psMetadata *_get_RowMetadata(
     const char *key0, const char *comm0, const char *val0,
-    const char *key1, const char *comm1, psS32 val1,
-    const char *key2, const char *comm2, psF32 val2,
-    const char *key3, const char *comm3, psF64 val3,
-    const char *key4, const char *comm4, psS32 val4);
+    const char *key1, const char *comm1, psS32  val1,
+    const char *key2, const char *comm2, psF32  val2,
+    const char *key3, const char *comm3, psF64  val3,
+    const char *key4, const char *comm4, psBool val4,
+    const char *key5, const char *comm5, psS32  val5);
 static psMetadata *_get_row( void );
 static psMetadata *_get_where( void );
-static psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3);
+static psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4);
 static void _print_row( psMetadata *row );
 
@@ -112,8 +115,9 @@
                "key_f32",    "Key",                0.0,
                "key_f64",    "",                   0.0,
+               "key_bool",   "",                   FALSE,
                "key_s32_0",  "Key,AUTO_INCREMENT", 0);
 }
 
-psMetadata *_get_RowMetadataValues(const char *val0, psS32 val1, psF32 val2, psF64 val3)
+psMetadata *_get_RowMetadataValues(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4)
 {
     return _get_RowMetadata(
@@ -122,4 +126,5 @@
                "key_f32",    "comment-f32",    val2,
                "key_f64",    "comment-f64",    val3,
+               "key_bool",   "comment-bool",   val4,
                NULL,         NULL,             0.0);
 }
@@ -127,11 +132,12 @@
 psMetadata *_get_RowMetadata(
     const char *key0, const char *comm0, const char *val0,
-    const char *key1, const char *comm1, psS32 val1,
-    const char *key2, const char *comm2, psF32 val2,
-    const char *key3, const char *comm3, psF64 val3,
-    const char *key4, const char *comm4, psS32 val4)
+    const char *key1, const char *comm1, psS32  val1,
+    const char *key2, const char *comm2, psF32  val2,
+    const char *key3, const char *comm3, psF64  val3,
+    const char *key4, const char *comm4, psBool val4,
+    const char *key5, const char *comm5, psS32  val5)
 {
     psMetadata *md = NULL;
-    psMetadataItem *str=NULL, *s32_0=NULL, *s32=NULL, *f32=NULL, *f64=NULL;
+    psMetadataItem *str=NULL, *s32_0=NULL, *s32=NULL, *f32=NULL, *f64=NULL, *b;
 
     md = psMetadataAlloc();
@@ -143,19 +149,21 @@
         str = psMetadataItemAllocStr(key0, comm0, val0);
     }
-    if (key4 != NULL) {
-        s32_0 = psMetadataItemAllocS32(key4, comm4, val4);
-    }
-    s32 = psMetadataItemAllocS32(key1, comm1, val1);
-    f32 = psMetadataItemAllocF32(key2, comm2, val2);
-    f64 = psMetadataItemAllocF64(key3, comm3, val3);
-
-    if ( ((key0 != NULL) && (str == NULL)) || (s32 == NULL) || (f32 == NULL) || (f64 == NULL) ||
-            ((key4 != NULL) && (s32_0 == NULL)) ) {
+    if (key5 != NULL) {
+        s32_0 = psMetadataItemAllocS32(key5, comm5, val5);
+    }
+    s32 = psMetadataItemAllocS32 (key1, comm1, val1);
+    f32 = psMetadataItemAllocF32 (key2, comm2, val2);
+    f64 = psMetadataItemAllocF64 (key3, comm3, val3);
+    b   = psMetadataItemAllocBool(key4, comm4, val4);
+
+    if ( ((key0 != NULL) && (str == NULL)) || (s32 == NULL) || (f32 == NULL) || (f64 == NULL) || (b == NULL) ||
+            ((key5 != NULL) && (s32_0 == NULL)) ) {
         psError(PS_ERR_UNKNOWN, true, "could not create psMetadataItem(s) in %s!", __func__ );
         return NULL;
     }
-    if ( ((key0 != NULL) && !psMetadataAddItem(md, str, 0, 0)) || !psMetadataAddItem(md, s32, 0, 0) ||
-            !psMetadataAddItem(md, f32, 0, 0) || !psMetadataAddItem(md, f64, 0, 0) ||
-            ((key4 != NULL) && !psMetadataAddItem(md, s32_0, 0, 0))) {
+    if ( ((key0 != NULL) && !psMetadataAddItem(md, str, 0, 0)) ||
+            !psMetadataAddItem(md, s32, 0, 0) || !psMetadataAddItem(md, f32, 0, 0) ||
+            !psMetadataAddItem(md, f64, 0, 0) || !psMetadataAddItem(md, b,   0, 0) ||
+            ((key5 != NULL) && !psMetadataAddItem(md, s32_0, 0, 0))) {
         psError(PS_ERR_UNKNOWN, true, "could not add psMetadataItem(s) to psMetadata in %s!", __func__ );
         return NULL;
@@ -168,4 +176,5 @@
     psFree(f32);
     psFree(f64);
+    psFree(b);
     if (s32_0 != NULL) {
         psFree(s32_0);
@@ -184,4 +193,5 @@
                "key_f32",    "comment-f32",    (double)rand()/RAND_MAX,
                "key_f64",    "comment-f64",    (double)rand()/RAND_MAX,
+               "key_bool",   "comment-bool",   round((double)rand()/RAND_MAX),
                NULL,         NULL,             0.0);
 }
@@ -194,4 +204,5 @@
                "key_f32",    "comment-f32",    F32_1,
                "key_f64",    "comment-f64",    F64_1,
+               "key_bool",   "comment-bool",   B_1,
                NULL,         NULL,             0.0);
 }
@@ -221,7 +232,7 @@
 }
 
-psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3)
-{
-    return _get_RowMetadataValues(val0, val1, val2, val3);
+psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4)
+{
+    return _get_RowMetadataValues(val0, val1, val2, val3, val4);
 }
 
@@ -241,4 +252,6 @@
         } else if (item->type == PS_META_F64) {
             psLogMsg( __func__, PS_LOG_INFO, "[%s]=[%g]\n", item->name, item->data.F64 );
+        } else if (item->type == PS_META_BOOL) {
+            psLogMsg( __func__, PS_LOG_INFO, "[%s]=[%s]\n", item->name, item->data.B ? "Yay" : "Nay" );
         }
     }
@@ -409,4 +422,28 @@
             psFree(ary);
         }
+
+        ary = psDBSelectColumn(dbh, table, "key_bool", 0);
+        if (ary == NULL) {
+            failed = 1;
+        } else {
+            ptr = psArrayGet(ary, 2);
+            psLogMsg( __func__, PS_LOG_INFO, "psDBSelectColumn: [%s]\n", ptr );
+
+            ptr = psArrayGet(ary, 1);
+            psLogMsg( __func__, PS_LOG_INFO, "psDBSelectColumn: [%s]\n", ptr );
+
+            ptr = psArrayGet(ary, 0);
+            psLogMsg( __func__, PS_LOG_INFO, "psDBSelectColumn: [%s]\n", ptr );
+
+            if (atoi(ptr) != B_1) {
+                psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected string output!\n" );
+                failed = 1;
+            } else {
+                psLogMsg( __func__, PS_LOG_INFO, "found expected string output.\n" );
+            }
+
+            psFree(ary);
+        }
+
         psDBDropTable(dbh, table);
     }
@@ -464,4 +501,21 @@
             psFree(vec);
         }
+
+        vec = psDBSelectColumnNum(dbh, table, "key_bool", PS_TYPE_BOOL, 0);
+        if (vec == NULL) {
+            failed = 1;
+        } else {
+            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[2] );
+            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[1] );
+            psLogMsg( __func__, PS_LOG_INFO, "bool=[%d]\n", (vec->data.U8)[0] );
+            if ((vec->data.U8)[0] != B_1) {
+                psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected bool output!\n" );
+                failed = 1;
+            } else {
+                psLogMsg( __func__, PS_LOG_INFO, "found expected bool output.\n" );
+            }
+            psFree(vec);
+        }
+
         psDBDropTable(dbh, table);
     }
@@ -531,4 +585,16 @@
                     }
 
+                    item = psMetadataLookup(row, "key_bool");
+                    if (item == NULL) {
+                        psLogMsg( __func__, PS_LOG_INFO, "oops, key_bool not found!\n" );
+                        failed = 1;
+                    } else if (item->data.B != B_1) {
+                        psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected output (%d vs %d)!\n",
+                                  item->data.B,B_1);
+                        failed = 1;
+                    } else {
+                        psLogMsg( __func__, PS_LOG_INFO, "found expected output.\n" );
+                    }
+
                     psFree(ary);
                 }
@@ -628,4 +694,12 @@
             }
 
+            item = psMetadataLookup(row, "key_bool");
+            if ((item == NULL) || (item->data.B != B_1)) {
+                psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected output!\n" );
+                failed = 1;
+            } else {
+                psLogMsg( __func__, PS_LOG_INFO, "found expected output.\n" );
+            }
+
             psFree(rowSet);
         }
@@ -691,4 +765,12 @@
                 }
 
+                item = psMetadataLookup(row, "key_bool");
+                if ((item == NULL) || (item->data.B != B_1)) {
+                    psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected output!\n" );
+                    failed = 1;
+                } else {
+                    psLogMsg( __func__, PS_LOG_INFO, "found expected output.\n" );
+                }
+
                 psFree(ary);
             }
@@ -710,5 +792,5 @@
     psDB *dbh = NULL;
     const char* table = "table9";
-    psMetadata *meta=NULL, *md = _get_CreateTableMetadata();
+    psMetadata *row=NULL, *meta=NULL, *md = _get_CreateTableMetadata();
 
     dbh = _init_psDB();
@@ -721,4 +803,17 @@
     failed = ! psDBCreateTable(dbh, table, md);
     if (!failed) {
+
+        row = _get_rand_row();
+        psDBInsertOneRow(dbh, table, row);
+        psFree(row);
+
+        row = _get_rand_row();
+        psDBInsertOneRow(dbh, table, row);
+        psFree(row);
+
+        row = _get_row();
+        failed = ! psDBInsertOneRow(dbh, table, row);
+        psFree(row);
+
         meta = psDBDumpCols(dbh, table);
         if (meta == NULL) {
@@ -774,5 +869,5 @@
         if (!failed) {
             where = _get_where();
-            updates = _get_update_values(STR_2, S32_2, F32_2, F64_2);
+            updates = _get_update_values(STR_2, S32_2, F32_2, F64_2, B_2);
             failed = (psDBUpdateRows(dbh, table, where, updates) < 0);
 
@@ -787,4 +882,12 @@
                 item = psMetadataLookup(row, "key_s32");
                 if ((item == NULL) || (item->data.S32 != S32_2)) {
+                    psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected output!\n" );
+                    failed = 1;
+                } else {
+                    psLogMsg( __func__, PS_LOG_INFO, "found expected output.\n" );
+                }
+
+                item = psMetadataLookup(row, "key_bool");
+                if ((item == NULL) || (item->data.B != B_2)) {
                     psLogMsg( __func__, PS_LOG_INFO, "oops, did not find expected output!\n" );
                     failed = 1;
