refdb-cvs Mailing List for RefDB (Page 76)
Status: Beta
Brought to you by:
mhoenicka
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(47) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(88) |
Feb
(50) |
Mar
(36) |
Apr
(9) |
May
(30) |
Jun
(30) |
Jul
(22) |
Aug
(16) |
Sep
(42) |
Oct
(18) |
Nov
(29) |
Dec
(23) |
2005 |
Jan
(18) |
Feb
(28) |
Mar
(21) |
Apr
(35) |
May
(62) |
Jun
(22) |
Jul
(5) |
Aug
(40) |
Sep
(98) |
Oct
(81) |
Nov
(51) |
Dec
(62) |
2006 |
Jan
(46) |
Feb
(36) |
Mar
(8) |
Apr
(16) |
May
(14) |
Jun
(16) |
Jul
(47) |
Aug
(60) |
Sep
(34) |
Oct
(16) |
Nov
(46) |
Dec
(11) |
2007 |
Jan
(16) |
Feb
(13) |
Mar
(58) |
Apr
(32) |
May
(4) |
Jun
(8) |
Jul
(31) |
Aug
(46) |
Sep
(22) |
Oct
(30) |
Nov
(58) |
Dec
(15) |
2008 |
Jan
(8) |
Feb
(8) |
Mar
(2) |
Apr
(6) |
May
(3) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
(6) |
Nov
(3) |
Dec
(5) |
2009 |
Jan
(1) |
Feb
(20) |
Mar
(8) |
Apr
(5) |
May
(8) |
Jun
(3) |
Jul
(6) |
Aug
(4) |
Sep
(7) |
Oct
(8) |
Nov
(2) |
Dec
(1) |
2010 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
(5) |
Feb
(5) |
Mar
(13) |
Apr
(3) |
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(5) |
Nov
|
Dec
(3) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(13) |
2014 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(4) |
May
(1) |
Jun
(1) |
Jul
|
Aug
(6) |
Sep
(3) |
Oct
|
Nov
(2) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2022 |
Jan
(9) |
Feb
(16) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Markus H. <mho...@us...> - 2003-12-26 00:10:06
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv22052 Modified Files: refdbdnote.c Log Message: call update_meta() where appropriate Index: refdbdnote.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdnote.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -U2 -r1.8 -r1.9 --- refdbdnote.c 24 Dec 2003 21:52:08 -0000 1.8 +++ refdbdnote.c 26 Dec 2003 00:10:02 -0000 1.9 @@ -204,7 +204,13 @@ Finish: + if (ptr_addresult->success || ptr_addresult->updated) { + /* database was changed, update meta info */ + update_meta(conn, ptr_clrequest); + } + if (conn_refdb) { dbi_conn_close(conn_refdb); } + dbi_conn_close(conn); delete_all_lilimem(&sentinel); @@ -233,4 +239,5 @@ int error; int result; + int retval = 1; unsigned long long n_periodical_id; unsigned long long n_id; @@ -328,8 +335,6 @@ LOG_PRINT(LOG_WARNING, "begin transaction failed"); iwrite(ptr_clrequest->fd, "begin transaction failed\n", 25); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -339,8 +344,6 @@ iwrite(ptr_clrequest->fd, "cannot lock tables", 18); LOG_PRINT(LOG_WARNING, "Cannot lock tables"); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -353,9 +356,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -387,9 +388,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } else if (dbi_result_next_row(dbires) != 0){ @@ -432,10 +431,8 @@ iwrite(ptr_clrequest->fd, "delete from t_xkeyword failed\n", 30); } - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } @@ -451,10 +448,8 @@ iwrite(ptr_clrequest->fd, "delete from t_xnote failed\n", 27); } - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } @@ -467,9 +462,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires); @@ -484,9 +477,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -504,9 +495,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires1); @@ -527,9 +516,14 @@ } /* end while */ + Finish: + if (conn && ptr_delresult->success) { + update_meta(conn, ptr_clrequest); + } + dbi_conn_close(conn); delete_all_lilid(&id_sentinel); delete_all_lilimem(&sentinel); - return 1; + return retval; } @@ -1969,4 +1963,5 @@ int result; int mode; + int retval = 1; int error = 0; /* codes: 0 = no error, 1 = out of memory, 2 = subselect failed */ unsigned long long n_id; @@ -2146,8 +2141,6 @@ } /* printf("error detected\n"); */ - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); - return 0; + retval = 0; + goto Finish; } @@ -2158,8 +2151,6 @@ dbires = dbi_conn_query(conn, sql_command); if (!dbires) { - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); - return 0; + retval = 0; + goto Finish; } @@ -2169,9 +2160,7 @@ else { dbi_result_free(dbires); - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); iwrite(ptr_clrequest->fd, "note not available\n", 19); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires); @@ -2251,8 +2240,6 @@ iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); ptr_addresult->failure++; - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); - return 0; + retval = 0; + goto Finish; } @@ -2293,8 +2280,6 @@ if (!dbires) { ptr_addresult->failure++; - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); - return 0; + retval = 0; + goto Finish; } @@ -2305,9 +2290,7 @@ ptr_addresult->failure++; dbi_result_free(dbires); - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - delete_all_liliform(&link_sentinel); iwrite(ptr_clrequest->fd, "target not available\n", 20); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires); @@ -2342,4 +2325,10 @@ } } + } + + Finish: + if (ptr_addresult->success) { + /* database was changed, update meta info */ + update_meta(conn, ptr_clrequest); } |
From: Markus H. <mho...@us...> - 2003-12-26 00:08:52
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv21928 Modified Files: dbfncs.c Log Message: added t_meta to GRANT statment; added t_note and t_xnote to my_dbi_conn_lock() Index: dbfncs.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -U2 -r1.12 -r1.13 --- dbfncs.c 24 Dec 2003 21:41:58 -0000 1.12 +++ dbfncs.c 26 Dec 2003 00:08:46 -0000 1.13 @@ -838,5 +838,5 @@ } - sprintf(buffer, "GRANT SELECT, INSERT, UPDATE, DELETE ON t_refdb, t_author, t_keyword, t_periodical, t_user, t_note, t_xauthor, t_xkeyword, t_xuser, t_xnote, t_refdb_refdb_id_seq, t_author_author_id_seq, t_keyword_keyword_id_seq, t_periodical_periodical_id_seq, t_user_user_id_seq, t_note_note_id_seq, t_xauthor_xauthor_id_seq, t_xkeyword_xkeyword_id_seq, t_xuser_xuser_id_seq, t_xnote_xnote_id_seq TO GROUP %suser", ptr_clrequest->argument); + sprintf(buffer, "GRANT SELECT, INSERT, UPDATE, DELETE ON t_meta, t_refdb, t_author, t_keyword, t_periodical, t_user, t_note, t_xauthor, t_xkeyword, t_xuser, t_xnote, t_refdb_refdb_id_seq, t_author_author_id_seq, t_keyword_keyword_id_seq, t_periodical_periodical_id_seq, t_user_user_id_seq, t_note_note_id_seq, t_xauthor_xauthor_id_seq, t_xkeyword_xkeyword_id_seq, t_xuser_xuser_id_seq, t_xnote_xnote_id_seq TO GROUP %suser", ptr_clrequest->argument); LOG_PRINT(LOG_DEBUG, buffer); @@ -1446,5 +1446,5 @@ return 1; } - sprintf(sql_command, "LOCK TABLES t_refdb WRITE, t_author WRITE, t_keyword WRITE, t_periodical WRITE, t_user WRITE, t_xauthor WRITE, t_xkeyword WRITE, t_xuser WRITE, %s.t_journal_words WRITE", MAIN_DB); + sprintf(sql_command, "LOCK TABLES t_refdb WRITE, t_author WRITE, t_keyword WRITE, t_periodical WRITE, t_user WRITE, t_xauthor WRITE, t_xkeyword WRITE, t_xuser WRITE, t_note WRITE, t_xnote WRITE, %s.t_journal_words WRITE", MAIN_DB); LOG_PRINT(LOG_DEBUG, sql_command); dbires = dbi_conn_query(conn, sql_command); @@ -1458,5 +1458,5 @@ int i; char sql_command[64]; - const char tables[8][13] = { + const char tables[10][13] = { "t_refdb", "t_author", @@ -1466,8 +1466,10 @@ "t_xauthor", "t_xkeyword", - "t_xuser" + "t_xuser", + "t_note", + "t_xnote" }; - for (i = 0; i < 8; i++) { + for (i = 0; i < 10; i++) { sprintf(sql_command, "LOCK TABLE %s IN SHARE MODE", tables[i]); dbires = dbi_conn_query(conn, sql_command); |
From: Markus H. <mho...@us...> - 2003-12-26 00:06:31
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv21653 Modified Files: backend.c Log Message: fixed noteunion vs. t_noteunion typos; removed erroneous t_note prefix from INSERT statements; failed INSERT into temp table cannot be treated as an error as dbires is NULL if the subselect returns zero hits Index: backend.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -U2 -r1.19 -r1.20 --- backend.c 24 Dec 2003 21:35:19 -0000 1.19 +++ backend.c 26 Dec 2003 00:06:28 -0000 1.20 @@ -331,5 +331,5 @@ if (!strcmp(drivername, "mysql")) { /* mysql */ - strcpy(sql_command, "CREATE TEMPORARY TABLE noteunion \ + strcpy(sql_command, "CREATE TEMPORARY TABLE t_noteunion \ (note_id INT, \ note_key VARCHAR(255), \ @@ -339,9 +339,9 @@ note_content_xmllang VARCHAR(255), \ note_user_id INT, \ - note_date DATE)"); + note_date DATETIME)"); } else if (!strcmp(drivername, "pgsql")) { /* pgsql */ - strcpy(sql_command, "CREATE TEMPORARY TABLE noteunion \ + strcpy(sql_command, "CREATE TEMPORARY TABLE t_noteunion \ (note_id BIGSERIAL, \ note_key VARCHAR(255) UNIQUE, \ @@ -387,5 +387,5 @@ if (mode & REFERENCE) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, t_note.note_content_type, t_note.note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xnote.xref_id=t_refdb.refdb_id AND t_xnote.xnote_type=\'REFERENCE\'", user, (unsigned long long)n_id); @@ -396,7 +396,7 @@ if (!dbires) { LOG_PRINT(LOG_WARNING, "insert into temporary table failed"); - free(sql_command); - free(sql_chunk); - return NULL; +/* free(sql_command); */ +/* free(sql_chunk); */ +/* return NULL; */ } } @@ -404,5 +404,5 @@ if (mode & KEYWORD) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, t_note.note_content_type, t_note.note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content FROM t_note,t_xnote, t_user, t_refdb, t_xkeyword, t_keyword WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xkeyword.keyword_id=t_keyword.keyword_id AND t_xkeyword.xref_id=t_refdb.refdb_id AND t_xnote.xref_id=t_keyword.keyword_id AND t_xnote.xnote_type=\'KEYWORD\'", user, (unsigned long long)n_id); @@ -413,7 +413,7 @@ if (!dbires) { LOG_PRINT(LOG_WARNING, "insert into temporary table failed"); - free(sql_command); - free(sql_chunk); - return NULL; +/* free(sql_command); */ +/* free(sql_chunk); */ +/* return NULL; */ } } @@ -421,5 +421,5 @@ if (mode & AUTHOR) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, t_note.note_content_type, t_note.note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_xauthor, t_author WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_xauthor.author_id=t_author.author_id AND t_xauthor.refdb_id=t_refdb.refdb_id AND t_xnote.xref_id=t_author.author_id AND t_xnote.xnote_type=\'AUTHOR\'", user, (unsigned long long)n_id); @@ -430,7 +430,7 @@ if (!dbires) { LOG_PRINT(LOG_WARNING, "insert into temporary table failed"); - free(sql_command); - free(sql_chunk); - return NULL; +/* free(sql_command); */ +/* free(sql_chunk); */ +/* return NULL; */ } } @@ -438,5 +438,5 @@ if (mode & PERIODICAL) { sprintf(sql_chunk, - "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, t_note.note_content_type, t_note.note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", + "INSERT INTO t_noteunion (note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang) SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_xnote, t_user, t_refdb, t_periodical WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND t_refdb.refdb_id="ULLSPEC" AND t_note.note_id=t_xnote.note_id AND t_refdb.refdb_periodical_id=t_periodical.periodical_id AND t_xnote.xref_id=t_periodical.periodical_id AND t_xnote.xnote_type=\'PERIODICAL\'", user, (unsigned long long)n_id); @@ -447,12 +447,12 @@ if (!dbires) { LOG_PRINT(LOG_WARNING, "insert into temporary table failed"); - free(sql_command); - free(sql_chunk); - return NULL; +/* free(sql_command); */ +/* free(sql_chunk); */ +/* return NULL; */ } } /* now retrieve the datasets again */ - sprintf(sql_command, "SELECT DISTINCT note_id, note_key, note_title, note_user_id, note_date, note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_noteunion"); + sprintf(sql_command, "SELECT DISTINCT note_id, note_key, note_title, note_user_id, note_date, note_content, note_content_type, note_content_xmllang FROM t_noteunion"); } @@ -462,9 +462,15 @@ LOG_PRINT(LOG_DEBUG, sql_command); dbires = dbi_conn_query(conn, sql_command); - free(sql_command); - if (!dbires) { - return NULL; - } + /* if (!dbires) { */ + /* begin weird hack */ +/* sprintf(sql_command, "SELECT refdb_id FROM t_refdb where refdb_id=-1"); */ +/* LOG_PRINT(LOG_DEBUG, sql_command); */ +/* dbires = dbi_conn_query(conn, sql_command); */ + /* end weird hack */ +/* return NULL; */ +/* } */ + + free(sql_command); return dbires; |
From: Markus H. <mho...@us...> - 2003-12-26 00:03:38
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv21276 Modified Files: backend-scrn.c Log Message: fixed item vs. citem typos; fixed ptr_rendinfo->dbires vs. orig_dbires typo Index: backend-scrn.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-scrn.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -U2 -r1.14 -r1.15 --- backend-scrn.c 25 Oct 2003 23:44:29 -0000 1.14 +++ backend-scrn.c 26 Dec 2003 00:03:34 -0000 1.15 @@ -579,5 +579,5 @@ || strstr((ptr_rendinfo->ptr_biblio_info)->format_string, "ALL") != NULL) { item = get_refdb_abstract_copy(ptr_rendinfo->dbires); - if (print_field_scrn(citem, ptr_rendinfo, "\nABSTRACT: ") == NULL) { + if (print_field_scrn(item, ptr_rendinfo, "\nABSTRACT: ") == NULL) { free(item); return NULL; @@ -591,5 +591,5 @@ || strstr((ptr_rendinfo->ptr_biblio_info)->format_string, "ALL") != NULL) { item = get_refdb_address_copy(ptr_rendinfo->dbires); - if (print_field_scrn(citem, ptr_rendinfo, "\nADDRESS: ") == NULL) { + if (print_field_scrn(item, ptr_rendinfo, "\nADDRESS: ") == NULL) { free(item); return NULL; @@ -842,5 +842,5 @@ } clean_request(dbires); - free_request_notes_by_ref(dbi_result_get_conn(ptr_rendinfo->dbires)); + free_request_notes_by_ref(dbi_result_get_conn(orig_dbires)); ptr_rendinfo->dbires = orig_dbires; } |
From: Michael S. <xm...@us...> - 2003-12-25 10:11:53
|
Update of /cvsroot/refdb/elisp In directory sc8-pr-cvs1:/tmp/cvs-serv16785 Modified Files: refdb-mode.el Log Message: RFE #864364 (output format) and #865638 (show version info) http://sourceforge.net/tracker/index.php?func=detail&aid=864364&group_id=26091&atid=385994 http://sourceforge.net/tracker/index.php?func=detail&aid=865638&group_id=26091&atid=385994 ---------------------------------------------------------------------- RFE #864364 - provide control over which fields appear in dataset output Enhancement: Added new functions refdb-select-data-output-format and refdb-select-additional-data-fields and corresponding new menu items 'Select Output Format' and 'Select Additional Data Fields'. Those control the value passed to the 'refdcbc -C getref -s' option, and so enable you to control which fields appear in data output -- either the default fields, all fields, IDs only, or a user-customizable set of additional fields that appear in addition to the default fields. ---------------------------------------------------------------------- RFE #865638 - Add "show version" feature Enhancement: Added new function refdb-show-version and corresponding menu item 'Show RefDB Version' for displaying version information both for refdb-mode and the version of refdbd that refdbd-mode is running against. Index: refdb-mode.el =================================================================== RCS file: /cvsroot/refdb/elisp/refdb-mode.el,v retrieving revision 1.4 retrieving revision 1.5 diff -u -U2 -r1.4 -r1.5 --- refdb-mode.el 17 Dec 2003 11:32:56 -0000 1.4 +++ refdb-mode.el 25 Dec 2003 10:11:49 -0000 1.5 @@ -32,8 +32,4 @@ ;; ------------------------------------------------------------------- -;;; Compatibility -;; ------------------------------------------------------------------- -;; -;; ------------------------------------------------------------------- ;;; Commentary ;;------------------------------------------------------------------- @@ -45,4 +41,22 @@ ;; ;; ------------------------------------------------------------------- +;;; Compatibility +;; ------------------------------------------------------------------- +;; `refdb-mode' has been tested and found to work with the Linux +;; (Debian), Cygwin/X-Windows, and MS Windows-native "NTEmacs" +;; versions of GNU Emacs 21.2 and 20.7. +;; +;; It has also been tested with OSX (Panther) using a build compiled +;; from current Emacs CVS source; some `refdb-mode' problems have been +;; seen with that OSX build that haven't been seen on other platforms. +;; +;; It has not been tested at all with Emacs 19 or with XEmacs, and +;; most likely will not work with those. +;; +;; Cygwin users need RefDB 0.9.4 or later in order to use the "addref" +;; feature (because releases prior to 0.9.4 cannot read from standard +;; input on Cygwin). +;; +;; ------------------------------------------------------------------- ;;; Installation and Configuration ;; ------------------------------------------------------------------- @@ -128,4 +142,5 @@ ;; ---- ;; Show RefDB Message Log +;; Show Version Information ;; Customize RefDB Mode ;; @@ -141,8 +156,8 @@ ;; passing parameters to 'refdbc -C getref'.) ;; -;; Select Output Type -;; Select the output type to use for data returned from RefDB -;; queries. (Passed as an argument to the -t option for the -;; 'refdbc -C getref' command.) +;; Customize Data Output +;; Select the output type and format to use for data returned from +;; RefDB queries (i.e., values passed as arguments to the -t and +;; -s options for the 'refdbc -C getref' command.) ;; ;; Select Database @@ -154,4 +169,7 @@ ;; commands. ;; +;; Show RefDB Version +;; Show refdb-mode and refdbd version information. +;; ;; Customize RefDB Mode ;; User-friendly interface for setting RefDB options and @@ -162,4 +180,5 @@ ;; ------------------------ ;; refdb-addref-on-region +; -- ;; refdb-getref-by-author ;; refdb-getref-by-title @@ -168,14 +187,16 @@ ;; refdb-getref-by-citekey ;; refdb-getref-by-advanced-search -;; refdb-select-output-type +;; -- +;; refdb-select-data-output-type +;; refdb-select-data-output-format +;; refdb-select-additional-data-fields +;; -- ;; refdb-select-database ;; refdb-show-messages +;; refdb-show-version ;; ;; ------------------------------------------------------------------- ;;; Bugs ;; ------------------------------------------------------------------- -;; Probably. Still needs more testing. Definitely seem to be some -;; compatibility issues on OS X (Panther), and maybe some problems -;; with interaction of RefDB commands on Cygwin. ;; ;; ------------------------------------------------------------------- @@ -224,4 +245,21 @@ ;; author names in its data cache. ;; +;; ------------------------------------------------------------------- +;;; Error Messages +;; ------------------------------------------------------------------- +;; "Could not set terminal attributes" +;; If a "Could not set terminal attributes" message appears in +;; the *refdb-output*, it's probably because you don't have a +;; password value set either in a RefDB client config file in +;; your $HOME directory (for example, your .refdbcrc file) or in +;; one of the global config files. +;; +;; "incorrect username" +;; This message means that refdbc or another RefDB client cannot +;; determine a valid username to use for interaction with the +;; RefDB server. Mostly likely, the cause is that you don't have +;; a username value set in a RefDB client config file either in +;; your $HOME directory (for example, your .refdbcrc file) or in +;; one of the global config files. ;; ;; ------------------------------------------------------------------- @@ -284,4 +322,9 @@ :group 'refdb) +(defcustom refdb-refdbd-program "refdbd" + "File name of the refdbd executable." + :type 'string + :group 'refdb) + (defcustom refdb-refdbc-program "refdbc" "File name of the refdbc executable." @@ -313,5 +356,5 @@ ) -(defcustom refdb-output-types +(defcustom refdb-data-output-types '( scrn @@ -329,4 +372,40 @@ :group 'refdb) +(defcustom refdb-data-output-formats + '( + default + more + ID + all + ) + "*List of supported data output formats for RefDB." + :type '(list symbol symbol symbol symbol) + :group 'refdb) + +(defcustom refdb-data-output-additional-fields + '(N1 N2 UR) + "*Use this to specify additional fields to display in Screen output." + :type '(set + (const :tag "Notes \(N1\)" N1) + (const :tag "Abstract \(N2\)" N2) + (const :tag "Reprint Status \(RP\)" RP) + (const :tag "City of Publication \(CY\)" CY) + (const :tag "Publisher \(PB\)" PB) + (const :tag "ISBN/ISSN \(SN\)" SN) + (const :tag "Contact Address \(AD\)" AD) + (const :tag "URL \(UR\)" UR) + (const :tag "User-Defined 1 \(U1\)" U1) + (const :tag "User-Defined 2 \(U2\)" U2) + (const :tag "User-Defined 3 \(U3\)" U3) + (const :tag "User-Defined 4 \(U4\)" U4) + (const :tag "User-Defined 5 \(U5\)" U5) + (const :tag "Miscellaneous 1 \(M1\)" M1) + (const :tag "Miscellaneous 2 \(M2\)" M2) + (const :tag "Miscellaneous 3 \(M3\)" M3) + (const :tag "Miscellaneous 4 \(M4\)" M4) + (const :tag "Miscellaneous 5 \(M5\)" M5) + ) + :group 'refdb) + ;; ******************************************************************* ;;; end of user-customizable options, part 1 @@ -366,5 +445,5 @@ ) -(defun refdb-select-output-type (outputtype) +(defun refdb-select-data-output-type (outputtype) "Set RefDB output type to OUTPUTTYPE. Note that OUTPUTTYPE is a symbol, not a string." @@ -373,5 +452,5 @@ (completing-read "Output Type: " - (refdb-make-alist-from-symbol-list refdb-output-types) + (refdb-make-alist-from-symbol-list refdb-data-output-types) nil t ) @@ -379,8 +458,49 @@ ) ) - (setq refdb-output-type outputtype) - (message (concat "Current output type is now " (symbol-name outputtype))) + (setq refdb-data-output-type outputtype) + (message "Current output type is now '%s'" (symbol-name outputtype)) ) +(defun refdb-select-data-output-format (format) + "Set dataset output to FORMAT. +Note that FORMAT is a symbol, not a string. + +Use this function to control the value that is passed to the +'refdcbc -C getref -s' option. + +Choose 'all' to display all fields (does not affect RIS output). +Choose 'ID' to display ID fields only (affects RIS output only). +Choose 'more' to display additional fields in non-RIS output. +Choose 'default' to display default fields only (in non-RIS output). +Use `refdb-select-additional-data-fields' to select which +additional (non-default) fields to display in non-RIS output." + (interactive + (list (intern + (completing-read + "Output Format: " + (refdb-make-alist-from-symbol-list refdb-data-output-formats) + nil t + ) + ) + ) + ) + (setq refdb-data-output-format format) + (message "Dataset output is now set to display %s fields." + (symbol-name format)) + (if (equal format 'more) + (setq refdb-data-output-formatstring + (format "\\\"%s\\\"" + ;; turn list of symbols into one big string + (mapconcat + 'symbol-name + refdb-data-output-additional-fields + " " + ) + ) + ) + (setq refdb-data-output-formatstring (upcase (symbol-name format))) + ) + ) + (defvar refdb-addref-menu-item ["Add References" (refdb-addref-on-region) t] @@ -430,50 +550,79 @@ ) -(defvar refdb-select-output-type-submenu-contents +(defvar refdb-select-data-output-type-submenu-contents (list "Select Output Type" ["Screen" - (refdb-select-output-type 'scrn) + (refdb-select-data-output-type 'scrn) :style toggle - :selected (eq refdb-output-type 'scrn)] + :selected (eq refdb-data-output-type 'scrn)] ["HTML" - (refdb-select-output-type 'html) + (refdb-select-data-output-type 'html) :style toggle - :selected (eq refdb-output-type 'html)] + :selected (eq refdb-data-output-type 'html)] ["XHTML" - (refdb-select-output-type 'xhtml) + (refdb-select-data-output-type 'xhtml) :style toggle - :selected (eq refdb-output-type 'xhtml)] + :selected (eq refdb-data-output-type 'xhtml)] ["DocBook SGML" - (refdb-select-output-type 'db31) + (refdb-select-data-output-type 'db31) :style toggle - :selected (eq refdb-output-type 'db31)] + :selected (eq refdb-data-output-type 'db31)] ["DocBook XML" - (refdb-select-output-type 'db31x) + (refdb-select-data-output-type 'db31x) :style toggle - :selected (eq refdb-output-type 'db31x) + :selected (eq refdb-data-output-type 'db31x) ] ["TEI XML" - (refdb-select-output-type 'teix) + (refdb-select-data-output-type 'teix) :style toggle - :selected (eq refdb-output-type 'teix) + :selected (eq refdb-data-output-type 'teix) ] ["BibTeX" - (refdb-select-output-type 'bibtex) + (refdb-select-data-output-type 'bibtex) :style toggle - :selected (eq refdb-output-type 'bibtex) + :selected (eq refdb-data-output-type 'bibtex) ] ["RIS" - (refdb-select-output-type 'ris) + (refdb-select-data-output-type 'ris) :style toggle - :selected (eq refdb-output-type 'ris) + :selected (eq refdb-data-output-type 'ris) ] ["RISX" - (refdb-select-output-type 'risx) + (refdb-select-data-output-type 'risx) :style toggle - :selected (eq refdb-output-type 'risx) + :selected (eq refdb-data-output-type 'risx) ] ) "RefDB 'Select Output Type' submenu. -FIXME: This probably should be generated from value of `refdb-output-types'." +FIXME: This probably should be generated from value of `refdb-data-output-types'." + ) + +(defvar refdb-select-data-output-format-submenu-contents + (list "Select Output Format" + ["Default" + (refdb-select-data-output-format 'default) + :style toggle + :selected (eq refdb-data-output-format 'default)] + ["IDs only" + (refdb-select-data-output-format 'ID) + :style toggle + :selected (eq refdb-data-output-format 'ID)] + ["More (additional) fields" + (refdb-select-data-output-format 'more) + :style toggle + :selected (eq refdb-data-output-format 'more)] + ["All fields" + (refdb-select-data-output-format 'all) + :style toggle + :selected (eq refdb-data-output-format 'all)] + ) + "RefDB 'Select Output Format' submenu. +FIXME: This probably should be generated from value of `refdb-data-output-formats'." + ) + +(defvar refdb-select-additional-data-fields-menu-item + ["Select Additional Data Fields..." + (refdb-select-additional-data-fields) t] + "RefDB 'Select Additional Data Fields' menu item." ) @@ -484,4 +633,35 @@ ) +(defun refdb-show-version () + "Show `redb-mode' and refdbd version." + (interactive) + (message + "refdb-mode %s running against refdbd %s" + (car + (cdr + (split-string "$Revision$") + ) + ) + (car + (cdr (split-string + (with-output-to-string + (with-current-buffer + standard-output + (call-process + shell-file-name nil '(t nil) nil shell-command-switch + (format "%s -version" + refdb-refdbd-program + ) + ) + ) + ) + ) + ) + ) + ) + ) + +(setq refdb-refdbd-program "refdbd") + (defun refdb-determine-input-type () "Set RefDB output type according to user prefs. @@ -570,42 +750,62 @@ You shouldn't call this function directly. Instead call, e.g., `refdb-getref-by-author'." - (if (not (eq (length refdb-database) 0)) - (progn + ;; temporarily set resize-mini-windows to nil to force Emacs to show + ;; output in separate buffer instead of minibuffer + (setq resize-mini-windows-default resize-mini-windows) + (setq resize-mini-windows nil) + (let ((formatstring + (if (equal refdb-data-output-format 'more) + (format "\\\"%s\\\"" + ;; turn list of symbols into one big string + (mapconcat + 'symbol-name + refdb-data-output-additional-fields + " " + ) + ) + (upcase (symbol-name refdb-data-output-format)) + ) + )) + (if (not (eq (length refdb-database) 0)) (shell-command (format - "%s %s -C getref %s -d %s -t %s :%s:=%s" + "%s %s -C getref :%s:=%s %s -d %s -t %s -s %s" refdb-refdbc-program refdb-refdbc-options - refdb-getref-options - refdb-database - refdb-output-type field value + refdb-getref-options + refdb-database + refdb-data-output-type + formatstring ) "*refdb-output*" "*refdb-messages*") - + ;; else if no db specified, prompt to select from available dbs and + ;; then call `refdb-getref-by-field' with same values + (progn + (call-interactively 'refdb-select-database) + (refdb-getref-by-field field value) ) - ;; else if no db specified, prompt to select from available dbs and - ;; then call `refdb-getref-by-field' with same values - (progn - (call-interactively 'refdb-select-database) - (refdb-getref-by-field field value) ) + (message + (format + "Displaying output for '%s %s -C getref :%s:=%s %s -d %s -t %s -s %s'" + refdb-refdbc-program + refdb-refdbc-options + field + value + refdb-getref-options + refdb-database + refdb-data-output-type + formatstring + ) + ) + (pop-to-buffer "*refdb-output*") + (if (not refdb-split-for-getref-output-flag) + (delete-other-windows) + ) + (refdb-output-buffer-choose-mode) + (setq resize-mini-windows resize-mini-windows-default) ) - (message - "Displaying output for '%s %s -C getref %s -d %s -t %s :%s:=%s'" - refdb-refdbc-program - refdb-refdbc-options - refdb-getref-options - refdb-database - refdb-output-type - field - value - ) - (pop-to-buffer "*refdb-output*") - (if (not refdb-split-for-getref-output-flag) - (delete-other-windows) - ) - (refdb-output-buffer-choose-mode) ) @@ -613,9 +813,9 @@ "Choose appropriate major mode for RefDB output buffer." (if (or - (eq refdb-output-type 'db31) - (eq refdb-output-type 'db31x) - (eq refdb-output-type 'teix) - (eq refdb-output-type 'risx) - (eq refdb-output-type 'xhtml) + (eq refdb-data-output-type 'db31) + (eq refdb-data-output-type 'db31x) + (eq refdb-data-output-type 'teix) + (eq refdb-data-output-type 'risx) + (eq refdb-data-output-type 'xhtml) ) (if (functionp 'nxml-mode) @@ -627,6 +827,6 @@ (if (and (or - (eq refdb-output-type 'db31) - (eq refdb-output-type 'html) + (eq refdb-data-output-type 'db31) + (eq refdb-data-output-type 'html) ) (functionp 'sgml-mode) @@ -635,10 +835,10 @@ ) (if (and - (eq refdb-output-type 'ris) + (eq refdb-data-output-type 'ris) (functionp 'ris-mode) ) (ris-mode) ) - (if (eq refdb-output-type 'bibtex) + (if (eq refdb-data-output-type 'bibtex) (bibtex-mode) ) @@ -684,36 +884,62 @@ "Display all RefDB datasets matching SEARCHSTRING." (interactive "sSearch string: ") - (refdb-message-getting-refs 'searchstring searchstring) - (if (not (eq (length refdb-database) 0)) - (progn - (shell-command - (format - "%s %s -C getref %s -d %s -t %s %s" - refdb-refdbc-program - refdb-refdbc-options - refdb-getref-options - refdb-database - refdb-output-type - searchstring - ) - "*refdb-output*" nil) + (setq resize-mini-windows-default resize-mini-windows) + (setq resize-mini-windows nil) + (let ((formatstring + (if (equal refdb-data-output-format 'more) + (format "\\\"%s\\\"" + ;; turn list of symbols into one big string + (mapconcat + 'symbol-name + refdb-data-output-additional-fields + " " + ) + ) + (upcase (symbol-name refdb-data-output-format)) + ) + )) + (message (format "Getting datasets for search string %s ..." searchstring)) + (if (not (eq (length refdb-database) 0)) + (progn + (shell-command + (format + "%s %s -C getref %s %s -d %s -t %s -s %s" + refdb-refdbc-program + refdb-refdbc-options + searchstring + refdb-getref-options + refdb-database + refdb-data-output-type + formatstring + ) + "*refdb-output*" "*refdb-messages*") + ) + ;; else if no db specified, prompt to select from available dbs and + ;; then call `refdb-getref-by-field' with same values + (progn + (call-interactively 'refdb-select-database) + (refdb-getref-by-advanced-search searchstring) ) - ;; else if no db specified, prompt to select from available dbs and - ;; then call `refdb-getref-by-field' with same values - (progn - (call-interactively 'refdb-select-database) - (refdb-getref-by-field field value) ) + (message + (format + "Displaying output for '%s %s -C getref %s %s -d %s -t %s -s %s'" + refdb-refdbc-program + refdb-refdbc-options + searchstring + refdb-getref-options + refdb-database + refdb-data-output-type + formatstring + ) + ) + (pop-to-buffer "*refdb-output*") + (if (not refdb-split-for-getref-output-flag) + (delete-other-windows) + ) + (refdb-output-buffer-choose-mode) + (setq resize-mini-windows resize-mini-windows-default) ) - (message - "Displaying output for '%s %s -C getref %s -d %s -t %s %s" - refdb-refdbc-program - refdb-refdbc-options - refdb-getref-options - refdb-database - refdb-output-type - searchstring - ) ) @@ -751,4 +977,9 @@ ) +(defun refdb-select-additional-data-fields () + "Choose additional data fields to display in Screen output." + (customize-variable 'refdb-data-output-additional-fields) + ) + (easy-mmode-define-minor-mode refdb-mode @@ -784,6 +1015,12 @@ ) +(defvar refdb-show-version-menu-item + ["Show Version Information" + (refdb-show-version) t] + "RefDB menu item for showing RefDB Mode version." + ) + (defvar refdb-customize-menu-item - ["Customize RefDB Menu..." + ["Customize RefDB Mode..." (customize-group 'refdb) t] "Customize submenu for command `refdb-mode'." @@ -845,5 +1082,5 @@ ) -(defcustom refdb-split-for-getref-output-flag t +(defcustom refdb-split-for-getref-output-flag nil "*Non-nil means split window for 'Get References' output. If nil \(off\), show 'Get References' output window at full @@ -853,71 +1090,104 @@ :group 'refdb) - (defcustom refdb-output-type 'scrn - "*Specifies the default output type. +(defcustom refdb-data-output-type 'ris + "*Specifies the default output type. Passed to the 'refdbc -C getref' command as the argument for the -t -option. FIXME: Should be generated from output-types list." - :type '(choice (const :tag "Screen " scrn) - (const :tag "HTML " html) - (const :tag "XHTML " xhtml) - (const :tag "DocBook SGML" db31) - (const :tag "DocBook XML " db31x) - (const :tag "TEX XML " teix) - (const :tag "BibTeX " bibtex) - (const :tag "RIS " ris) - (const :tag "RISX " risx) - ) - :group 'refdb - ) +option. FIXME: Should be generated from output-types list." + :type '(choice (const :tag "Screen " scrn) + (const :tag "HTML " html) + (const :tag "XHTML " xhtml) + (const :tag "DocBook SGML" db31) + (const :tag "DocBook XML " db31x) + (const :tag "TEX XML " teix) + (const :tag "BibTeX " bibtex) + (const :tag "RIS " ris) + (const :tag "RISX " risx) + ) + :group 'refdb + ) - (defcustom refdb-getref-submenu-contents - '( - refdb-getref-by-author-menu-item - refdb-getref-by-title-menu-item - refdb-getref-by-keyword-menu-item - refdb-getref-by-id-menu-item - refdb-getref-by-citekey-menu-item - refdb-getref-by-advanced-search-menu-item - ) - "*Contents of 'Get References' submenu for RefDB mode. -Customize this to add/remove/rearrange submenus." - :set (lambda (sym val) - (setq refdb-getref-submenu-contents val) - (setq refdb-getref-submenu-definition - (cons "Get References" - ;; turn quoted contents value back into a real list - ;; thanks, sachac :) - (mapcar (lambda (item) (if (symbolp item) (eval item) item)) val) - ) +(defcustom refdb-data-output-format 'default + "*Specifies the default output type. +Passed to the 'refdbc -C getref' command as the argument for the -t +option. FIXME: Should be generated from output-formats list." + :type '(choice (const :tag "Default " default) + (const :tag "All fields " all) + (const :tag "IDs only " ID) + (const :tag "Additional fields" more) ) - ) - :group 'refdb - :type '(repeat variable) - ) + :group 'refdb + ) - (defcustom refdb-menu-contents - '( - refdb-addref-menu-item - refdb-getref-submenu-definition - refdb-select-output-type-submenu-contents - refdb-selectdb-submenu-contents - refdb-menu-item-separator4 - refdb-show-messages-menu-item - refdb-customize-menu-item - ) - "*Contents of command `refdb-mode' menu. +(defcustom refdb-data-output-submenu-contents + '( + refdb-select-data-output-type-submenu-contents + refdb-select-data-output-format-submenu-contents + refdb-select-additional-data-fields-menu-item + ) + "*Contents of 'Customize Data Output' submenu for RefDB mode. Customize this to add/remove/rearrange submenus." - :set (lambda (sym val) - (setq refdb-menu-contents val) - (setq refdb-menu-definition - (cons "RefDB" - (mapcar (lambda (item) (if (symbolp item) (eval item) item)) val) - ) - ) - ) - :group 'refdb - :type '(repeat variable) + :set (lambda (sym val) + (setq refdb-data-output-submenu-contents val) + (setq refdb-data-output-submenu-definition + (cons "Customize Data Output" + ;; turn quoted contents value back into a real list + (mapcar (lambda (item) (if (symbolp item) (eval item) item)) val) + ) + ) + ) + :group 'refdb + :type '(repeat variable) + ) + +(defcustom refdb-getref-submenu-contents + '( + refdb-getref-by-author-menu-item + refdb-getref-by-title-menu-item + refdb-getref-by-keyword-menu-item + refdb-getref-by-id-menu-item + refdb-getref-by-citekey-menu-item + refdb-getref-by-advanced-search-menu-item ) + "*Contents of 'Get References' submenu for RefDB mode. +Customize this to add/remove/rearrange submenus." + :set (lambda (sym val) + (setq refdb-getref-submenu-contents val) + (setq refdb-getref-submenu-definition + (cons "Get References" + ;; turn quoted contents value back into a real list + ;; thanks, sachac :) + (mapcar (lambda (item) (if (symbolp item) (eval item) item)) val) + ) + ) + ) + :group 'refdb + :type '(repeat variable) + ) +(defcustom refdb-menu-contents + '( + refdb-addref-menu-item + refdb-getref-submenu-definition + refdb-data-output-submenu-definition + refdb-selectdb-submenu-contents + refdb-menu-item-separator4 + refdb-show-messages-menu-item + refdb-show-version-menu-item + refdb-customize-menu-item + ) + "*Contents of command `refdb-mode' menu. +Customize this to add/remove/rearrange submenus." + :set (lambda (sym val) + (setq refdb-menu-contents val) + (setq refdb-menu-definition + (cons "RefDB" + (mapcar (lambda (item) (if (symbolp item) (eval item) item)) val) + ) + ) + ) + :group 'refdb + :type '(repeat variable) ) +) ;; ******************************************************************* ;;; end of user-customizable options, part 2 |
From: Markus H. <mho...@us...> - 2003-12-24 21:59:51
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv29310 Modified Files: risdb.c Log Message: fixed checks of remove_xnote_entries() return value Index: risdb.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/risdb.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -U2 -r1.33 -r1.34 --- risdb.c 17 Dec 2003 00:15:27 -0000 1.33 +++ risdb.c 24 Dec 2003 21:59:48 -0000 1.34 @@ -2819,5 +2819,5 @@ result = remove_xnote_entries(n_keyword_id, conn, 2 /*keyword*/); - if (result > 0 && result < 4) { + if (result != 0 && result != 4) { dbi_result_free(dbires1); dbi_result_free(dbires); @@ -2909,5 +2909,5 @@ result = remove_xnote_entries(n_author_id, conn, 1 /*author*/); - if (result) { + if (result != 0 && result != 4) { dbi_result_free(dbires1); dbi_result_free(dbires); @@ -3060,5 +3060,5 @@ result = remove_xnote_entries(n_periodical_id, conn, 3 /*periodical*/); - if (result) { + if (result != 0 && result != 4) { dbi_result_free(dbires); return 4; |
From: Markus H. <mho...@us...> - 2003-12-24 21:58:32
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv29185 Modified Files: refdbd.h.in Log Message: added update_meta(); added skipped to struct DELRESULT Index: refdbd.h.in =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -U2 -r1.2 -r1.3 --- refdbd.h.in 17 Dec 2003 00:12:00 -0000 1.2 +++ refdbd.h.in 24 Dec 2003 21:58:28 -0000 1.3 @@ -39,4 +39,5 @@ unsigned long long success; /* number of successfully deleted references */ unsigned long long failure; /* number of failures */ + unsigned long long skipped; /* number of skipped references */ }; @@ -129,4 +130,5 @@ int initialize_client_request(struct CLIENT_REQUEST* ptr_clrequest); int free_client_request(struct CLIENT_REQUEST* ptr_clrequest); +int update_meta(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); |
From: Markus H. <mho...@us...> - 2003-12-24 21:58:09
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv29094 Modified Files: refdbdref.c Log Message: new function update_meta(); extended whichdb() output; added hooks for update_meta() in all functions that modify databases Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -U2 -r1.41 -r1.42 --- refdbdref.c 21 Dec 2003 23:14:08 -0000 1.41 +++ refdbdref.c 24 Dec 2003 21:58:05 -0000 1.42 @@ -60,8 +60,46 @@ /* forward declaration of local functions */ static unsigned long long read_ris_data(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, dbi_conn conn, dbi_conn conn_refdb, int replace_ref, int n_keep_id, const char* the_user, Lilid* ptr_sentinel); -static int real_run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode); +static int real_run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode, int* ptr_insert); /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + update_meta(): updates the meta information in a reference database + + int update_meta returns 1 if failed, 0 if successful + + dbi_conn conn connection to a database + + struct CLIENT_REQUEST* ptr_clrequest ptr to structure with client info + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +int update_meta(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest) { + dbi_result dbires; + char date_buffer[24]; + char sql_command[128]; + time_t the_time; + + time(&the_time); + strftime(date_buffer, 24, "%F %T", gmtime(&the_time)); + + if (!strcmp(my_dbi_conn_get_cap(conn, "multiple_db"), "f")) { + sprintf(sql_command, "UPDATE t_meta SET meta_modify_date='%s'", date_buffer); + } + else { + sprintf(sql_command, "UPDATE %s.t_meta SET meta_modify_date='%s'", ptr_clrequest->current_db, date_buffer); + } + + LOG_PRINT(LOG_DEBUG, sql_command); + + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + /* treat as non-critical */ + LOG_PRINT(LOG_WARNING, "updating t_meta failed"); + return 1; + } + + return 0; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ whichdb(): implements the client command whichdb @@ -75,4 +113,6 @@ dbi_result dbires; dbi_error_flag errflag; + char create_date[64]; + char modify_date[64]; char* return_msg; unsigned long long numrefs; @@ -83,7 +123,8 @@ int numbyte; int error; + time_t the_time; /* get some memory for a return message */ - return_msg = (char*)malloc((size_t)256); + return_msg = (char*)malloc((size_t)512); if (return_msg == NULL) { iwrite(ptr_clrequest->fd, negative.text, negative.length); @@ -142,6 +183,52 @@ dbi_result_free(dbires); + dbires = dbi_conn_query(conn, "SELECT meta_app,meta_type,meta_version,meta_create_date,meta_modify_date FROM t_meta"); + if (!dbires) { + iwrite(ptr_clrequest->fd, "cannot get meta info\n", 21); + dbi_conn_close(conn); + free(return_msg); + LOG_PRINT(LOG_WARNING, "Cannot get meta info"); + return 0; + } + + if (!dbi_result_next_row(dbires)) { + iwrite(ptr_clrequest->fd, "whichdb failed\n", 15); + dbi_result_free(dbires); + dbi_conn_close(conn); + LOG_PRINT(LOG_WARNING, "whichdb query error"); + free(return_msg); + return 0; + } + + the_time = dbi_result_get_datetime(dbires, "meta_create_date"); + if (dbi_conn_error_flag(conn) == 0) { + if (the_time) { + strftime(create_date, 64, "%F %T", gmtime(&the_time)); + } + else { + strcpy(create_date, "nd"); + } + } + else { + strcpy(create_date, "nd"); + } + + the_time = dbi_result_get_datetime(dbires, "meta_modify_date"); + if (dbi_conn_error_flag(conn) == 0) { + if (the_time) { + strftime(modify_date, 64, "%F %T", gmtime(&the_time)); + } + else { + strcpy(modify_date, "nd"); + } + } + else { + strcpy(modify_date, "nd"); + } + /* The returned integers are quads (8byte) */ - sprintf(return_msg, "Current database: %s\nNumber of references: "ULLSPEC"\nHighest reference ID: "ULLSPEC"\nNumber of notes: "ULLSPEC"\nHighest note ID: "ULLSPEC"\n", ptr_clrequest->current_db, (unsigned long long)numrefs, (unsigned long long)maxid, (unsigned long long)numnotes, (unsigned long long)maxnid); + sprintf(return_msg, "Current database: %s\nNumber of references: "ULLSPEC"\nHighest reference ID: "ULLSPEC"\nNumber of notes: "ULLSPEC"\nHighest note ID: "ULLSPEC"\nDatabase type: %s\nCreated: %s UTC\nUsing %s version: %s\nLast modified: %s UTC\n", ptr_clrequest->current_db, (unsigned long long)numrefs, (unsigned long long)maxid, (unsigned long long)numnotes, (unsigned long long)maxnid, dbi_result_get_string(dbires, "meta_type"), create_date, dbi_result_get_string(dbires, "meta_app"), dbi_result_get_string(dbires, "meta_version"), modify_date); + + dbi_result_free(dbires); numbyte = iwrite(ptr_clrequest->fd, return_msg, strlen(return_msg)); @@ -364,4 +451,9 @@ Finish: + if (ptr_addresult->success || ptr_addresult->updated) { + /* database was changed, update meta info */ + update_meta(conn, ptr_clrequest); + } + if (conn_refdb) { dbi_conn_close(conn_refdb); @@ -536,18 +628,34 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ int run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode) { + int retval; + int n_insert = 0; /* number of inserts that actually ran */ + dbi_conn conn; + if (!mode) { /* check only references */ - return real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 0); + retval = real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 0, &n_insert); } else if (mode == 1) { /* check only notes */ - return real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 1); + retval = real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 1, &n_insert); } else { /* check both references and notes */ - if (real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 0)) { - return 1; + retval = real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 0, &n_insert); + + if (!retval) { + retval = real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 1, &n_insert); } - else { - return real_run_keyword_scan(ptr_clrequest, ptr_sentinel, 1); + } + + if (n_insert) { + /* connect to database server*/ + if ((conn = connect_to_db(ptr_clrequest, NULL)) == NULL) { + LOG_PRINT(LOG_ERR, connerr.text); + return 1; } + update_meta(conn, ptr_clrequest); + + dbi_conn_close(conn); } + + return retval; } @@ -564,6 +672,9 @@ int mode 0 = reference entries 1 = note entries + + int* ptr_insert ptr to insert counter + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -static int real_run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode) { +static int real_run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode, int* ptr_insert) { int i; unsigned long long keyword_id; @@ -720,4 +831,6 @@ return 1; } + *ptr_insert++; + dbi_result_free(dbires2); @@ -767,8 +880,10 @@ dbi_result dbires1; dbi_result dbires2; + dbi_result dbires_user; int i; int numbyte; /* number of bytes written */ int error; int result; + int retval = 1; unsigned long long n_periodical_id; unsigned long long n_id; @@ -858,4 +973,5 @@ ptr_delresult->success = 0; ptr_delresult->failure = 0; + ptr_delresult->skipped = 0; /* The general procedure to remove a reference is as follows: Remove @@ -875,8 +991,6 @@ LOG_PRINT(LOG_WARNING, "begin transaction failed"); iwrite(ptr_clrequest->fd, "begin transaction failed\n", 25); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -889,8 +1003,60 @@ iwrite(ptr_clrequest->fd, "cannot lock tables", 18); LOG_PRINT(LOG_WARNING, "Cannot lock tables"); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; + } + + sprintf(sql_command, "SELECT refdb_id FROM t_refdb WHERE refdb_type != \"DUMMY\" AND refdb_id="ULLSPEC, (unsigned long long)(ptr_curr->value)); + LOG_PRINT(LOG_DEBUG, sql_command); + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + if (ptr_clrequest->n_cgi) { + iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); + } + iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + LOG_PRINT(LOG_WARNING, "query error"); + retval = 0; + goto Finish; + } + + if (dbi_result_get_numrows(dbires) == 0) { + /* ID does not exist - nothing to do */ + sprintf(sql_command, "ID "ULLSPEC" not found\n", (unsigned long long)(ptr_curr->value)); + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + dbi_result_free(dbires); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + ptr_delresult->skipped++; + continue; + } + + dbi_result_free(dbires); + + sprintf(sql_command, "SELECT user_id, xuser_id FROM t_xuser WHERE refdb_id="ULLSPEC, (unsigned long long)(ptr_curr->value)); + LOG_PRINT(LOG_DEBUG, sql_command); + dbires_user = dbi_conn_query(conn, sql_command); + if (!dbires_user) { + if (ptr_clrequest->n_cgi) { + iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); + } + iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + LOG_PRINT(LOG_WARNING, "query error"); + retval = 0; + goto Finish; + } + + if (dbi_result_get_numrows(dbires_user) > 1) { + /* dataset is used by at least one other user, refuse to delete it */ + sprintf(sql_command, "ID "ULLSPEC" is still in use\n", (unsigned long long)(ptr_curr->value)); + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + dbi_result_free(dbires_user); + ptr_delresult->skipped++; + continue; } @@ -905,11 +1071,10 @@ } iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -919,8 +1084,10 @@ } iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); + dbi_result_free(dbires_user); + dbi_result_free(dbires); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_result_free(dbires); LOG_PRINT(LOG_INFO, "ID requested for delete not found"); + ptr_delresult->skipped++; continue; /* try next ID, this one most likely does not exist */ } @@ -951,10 +1118,9 @@ iwrite(ptr_clrequest->fd, "delete from t_xkeyword failed\n", 30); } - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } @@ -975,10 +1141,9 @@ iwrite(ptr_clrequest->fd, "delete from t_xauthor failed\n", 29); } - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } @@ -987,5 +1152,5 @@ result = remove_xnote_entries(ptr_curr->value, conn, 0 /*ref*/); - if (result) { + if (result != 0 && result != 4) { if (ptr_clrequest->n_cgi) { iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); @@ -997,10 +1162,9 @@ iwrite(ptr_clrequest->fd, "delete from t_xnote failed\n", 27); } - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } @@ -1015,10 +1179,9 @@ } iwrite(ptr_clrequest->fd, "remove periodical failed\n", 25); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - return 0; + retval = 0; + goto Finish; } } @@ -1038,35 +1201,17 @@ } iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires); - /* search orphans in t_user */ - sprintf(sql_command, "SELECT user_id, xuser_id FROM t_xuser WHERE refdb_id="ULLSPEC, (unsigned long long)(ptr_curr->value)); - LOG_PRINT(LOG_DEBUG, sql_command); - dbires = dbi_conn_query(conn, sql_command); - if (!dbires) { - if (ptr_clrequest->n_cgi) { - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } - iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); - my_dbi_conn_unlock(conn); - my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; - } - - while (dbi_result_next_row(dbires)) { - n_id = my_dbi_result_get_idval(dbires, "user_id"); - n_xid = my_dbi_result_get_idval(dbires, "xuser_id"); + /* search orphans in t_user. The query returning dbires_user ran above */ + while (dbi_result_next_row(dbires_user)) { + n_id = my_dbi_result_get_idval(dbires_user, "user_id"); + n_xid = my_dbi_result_get_idval(dbires_user, "xuser_id"); sprintf(sql_command, "SELECT xuser_id FROM t_xuser WHERE user_id="ULLSPEC, (unsigned long long)n_id); LOG_PRINT(LOG_DEBUG, sql_command); @@ -1077,12 +1222,10 @@ } iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); - dbi_result_free(dbires); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -1100,12 +1243,10 @@ iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); dbi_result_free(dbires1); - dbi_result_free(dbires); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires2); @@ -1122,12 +1263,10 @@ iwrite(ptr_clrequest->fd, "deleteref failed\n", 17); dbi_result_free(dbires1); - dbi_result_free(dbires); + dbi_result_free(dbires_user); my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires2); @@ -1135,5 +1274,5 @@ } - dbi_result_free(dbires); + dbi_result_free(dbires_user); ptr_delresult->success++; @@ -1147,9 +1286,14 @@ } /* end for */ + Finish: + if (conn && ptr_delresult->success) { + update_meta(conn, ptr_clrequest); + } + dbi_conn_close(conn); delete_all_lilid(&id_sentinel); delete_all_lilimem(&sentinel); - return 1; + return retval; } @@ -1177,4 +1321,5 @@ int numbyte; /* number of bytes written */ int n_bufsize; + int retval = 1; unsigned long long n_id; unsigned long long num_entries; @@ -1275,4 +1420,5 @@ ptr_delresult->success = 0; ptr_delresult->failure = 0; + ptr_delresult->skipped = 0; /* The general procedure to pick a reference is: @@ -1291,8 +1437,6 @@ LOG_PRINT(LOG_WARNING, "begin transaction failed"); iwrite(ptr_clrequest->fd, "begin transaction failed\n", 25); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -1305,8 +1449,6 @@ iwrite(ptr_clrequest->fd, "cannot lock tables", 18); LOG_PRINT(LOG_WARNING, "Cannot lock tables"); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; + retval = 0; + goto Finish; } @@ -1324,9 +1466,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } @@ -1340,8 +1480,5 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 1; + goto Finish; } /* create an entry for the current user in t_user */ @@ -1359,9 +1496,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } /* retrieve the generated user_id in t_user */ @@ -1383,9 +1518,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "driver not supported"); - return 0; + retval = 0; + goto Finish; } @@ -1405,9 +1538,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } } @@ -1441,9 +1572,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_CRIT, outomem.text); - return 0; + retval = 0; + goto Finish; } else { @@ -1458,9 +1587,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_CRIT, outomem.text); - return 0; + retval = 0; + goto Finish; } else { @@ -1478,9 +1605,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } @@ -1517,9 +1642,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_CRIT, outomem.text); - return 0; + retval = 0; + goto Finish; } else { @@ -1534,9 +1657,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_CRIT, outomem.text); - return 0; + retval = 0; + goto Finish; } else { @@ -1554,9 +1675,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } @@ -1581,9 +1700,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } @@ -1607,9 +1724,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref query error"); - return 0; + retval = 0; + goto Finish; } } @@ -1644,9 +1759,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } else { @@ -1661,9 +1774,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } else { @@ -1681,9 +1792,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } @@ -1727,9 +1836,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } else { @@ -1747,9 +1854,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } @@ -1792,9 +1897,7 @@ my_dbi_conn_unlock(conn); my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); LOG_PRINT(LOG_WARNING, "pickref failed"); - return 0; + retval = 0; + goto Finish; } dbi_result_free(dbires); @@ -1821,7 +1924,13 @@ } } - + my_dbi_conn_unlock(conn); my_dbi_conn_commit(conn); + + Finish: + if (conn && ptr_delresult->success) { + update_meta(conn, ptr_clrequest); + } + dbi_conn_close(conn); delete_all_lilid(&id_sentinel); |
From: Markus H. <mho...@us...> - 2003-12-24 21:52:17
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv27022 Modified Files: refdbdnote.c Log Message: check existence of note before deleting; only owner may delete note; getnote now allows to search for links to authors, keywords etc Index: refdbdnote.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdnote.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -U2 -r1.7 -r1.8 --- refdbdnote.c 21 Dec 2003 23:12:36 -0000 1.7 +++ refdbdnote.c 24 Dec 2003 21:52:08 -0000 1.8 @@ -242,4 +242,5 @@ char periodical_id[32]; /* will hold the ID until used */ char* id_list; + const char* owner; const char* drivername; struct lilimem sentinel; @@ -309,4 +310,5 @@ ptr_delresult->success = 0; ptr_delresult->failure = 0; + ptr_delresult->skipped = 0; /* The general procedure to remove a note is as follows: Remove @@ -343,4 +345,78 @@ } + sprintf(sql_command, "SELECT note_id FROM t_note WHERE note_id="ULLSPEC, ptr_curr->value); + + LOG_PRINT(LOG_DEBUG, sql_command); + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + iwrite(ptr_clrequest->fd, "deletenote failed\n", 18); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + dbi_conn_close(conn); + LOG_PRINT(LOG_WARNING, "query error"); + delete_all_lilid(&id_sentinel); + delete_all_lilimem(&sentinel); + return 0; + } + + if (dbi_result_get_numrows(dbires) == 0) { + ptr_delresult->skipped++; + dbi_result_free(dbires); + my_dbi_conn_unlock(conn); + my_dbi_conn_commit(conn); + + if (!ptr_clrequest->n_cgi) { + /* send message to client, reuse sql_command */ + sprintf(sql_command, "NID "ULLSPEC" not found\n", (unsigned long long)(ptr_curr->value)); + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + } + continue; + } + + dbi_result_free(dbires); + + /* get user id and name */ + owner = NULL; + + sprintf(sql_command, "SELECT note_user_id, user_name FROM t_note,t_user WHERE t_note.note_user_id=t_user.user_id AND note_id="ULLSPEC, ptr_curr->value); + + LOG_PRINT(LOG_DEBUG, sql_command); + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + iwrite(ptr_clrequest->fd, "deletenote failed\n", 18); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + dbi_conn_close(conn); + LOG_PRINT(LOG_WARNING, "query error"); + delete_all_lilid(&id_sentinel); + delete_all_lilimem(&sentinel); + return 0; + } + else if (dbi_result_next_row(dbires) != 0){ + n_user_id = my_dbi_result_get_idval_idx(dbires, 1); + owner = dbi_result_get_string_idx(dbires, 2); + } + else { + n_user_id = 0; + } + + if (owner && *owner) { + if (strcmp(owner, ptr_clrequest->username)) { + /* only owner can delete this note */ + ptr_delresult->skipped++; + my_dbi_conn_unlock(conn); + my_dbi_conn_commit(conn); + + if (!ptr_clrequest->n_cgi) { + /* send message to client, reuse sql_command */ + sprintf(sql_command, "Only the owner %s can remove ID "ULLSPEC"\n", owner, (unsigned long long)(ptr_curr->value)); + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + } + continue; + } + } + + dbi_result_free(dbires); + /* search orphans in t_keyword */ result = remove_keyword_entries(ptr_curr->value, conn, 1); @@ -383,28 +459,4 @@ } - /* get user id */ - sprintf(sql_command, "SELECT note_user_id from t_note WHERE note_id="ULLSPEC, ptr_curr->value); - - LOG_PRINT(LOG_DEBUG, sql_command); - dbires = dbi_conn_query(conn, sql_command); - if (!dbires) { - iwrite(ptr_clrequest->fd, "deletenote failed\n", 18); - my_dbi_conn_unlock(conn); - my_dbi_conn_rollback(conn); - dbi_conn_close(conn); - LOG_PRINT(LOG_WARNING, "query error"); - delete_all_lilid(&id_sentinel); - delete_all_lilimem(&sentinel); - return 0; - } - else if (dbi_result_next_row(dbires) != 0){ - n_user_id = my_dbi_result_get_idval_idx(dbires, 1); - } - else { - n_user_id = 0; - } - - dbi_result_free(dbires); - /* delete entry in main table */ sprintf(sql_command, "DELETE FROM t_note WHERE note_id="ULLSPEC, ptr_curr->value); @@ -473,5 +525,5 @@ my_dbi_conn_unlock(conn); my_dbi_conn_commit(conn); - } /* end for */ + } /* end while */ dbi_conn_close(conn); @@ -663,5 +715,5 @@ else { /*----------------------------------------------------------------*/ - /* keyword */ + /* keywords of note datasets */ if (strncmp(token, ":NKW:", 5) == 0) { /* keyword query */ strncpy(operator, &token[5], sqltoken.length-5); /* save the comparison operator */ @@ -907,18 +959,500 @@ } } + + /*----------------------------------------------------------------*/ - /* journal */ - else if (strncmp(token, ":NJO:", 5) == 0 || strncmp(token, ":NJF:", 5) == 0 || strncmp(token, ":NJ1:", 5) == 0 || strncmp(token, ":NJ2:", 5) == 0) { /* periodical query */ - strncpy(operator, &token[5], sqltoken.length-5); /* save the comparison operator */ - operator[sqltoken.length-5] = '\0'; /* terminate string */ + /* queries linking to keywords */ + else if (strncmp(token, ":KW:", 4) == 0) { /* keyword query */ + strncpy(operator, &token[4], sqltoken.length-4); /* save the comparison operator */ + operator[sqltoken.length-4] = '\0'; /* terminate string */ + + /* assemble a surrogate subselect query */ + token = sql_tokenize(newtoken, &sqltoken); + newtoken = sqltoken.next_token; + if (token != NULL) { + strncpy(buffer, token, sqltoken.length); + buffer[sqltoken.length] ='\0'; /* terminate string */ + len = 0; + token = nstrtok(buffer, &len, " "); + if (token != NULL) { + if (*token != '&' && *token != '|') { + /* simple keyword query */ + sprintf(sql_command, "SELECT t_xnote.note_id FROM t_xnote, t_keyword WHERE t_keyword.keyword_id=t_xnote.xref_id AND t_xnote.xnote_type=\"KEYWORD\" AND t_keyword.keyword_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + quoted_token = mstrdup(token); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + } + else if (*token == '|') { + strcpy(sql_command, "SELECT DISTINCT t_xnote.note_id FROM t_xnote, t_keyword WHERE t_keyword.keyword_id=t_xnote.xref_id AND t_xnote.xnote_type=\"KEYWORD\" AND ("); + while (token != NULL) { + token = nstrtok(token+len, &len, " "); + if (token != NULL) { + sprintf(bitsandpieces, "t_keyword.keyword_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + if ((new_sql_command = mstrcat(sql_command, bitsandpieces, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + if ((new_stringbuf = mstrncpy(stringbuf, token, len, &stringbuf_len)) == NULL) { + error = 1; + break; + } + else { + stringbuf = new_stringbuf; + } + stringbuf[len] = '\0'; + quoted_token = mstrdup(stringbuf); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + + if ((new_sql_command = mstrcat(sql_command, " OR ", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + else { + if ((new_sql_command = mstrcat(sql_command, ") ", &sql_command_len, 4)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + } + else if (*token == '&') { + counter = 0; + strcpy(sql_command, "SELECT DISTINCT t_xnote.note_id, COUNT(*) FROM t_xnote, t_keyword WHERE t_keyword.keyword_id=t_xnote.xref_id AND t_xnote.xnote_type=\"KEYWORD\" AND ("); + + while (token != NULL) { + token = nstrtok(token+len, &len, " "); + if (token != NULL) { + sprintf(bitsandpieces, "t_keyword.keyword_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + if ((new_sql_command = mstrcat(sql_command, bitsandpieces, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + if ((new_stringbuf = mstrncpy(stringbuf, token, len, &stringbuf_len)) == NULL) { + error = 1; + break; + } + else { + stringbuf = new_stringbuf; + } + stringbuf[len] = '\0'; + quoted_token = mstrdup(stringbuf); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + + if ((new_sql_command = mstrcat(sql_command, " OR ", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + counter++; + } + else { + if ((new_sql_command = mstrcat(sql_command, ") ", &sql_command_len, 4)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + if ((new_sql_command = mstrcat(sql_command, " GROUP BY t_xnote.note_id HAVING count=", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + sprintf(buffer, "%d", counter); + if ((new_sql_command = mstrcat(sql_command, buffer, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + } + + LOG_PRINT(LOG_DEBUG, sql_command); + + /* dbires will contain all note_ids that match the above + keyword requirements in the pseudo-subselect */ + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + error = 2; + break; + } + + if ((new_sql_command1 = mstrcat(sql_command1, "t_note.note_id IN (", &sql_command1_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command1 = new_sql_command1; + } + + n_havesome = 0; + while (dbi_result_next_row(dbires) != 0) { + n_havesome = 1; + n_id = my_dbi_result_get_idval_idx(dbires, 1); + sprintf(the_id, ULLSPEC, (unsigned long long)n_id); + if ((new_sql_command1 = mstrcat(sql_command1, the_id, &sql_command1_len, 0)) == NULL) { + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + if ((new_sql_command1 = mstrcat(sql_command1, ",", &sql_command1_len, 0)) == NULL) { + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + } + if (!n_havesome) { /* use a dummy value that does not exist in the database */ + if ((new_sql_command1 = mstrcat(sql_command1, "-1,", &sql_command1_len, 0)) == NULL) { /* the comma will be removed further down */ + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + } + + dbi_result_free(dbires); + if (error) { + break; + } + if ((new_sql_command1 = mstrcat(sql_command1, ")", &sql_command1_len, 1)) == NULL) { + error = 1; + break; + } + else { + sql_command1 = new_sql_command1; + } + } + + /*----------------------------------------------------------------*/ + /* queries linking to author names */ + else if (strncmp(token, ":AU:", 4) == 0) { /* author query */ + strncpy(operator, &token[4], sqltoken.length-4); /* save the comparison operator */ + operator[sqltoken.length-4] = '\0'; /* terminate string */ + + /* assemble a surrogate subselect query */ + token = sql_tokenize(newtoken, &sqltoken); + newtoken = sqltoken.next_token; + if (token != NULL) { + strncpy(buffer, token, sqltoken.length); + buffer[sqltoken.length] ='\0'; /* terminate string */ + len = 0; + token = nstrtok(buffer, &len, " "); + if (token != NULL) { + if (*token != '&' && *token != '|') { + /* simple keyword query */ + sprintf(sql_command, "SELECT t_xnote.note_id FROM t_xnote, t_author WHERE t_author.author_id=t_xnote.xref_id AND t_xnote.xnote_type=\"AUTHOR\" AND t_author.author_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + quoted_token = mstrdup(token); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + } + else if (*token == '|') { + strcpy(sql_command, "SELECT DISTINCT t_xnote.note_id FROM t_xnote, t_author WHERE t_author.author_id=t_xnote.xref_id AND t_xnote.xnote_type=\"AUTHOR\" AND ("); + while (token != NULL) { + token = nstrtok(token+len, &len, " "); + if (token != NULL) { + sprintf(bitsandpieces, "t_author.author_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + if ((new_sql_command = mstrcat(sql_command, bitsandpieces, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + if ((new_stringbuf = mstrncpy(stringbuf, token, len, &stringbuf_len)) == NULL) { + error = 1; + break; + } + else { + stringbuf = new_stringbuf; + } + stringbuf[len] = '\0'; + quoted_token = mstrdup(stringbuf); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + + if ((new_sql_command = mstrcat(sql_command, " OR ", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + else { + if ((new_sql_command = mstrcat(sql_command, ") ", &sql_command_len, 4)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + } + else if (*token == '&') { + counter = 0; + strcpy(sql_command, "SELECT DISTINCT t_xnote.note_id, COUNT(*) FROM t_xnote, t_author WHERE t_author.author_id=t_xnote.xref_id AND t_xnote.xnote_type=\"AUTHOR\" AND ("); + + while (token != NULL) { + token = nstrtok(token+len, &len, " "); + if (token != NULL) { + sprintf(bitsandpieces, "t_author.author_name %s ", my_dbi_conn_get_cap(conn, "rlike")); + if ((new_sql_command = mstrcat(sql_command, bitsandpieces, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + if ((new_stringbuf = mstrncpy(stringbuf, token, len, &stringbuf_len)) == NULL) { + error = 1; + break; + } + else { + stringbuf = new_stringbuf; + } + stringbuf[len] = '\0'; + quoted_token = mstrdup(stringbuf); + if (!quoted_token) { + error = 1; + break; + } + if (dbi_driver_quote_string(driver, "ed_token) == -1) { + error = 1; + break; + } + if ((new_sql_command = mstrcat(sql_command, quoted_token, &sql_command_len, 0)) == NULL) { + error = 1; + free(quoted_token); + break; + } + else { + sql_command = new_sql_command; + } + free(quoted_token); + + if ((new_sql_command = mstrcat(sql_command, " OR ", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + counter++; + } + else { + if ((new_sql_command = mstrcat(sql_command, ") ", &sql_command_len, 4)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + if ((new_sql_command = mstrcat(sql_command, " GROUP BY t_xnote.note_id HAVING count=", &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + sprintf(buffer, "%d", counter); + if ((new_sql_command = mstrcat(sql_command, buffer, &sql_command_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command = new_sql_command; + } + } + } + } + + LOG_PRINT(LOG_DEBUG, sql_command); + + /* dbires will contain all note_ids that match the above + keyword requirements in the pseudo-subselect */ + dbires = dbi_conn_query(conn, sql_command); + if (!dbires) { + error = 2; + break; + } + + if ((new_sql_command1 = mstrcat(sql_command1, "t_note.note_id IN (", &sql_command1_len, 0)) == NULL) { + error = 1; + break; + } + else { + sql_command1 = new_sql_command1; + } + + n_havesome = 0; + while (dbi_result_next_row(dbires) != 0) { + n_havesome = 1; + n_id = my_dbi_result_get_idval_idx(dbires, 1); + sprintf(the_id, ULLSPEC, (unsigned long long)n_id); + if ((new_sql_command1 = mstrcat(sql_command1, the_id, &sql_command1_len, 0)) == NULL) { + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + if ((new_sql_command1 = mstrcat(sql_command1, ",", &sql_command1_len, 0)) == NULL) { + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + } + if (!n_havesome) { /* use a dummy value that does not exist in the database */ + if ((new_sql_command1 = mstrcat(sql_command1, "-1,", &sql_command1_len, 0)) == NULL) { /* the comma will be removed further down */ + error = 1; + dbi_result_free(dbires); + break; + } + else { + sql_command1 = new_sql_command1; + } + } + + dbi_result_free(dbires); + if (error) { + break; + } + if ((new_sql_command1 = mstrcat(sql_command1, ")", &sql_command1_len, 1)) == NULL) { + error = 1; + break; + } + else { + sql_command1 = new_sql_command1; + } + } + + /*----------------------------------------------------------------*/ + /* queries linking to journal names */ + else if (strncmp(token, ":JO:", 4) == 0 || strncmp(token, ":JF:", 4) == 0 || strncmp(token, ":J1:", 4) == 0 || strncmp(token, ":J2:", 4) == 0) { /* periodical query */ + strncpy(operator, &token[4], sqltoken.length-4); /* save the comparison operator */ + operator[sqltoken.length-4] = '\0'; /* terminate string */ /* assemble a surrogate subselect query */ - if (strncmp(token, ":NJF:", 5) == 0) { + if (strncmp(token, ":JF:", 4) == 0) { strcpy(sql_command, "SELECT t_xnote.note_id FROM t_xnote, t_periodical WHERE t_periodical.periodical_id=t_xnote.xref_id AND t_periodical.periodical_name"); } - else if (strncmp(token, ":NJO:", 5) == 0) { + else if (strncmp(token, ":JO:", 4) == 0) { strcpy(sql_command, "SELECT t_xnote.note_id FROM t_xnote, t_periodical WHERE t_periodical.periodical_id=t_xnote.xref_id AND t_periodical.periodical_abbrev"); } - else if (strncmp(token, ":NJ1:", 5) == 0) { + else if (strncmp(token, ":J1:", 4) == 0) { strcpy(sql_command, "SELECT t_xnote.note_id FROM t_xnote, t_periodical WHERE t_periodical.periodical_id=t_xnote.xref_id AND t_periodical.periodical_custabbrev1"); } @@ -1042,5 +1576,5 @@ /*----------------------------------------------------------------*/ - /* queries related to references */ + /* queries linking to references */ else if (strncmp(token, ":ID:", 4) == 0 || strncmp(token, ":CK:", 4) == 0) { /* reference by ID or by citation key */ strncpy(operator, &token[4], sqltoken.length-4); /* save the comparison operator */ @@ -1290,8 +1824,8 @@ /* now assemble the SQL query string proper */ if (n_privatelist) { - sprintf(sql_command, "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_user WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND ", ptr_clrequest->username); + sprintf(sql_command, "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang, t_user.user_name FROM t_note,t_user WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name=\'%s\' AND ", ptr_clrequest->username); } else { - strcpy(sql_command, "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang FROM t_note,t_user WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name LIKE \'%\' AND "); + strcpy(sql_command, "SELECT DISTINCT t_note.note_id, t_note.note_key, t_note.note_title, t_note.note_user_id, t_note.note_date, t_note.note_content, t_note.note_content_type, t_note.note_content_xmllang, t_user.user_name FROM t_note,t_user WHERE t_note.note_user_id=t_user.user_id AND t_user.user_name LIKE \'%\' AND "); } |
From: Markus H. <mho...@us...> - 2003-12-24 21:49:11
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv26610 Modified Files: refdbdbib.c Log Message: initialize skipped in delresult Index: refdbdbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdbib.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -U2 -r1.25 -r1.26 --- refdbdbib.c 7 Oct 2003 23:07:37 -0000 1.25 +++ refdbdbib.c 24 Dec 2003 21:49:05 -0000 1.26 @@ -1577,4 +1577,5 @@ ptr_delresult->success = 0; ptr_delresult->failure = 0; + ptr_delresult->skipped = 0; /* get some memory for a return message */ |
From: Markus H. <mho...@us...> - 2003-12-24 21:47:38
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv26453 Modified Files: refdbda.c Log Message: insert meta data in createdb() Index: refdbda.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbda.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -U2 -r1.30 -r1.31 --- refdbda.c 25 Oct 2003 23:58:00 -0000 1.30 +++ refdbda.c 24 Dec 2003 21:47:31 -0000 1.31 @@ -28,4 +28,5 @@ #include <syslog.h> #include <fcntl.h> +#include <time.h> /* for strftime */ #include <sys/types.h> #include <sys/socket.h> @@ -751,6 +752,8 @@ dbi_result dbires; int error; + char date_buffer[24]; char *sql_command; const char *drivername; + time_t the_time; /* it is not necessary to quote database names */ @@ -764,4 +767,12 @@ drivername = dbi_driver_get_name(dbi_conn_get_driver(conn)); + /* allocate a buffer to assemble the sql command (give some extra byte + for the command and encoding strings */ + sql_command = (char*)malloc((size_t)(strlen(dbname) + 256)); + if (sql_command == NULL) { /* malloc failed */ + iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); + return 0; + } + /* create a new database. There is no such SQL command for sqlite. sqlite will create the database for us as soon as we try to access @@ -769,12 +780,4 @@ if (strcmp(drivername, "sqlite")) { - /* allocate a buffer to assemble the sql command (give some extra byte - for the command and encoding strings */ - sql_command = (char*)malloc((size_t)(strlen(dbname) + 64)); - if (sql_command == NULL) { /* malloc failed */ - iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); - return 0; - } - /* assemble sql command */ if (!strcmp(my_dbi_conn_get_cap(conn, "encoding"), "t")) { @@ -803,5 +806,4 @@ dbi_result_free(dbires); - free(sql_command); } /* end if not sqlite */ @@ -813,4 +815,5 @@ iwrite(ptr_clrequest->fd, "selectdb failed\n", 16); dbi_conn_close(conn); + free(sql_command); return 0; } @@ -819,4 +822,5 @@ /* function provides message to client */ dbi_conn_close(conn); + free(sql_command); LOG_PRINT(LOG_ERR, "create tables failed"); return 0; @@ -829,4 +833,5 @@ if ((conn = connect_to_db(ptr_clrequest, dbname)) == NULL) { iwrite(ptr_clrequest->fd, connerr_n.text, connerr_n.length); + free(sql_command); return 0; } @@ -837,4 +842,5 @@ dbi_conn_close(conn); LOG_PRINT(LOG_ERR, "create tables failed"); + free(sql_command); return 0; } @@ -845,4 +851,5 @@ dbi_conn_close(conn); LOG_PRINT(LOG_ERR, "create tables failed"); + free(sql_command); return 0; } @@ -851,6 +858,26 @@ } + /* insert the meta data */ + time(&the_time); + strftime(date_buffer, 24, "%F %T", gmtime(&the_time)); + sprintf(sql_command, "INSERT INTO t_meta (meta_app,meta_type,meta_version,meta_create_date,meta_modify_date) VALUES (\'%s\', \'risx\', \'%s\', \'%s\', \'%s\')", PACKAGE, VERSION, date_buffer, date_buffer); + LOG_PRINT(LOG_DEBUG, sql_command); + + dbires = dbi_conn_query(conn, sql_command); + + if (!dbires) { + iwrite(ptr_clrequest->fd, "insert into t_meta failed\n", 26); + LOG_PRINT(LOG_ERR, "insert into t_meta failed"); + free(sql_command); + return 1; + } + + dbi_result_free(dbires); + + /* cleanup */ dbi_conn_close(conn); + free(sql_command); + return 1; } |
From: Markus H. <mho...@us...> - 2003-12-24 21:44:57
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv26107 Modified Files: refdbd.c Log Message: report skipped datasets in return message Index: refdbd.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.c,v retrieving revision 1.62 retrieving revision 1.63 diff -u -U2 -r1.62 -r1.63 --- refdbd.c 15 Dec 2003 23:34:43 -0000 1.62 +++ refdbd.c 24 Dec 2003 21:44:53 -0000 1.63 @@ -1331,16 +1331,16 @@ if (n_success) { if (ptr_child_clrequest->n_cgi) { /* cgi output */ - sprintf(child_returnmsg, "<tbody><tr><td class=\"result\">"ULLSPEC" datasets deleted</td></tr>", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, "<tbody><tr><td class=\"result\">"ULLSPEC" datasets deleted, "ULLSPEC" skipped</td></tr>", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } else { - sprintf(child_returnmsg, ULLSPEC" datasets deleted", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, ULLSPEC" datasets deleted, "ULLSPEC" skipped", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } } else { /* if no success */ if (ref_format == 6) { - sprintf(child_returnmsg, "<tbody><tr><td class=\"result\">"ULLSPEC" datasets successfully deleted, stopped after error</td></tr>", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, "<tbody><tr><td class=\"result\">"ULLSPEC" datasets successfully deleted, "ULLSPEC" skipped, stopped after error</td></tr>", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } else { - sprintf(child_returnmsg, ULLSPEC" datasets successfully deleted, stopped after error", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, ULLSPEC" datasets successfully deleted, "ULLSPEC" skipped, stopped after error", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } } @@ -1478,8 +1478,8 @@ /* let the client know what happened */ if (n_success) { - sprintf(child_returnmsg, ULLSPEC" datasets deleted", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, ULLSPEC" datasets deleted, "ULLSPEC" skipped", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } else { /* if no success */ - sprintf(child_returnmsg, ULLSPEC" datasets successfully deleted, stopped after error", (unsigned long long)(delresult.success)); + sprintf(child_returnmsg, ULLSPEC" datasets successfully deleted, "ULLSPEC" skipped, stopped after error", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped)); } } @@ -1638,5 +1638,5 @@ /* let the client know what happened */ - sprintf(child_returnmsg, ULLSPEC" style(s) deleted, "ULLSPEC" failed\n", (unsigned long long)(delresult.success), (unsigned long long)(delresult.failure)); + sprintf(child_returnmsg, ULLSPEC" style(s) deleted, "ULLSPEC" skipped, "ULLSPEC" failed\n", (unsigned long long)(delresult.success), (unsigned long long)(delresult.skipped), (unsigned long long)(delresult.failure)); } |
From: Markus H. <mho...@us...> - 2003-12-24 21:42:52
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv25877 Modified Files: refdbc.c Log Message: fixed addlink argument handling and help output Index: refdbc.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbc.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -U2 -r1.59 -r1.60 --- refdbc.c 17 Dec 2003 00:09:32 -0000 1.59 +++ refdbc.c 24 Dec 2003 21:42:47 -0000 1.60 @@ -4757,20 +4757,19 @@ db[_POSIX_PATH_MAX-1] = '\0'; /* terminate in case string got truncated */ break; - case 'f': - /* printf("-f %s\n", optarg); */ - if (!strcmp(optarg, "stdin")) { - n_read_stdin = 1; - } - else { - infile = canonicalize_path(optarg); - if (insert_lilimem(&sentinel, (void**)&infile, NULL)) { - delete_all_lilimem(&sentinel); - return 1; - } - n_read_file = 1; - } - break; +/* case 'f': */ +/* if (!strcmp(optarg, "stdin")) { */ +/* n_read_stdin = 1; */ +/* } */ +/* else { */ +/* infile = canonicalize_path(optarg); */ +/* if (insert_lilimem(&sentinel, (void**)&infile, NULL)) { */ +/* delete_all_lilimem(&sentinel); */ +/* return 1; */ +/* } */ +/* n_read_file = 1; */ +/* } */ +/* break; */ case 'h': - printf("Displays the result of a database search for notes.\nSyntax: getnote [-c command] [-d database] [-h] [-o outfile] [-O outfile][-P] [-R pdfroot] [-s format] [-S tag] [-t output-format] {search-string|-f infile}\nSearch-string: {:XY:{<|=|!=|>}{unix-regexp}} [AND|OR|AND NOT] [...]\nwhere XY specifies the field to search in\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -h prints this mini-help\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -P limit search to personal interest list\n -R use pdfroot as root for path of pdf files\n -s format specify fields for screen or style for DocBook output\n -S tag sort output by tag ID (default) or PY\n -t output-format display as format scrn, html, db31, teix, ris, or bibtex\n -f infile use the saved search line in file infile\n All other arguments are interpreted as the search string.\n"); + printf("Links an existing note to one or more references, keywords, periodicals, or authors.\nSyntax: addlink [-c command] [-d database] [-h] [-o outfile] [-O outfile][-r] :NID:|:NCK: :XY:=value [:XY:=value1...]\nNID or NCK specify a note by its ID or key, respectively\nXY is one of ID, CK (reference by ID or citekey), KW (keyword), JO|JF|J1|J2 (periodical abbreviated|full|user1|user2), AU (author name)\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -h prints this mini-help\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -r remove specified links\n"); delete_all_lilimem(&sentinel); return 0; @@ -4802,4 +4801,5 @@ case 'e': case 'E': + case 'f': case 'F': case 'g': |
From: Markus H. <mho...@us...> - 2003-12-24 21:42:01
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv25778 Modified Files: dbfncs.c Log Message: added t_meta table to reference databases Index: dbfncs.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -U2 -r1.11 -r1.12 --- dbfncs.c 21 Dec 2003 23:07:59 -0000 1.11 +++ dbfncs.c 24 Dec 2003 21:41:58 -0000 1.12 @@ -133,4 +133,14 @@ dbi_result dbires; + /* create the metadata table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_meta (meta_app VARCHAR(20), meta_type VARCHAR(20), meta_version VARCHAR(20), meta_create_date DATETIME, meta_modify_date DATETIME)"); + + if (!dbires) { + iwrite(ptr_clrequest->fd, "create t_meta failed\n", 21); + return 1; + } + + dbi_result_free(dbires); + /* create the main table */ /* Version issue: later versions support something like: @@ -143,5 +153,4 @@ support this so a simple INT has to do the trick */ - /* ToDo: check these constraints with other database servers */ dbires = dbi_conn_query(conn, "CREATE TABLE t_refdb \ (refdb_id INT NOT NULL AUTO_INCREMENT, \ @@ -377,4 +386,14 @@ char buffer[512]; + /* create the metadata table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_meta (meta_app VARCHAR(20), meta_type VARCHAR(20), meta_version VARCHAR(20), meta_create_date TIMESTAMP, meta_modify_date TIMESTAMP)"); + + if (!dbires) { + iwrite(ptr_clrequest->fd, "create t_meta failed\n", 21); + return 1; + } + + dbi_result_free(dbires); + /* create the main table */ /* using a DATE field for refdb_pubyear is not possible as MySQL < 3.23 @@ -844,4 +863,14 @@ int create_tables_sqlite(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest) { dbi_result dbires; + + /* create the metadata table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_meta (meta_app VARCHAR(20), meta_type VARCHAR(20), meta_version VARCHAR(20), meta_create_date DATETIME, meta_modify_date DATETIME)"); + + if (!dbires) { + iwrite(ptr_clrequest->fd, "create t_meta failed\n", 21); + return 1; + } + + dbi_result_free(dbires); /* create the main table */ |
From: Markus H. <mho...@us...> - 2003-12-24 21:41:17
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv25717 Modified Files: backendn-notex.c Log Message: use set owner instead of current user in output Index: backendn-notex.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backendn-notex.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -U2 -r1.4 -r1.5 --- backendn-notex.c 21 Dec 2003 23:05:55 -0000 1.4 +++ backendn-notex.c 24 Dec 2003 21:41:14 -0000 1.5 @@ -128,4 +128,5 @@ char date_buffer[256]; const char* citem; + const char* owner; char* item; char* new_ref; @@ -157,6 +158,12 @@ get_refdb_note_date(ptr_rendinfo->dbires, date_buffer, 1); + owner = get_refdb_note_user_name(ptr_rendinfo->dbires); + + if (!owner && !*owner) { + owner = ptr_rendinfo->username; + } + if (*id) { - if (print_elstart_x(ptr_rendinfo->ptr_ref, ptr_rendinfo->ptr_ref_len, "xnote", "id", id, "key", citem, "user", ptr_rendinfo->username, "date", date_buffer, 0, &xindent) == NULL) { + if (print_elstart_x(ptr_rendinfo->ptr_ref, ptr_rendinfo->ptr_ref_len, "xnote", "id", id, "key", citem, "user", owner, "date", date_buffer, 0, &xindent) == NULL) { return NULL; } |
From: Markus H. <mho...@us...> - 2003-12-24 21:35:26
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv22021 Modified Files: backend.c backend.h Log Message: new function get_refdb_note_user_name() Index: backend.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -U2 -r1.18 -r1.19 --- backend.c 21 Dec 2003 23:02:38 -0000 1.18 +++ backend.c 24 Dec 2003 21:35:19 -0000 1.19 @@ -102,4 +102,26 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + get_refdb_note_user_name(): retrieves the user_name element from a note query + + char* get_refdb_note_user_name returns a pointer to a string containing the + user_name element + + dbi_result dbires database query result, pointing to the current + dataset + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +const char* get_refdb_note_user_name(dbi_result dbires) { + const char* result; + + result = dbi_result_get_string(dbires, "user_name"); + if (dbi_conn_error_flag(dbi_result_get_conn(dbires))) { + return NULL; + } + else { + return result; + } +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ get_refdb_note_title_copy(): retrieves the title element from a note query Index: backend.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -U2 -r1.20 -r1.21 --- backend.h 21 Dec 2003 23:03:39 -0000 1.20 +++ backend.h 24 Dec 2003 21:35:19 -0000 1.21 @@ -94,4 +94,5 @@ char* get_refdb_note_id(dbi_result dbires, char* id); const char* get_refdb_note_key(dbi_result dbires); +const char* get_refdb_note_user_name(dbi_result dbires); char* get_refdb_note_title_copy(dbi_result dbires); char* get_refdb_note_content_copy(dbi_result dbires); |