Index: trunk/psLib/src/db/psDB.c
===================================================================
--- trunk/psLib/src/db/psDB.c	(revision 9990)
+++ trunk/psLib/src/db/psDB.c	(revision 9999)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.111 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-11-15 01:34:42 $
+ *  @version $Revision: 1.112 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-11-15 03:49:43 $
  *
  *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
@@ -1083,102 +1083,129 @@
         psFree(mType);
 
-        // input data length is determined by the MYSQL_TYPE_* unless it's a string
-        if (item->type == PS_TYPE_S32) {
-            bind[i].length  = 0;
-            bind[i].buffer  = &item->data.S32;
-            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S32)
-                              ? (my_bool *)&isNull
-                              : NULL;
-        } else if (item->type == PS_TYPE_F32) {
-            bind[i].length  = 0;
-            bind[i].buffer  = &item->data.F32;
-            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F32)
-                              ? (my_bool *)&isNull
-                              : NULL;
-        } else if (item->type == PS_TYPE_F64) {
-            bind[i].length  = 0;
-            bind[i].buffer  = &item->data.F64;
-            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64)
-                              ? (my_bool *)&isNull
-                              : NULL;
-        } else if (item->type == PS_TYPE_BOOL) {
-            // XXX: ASC HACK NOTE (2005/06/03): set extreme bytes to the
-            // boolean character value.  sizeof(psBool)==4 which triggers an
-            // endianess issue in the MySQL conversion (reading only 1 byte),
-            // on Macintosh hardware (and maybe others?)
-            unsigned int c  = (unsigned int)item->data.B;
-            item->data.S32  = (unsigned int)((c<<24) | c);
-            bind[i].length  = 0;
-            bind[i].buffer  = &item->data.B;
-            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.B)
-                              ? (my_bool *)&isNull
-                              : NULL;
-        } else if (item->type == PS_DATA_STRING) {
-            // convert NaNs to NULL and set the buffer_length for strings
-
-            if (item->data.str) {
-                // will handle the case of "" as a NULL database value
-                bind[i].buffer_length = (unsigned long)strlen(item->data.str);
-                bind[i].length  = &bind[i].buffer_length;
-                bind[i].buffer  = psStringCopy(item->data.V);
-                bind[i].is_null = *item->data.str == '\0'
+        // input data length is determined by the MYSQL_TYPE_* unless it's a
+        // string
+        switch (item->type) {
+        case PS_TYPE_S32: {
+                bind[i].length  = 0;
+                bind[i].buffer  = &item->data.S32;
+                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S32)
                                   ? (my_bool *)&isNull
                                   : NULL;
-            } else {
-                // handles the case of NULL as a NULL database value
-                bind[i].buffer_length = 0;
-                bind[i].length  = &bind[i].buffer_length;
-                bind[i].buffer  = NULL;
-                bind[i].is_null = (my_bool *)&isNull;
+                break;
             }
-        } else if (item->type == PS_DATA_TIME) {
-            // XXX we're abusing the comment field of the metadata item here as
-            // we need to have a buffer that exists outside this functions
-            // scope without leaking memory
-            // make a copy of the psTime so we don't modify user data when we
-            // try to do the conversion
-            if (item->data.str) {
-                psTime *time = (psTime *)item->data.V;
-                struct tm *tmTime = psTimeToTM(time);
-
-                // XXX it wouldn't hurt to make this conversion it's own
-                // function
-                // myTime is used as the 'buffer' so it doesn't have to be
-                // free'd
-                MYSQL_TIME *myTime = psAlloc(sizeof(MYSQL_TIME));
-                myTime->year    = (unsigned int)tmTime->tm_year + 1900;
-                myTime->month   = (unsigned int)tmTime->tm_mon + 1;
-                myTime->day     = (unsigned int)tmTime->tm_mday;
-                myTime->hour    = (unsigned int)tmTime->tm_hour;
-                myTime->minute  = (unsigned int)tmTime->tm_min;
-                myTime->second  = (unsigned int)tmTime->tm_sec;
-                // assume for the time being that we don't have negative time
-                // as ISO8601 doesn't support dates prior to 0
-                myTime->neg     = (my_bool)false;
-                // currently unused by mysql
-                myTime->second_part  = (unsigned long)time->nsec;
-                psFree(tmTime);
-
-                bind[i].buffer  = myTime;
-                bind[i].buffer_length = sizeof(MYSQL_TIME);
-                bind[i].length  = &bind[i].buffer_length;
-                bind[i].is_null = NULL;
-            } else {
-                // handles the case of NULL as a NULL database value
-                bind[i].buffer_length = 0;
-                bind[i].length  = &bind[i].buffer_length;
-                bind[i].buffer  = NULL;
-                bind[i].is_null = (my_bool *)&isNull;
+        case PS_TYPE_S64: {
+                bind[i].length  = 0;
+                bind[i].buffer  = &item->data.S64;
+                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S64)
+                                  ? (my_bool *)&isNull
+                                  : NULL;
+                break;
             }
-        } else {
-            psError(PS_ERR_BAD_PARAMETER_TYPE , true,
-                    "FIXME: Only type of PS_TYPE_S32 (PS_DATA_S32), "
-                    "PS_TYPE_F32 (PS_DATA_F32), PS_TYPE_F64 (PS_DATA_F64), "
-                    "PS_TYPE_BOOL (PS_DATA_BOOL), PS_DATA_STRING"
-                    "and PS_DATA_TIME are supported.");
-
-            psFree(cursor);
-
-            return false;
+        case PS_TYPE_F32: {
+                bind[i].length  = 0;
+                bind[i].buffer  = &item->data.F32;
+                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F32)
+                                  ? (my_bool *)&isNull
+                                  : NULL;
+                break;
+            }
+        case PS_TYPE_F64: {
+                bind[i].length  = 0;
+                bind[i].buffer  = &item->data.F64;
+                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64)
+                                  ? (my_bool *)&isNull
+                                  : NULL;
+                break;
+            }
+        case PS_TYPE_BOOL: {
+                // XXX: ASC HACK NOTE (2005/06/03): set extreme bytes to the
+                // boolean character value.  sizeof(psBool)==4 which triggers
+                // an endianess issue in the MySQL conversion (reading only 1
+                // byte), on Macintosh hardware (and maybe others?)
+                unsigned int c  = (unsigned int)item->data.B;
+                item->data.S32  = (unsigned int)((c<<24) | c);
+                bind[i].length  = 0;
+                bind[i].buffer  = &item->data.B;
+                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.B)
+                                  ? (my_bool *)&isNull
+                                  : NULL;
+                break;
+            }
+        case PS_DATA_STRING: {
+                // convert NaNs to NULL and set the buffer_length for strings
+
+                if (item->data.str) {
+                    // will handle the case of "" as a NULL database value
+                    bind[i].buffer_length = (unsigned long)strlen(item->data.str);
+                    bind[i].length  = &bind[i].buffer_length;
+                    bind[i].buffer  = psStringCopy(item->data.V);
+                    bind[i].is_null = *item->data.str == '\0'
+                                      ? (my_bool *)&isNull
+                                      : NULL;
+                } else {
+                    // handles the case of NULL as a NULL database value
+                    bind[i].buffer_length = 0;
+                    bind[i].length  = &bind[i].buffer_length;
+                    bind[i].buffer  = NULL;
+                    bind[i].is_null = (my_bool *)&isNull;
+                }
+                break;
+            }
+        case PS_DATA_TIME: {
+                // XXX we're abusing the comment field of the metadata item
+                // here as we need to have a buffer that exists outside this
+                // functions scope without leaking memory make a copy of the
+                // psTime so we don't modify user data when we try to do the
+                // conversion
+                if (item->data.str) {
+                    psTime *time = (psTime *)item->data.V;
+                    struct tm *tmTime = psTimeToTM(time);
+
+                    // XXX it wouldn't hurt to make this conversion it's own
+                    // function myTime is used as the 'buffer' so it doesn't
+                    // have to be free'd
+                    MYSQL_TIME *myTime = psAlloc(sizeof(MYSQL_TIME));
+                    myTime->year    = (unsigned int)tmTime->tm_year + 1900;
+                    myTime->month   = (unsigned int)tmTime->tm_mon + 1;
+                    myTime->day     = (unsigned int)tmTime->tm_mday;
+                    myTime->hour    = (unsigned int)tmTime->tm_hour;
+                    myTime->minute  = (unsigned int)tmTime->tm_min;
+                    myTime->second  = (unsigned int)tmTime->tm_sec;
+                    // assume for the time being that we don't have negative
+                    // time as ISO8601 doesn't support dates prior to 0
+                    myTime->neg     = (my_bool)false;
+                    // currently unused by mysql
+                    myTime->second_part  = (unsigned long)time->nsec;
+                    psFree(tmTime);
+
+                    bind[i].buffer  = myTime;
+                    bind[i].buffer_length = sizeof(MYSQL_TIME);
+                    bind[i].length  = &bind[i].buffer_length;
+                    bind[i].is_null = NULL;
+                } else {
+                    // handles the case of NULL as a NULL database value
+                    bind[i].buffer_length = 0;
+                    bind[i].length  = &bind[i].buffer_length;
+                    bind[i].buffer  = NULL;
+                    bind[i].is_null = (my_bool *)&isNull;
+                }
+                break;
+            }
+        default: {
+                psError(PS_ERR_BAD_PARAMETER_TYPE , true,
+                        "FIXME: Only type of "
+                        "PS_TYPE_S32 (PS_DATA_S32), "
+                        "PS_TYPE_S64 (PS_DATA_S64), "
+                        "PS_TYPE_F32 (PS_DATA_F32), "
+                        "PS_TYPE_F64 (PS_DATA_F64), "
+                        "PS_TYPE_BOOL (PS_DATA_BOOL), "
+                        "PS_DATA_STRING "
+                        "and PS_DATA_TIME are supported.");
+
+                psFree(cursor);
+
+                return false;
+                break;                  // unreachable
+            }
         }
     }
@@ -1252,31 +1279,35 @@
     // find column name and type
     while ((item = psListGetAndIncrement(cursor))) {
-        if ((item->type == PS_DATA_S32)
-                || (item->type == PS_DATA_F32)
-                || (item->type == PS_DATA_F64)
-                || (item->type == PS_TYPE_S32)
-                || (item->type == PS_TYPE_F32)
-                || (item->type == PS_TYPE_F64)
-                || (item->type == PS_TYPE_BOOL)
-                || (item->type == PS_DATA_BOOL)
-                || (item->type == PS_DATA_TIME)
-           ) {
-            // + column name + _ + column type
-            colType = psDBPTypeToSQL(item->type);
-            psStringAppend(&query, "%s %s", item->name, colType);
-            psFree(colType);
-        } else if (item->type == PS_DATA_STRING) {
-            // + column name + _ + varchar( + length + )
-            psStringAppend(&query, "%s VARCHAR(%s)", item->name, item->data.str);
-        } else {
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    "FIXME: Only type of PS_DATA_S32, PS_DATA_F32, PS_DATA_F64, PS_DATA_BOOL, "
-                    "and PS_DATA_STRING are supported, (not %d).", item->type);
-
-            psFree(query);
-            psFree(cursor);
-
-            return NULL;
-        }
+        switch (item->type) {
+        case PS_DATA_S32:
+        case PS_DATA_S64:
+        case PS_DATA_F32:
+        case PS_DATA_F64:
+        case PS_DATA_BOOL:
+        case PS_DATA_TIME: {
+                // + column name + _ + column type
+                colType = psDBPTypeToSQL(item->type);
+                psStringAppend(&query, "%s %s", item->name, colType);
+                psFree(colType);
+                break;
+            }
+        case PS_DATA_STRING: {
+                // + column name + _ + varchar( + length + )
+                psStringAppend(&query, "%s VARCHAR(%s)", item->name, item->data.str);
+                break;
+            }
+        default: {
+                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                        "FIXME: Only type of PS_DATA_S32, PS_DATA_F32, PS_DATA_F64, PS_DATA_BOOL, "
+                        "and PS_DATA_STRING are supported, (not %d).", item->type);
+
+                psFree(query);
+                psFree(cursor);
+
+                return NULL;
+                break;                  // unreachable
+            }
+        }
+
         if (strstr(item->comment, "AUTO_INCREMENT")) {
             psStringAppend(&query, " %s", "AUTO_INCREMENT");
