Index: /trunk/psLib/test/dataIO/tst_psDB.c
===================================================================
--- /trunk/psLib/test/dataIO/tst_psDB.c	(revision 4279)
+++ /trunk/psLib/test/dataIO/tst_psDB.c	(revision 4280)
@@ -9,6 +9,6 @@
  *  @author Aaron Culliney, MHPCC
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-15 19:53:05 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-16 01:49:23 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -37,4 +37,16 @@
 #define B_1 TRUE
 #define B_2 FALSE
+
+#define CONST_ROW_1_STR      "randrow1"
+#define CONST_ROW_1_S32      12345
+#define CONST_ROW_1_F32      9876.5
+#define CONST_ROW_1_F64      456.75
+#define CONST_ROW_1_BOOL     TRUE
+
+#define CONST_ROW_2_STR      "randrow2"
+#define CONST_ROW_2_S32      2345
+#define CONST_ROW_2_F32      876.5
+#define CONST_ROW_2_F64      56.75
+#define CONST_ROW_2_BOOL     FALSE
 
 static psDB *_init_psDB( void );
@@ -74,5 +86,5 @@
                               {TPDBCreateTable,    843,  "dbCreateTable",     0, false},
                               {TPDBDropTable,      844,  "dbDropTable",       0, false},
-                              {TPDBSelectColumn,    -5,  "dbSelectColumn",    0, false},
+                              {TPDBSelectColumn,   845,  "dbSelectColumn",    0, false},
                               {TPDBSelectColumnNum, -6,  "dbSelectColumnNum", 0, false},
                               {TPDBSelectRows,      -7,  "dbSelectRows",      0, false},
@@ -186,15 +198,11 @@
 {
     char buf[32];
-    snprintf(buf, 32, "%s","randrow1" );
+    snprintf(buf, 32, "%s", CONST_ROW_1_STR );
     return _get_RowMetadata(
                "key_string", "comment-string", buf,
-               //               "key_s32",    "comment-s32",    rand(),
-               "key_s32",    "comment-s32",    12345,
-               //               "key_f32",    "comment-f32",    (double)rand()/RAND_MAX,
-               "key_f32",    "comment-f32",    9876.5,
-               //               "key_f64",    "comment-f64",    (double)rand()/RAND_MAX,
-               "key_f64",    "comment-f64",    456.75,
-               //               "key_bool",   "comment-bool",   round((double)rand()/RAND_MAX),
-               "key_bool",   "comment-bool",   true,
+               "key_s32",    "comment-s32",    CONST_ROW_1_S32,
+               "key_f32",    "comment-f32",    CONST_ROW_1_F32,
+               "key_f64",    "comment-f64",    CONST_ROW_1_F64,
+               "key_bool",   "comment-bool",   CONST_ROW_1_BOOL,
                NULL,         NULL,             0.0);
 }
@@ -203,15 +211,11 @@
 {
     char buf[32];
-    snprintf(buf, 32, "%s","randrow2");
+    snprintf(buf, 32, "%s",CONST_ROW_2_STR);
     return _get_RowMetadata(
                "key_string", "comment-string", buf,
-               //               "key_s32",    "comment-s32",    rand(),
-               "key_s32",    "comment-s32",    2345,
-               //               "key_f32",    "comment-f32",    (double)rand()/RAND_MAX,
-               "key_f32",    "comment-f32",    876.5,
-               //               "key_f64",    "comment-f64",    (double)rand()/RAND_MAX,
-               "key_f64",    "comment-f64",    56.75,
-               //               "key_bool",   "comment-bool",   round((double)rand()/RAND_MAX),
-               "key_bool",   "comment-bool",   false,
+               "key_s32",    "comment-s32",    CONST_ROW_2_S32,
+               "key_f32",    "comment-f32",    CONST_ROW_2_F32,
+               "key_f64",    "comment-f64",    CONST_ROW_2_F64,
+               "key_bool",   "comment-bool",   CONST_ROW_2_BOOL,
                NULL,         NULL,             0.0);
 }
@@ -408,5 +412,4 @@
 psS32 TPDBDropTable( void )
 {
-    psS32 failed = 0;
     psDB *dbh = NULL;
     const char* table = "table2";
@@ -423,9 +426,11 @@
 
     // Create table in database
-    failed = ! psDBCreateTable(dbh, table, md);
-    if (!failed) {
+    if(psDBCreateTable(dbh, table, md)) {
 
         // Drop table with valid arguments
-        failed = ! psDBDropTable(dbh, table);
+        if(!psDBDropTable(dbh, table)) {
+            psError(PS_ERR_UNKNOWN,true,"Did not expect return false for valid arguments");
+            return 2;
+        }
 
         // insert should fail since the table has been drop from database
@@ -433,8 +438,11 @@
         row = _get_row();
         if (psDBInsertOneRow(dbh, table, row)) {
-            psLogMsg( __func__, PS_LOG_INFO, "oops, insert unexpectedly succeeded!\n" );
-            failed = 1;
+            psError(PS_ERR_UNKNOWN,true,"Did not expect to successfully insert row into dropped table");
+            return 3;
         }
         psFree(row);
+    } else {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return false to create table");
+        return 4;
     }
 
@@ -443,5 +451,5 @@
     if(psDBDropTable(NULL,table)) {
         psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for NULL database object");
-        return 2;
+        return 5;
     }
 
@@ -450,5 +458,5 @@
     if(psDBDropTable(dbh,"table99")) {
         psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for invalid table");
-        return 3;
+        return 6;
     }
 
@@ -457,5 +465,5 @@
     if(psDBDropTable(dbh,NULL)) {
         psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for NULL table");
-        return 4;
+        return 7;
     }
 
@@ -463,93 +471,197 @@
     psDBCleanup(dbh);
 
-    return failed;
-}
-
-// Testpoint #XXX, TPDBSelectColumn shall write/select a column from a test table ...
+    return 0;
+}
+
+// Testpoint #845, TPDBSelectColumn shall write/select a column from a test table ...
 psS32 TPDBSelectColumn( void )
 {
-    psS32 failed = 0;
     psDB *dbh = NULL;
     const char* table = "table3";
     psArray *ary = NULL;
+    char *ptr=NULL;
+
+    // Create table definition metadata
     psMetadata *row=NULL, *md = _get_CreateTableMetadata();
-    char *ptr=NULL;
-
+
+    // Initialize database connection
     dbh = _init_psDB();
     if (dbh == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return NULL to initialize database connection");
         return 1;
     }
 
-    psLogMsg( __func__, PS_LOG_INFO, "psDBSelectColumn shall select data from a test table.\n" );
-
-    failed = ! psDBCreateTable(dbh, table, md);
-    if (!failed) {
-
-        row = _get_const_row1();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        row = _get_const_row2();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        row = _get_row();
-        psDBInsertOneRow(dbh, table, row);
-        psFree(row);
-
-        ary = psDBSelectColumn(dbh, table, "key_string", 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 (strcmp(ptr, STR_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);
-        }
-
-        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 output [%d] != [%d]!\n",
-                          atoi(ptr), B_1 );
-                failed = 1;
-            } else {
-                psLogMsg( __func__, PS_LOG_INFO, "found expected string output.\n" );
-            }
-
-            psFree(ary);
-        }
-
-        psDBDropTable(dbh, table);
-    }
-
+    // Create database table
+    if(!psDBCreateTable(dbh,table,md)) {
+        psError(PS_ERR_UNKNOWN,true,"Unable to create database table for testing");
+        psDBCleanup(dbh);
+        return 2;
+    }
+
+    // Insert known constant row #1
+    row = _get_const_row1();
+    if(!psDBInsertOneRow(dbh, table, row)) {
+        psError(PS_ERR_UNKNOWN,true,"Unable to add rows to test database");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 3;
+    }
+    psFree(row);
+
+    // Insert known constant row #2
+    row = _get_const_row2();
+    if(!psDBInsertOneRow(dbh, table, row)) {
+        psError(PS_ERR_UNKNOWN,true,"Unable to add rows to test database");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 4;
+    }
+    psFree(row);
+
+    // Insert known row
+    row = _get_row();
+    if(!psDBInsertOneRow(dbh, table, row)) {
+        psError(PS_ERR_UNKNOWN,true,"Unable to add rows to test database");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 5;
+    }
+    psFree(row);
+
+    // Select all items in column key_string with valid arguments
+    ary = psDBSelectColumn(dbh, table, "key_string", 0);
+    if (ary == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return value of NULL");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 6;
+    }
+
+    // Verify array contents
+    if(ary->n != 3) {
+        psError(PS_ERR_UNKNOWN,true,"Array number of items %d not equal to expected %d",
+                ary->n, 3);
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 60;
+    }
+    ptr = psArrayGet(ary, 2);
+    if (strcmp(ptr, CONST_ROW_1_STR)) {
+        psError(PS_ERR_UNKNOWN,true,"key_str column entry[%d] = %s not as expected %s",
+                2,CONST_ROW_1_STR,ptr);
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 7;
+    }
+    ptr = psArrayGet(ary, 1);
+    if (strcmp(ptr, CONST_ROW_2_STR)) {
+        psError(PS_ERR_UNKNOWN,true,"key_str column entry[%d] = %s not as expected %s",
+                1,CONST_ROW_2_STR,ptr);
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 8;
+    }
+    ptr = psArrayGet(ary, 0);
+    if (strcmp(ptr, STR_1)) {
+        psError(PS_ERR_UNKNOWN,true,"key_str column entry[%d] = %s not as expected %s",
+                0,STR_1,ptr);
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 9;
+    }
+    psFree(ary);
+
+    // Select items in column key_bool with limit 10 and valid arguments
+    ary = psDBSelectColumn(dbh, table, "key_bool", 10);
+    if (ary == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect return value of NULL");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 10;
+    }
+
+    // Verify array contents
+    if(ary->n != 3) {
+        psError(PS_ERR_UNKNOWN,true,"Array number of items %d not equal to expected %d",
+                ary->n, 3);
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 100;
+    }
+    ptr = psArrayGet(ary, 2);
+    if(atoi(ptr) != CONST_ROW_1_BOOL) {
+        psError(PS_ERR_UNKNOWN,true,"key_bool column entry[%d] = %d not as expected %d",
+                2,CONST_ROW_1_BOOL,atoi(ptr));
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 11;
+    }
+    ptr = psArrayGet(ary, 1);
+    if(atoi(ptr) != CONST_ROW_2_BOOL) {
+        psError(PS_ERR_UNKNOWN,true,"key_bool column entry[%d] = %d not as expected %d",
+                1,CONST_ROW_2_BOOL,atoi(ptr));
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 12;
+    }
+    ptr = psArrayGet(ary, 0);
+    if(atoi(ptr) != B_1) {
+        psError(PS_ERR_UNKNOWN,true,"key_bool column entry[%d] = %d not as expected %d",
+                0,B_1,atoi(ptr));
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 13;
+    }
+    psFree(ary);
+
+    // Attempt to select columns from NULL database object
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL database");
+    if(psDBSelectColumn(NULL,table,"key_str",10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for selecting from NULL database");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 14;
+    }
+
+    // Attempt to select column from NULL table
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL table");
+    if(psDBSelectColumn(dbh,NULL,"key_str",10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for NULL table");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 15;
+    }
+
+    // Attempt to select column from invalid table
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid table");
+    if(psDBSelectColumn(dbh,"table99","key_str",10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for invalid table");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 16;
+    }
+
+    // Attempt to select invalid column from valid database object and valid table
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid column");
+    if(psDBSelectColumn(dbh,table,"key_null",10) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for invalid column");
+        psDBDropTable(dbh, table);
+        psDBCleanup(dbh);
+        return 17;
+    }
+
+    // Attempt to select NULL column from valid database object and valid table
+    //    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL column");
+    //    if(psDBSelectColumn(dbh,table,NULL,10) != NULL) {
+    //        psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL return for NULL column");
+    //        return 18;
+    //    }
+
+    // Clean up table and memory
+    psDBDropTable(dbh, table);
     psFree(md);
     psDBCleanup(dbh);
 
-    return failed;
+    return 0;
 }
 
Index: /trunk/psLib/test/dataIO/verified/tst_psDB.stderr
===================================================================
--- /trunk/psLib/test/dataIO/verified/tst_psDB.stderr	(revision 4279)
+++ /trunk/psLib/test/dataIO/verified/tst_psDB.stderr	(revision 4280)
@@ -92,21 +92,27 @@
 
 <DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn shall select data from a test table.
+    Following should generate error message for NULL database
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Invalid psDB has been specified.
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [randrow1]
+    Following should generate error message for NULL table
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Failed to execute SQL query.  Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null) LIMIT 10' at line 1
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [randrow2]
+    Following should generate error message for invalid table
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Failed to execute SQL query.  Error: Table 'test.table99' doesn't exist
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 <DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [hello world!]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    found expected string output.
-<DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [1]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [0]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    psDBSelectColumn: [1]
-<DATE><TIME>|<HOST>|I|TPDBSelectColumn
-    found expected string output.
+    Following should generate error message for invalid column
+<DATE><TIME>|<HOST>|E|p_psDBRunQuery (FILE:LINENO)
+    Failed to execute SQL query.  Error: Unknown column 'key_null' in 'field list'
+<DATE><TIME>|<HOST>|E|psDBSelectColumn (FILE:LINENO)
+    Failed to select column.
 
 ---> TESTPOINT PASSED (psDB{dbSelectColumn} | tst_psDB.c)
