[svn-commits] russell: branch russell/events r121400 - in /team/russell/events: ./ apps/ ch...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 9 19:21:00 CDT 2008


Author: russell
Date: Mon Jun  9 19:20:59 2008
New Revision: 121400

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121400
Log:
resolve, reset

Modified:
    team/russell/events/   (props changed)
    team/russell/events/apps/app_meetme.c
    team/russell/events/apps/app_queue.c
    team/russell/events/apps/app_voicemail.c
    team/russell/events/channels/chan_iax2.c
    team/russell/events/channels/chan_sip.c
    team/russell/events/include/asterisk/config.h
    team/russell/events/main/taskprocessor.c
    team/russell/events/main/utils.c
    team/russell/events/res/res_config_curl.c
    team/russell/events/res/res_config_odbc.c
    team/russell/events/res/res_config_pgsql.c

Propchange: team/russell/events/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun  9 19:20:59 2008
@@ -1,1 +1,1 @@
-/trunk:1-121363
+/trunk:1-121399

Modified: team/russell/events/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_meetme.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/apps/app_meetme.c (original)
+++ team/russell/events/apps/app_meetme.c Mon Jun  9 19:20:59 2008
@@ -1743,7 +1743,10 @@
 	if (rt_log_members) {
 		/* Update table */
 		snprintf(members, sizeof(members), "%d", conf->users);
-		ast_realtime_require_field("meetme", "confno", RQ_INTEGER, strlen(conf->confno), "members", RQ_INTEGER, strlen(members), NULL);
+		ast_realtime_require_field("meetme",
+			"confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno),
+			"members", RQ_UINTEGER1, strlen(members),
+			NULL);
 		ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL);
 	}
 	setusercount = 1;
@@ -2683,7 +2686,10 @@
 			if (rt_log_members) {
 				/* Update table */
 				snprintf(members, sizeof(members), "%d", conf->users);
-				ast_realtime_require_field("meetme", "confno", RQ_INTEGER, strlen(conf->confno), "members", RQ_INTEGER, strlen(members), NULL);
+				ast_realtime_require_field("meetme",
+					"confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno),
+					"members", RQ_UINTEGER1, strlen(members),
+					NULL);
 				ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL);
 			}
 			if (confflags & CONFFLAG_MARKEDUSER) 
@@ -5710,7 +5716,7 @@
 	res |= ast_devstate_prov_add("SLA", sla_state);
 
 	res |= ast_custom_function_register(&meetme_info_acf);
-	ast_realtime_require_field("meetme", "confno", RQ_INTEGER, 3, "members", RQ_INTEGER, 3, NULL);
+	ast_realtime_require_field("meetme", "confno", RQ_UINTEGER2, 3, "members", RQ_UINTEGER1, 3, NULL);
 
 	return res;
 }

Modified: team/russell/events/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_queue.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/apps/app_queue.c (original)
+++ team/russell/events/apps/app_queue.c Mon Jun  9 19:20:59 2008
@@ -6338,7 +6338,7 @@
 		res = -1;
 	}
 
-	ast_realtime_require_field("queue_members", "paused", RQ_INTEGER, 1, "uniqueid", RQ_INTEGER, 5, NULL);
+	ast_realtime_require_field("queue_members", "paused", RQ_INTEGER1, 1, "uniqueid", RQ_UINTEGER2, 5, NULL);
 
 	return res ? AST_MODULE_LOAD_DECLINE : 0;
 }

Modified: team/russell/events/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_voicemail.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/apps/app_voicemail.c (original)
+++ team/russell/events/apps/app_voicemail.c Mon Jun  9 19:20:59 2008
@@ -10089,8 +10089,8 @@
 	ast_cli_register_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry));
 
 	ast_install_vm_functions(has_voicemail, inboxcount, messagecount, sayname);
-	ast_realtime_require_field("voicemail", "uniqueid", RQ_INTEGER, 11, "password", RQ_CHAR, 10, NULL);
-	ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_INTEGER, 5, NULL);
+	ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, NULL);
+	ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, NULL);
 
 	return res;
 }

Modified: team/russell/events/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/chan_iax2.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/channels/chan_iax2.c (original)
+++ team/russell/events/channels/chan_iax2.c Mon Jun  9 19:20:59 2008
@@ -12188,7 +12188,7 @@
 	reload_firmware(0);
 	iax_provision_reload(0);
 
-	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_INTEGER, 5, "regseconds", RQ_INTEGER, 6, NULL);
+	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_UINTEGER2, 5, "regseconds", RQ_UINTEGER2, 6, NULL);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: team/russell/events/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/chan_sip.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/channels/chan_sip.c (original)
+++ team/russell/events/channels/chan_sip.c Mon Jun  9 19:20:59 2008
@@ -22863,8 +22863,8 @@
 	ast_realtime_require_field(ast_check_realtime("sipregs") ? "sipregs" : "sippeers",
 		"name", RQ_CHAR, 10,
 		"ipaddr", RQ_CHAR, 15,
-		"port", RQ_INTEGER, 5,
-		"regseconds", RQ_INTEGER, 5,
+		"port", RQ_UINTEGER2, 5,
+		"regseconds", RQ_UINTEGER2, 5,   /* Max of 18 hours */
 		"defaultuser", RQ_CHAR, 10,
 		"fullcontact", RQ_CHAR, 20,
 		"regserver", RQ_CHAR, 20,

Modified: team/russell/events/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/config.h?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/include/asterisk/config.h (original)
+++ team/russell/events/include/asterisk/config.h Mon Jun  9 19:20:59 2008
@@ -28,6 +28,7 @@
 #endif
 
 #include "asterisk/utils.h"
+#include "asterisk/inline_api.h"
 
 struct ast_config;
 
@@ -50,7 +51,16 @@
  * \brief Types used in ast_realtime_require_field
  */
 typedef enum {
-	RQ_INTEGER,
+	RQ_INTEGER1,
+	RQ_UINTEGER1,
+	RQ_INTEGER2,
+	RQ_UINTEGER2,
+	RQ_INTEGER3,
+	RQ_UINTEGER3,
+	RQ_INTEGER4,
+	RQ_UINTEGER4,
+	RQ_INTEGER8,
+	RQ_UINTEGER8,
 	RQ_CHAR,
 	RQ_FLOAT,
 	RQ_DATE,
@@ -451,6 +461,27 @@
 #define CV_DSTR(__x, __dst)	CV_F(__x, if (__dst) ast_free(__dst); __dst = ast_strdup(__val))
 #define CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val))
 
+AST_INLINE_API(
+int ast_rq_is_int(require_type type),
+{
+	switch (type) {
+	case RQ_INTEGER1:
+	case RQ_UINTEGER1:
+	case RQ_INTEGER2:
+	case RQ_UINTEGER2:
+	case RQ_INTEGER3:
+	case RQ_UINTEGER3:
+	case RQ_INTEGER4:
+	case RQ_UINTEGER4:
+	case RQ_INTEGER8:
+	case RQ_UINTEGER8:
+		return 1;
+	default:
+		return 0;
+	}
+}
+)
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/russell/events/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/taskprocessor.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/main/taskprocessor.c (original)
+++ team/russell/events/main/taskprocessor.c Mon Jun  9 19:20:59 2008
@@ -354,6 +354,8 @@
 	ast_mutex_unlock(&t->taskprocessor_lock);
 	pthread_join(t->poll_thread, NULL);
 	t->poll_thread = AST_PTHREADT_NULL;
+	ast_mutex_destroy(&t->taskprocessor_lock);
+	ast_cond_destroy(&t->poll_cond);
 	/* free it */
 	if (t->stats) {
 		ast_free(t->stats);
@@ -424,6 +426,10 @@
 		ast_log(LOG_WARNING, "failed to create taskprocessor '%s'\n", name);
 		return NULL;
 	}
+
+	ast_cond_init(&p->poll_cond, NULL);
+	ast_mutex_init(&p->taskprocessor_lock);
+
 	if (!(p->stats = ast_calloc(1, sizeof(*p->stats)))) {
 		ao2_unlock(tps_singletons);
 		ast_log(LOG_WARNING, "failed to create taskprocessor stats for '%s'\n", name);
@@ -436,7 +442,6 @@
 		return NULL;
 	}
 	p->poll_thread_run = 1;
-	ast_cond_init(&p->poll_cond, NULL);
 	p->poll_thread = AST_PTHREADT_NULL;
 	if (ast_pthread_create(&p->poll_thread, NULL, tps_processing_function, p) < 0) {
 		ao2_unlock(tps_singletons);

Modified: team/russell/events/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/utils.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/main/utils.c (original)
+++ team/russell/events/main/utils.c Mon Jun  9 19:20:59 2008
@@ -58,6 +58,9 @@
 
 #define AST_API_MODULE
 #include "asterisk/threadstorage.h"
+
+#define AST_API_MODULE
+#include "asterisk/config.h"
 
 static char base64[64];
 static char b2a[256];

Modified: team/russell/events/res/res_config_curl.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/res_config_curl.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/res/res_config_curl.c (original)
+++ team/russell/events/res/res_config_curl.c Mon Jun  9 19:20:59 2008
@@ -430,7 +430,16 @@
 		ast_uri_encode(elm, field, sizeof(field), EncodeSpecialChars);
 		ast_str_append(&query, 0, "%s=%s%%3A%d", field,
 			type == RQ_CHAR ? "char" :
-			type == RQ_INTEGER ? "integer" :
+			type == RQ_INTEGER1 ? "integer1" :
+			type == RQ_UINTEGER1 ? "uinteger1" :
+			type == RQ_INTEGER2 ? "integer2" :
+			type == RQ_UINTEGER2 ? "uinteger2" :
+			type == RQ_INTEGER3 ? "integer3" :
+			type == RQ_UINTEGER3 ? "uinteger3" :
+			type == RQ_INTEGER4 ? "integer4" :
+			type == RQ_UINTEGER4 ? "uinteger4" :
+			type == RQ_INTEGER8 ? "integer8" :
+			type == RQ_UINTEGER8 ? "uinteger8" :
 			type == RQ_DATE ? "date" :
 			type == RQ_DATETIME ? "datetime" :
 			type == RQ_FLOAT ? "float" :

Modified: team/russell/events/res/res_config_odbc.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/res_config_odbc.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/res/res_config_odbc.c (original)
+++ team/russell/events/res/res_config_odbc.c Mon Jun  9 19:20:59 2008
@@ -878,8 +878,8 @@
 	return cfg;
 }
 
-#define warn_length(col, size)	ast_log(LOG_WARNING, "Column %s is not long enough to contain realtime data (needs %d)\n", col->name, size)
-#define warn_type(col, type)	ast_log(LOG_WARNING, "Column %s is of the incorrect type to contain realtime data\n", col->name)
+#define warn_length(col, size)	ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is not long enough to contain realtime data (needs %d)\n", table, database, col->name, size)
+#define warn_type(col, type)	ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is of the incorrect type (%d) to contain the required realtime data\n", table, database, col->name, col->type)
 
 static int require_odbc(const char *database, const char *table, va_list ap)
 {
@@ -907,15 +907,28 @@
 				case SQL_VARBINARY:
 				case SQL_LONGVARBINARY:
 				case SQL_GUID:
-					if ((type == RQ_INTEGER && size > 10) || (type == RQ_CHAR && col->size < size)) {
-						warn_length(col, size);
-					} else if (type == RQ_DATE && col->size < 10) {
-						warn_length(col, 10);
-					} else if (type == RQ_DATETIME && col->size < 19) {
-						warn_length(col, 19);
-					} else if (type == RQ_FLOAT && col->size < 10) {
-						warn_length(col, 10);
+#define CHECK_SIZE(n) \
+						if (col->size < n) {      \
+							warn_length(col, n);  \
+						}                         \
+						break;
+					switch (type) {
+					case RQ_UINTEGER1: CHECK_SIZE(3)  /*         255 */
+					case RQ_INTEGER1:  CHECK_SIZE(4)  /*        -128 */
+					case RQ_UINTEGER2: CHECK_SIZE(5)  /*       65535 */
+					case RQ_INTEGER2:  CHECK_SIZE(6)  /*      -32768 */
+					case RQ_UINTEGER3:                /*    16777215 */
+					case RQ_INTEGER3:  CHECK_SIZE(8)  /*    -8388608 */
+					case RQ_DATE:                     /*  2008-06-09 */
+					case RQ_UINTEGER4: CHECK_SIZE(10) /*  4200000000 */
+					case RQ_INTEGER4:  CHECK_SIZE(11) /* -2100000000 */
+					case RQ_DATETIME:                 /* 2008-06-09 16:03:47 */
+					case RQ_UINTEGER8: CHECK_SIZE(19) /* trust me    */
+					case RQ_INTEGER8:  CHECK_SIZE(20) /* ditto       */
+					case RQ_FLOAT:
+					case RQ_CHAR:      CHECK_SIZE(size)
 					}
+#undef CHECK_SIZE
 					break;
 				case SQL_TYPE_DATE:
 					if (type != RQ_DATE) {
@@ -928,44 +941,98 @@
 						warn_type(col, type);
 					}
 					break;
+				case SQL_BIT:
+					warn_length(col, size);
+					break;
+#define WARN_TYPE_OR_LENGTH(n)	\
+						if (!ast_rq_is_int(type)) {  \
+							warn_type(col, type);    \
+						} else {                     \
+							warn_length(col, n);  \
+						}
+				case SQL_TINYINT:
+					if (type != RQ_UINTEGER1) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
+				case SQL_C_STINYINT:
+					if (type != RQ_INTEGER1) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
+				case SQL_C_USHORT:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
+				case SQL_SMALLINT:
+				case SQL_C_SSHORT:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_INTEGER2) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
+				case SQL_C_ULONG:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 &&
+						type != RQ_UINTEGER2 && type != RQ_INTEGER2 &&
+						type != RQ_UINTEGER3 && type != RQ_INTEGER3 &&
+						type != RQ_INTEGER4) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
 				case SQL_INTEGER:
+				case SQL_C_SLONG:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 &&
+						type != RQ_UINTEGER2 && type != RQ_INTEGER2 &&
+						type != RQ_UINTEGER3 && type != RQ_INTEGER3 &&
+						type != RQ_UINTEGER4) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
+				case SQL_C_UBIGINT:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 &&
+						type != RQ_UINTEGER2 && type != RQ_INTEGER2 &&
+						type != RQ_UINTEGER3 && type != RQ_INTEGER3 &&
+						type != RQ_UINTEGER4 && type != RQ_INTEGER4 &&
+						type != RQ_INTEGER8) {
+						WARN_TYPE_OR_LENGTH(size)
+					}
+					break;
 				case SQL_BIGINT:
-				case SQL_SMALLINT:
-				case SQL_TINYINT:
-				case SQL_BIT:
-					if (type != RQ_INTEGER) {
-						warn_type(col, type);
+				case SQL_C_SBIGINT:
+					if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 &&
+						type != RQ_UINTEGER2 && type != RQ_INTEGER2 &&
+						type != RQ_UINTEGER3 && type != RQ_INTEGER3 &&
+						type != RQ_UINTEGER4 && type != RQ_INTEGER4 &&
+						type != RQ_UINTEGER8) {
+						WARN_TYPE_OR_LENGTH(size)
 					}
-					if ((col->type == SQL_BIT && size > 1) ||
-						(col->type == SQL_TINYINT && size > 2) ||
-						(col->type == SQL_SMALLINT && size > 4) ||
-						(col->type == SQL_INTEGER && size > 10)) {
-						warn_length(col, size);
-					}
-					break;
+					break;
+#undef WARN_TYPE_OR_LENGTH
 				case SQL_NUMERIC:
 				case SQL_DECIMAL:
 				case SQL_FLOAT:
 				case SQL_REAL:
 				case SQL_DOUBLE:
-					if (type != RQ_INTEGER && type != RQ_FLOAT) {
+					if (!ast_rq_is_int(type) && type != RQ_FLOAT) {
 						warn_type(col, type);
 					}
 					break;
 				default:
-					ast_log(LOG_WARNING, "Column type (%d) unrecognized for field '%s' in %s@%s\n", col->type, elm, table, database);
+					ast_log(LOG_WARNING, "Realtime table %s@%s: column type (%d) unrecognized for column '%s'\n", table, database, col->type, elm);
 				}
 				break;
 			}
 		}
 		if (!col) {
-			ast_log(LOG_WARNING, "Table %s@%s requires column '%s', but that column does not exist!\n", table, database, elm);
+			ast_log(LOG_WARNING, "Realtime table %s@%s requires column '%s', but that column does not exist!\n", table, database, elm);
 		}
 	}
 	va_end(ap);
 	AST_RWLIST_UNLOCK(&tableptr->columns);
 	return 0;
 }
+#undef warn_length
+#undef warn_type
 
 static int unload_odbc(const char *database, const char *tablename)
 {

Modified: team/russell/events/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/res_config_pgsql.c?view=diff&rev=121400&r1=121399&r2=121400
==============================================================================
--- team/russell/events/res/res_config_pgsql.c (original)
+++ team/russell/events/res/res_config_pgsql.c Mon Jun  9 19:20:59 2008
@@ -943,14 +943,21 @@
 				} else if (strncmp(column->type, "int", 3) == 0) {
 					int typesize = atoi(column->type + 3);
 					/* Integers can hold only other integers */
-					if (type == RQ_INTEGER && ((typesize == 2 && size > 4) || (typesize == 4 && size > 10))) {
+					if ((type == RQ_INTEGER8 || type == RQ_UINTEGER8 ||
+						type == RQ_INTEGER4 || type == RQ_UINTEGER4 ||
+						type == RQ_INTEGER3 || type == RQ_UINTEGER3 ||
+						type == RQ_UINTEGER2) && typesize == 2) {
 						ast_log(LOG_WARNING, "Column '%s' may not be large enough for the required data length: %d\n", column->name, size);
 						res = -1;
-					} else if (type != RQ_INTEGER) {
-						ast_log(LOG_WARNING, "Column '%s' is of the incorrect type: (need %s(%d) but saw %s)\n", column->name, type == RQ_CHAR ? "char" : "something else ", size, column->type);
+					} else if ((type == RQ_INTEGER8 || type == RQ_UINTEGER8 ||
+						type == RQ_UINTEGER4) && typesize == 4) {
+						ast_log(LOG_WARNING, "Column '%s' may not be large enough for the required data length: %d\n", column->name, size);
+						res = -1;
+					} else if (type == RQ_CHAR || type == RQ_DATETIME || type == RQ_FLOAT || type == RQ_DATE) {
+						ast_log(LOG_WARNING, "Column '%s' is of the incorrect type: (need %s(%d) but saw %s)\n", column->name, type == RQ_CHAR ? "char" : type == RQ_DATETIME ? "datetime" : type == RQ_DATE ? "date" : type == RQ_FLOAT ? "float" : "a rather stiff drink ", size, column->type);
 						res = -1;
 					}
-				} else if (strncmp(column->type, "float", 5) == 0 && type != RQ_INTEGER && type != RQ_FLOAT) {
+				} else if (strncmp(column->type, "float", 5) == 0 && !ast_rq_is_int(type) && type != RQ_FLOAT) {
 					ast_log(LOG_WARNING, "Column %s cannot be a %s\n", column->name, column->type);
 					res = -1;
 				} else { /* There are other types that no module implements yet */
@@ -965,25 +972,32 @@
 			if (requirements == RQ_WARN) {
 				ast_log(LOG_WARNING, "Table %s requires a column '%s' of size '%d', but no such column exists.\n", tablename, elm, size);
 			} else {
-				struct ast_str *sql = ast_str_create(100), *fieldtype = ast_str_create(16);
+				struct ast_str *sql = ast_str_create(100);
+				char fieldtype[15];
 				PGresult *res;
 
 				if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
-					ast_str_set(&fieldtype, 0, "CHAR(%d)", size);
-				} else if (type == RQ_INTEGER) {
-					ast_str_set(&fieldtype, 0, "INT%d", size < 5 ? 2 : (size < 11 ? 4 : 8));
+					snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)", size);
+				} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {
+					snprintf(fieldtype, sizeof(fieldtype), "INT2");
+				} else if (type == RQ_UINTEGER2 || type == RQ_INTEGER3 || type == RQ_UINTEGER3 || type == RQ_INTEGER4) {
+					snprintf(fieldtype, sizeof(fieldtype), "INT4");
+				} else if (type == RQ_UINTEGER4 || type == RQ_INTEGER8) {
+					snprintf(fieldtype, sizeof(fieldtype), "INT8");
+				} else if (type == RQ_UINTEGER8) {
+					/* No such type on PostgreSQL */
+					snprintf(fieldtype, sizeof(fieldtype), "CHAR(20)");
 				} else if (type == RQ_FLOAT) {
-					ast_str_set(&fieldtype, 0, "FLOAT8");
+					snprintf(fieldtype, sizeof(fieldtype), "FLOAT8");
 				} else if (type == RQ_DATE) {
-					ast_str_set(&fieldtype, 0, "DATE");
+					snprintf(fieldtype, sizeof(fieldtype), "DATE");
 				} else if (type == RQ_DATETIME) {
-					ast_str_set(&fieldtype, 0, "TIMESTAMP");
+					snprintf(fieldtype, sizeof(fieldtype), "TIMESTAMP");
 				} else {
 					ast_free(sql);
-					ast_free(fieldtype);
 					continue;
 				}
-				ast_str_set(&sql, 0, "ALTER TABLE %s ADD COLUMN %s %s", tablename, elm, fieldtype->str);
+				ast_str_set(&sql, 0, "ALTER TABLE %s ADD COLUMN %s %s", tablename, elm, fieldtype);
 				ast_debug(1, "About to lock pgsql_lock (running alter on table '%s' to add column '%s')\n", tablename, elm);
 
 				ast_mutex_lock(&pgsql_lock);
@@ -991,7 +1005,6 @@
 					ast_mutex_unlock(&pgsql_lock);
 					ast_log(LOG_ERROR, "Unable to add column: %s\n", sql->str);
 					ast_free(sql);
-					ast_free(fieldtype);
 					continue;
 				}
 
@@ -1005,7 +1018,6 @@
 				ast_mutex_unlock(&pgsql_lock);
 
 				ast_free(sql);
-				ast_free(fieldtype);
 			}
 		}
 	}




More information about the svn-commits mailing list