[svn-commits] tilghman: branch tilghman/realtime_update2 r147590 - /team/tilghman/realtime_...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 8 12:53:17 CDT 2008


Author: tilghman
Date: Wed Oct  8 12:53:17 2008
New Revision: 147590

URL: http://svn.digium.com/view/asterisk?view=rev&rev=147590
Log:
Fixup some typos

Modified:
    team/tilghman/realtime_update2/res/res_config_curl.c
    team/tilghman/realtime_update2/res/res_config_ldap.c
    team/tilghman/realtime_update2/res/res_config_odbc.c
    team/tilghman/realtime_update2/res/res_config_pgsql.c

Modified: team/tilghman/realtime_update2/res/res_config_curl.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/realtime_update2/res/res_config_curl.c?view=diff&rev=147590&r1=147589&r2=147590
==============================================================================
--- team/tilghman/realtime_update2/res/res_config_curl.c (original)
+++ team/tilghman/realtime_update2/res/res_config_curl.c Wed Oct  8 12:53:17 2008
@@ -281,7 +281,7 @@
 	char buf1[200], buf2[200];
 	const char *newparam, *newval;
 	char *stringp;
-	int i, rowcount = -1, lookup = 1, first = 1;
+	int rowcount = -1, lookup = 1, first = 1;
 	const int EncodeSpecialChars = 1, bufsize = 100;
 	char *buffer;
 

Modified: team/tilghman/realtime_update2/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/realtime_update2/res/res_config_ldap.c?view=diff&rev=147590&r1=147589&r2=147590
==============================================================================
--- team/tilghman/realtime_update2/res/res_config_ldap.c (original)
+++ team/tilghman/realtime_update2/res/res_config_ldap.c Wed Oct  8 12:53:17 2008
@@ -1468,7 +1468,6 @@
 	}
 	/* Ready to update */
 	if ((num_entries = ldap_count_entries(ldapConn, ldap_result_msg)) > 0) {
-		ast_debug(3, "LINE(%d) Modifying %s=%s hits: %d\n", __LINE__, attribute, lookup, num_entries);
 		for (i = 0; option_debug > 2 && i < mods_size - 1; i++)
 			ast_debug(3, "LINE(%d) %s=%s \n", __LINE__, ldap_mods[i]->mod_type, ldap_mods[i]->mod_values[0]);
 

Modified: team/tilghman/realtime_update2/res/res_config_odbc.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/realtime_update2/res/res_config_odbc.c?view=diff&rev=147590&r1=147589&r2=147590
==============================================================================
--- team/tilghman/realtime_update2/res/res_config_odbc.c (original)
+++ team/tilghman/realtime_update2/res/res_config_odbc.c Wed Oct  8 12:53:17 2008
@@ -484,7 +484,7 @@
 
 static SQLHSTMT update2_prepare(struct odbc_obj *obj, void *data)
 {
-	int res, x = 1, count = 0, first = 1;
+	int res, x = 1, first = 1;
 	struct update2_prepare_struct *ups = data;
 	const char *newparam, *newval;
 	struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
@@ -501,7 +501,7 @@
 	}
 
 	if (!tableptr) {
-		ast_log(LOG_ERROR, "Could not retrieve metadata for table '%s@%s'.  Update will fail!\n", ups->table, ups->description);
+		ast_log(LOG_ERROR, "Could not retrieve metadata for table '%s@%s'.  Update will fail!\n", ups->table, ups->database);
 		return NULL;
 	}
 
@@ -524,11 +524,11 @@
 	while ((newparam = va_arg(ap, const char *))) {
 		newval = va_arg(ap, const char *);
 		if ((column = ast_odbc_find_column(tableptr, newparam))) {
-			ast_str_append(&sql, "%s%s ? ", first ? "" : ", ", newparam);
+			ast_str_append(&sql, 0, "%s%s ? ", first ? "" : ", ", newparam);
 			SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);
 			first = 0;
 		} else {
-			ast_log(LOG_NOTICE, "Not updating column '%s' in '%s@%s' because that column does not exist!\n", newparam, table, database);
+			ast_log(LOG_NOTICE, "Not updating column '%s' in '%s@%s' because that column does not exist!\n", newparam, ups->table, ups->database);
 		}
 	}
 	va_end(ap);
@@ -546,7 +546,7 @@
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			return NULL;
 		}
-		ast_str_append(&sql, "%s%s ? ", first ? "" : ", ", newparam);
+		ast_str_append(&sql, 0, "%s%s ? ", first ? "" : ", ", newparam);
 		SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);
 		first = 0;
 	}
@@ -585,6 +585,8 @@
 	SQLHSTMT stmt;
 	struct update2_prepare_struct ups = { .database = database, .table = table, };
 	struct ast_str *sql;
+	int res;
+	SQLLEN rowcount = 0;
 
 	va_copy(ups.ap, ap);
 

Modified: team/tilghman/realtime_update2/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/realtime_update2/res/res_config_pgsql.c?view=diff&rev=147590&r1=147589&r2=147590
==============================================================================
--- team/tilghman/realtime_update2/res/res_config_pgsql.c (original)
+++ team/tilghman/realtime_update2/res/res_config_pgsql.c Wed Oct  8 12:53:17 2008
@@ -116,7 +116,7 @@
 {
 	struct columns *column;
 	struct tables *table;
-	struct ast_str *sql = ast_str_thread_get(findtable_buf, 330);
+	struct ast_str *sql = ast_str_thread_get(&findtable_buf, 330);
 	char *pgerror;
 	PGresult *result;
 	char *fname, *ftype, *flen, *fnotnull, *fdef;
@@ -223,8 +223,8 @@
 {
 	PGresult *result = NULL;
 	int num_rows = 0, pgresult;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 100);
-	struct ast_str *escapebuf = ast_str_thread_get(escapebuf_buf, 100);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100);
+	struct ast_str *escapebuf = ast_str_thread_get(&escapebuf_buf, 100);
 	char *stringp;
 	char *chunk;
 	char *op;
@@ -358,8 +358,8 @@
 {
 	PGresult *result = NULL;
 	int num_rows = 0, pgresult;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 100);
-	struct ast_str *escapebuf, ast_str_thread_get(escapebuf_buf, 100);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100);
+	struct ast_str *escapebuf = ast_str_thread_get(&escapebuf_buf, 100);
 	const char *initfield = NULL;
 	char *stringp;
 	char *chunk;
@@ -518,8 +518,8 @@
 	PGresult *result = NULL;
 	int numrows = 0, pgresult;
 	const char *newparam, *newval;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 100);
-	struct ast_str *escapebuf = ast_str_thread_get(escapebuf_buf, 100);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100);
+	struct ast_str *escapebuf = ast_str_thread_get(&escapebuf_buf, 100);
 	struct tables *table;
 	struct columns *column = NULL;
 
@@ -570,12 +570,12 @@
 		release_table(table);
 		return -1;
 	}
-	ast_str_set(&sql, 0, "UPDATE %s SET %s = '%s'", tablename, newparam, escapebuf);
+	ast_str_set(&sql, 0, "UPDATE %s SET %s = '%s'", tablename, newparam, escapebuf->str);
 
 	while ((newparam = va_arg(ap, const char *))) {
 		newval = va_arg(ap, const char *);
 
-		if (!find_column(table, column)) {
+		if (!find_column(table, newparam)) {
 			ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", newparam, tablename);
 			continue;
 		}
@@ -588,7 +588,7 @@
 			return -1;
 		}
 
-		ast_str_append(&sql, 0, ", %s = '%s'", newparam, escapebuf);
+		ast_str_append(&sql, 0, ", %s = '%s'", newparam, escapebuf->str);
 	}
 	va_end(ap);
 	release_table(table);
@@ -600,7 +600,7 @@
 		return -1;
 	}
 
-	ast_str_append(&sql, 0, " WHERE %s = '%s'", keyfield, escapebuf);
+	ast_str_append(&sql, 0, " WHERE %s = '%s'", keyfield, escapebuf->str);
 
 	ast_debug(1, "PostgreSQL RealTime: Update SQL: %s\n", sql->str);
 
@@ -657,12 +657,11 @@
 {
 	PGresult *result = NULL;
 	int numrows = 0, pgresult, first = 1;
-	struct ast_str *escapebuf = ast_str_thread_get(escapebuf_buf, 16);
+	struct ast_str *escapebuf = ast_str_thread_get(&escapebuf_buf, 16);
 	const char *newparam, *newval;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 100);
-	struct ast_str *where = ast_str_thread_get(where_buf, 100);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100);
+	struct ast_str *where = ast_str_thread_get(&where_buf, 100);
 	struct tables *table;
-	struct columns *column = NULL;
 
 	if (!tablename) {
 		ast_log(LOG_WARNING, "PostgreSQL RealTime: No table specified.\n");
@@ -679,15 +678,13 @@
 		return -1;
 	}
 
-	ast_str_set(&sql, 0, "UPDATE %s SET ");
-	ast_set_set(&where, 0, "WHERE");
-
-	va_start(ap);
+	ast_str_set(&sql, 0, "UPDATE %s SET ", tablename);
+	ast_str_set(&where, 0, "WHERE");
+
 	while ((newparam = va_arg(ap, const char *))) {
 		if (!find_column(table, newparam)) {
 			ast_log(LOG_ERROR, "Attempted to update based on criteria column '%s' (%s@%s), but that column does not exist!\n", newparam, tablename, database);
 			release_table(table);
-			va_end(ap);
 			return -1;
 		}
 			
@@ -695,7 +692,6 @@
 		ESCAPE_STRING(escapebuf, newval);
 		if (pgresult) {
 			ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
-			va_end(ap);
 			release_table(table);
 			ast_free(sql);
 			return -1;
@@ -712,7 +708,6 @@
 			pgsqlConn = NULL;
 		}
 		release_table(table);
-		va_end(ap);
 		return -1;
 	}
 
@@ -722,7 +717,7 @@
 		newval = va_arg(ap, const char *);
 
 		/* If the column is not within the table, then skip it */
-		if (!find_column(column)) {
+		if (!find_column(table, newparam)) {
 			ast_log(LOG_NOTICE, "Attempted to update column '%s' in table '%s@%s', but column does not exist!\n", newparam, tablename, database);
 			continue;
 		}
@@ -730,15 +725,13 @@
 		ESCAPE_STRING(escapebuf, newval);
 		if (pgresult) {
 			ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
-			va_end(ap);
 			release_table(table);
 			ast_free(sql);
 			return -1;
 		}
 
-		ast_str_append(&sql, 0, "%s %s='%s'", first ? "" : ",", newparam, escapebuf);
-	}
-	va_end(ap);
+		ast_str_append(&sql, 0, "%s %s='%s'", first ? "" : ",", newparam, escapebuf->str);
+	}
 	release_table(table);
 
 	ast_str_append(&sql, 0, " %s", where->str);
@@ -796,9 +789,9 @@
 {
 	PGresult *result = NULL;
 	Oid insertid;
-	struct ast_str *buf = ast_str_thread_get(escapebuf_buf, 256);
-	struct ast_str *sql1 = ast_str_thread_get(sql_buf, 256);
-	struct ast_str *sql2 = ast_str_thread_get(where_buf, 256);
+	struct ast_str *buf = ast_str_thread_get(&escapebuf_buf, 256);
+	struct ast_str *sql1 = ast_str_thread_get(&sql_buf, 256);
+	struct ast_str *sql2 = ast_str_thread_get(&where_buf, 256);
 	int pgresult;
 	const char *newparam, *newval;
 
@@ -889,8 +882,8 @@
 	PGresult *result = NULL;
 	int numrows = 0;
 	int pgresult;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 256);
-	struct ast_str *buf1 = ast_str_thread_get(where_buf, 60), *buf2 = ast_str_thread_get(escapebuf_buf, 60);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 256);
+	struct ast_str *buf1 = ast_str_thread_get(&where_buf, 60), *buf2 = ast_str_thread_get(&escapebuf_buf, 60);
 	const char *newparam, *newval;
 
 	if (!table) {
@@ -984,7 +977,7 @@
 	long num_rows;
 	struct ast_variable *new_v;
 	struct ast_category *cur_cat = NULL;
-	struct ast_str *sql = ast_str_thread_get(sql_buf, 100);
+	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100);
 	char last[80] = "";
 	int last_cat_metric = 0;
 
@@ -1188,7 +1181,7 @@
 			}
 		}
 	}
-	ast_mutex_unlock(&table->lock);
+	release_table(table);
 	return res;
 }
 
@@ -1222,6 +1215,7 @@
 	.store_func = store_pgsql,
 	.destroy_func = destroy_pgsql,
 	.update_func = update_pgsql,
+	.update2_func = update2_pgsql,
 	.require_func = require_pgsql,
 	.unload_func = unload_pgsql,
 };
@@ -1474,7 +1468,7 @@
 			AST_LIST_TRAVERSE(&cur->columns, col, list) {
 				ast_cli(a->fd, "%-20.20s %-20.20s %3d %-8.8s\n", col->name, col->type, col->len, col->notnull ? "NOT NULL" : "");
 			}
-			ast_mutex_unlock(&cur->lock);
+			release_table(cur);
 		} else {
 			ast_cli(a->fd, "No such table '%s'\n", a->argv[4]);
 		}




More information about the svn-commits mailing list