Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13739
Modified Files:
noteshandler.c
Log Message:
use unique temporary citation key to avoid problems with concurrent inserts
Index: noteshandler.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/noteshandler.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -U2 -r1.15 -r1.16
--- noteshandler.c 10 Feb 2004 23:49:49 -0000 1.15
+++ noteshandler.c 15 Feb 2004 22:58:15 -0000 1.16
@@ -368,5 +368,6 @@
/* generate temporary key if necessary */
if (!*(ptr_andata->real_key)) {
- sprintf(ptr_andata->real_key, ULLSPEC, (unsigned long long)0);
+ /* use pid to avoid problems with concurrent inserts */
+ sprintf(ptr_andata->real_key, "dummy%d", getpid());
}
@@ -933,5 +934,5 @@
/* insert new citekey if required */
- if (!strcmp(ptr_andata->real_key, "0") && ptr_andata->create_new) {
+ if (!strncmp(ptr_andata->real_key, "dummy", 5) && ptr_andata->create_new) {
key = get_unique_citekey(ptr_andata->conn, ptr_andata->user, atoi(ptr_andata->year), ptr_andata->n_note_id, 1 /* notes */);
@@ -974,5 +975,11 @@
if (strcmp(my_dbi_conn_get_cap(ptr_andata->conn, "transaction"), "t")) {
/* we have to delete the junk reference manually */
- sprintf(sql_command, "DELETE FROM t_note WHERE note_key=\'DUMMY\'");
+ if (*(ptr_andata->real_key)) {
+ sprintf(sql_command, "DELETE FROM t_note WHERE note_key=\'%s\'", ptr_andata->real_key);
+ }
+ else {
+ sprintf(sql_command, "DELETE FROM t_note WHERE note_key=\'dummy%d\'", getpid());
+ }
+
LOG_PRINT(LOG_DEBUG, sql_command);
dbires = dbi_conn_query(ptr_andata->conn, sql_command);
|