[asterisk-commits] tilghman: trunk r134925 - /trunk/res/res_config_pgsql.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 31 15:10:40 CDT 2008
Author: tilghman
Date: Thu Jul 31 15:10:39 2008
New Revision: 134925
URL: http://svn.digium.com/view/asterisk?view=rev&rev=134925
Log:
Increase column size beyond the minimum required, since PostgreSQL won't let
us modify existing columns.
Modified:
trunk/res/res_config_pgsql.c
Modified: trunk/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_pgsql.c?view=diff&rev=134925&r1=134924&r2=134925
==============================================================================
--- trunk/res/res_config_pgsql.c (original)
+++ trunk/res/res_config_pgsql.c Thu Jul 31 15:10:39 2008
@@ -991,7 +991,12 @@
PGresult *res;
if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
- snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)", size);
+ /* Size is minimum length; make it at least 50% greater,
+ * just to be sure, because PostgreSQL doesn't support
+ * resizing columns. */
+ snprintf(fieldtype, sizeof(fieldtype), "CHAR(%d)",
+ size < 15 ? size * 2 :
+ (size * 3 / 2 > 255) ? 255 : size * 3 / 2);
} 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) {
@@ -1008,6 +1013,7 @@
} else if (type == RQ_DATETIME) {
snprintf(fieldtype, sizeof(fieldtype), "TIMESTAMP");
} else {
+ ast_log(LOG_ERROR, "Unrecognized request type %d\n", type);
ast_free(sql);
continue;
}
@@ -1042,22 +1048,22 @@
static int unload_pgsql(const char *database, const char *tablename)
{
struct tables *cur;
- ast_debug(1, "About to lock table cache list\n");
+ ast_debug(2, "About to lock table cache list\n");
AST_LIST_LOCK(&psql_tables);
- ast_debug(1, "About to traverse table cache list\n");
+ ast_debug(2, "About to traverse table cache list\n");
AST_LIST_TRAVERSE_SAFE_BEGIN(&psql_tables, cur, list) {
if (strcmp(cur->name, tablename) == 0) {
- ast_debug(1, "About to remove matching cache entry\n");
+ ast_debug(2, "About to remove matching cache entry\n");
AST_LIST_REMOVE_CURRENT(list);
- ast_debug(1, "About to destroy matching cache entry\n");
+ ast_debug(2, "About to destroy matching cache entry\n");
destroy_table(cur);
- ast_debug(1, "Cache entry destroyed\n");
+ ast_debug(1, "Cache entry '%s@%s' destroyed\n", tablename, database);
break;
}
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&psql_tables);
- ast_debug(1, "About to return\n");
+ ast_debug(2, "About to return\n");
return cur ? 0 : -1;
}
More information about the asterisk-commits
mailing list