[dovecot-cvs] dovecot/src/lib-dict dict-sql.c,1.9,1.10

cras at dovecot.org cras at dovecot.org
Fri Jun 16 12:54:16 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-dict
In directory talvi:/tmp/cvs-serv5738

Modified Files:
	dict-sql.c 
Log Message:
Fixes to SQL update statements



Index: dict-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-sql.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dict-sql.c	14 Jun 2006 11:16:49 -0000	1.9
+++ dict-sql.c	16 Jun 2006 09:54:14 -0000	1.10
@@ -306,23 +306,23 @@
 	t_push();
 	if (priv) {
 		query = t_strdup_printf(
-			"INSERT INTO %s (%s, %s, %s) VALUES (%s, %s, %s) "
+			"INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s') "
 			"ON DUPLICATE KEY UPDATE %s = '%s'",
 			dict->table, dict->select_field, dict->where_field,
 			dict->username_field,
 			sql_escape_string(dict->db, key),
 			sql_escape_string(dict->db, value),
 			sql_escape_string(dict->db, dict->username),
-			sql_escape_string(dict->db, key),
+			dict->select_field,
 			sql_escape_string(dict->db, value));
 	} else {
 		query = t_strdup_printf(
-			"INSERT INTO %s (%s, %s) VALUES (%s, %s) "
+			"INSERT INTO %s (%s, %s) VALUES ('%s', '%s') "
 			"ON DUPLICATE KEY UPDATE %s = '%s'",
 			dict->table, dict->select_field, dict->where_field,
 			sql_escape_string(dict->db, key),
 			sql_escape_string(dict->db, value),
-                        sql_escape_string(dict->db, key),
+                        dict->select_field,
 			sql_escape_string(dict->db, value));
 	}
 	sql_update(ctx->sql_ctx, query);
@@ -344,22 +344,20 @@
 	t_push();
 	if (priv) {
 		query = t_strdup_printf(
-			"INSERT INTO %s (%s, %s, %s) VALUES (%s, %lld, %s) "
+			"INSERT INTO %s (%s, %s, %s) VALUES ('%s', %lld, '%s') "
 			"ON DUPLICATE KEY UPDATE %s = %s + %lld",
 			dict->table, dict->select_field, dict->where_field,
 			dict->username_field,
                         sql_escape_string(dict->db, key), diff,
 			sql_escape_string(dict->db, dict->username),
-                        sql_escape_string(dict->db, key),
-			sql_escape_string(dict->db, key), diff);
+                        dict->select_field, dict->select_field, diff);
 	} else {
 		query = t_strdup_printf(
 			"INSERT INTO %s (%s, %s) VALUES (%s, %lld) "
 			"ON DUPLICATE KEY UPDATE %s = %s + %lld",
 			dict->table, dict->select_field, dict->where_field,
                         sql_escape_string(dict->db, key), diff,
-                        sql_escape_string(dict->db, key),
-			sql_escape_string(dict->db, key), diff);
+                        dict->select_field, dict->select_field, diff);
 	}
 	sql_update(ctx->sql_ctx, query);
 	t_pop();



More information about the dovecot-cvs mailing list