[Refdb-cvs] CVS: refdb/src backend.c,1.27,1.27.2.1 dbfncs.c,1.15.2.7,1.15.2.8 dbfncs.h,1.6.2.1,1.6.2
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-05-05 17:22:14
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18941 Modified Files: Tag: Release_0_9_5_stable backend.c dbfncs.c dbfncs.h refdbd.c refdbda.c refdbdbib.c noteshandler.c risdb.c risxhandler.c xmlhandler.c Log Message: added sqlite3 support Index: backend.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.c,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -U2 -r1.27 -r1.27.2.1 --- backend.c 1 May 2004 23:40:13 -0000 1.27 +++ backend.c 5 May 2005 17:21:11 -0000 1.27.2.1 @@ -401,5 +401,5 @@ /* mysql */ strcpy(sql_command, "CREATE TEMPORARY TABLE t_noteunion \ - (note_id INT, \ + (note_id BIGINT, \ note_key VARCHAR(255), \ note_title VARCHAR(255), \ @@ -407,5 +407,5 @@ note_content_type VARCHAR(255), \ note_content_xmllang VARCHAR(255), \ - note_user_id INT, \ + note_user_id BIGINT, \ note_date DATETIME)"); } @@ -434,11 +434,17 @@ note_content TEXT)"); } - else { - /* should never happen */ - LOG_PRINT(LOG_WARNING, "unsupported driver"); - free(sql_command); - free(sql_chunk); - return NULL; + else if (!strcmp(drivername, "sqlite3")) { + /* sqlite3 */ + strcpy(sql_command, "CREATE TEMPORARY TABLE t_noteunion \ + (note_id BIGINT, \ + note_key TEXT, \ + note_title TEXT, \ + note_content_type TEXT, \ + note_content_xmllang TEXT, \ + note_user_id BIGINT, \ + note_date DATE, \ + note_content TEXT)"); } + /* else: will be caught earlier */ LOG_PRINT(LOG_DEBUG, sql_command); Index: dbfncs.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.c,v retrieving revision 1.15.2.7 retrieving revision 1.15.2.8 diff -u -U2 -r1.15.2.7 -r1.15.2.8 --- dbfncs.c 15 Apr 2005 22:45:08 -0000 1.15.2.7 +++ dbfncs.c 5 May 2005 17:21:25 -0000 1.15.2.8 @@ -72,4 +72,5 @@ strcpy(ptr_caps->bigint, "t"); strcpy(ptr_caps->sql_union, "f"); + strcpy(ptr_caps->named_seq, "f"); ptr_caps->has_versioninfo = 0; } @@ -87,4 +88,5 @@ strcpy(ptr_caps->bigint, "t"); strcpy(ptr_caps->sql_union, "t"); + strcpy(ptr_caps->named_seq, "t"); ptr_caps->has_versioninfo = 1; } @@ -102,4 +104,21 @@ strcpy(ptr_caps->bigint, "f"); strcpy(ptr_caps->sql_union, "t"); + strcpy(ptr_caps->named_seq, "f"); + ptr_caps->has_versioninfo = 1; + } + else if (!strcmp(ptr_clrequest->dbserver, "sqlite3")) { + strcpy(ptr_caps->multiple_db, "f"); + strcpy(ptr_caps->sql_enum, "f"); + strcpy(ptr_caps->rlike, "LIKE"); + strcpy(ptr_caps->not_rlike, "NOT LIKE"); + strcpy(ptr_caps->transaction, "t"); + strcpy(ptr_caps->localhost, "NA"); + strcpy(ptr_caps->encoding, ""); + strcpy(ptr_caps->groups, "NA"); + strcpy(ptr_caps->admin_systable, "NA"); + strcpy(ptr_caps->listall, "%"); + strcpy(ptr_caps->bigint, "t"); + strcpy(ptr_caps->sql_union, "t"); + strcpy(ptr_caps->named_seq, "f"); ptr_caps->has_versioninfo = 1; } @@ -1280,4 +1299,425 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + create_tables_sqlite3(): creates SQLite3-specific reference data tables + + int create_tables_sqlite3 returns >0 if error, 0 if successful + + struct CLIENT_REQUEST* ptr_clrequest ptr to structure with client info + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +int create_tables_sqlite3(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_dbversion SMALLINT, meta_create_date DATETIME, meta_modify_date DATETIME)"); + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(211)); + return 211; + } + + dbi_result_free(dbires); + + /* create the main table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_refdb \ + (refdb_id BIGINT PRIMARY KEY, \ + refdb_citekey TEXT UNIQUE, \ + refdb_type TEXT, \ + refdb_pubyear SMALLINT, \ + refdb_secyear SMALLINT, \ + refdb_startpage TEXT, \ + refdb_endpage TEXT, \ + refdb_abstract TEXT, \ + refdb_title TEXT, \ + refdb_volume TEXT, \ + refdb_issue TEXT, \ + refdb_booktitle TEXT, \ + refdb_city TEXT, \ + refdb_publisher TEXT, \ + refdb_title_series TEXT, \ + refdb_address TEXT, \ + refdb_url TEXT, \ + refdb_issn TEXT, \ + refdb_pyother_info TEXT, \ + refdb_secother_info TEXT, \ + refdb_periodical_id BIGINT, \ + refdb_user1 TEXT, \ + refdb_user2 TEXT, \ + refdb_user3 TEXT, \ + refdb_user4 TEXT, \ + refdb_user5 TEXT, \ + refdb_misc1 TEXT, \ + refdb_misc2 TEXT, \ + refdb_misc3 TEXT, \ + refdb_linkpdf TEXT, \ + refdb_linkfull TEXT, \ + refdb_linkrel TEXT, \ + refdb_linkimg TEXT)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(212)); + return 212; + } + + dbi_result_free(dbires); + + /* create the main table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_refdb_pubyear ON t_refdb (refdb_pubyear)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(212)); + return 212; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE UNIQUE INDEX i_refdb_citekey ON t_refdb (refdb_citekey)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(212)); + return 212; + } + + dbi_result_free(dbires); + + /* create the author table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_author \ + (author_id BIGINT PRIMARY KEY, \ + author_name TEXT NOT NULL, \ + author_lastname TEXT, \ + author_firstname TEXT, \ + author_middlename TEXT, \ + author_suffix TEXT)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(213)); + return 213; + } + + dbi_result_free(dbires); + + /* create t_author table index */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_author_name ON t_author (author_name)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(213)); + return 213; + } + + dbi_result_free(dbires); + + /* create the keyword table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_keyword \ + (keyword_id BIGINT PRIMARY KEY, \ + keyword_name TEXT NOT NULL)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(214)); + return 214; + } + + dbi_result_free(dbires); + + /* create t_keyword table index */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_keyword_name ON t_keyword (keyword_name)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(214)); + return 214; + } + + dbi_result_free(dbires); + + /* create the periodical table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_periodical \ + (periodical_id BIGINT PRIMARY KEY, \ + periodical_name TEXT, \ + periodical_abbrev TEXT, \ + periodical_custabbrev1 TEXT, \ + periodical_custabbrev2 TEXT)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(215)); + return 215; + } + + dbi_result_free(dbires); + + /* create t_periodical table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_periodical_name ON t_periodical (periodical_name)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(215)); + return 215; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_periodical_abbrev ON t_periodical (periodical_abbrev)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(215)); + return 215; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_periodical_custabbrev1 ON t_periodical (periodical_custabbrev1)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(215)); + return 215; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_periodical_custabbrev2 ON t_periodical (periodical_custabbrev2)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(215)); + return 215; + } + + dbi_result_free(dbires); + + /* create the notes table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_note \ + (note_id BIGINT PRIMARY KEY, \ + note_key TEXT UNIQUE, \ + note_title TEXT, \ + note_content_type TEXT, \ + note_content_xmllang TEXT, \ + note_user_id BIGINT, \ + note_date DATE, \ + note_content TEXT)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(216)); + return 216; + } + + dbi_result_free(dbires); + + /* create t_note table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_note_title ON t_note (note_title)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(216)); + return 216; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_note_note_userid ON t_note (note_user_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(216)); + return 216; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_note_date ON t_note (note_date)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(216)); + return 216; + } + + dbi_result_free(dbires); + + /* create the user table */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_user \ + (user_id BIGINT PRIMARY KEY, \ + user_name TEXT NOT NULL)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(217)); + return 217; + } + + dbi_result_free(dbires); + + /* create t_user table index */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_user_name ON t_user (user_name)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(217)); + return 217; + } + + dbi_result_free(dbires); + + /* create the author xtable */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_xauthor \ + (xauthor_id BIGINT PRIMARY KEY, \ + author_id BIGINT NOT NULL, \ + refdb_id BIGINT NOT NULL, \ + xauthor_type SMALLINT DEFAULT 1, \ + xauthor_role TEXT, \ + xauthor_position INTEGER)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(218)); + return 218; + } + + dbi_result_free(dbires); + + /* create t_xauthor table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_xauthor_autid ON t_xauthor (author_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(218)); + return 218; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_xauthor_refid ON t_xauthor (refdb_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(218)); + return 218; + } + + dbi_result_free(dbires); + + /* create the keyword xtable */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_xkeyword \ + (xkeyword_id BIGINT PRIMARY KEY, \ + xkeyword_type TEXT, \ + keyword_id BIGINT NOT NULL, \ + xref_id BIGINT NOT NULL)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(219)); + return 219; + } + + dbi_result_free(dbires); + + /* create t_xkeyword table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_xkeyword_kwid ON t_xkeyword (keyword_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(219)); + return 219; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_xkeyword_xrefid ON t_xkeyword (xref_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(219)); + return 219; + } + + dbi_result_free(dbires); + + /* create the user xtable */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_xuser \ + (xuser_id BIGINT PRIMARY KEY, \ + user_id BIGINT NOT NULL, \ + refdb_id BIGINT NOT NULL, \ + xuser_reprint TEXT DEFAULT \'NOT IN FILE\', \ + xuser_date DATE, \ + xuser_avail TEXT, \ + xuser_notes TEXT)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(220)); + return 220; + } + + dbi_result_free(dbires); + + /* create t_xuser table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_xuser_userid ON t_xuser (user_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(220)); + return 220; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_xuser_refid ON t_xuser (refdb_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(220)); + return 220; + } + + dbi_result_free(dbires); + + /* create the notes xtable */ + dbires = dbi_conn_query(conn, "CREATE TABLE t_xnote \ + (xnote_id BIGINT PRIMARY KEY, \ + note_id BIGINT NOT NULL, \ + xref_id BIGINT NOT NULL, \ + xnote_type TEXT DEFAULT \'REFERENCE\')"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(221)); + return 221; + } + + dbi_result_free(dbires); + + /* create t_xnote table indexes */ + dbires = dbi_conn_query(conn, "CREATE INDEX i_xnote_noteid ON t_xnote (note_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(221)); + return 221; + } + + dbi_result_free(dbires); + + dbires = dbi_conn_query(conn, "CREATE INDEX i_xnote_xrefid ON t_xnote (xref_id)"); + + + if (!dbires) { + LOG_PRINT(LOG_ERR, get_status_msg(221)); + return 221; + } + + dbi_result_free(dbires); + + return 0; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ is_user_pgsql(): checks whether a user exists @@ -1655,4 +2095,7 @@ return ptr_dbcaps->sql_union; } + else if (!strcmp(cap, "named_seq")) { + return ptr_dbcaps->named_seq; + } /* else: should never happen */ Index: dbfncs.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.h,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -U2 -r1.6.2.1 -r1.6.2.2 --- dbfncs.h 12 Feb 2005 01:50:01 -0000 1.6.2.1 +++ dbfncs.h 5 May 2005 17:21:25 -0000 1.6.2.2 @@ -35,4 +35,5 @@ char bigint[2]; /* if t, db engine supports unsigned long long */ char sql_union[2]; /* if t, the db engine supports UNION in SELECT */ + char named_seq[2]; /* if t, sequence_last() needs seq name */ int has_versioninfo; /* if non-zero, struct was updated with db engine version-specific information */ @@ -44,4 +45,5 @@ int create_tables_pgsql(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); int create_tables_sqlite(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); +int create_tables_sqlite3(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); int is_user_pgsql(dbi_conn conn, const char* username); int is_group_pgsql(dbi_conn conn, const char* groupname); Index: refdbd.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.c,v retrieving revision 1.74.2.12 retrieving revision 1.74.2.13 diff -u -U2 -r1.74.2.12 -r1.74.2.13 --- refdbd.c 19 Apr 2005 19:43:36 -0000 1.74.2.12 +++ refdbd.c 5 May 2005 17:21:25 -0000 1.74.2.13 @@ -297,5 +297,5 @@ break; case 'h': - fprintf(stderr, "Usage: refdbd [-b dbs_port] [-d database] [-D dbserver] [-e dest] [-E encoding] [-h] [-i address] [-I] [-k] [-K] [-l level] [-L file] [-p port] [-P PIDfile] [-q] [-r] [-s] [-T time] [-u] [-v] [-V] [-y confdir] [-Y driverdir]\nOptions: -b set database server port\n -D select database server (mysql|pgsql|sqlite)\n -e set log destination to dest (0-2)\n -h prints this help\n -i set server IP address to address\n -I allow remote connections\n -k keep periodical names when deleting references\n -K activate automatic keyword scan\n -l set the log level to level (0<=level<=7)\n -L use file as log-file (full path)\n -p set refdbd port\n -P set path to PID file\n -q ignore init-file\n -r allow remote administration\n -s run standalone, not as daemon\n -T set timeout to time\n -U uppercase citation keys (for SGML)\n -v show version information\n -V switch to verbose mode\n -y look for configuration files in confdir\n -Y look for dbi drivers in driverdir\n"); + fprintf(stderr, "Usage: refdbd [-b dbs_port] [-d database] [-D dbserver] [-e dest] [-E encoding] [-h] [-i address] [-I] [-k] [-K] [-l level] [-L file] [-p port] [-P PIDfile] [-q] [-r] [-s] [-T time] [-u] [-v] [-V] [-y confdir] [-Y driverdir]\nOptions: -b set database server port\n -D select database server (mysql|pgsql|sqlite|sqlite3)\n -e set log destination to dest (0-2)\n -h prints this help\n -i set server IP address to address\n -I allow remote connections\n -k keep periodical names when deleting references\n -K activate automatic keyword scan\n -l set the log level to level (0<=level<=7)\n -L use file as log-file (full path)\n -p set refdbd port\n -P set path to PID file\n -q ignore init-file\n -r allow remote administration\n -s run standalone, not as daemon\n -T set timeout to time\n -U uppercase citation keys (for SGML)\n -v show version information\n -V switch to verbose mode\n -y look for configuration files in confdir\n -Y look for dbi drivers in driverdir\n"); free(ptr_clrequest); exit (0); @@ -362,5 +362,5 @@ break; case ':': - fprintf(stderr, "Usage: refdbd [-b dbs_port] [-D dbserver] [-e dest] [-h] [-i address] [-I] [-k] [-K] [-l level] [-L file] [-p port] [-P PIDfile] [-q] [-r] [-s] [-T time] [-u] [-v] [-V] [-y confdir] [-Y driverdir]\nOptions: -b set database server port\n -D select database server (mysql|pgsql|sqlite)\n -e set log destination to dest (0-2)\n -h prints this help\n -i set server IP address to address\n -I allow remote connections\n -k keep periodical names when deleting references\n -K activate automatic keyword scan\n -l set the log level to level (0<=level<=7)\n -L use file as log-file (full path)\n -p set refdbd port\n -P set path to PID file\n -q ignore init-file\n -r allow remote administration\n -s run standalone, not as daemon\n -T set timeout to time\n -U uppercase citation keys (for SGML)\n -v show version information\n -V switch to verbose mode\n -y look for configuration files in confdir\n -Y look for dbi drivers in driverdir\n"); + fprintf(stderr, "Usage: refdbd [-b dbs_port] [-D dbserver] [-e dest] [-h] [-i address] [-I] [-k] [-K] [-l level] [-L file] [-p port] [-P PIDfile] [-q] [-r] [-s] [-T time] [-u] [-v] [-V] [-y confdir] [-Y driverdir]\nOptions: -b set database server port\n -D select database server (mysql|pgsql|sqlite|sqlite3)\n -e set log destination to dest (0-2)\n -h prints this help\n -i set server IP address to address\n -I allow remote connections\n -k keep periodical names when deleting references\n -K activate automatic keyword scan\n -l set the log level to level (0<=level<=7)\n -L use file as log-file (full path)\n -p set refdbd port\n -P set path to PID file\n -q ignore init-file\n -r allow remote administration\n -s run standalone, not as daemon\n -T set timeout to time\n -U uppercase citation keys (for SGML)\n -v show version information\n -V switch to verbose mode\n -y look for configuration files in confdir\n -Y look for dbi drivers in driverdir\n"); free(ptr_clrequest); exit (1); @@ -386,5 +386,7 @@ strup(default_input_encoding); - if (!strcmp(ptr_clrequest->dbserver, "sqlite") && *ip_or_path) { + if ((!strcmp(ptr_clrequest->dbserver, "sqlite") + || !strcmp(ptr_clrequest->dbserver, "sqlite3")) + && *ip_or_path) { strcpy(ptr_clrequest->db_path, ip_or_path); } Index: refdbda.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbda.c,v retrieving revision 1.41.2.10 retrieving revision 1.41.2.11 diff -u -U2 -r1.41.2.10 -r1.41.2.11 --- refdbda.c 19 Apr 2005 19:46:11 -0000 1.41.2.10 +++ refdbda.c 5 May 2005 17:21:28 -0000 1.41.2.11 @@ -43,13 +43,5 @@ #include "dbfncs.h" -/* these externs are all defined in refdbd.c */ -extern struct BSTRING outomem; -extern struct BSTRING outomem_n; -extern struct BSTRING connerr; -extern struct BSTRING connerr_n; -extern struct BSTRING positive; -extern struct BSTRING negative; -extern struct BSTRING cgihead_html; -extern struct BSTRING cgihead_plain; +/* these are defined in refdbd.c */ extern char server_ip[]; extern char log_file[]; @@ -400,4 +392,5 @@ if (!conn) { LOG_PRINT(LOG_WARNING, "creating database connection structure failed"); + LOG_PRINT(LOG_WARNING, "check your libdbi installation"); return NULL; } @@ -424,11 +417,18 @@ } } - else if (!strcmp(ptr_clrequest->dbserver, "sqlite")) { + else if (!strcmp(ptr_clrequest->dbserver, "sqlite") + || !strcmp(ptr_clrequest->dbserver, "sqlite3")) { dbi_conn_set_option(conn, "sqlite_dbdir", ptr_clrequest->db_path); } if (dbi_conn_connect(conn) < 0) { /* -1 and -2 indicate errors */ + const char* errmsg = NULL; + LOG_PRINT(LOG_WARNING, "failed to connect to database server using database:"); LOG_PRINT(LOG_WARNING, my_db); + dbi_conn_error(conn, &errmsg); + if (errmsg) { + LOG_PRINT(LOG_WARNING, errmsg); + } dbi_conn_close(conn); return NULL; @@ -436,5 +436,5 @@ if (!nocheck && strcmp(my_db, MAIN_DB) && !is_reference_database(NULL, conn, my_db)) { - LOG_PRINT(LOG_WARNING, "failed to connect to database server using database:"); + LOG_PRINT(LOG_WARNING, "does not appear to be a RefDB reference database:"); LOG_PRINT(LOG_WARNING, my_db); dbi_conn_close(conn); @@ -602,11 +602,4 @@ /* selectdb */ - if (ptr_clrequest->n_cgi) { - send_status(ptr_clrequest->fd, 0, TERM_NO); - iwrite(ptr_clrequest->fd, cgihead_html.text, cgihead_html.length); - tiwrite(ptr_clrequest->fd, html_head, TERM_NO); - tiwrite(ptr_clrequest->fd, "<thead><tr><th class=\"result\">Current Database</th></tr></thead><tbody><tr><td class=\"result\">", TERM_NO); - free(html_head); - } if (dbi_result_next_row(dbires)) { /* this is just to prevent problems if the SQL server @@ -664,11 +657,4 @@ /* listdb */ - if (ptr_clrequest->n_cgi) { - send_status(ptr_clrequest->fd, 0, TERM_NO); - iwrite(ptr_clrequest->fd, cgihead_html.text, cgihead_html.length); - tiwrite(ptr_clrequest->fd, html_head, TERM_NO); - tiwrite(ptr_clrequest->fd, "<thead><tr><th class=\"result\">Available Databases</th></tr></thead><tbody><tr><td><input type=\"button\" value=\"Select database\" onclick=\"seldb()\"></td></tr>", TERM_NO); - free(html_head); - } while (dbi_result_next_row(dbires)) { dbname = dbi_result_get_string_idx(dbires, 1); @@ -692,8 +678,4 @@ } } - if (ptr_clrequest->n_cgi) { - tiwrite(ptr_clrequest->fd, html_foot, TERM_NO); - free(html_foot); - } } dbi_result_free(dbires); @@ -1086,5 +1068,6 @@ it */ - if (strcmp(drivername, "sqlite")) { + if (strcmp(drivername, "sqlite") + && strcmp(drivername, "sqlite3")) { const char* encoding_string; @@ -1172,4 +1155,12 @@ } } + else if (!strcmp(drivername, "sqlite3")) { + if ((error = create_tables_sqlite3(conn, ptr_clrequest)) != 0) { + /* function provides log message */ + snprintf(message, 128, "%d:%s\n", error, dbname); + retval = 2; + goto finish; + } + } /* else: should never happen */ } @@ -1269,5 +1260,6 @@ error = 0; - if (!strcmp(drivername, "sqlite")) { + if (!strcmp(drivername, "sqlite") + || !strcmp(drivername, "sqlite3")) { /* sqlite has no SQL way to drop databases. Try to remove the database file from the file system manually */ @@ -1457,5 +1449,7 @@ drivername = dbi_driver_get_name(dbi_conn_get_driver(conn)); - if (!strcmp(drivername, "sqlite")) { /* driver does not support SQL-based access control */ + if (!strcmp(drivername, "sqlite") + || !strcmp(drivername, "sqlite3")) { + /* driver does not support SQL-based access control */ send_status(ptr_clrequest->fd, 224, TERM_NO); LOG_PRINT(LOG_WARNING, "999:access control not supported"); Index: refdbdbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdbib.c,v retrieving revision 1.36.2.16 retrieving revision 1.36.2.17 diff -u -U2 -r1.36.2.16 -r1.36.2.17 --- refdbdbib.c 17 Apr 2005 00:09:10 -0000 1.36.2.16 +++ refdbdbib.c 5 May 2005 17:21:31 -0000 1.36.2.17 @@ -364,7 +364,7 @@ if (!strcmp(ptr_clrequest->dbserver, "mysql")) { - sprintf(sql_command, "CREATE TEMPORARY TABLE %s (id INT NOT NULL AUTO_INCREMENT, \ + sprintf(sql_command, "CREATE TEMPORARY TABLE %s (id BIGINT NOT NULL AUTO_INCREMENT, \ dbname VARCHAR(64), \ - orig_id INT, \ + orig_id BIGINT, \ entry_id BLOB, \ article_title BLOB, \ @@ -384,7 +384,7 @@ } else if (!strcmp(ptr_clrequest->dbserver, "pgsql")) { - sprintf(sql_command, "CREATE TEMPORARY TABLE %s (id SERIAL, \ + sprintf(sql_command, "CREATE TEMPORARY TABLE %s (id BIGSERIAL, \ dbname VARCHAR(64), \ - orig_id INTEGER, \ + orig_id BIGINT, \ entry_id TEXT, \ article_title TEXT, \ @@ -422,4 +422,23 @@ year_uni_suffix TEXT)", table_name); } + else if (!strcmp(ptr_clrequest->dbserver, "sqlite3")) { + sprintf(sql_command, "CREATE TEMPORARY TABLE %s (id BIGINT PRIMARY KEY, \ + dbname VARCHAR(64), \ + orig_id BIGINT, \ + entry_id TEXT, \ + article_title TEXT, \ + author_concat TEXT, \ + periodical TEXT, \ + volume TEXT, \ + issue TEXT, \ + startpage TEXT, \ + pubyear SMALLINT, \ + citation_pos INTEGER, \ + xref_pos INTEGER, \ + multi_id TEXT, \ + sorted_pos INTEGER DEFAULT 1, \ + author_abbrevlist TEXT, \ + year_uni_suffix TEXT)", table_name); + } LOG_PRINT(LOG_DEBUG, sql_command); Index: noteshandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/noteshandler.c,v retrieving revision 1.18.2.4 retrieving revision 1.18.2.5 diff -u -U2 -r1.18.2.4 -r1.18.2.5 --- noteshandler.c 15 Apr 2005 22:45:08 -0000 1.18.2.4 +++ noteshandler.c 5 May 2005 17:21:34 -0000 1.18.2.5 @@ -390,14 +390,9 @@ /* retrieve note_id of newly created dataset */ - if (!strcmp(ptr_andata->drivername, "mysql") || !strcmp(ptr_andata->drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(ptr_andata->conn, "named_seq"), "f")) { ptr_andata->n_note_id = dbi_conn_sequence_last(ptr_andata->conn, NULL); } - else if (!strcmp(ptr_andata->drivername, "pgsql")) { - ptr_andata->n_note_id = dbi_conn_sequence_last(ptr_andata->conn, "t_note_note_id_seq"); - } else { - LOG_PRINT(LOG_ERR, "driver not supported"); - (ptr_andata->ndb_error)++; - return; + ptr_andata->n_note_id = dbi_conn_sequence_last(ptr_andata->conn, "t_note_note_id_seq"); } Index: risdb.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/risdb.c,v retrieving revision 1.44.2.3 retrieving revision 1.44.2.4 diff -u -U2 -r1.44.2.3 -r1.44.2.4 --- risdb.c 17 Apr 2005 00:09:12 -0000 1.44.2.3 +++ risdb.c 5 May 2005 17:21:36 -0000 1.44.2.4 @@ -643,5 +643,5 @@ /* retrieve refdb_id of newly created dataset */ - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { n_refdb_id = dbi_conn_sequence_last(conn, NULL); } @@ -1917,15 +1917,9 @@ } - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { n_periodical_id = dbi_conn_sequence_last(conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - n_periodical_id = dbi_conn_sequence_last(conn, "t_periodical_periodical_id_seq"); - } else { - dbi_result_free(dbires); - free(sql_command); - LOG_PRINT(LOG_ERR, "driver not supported"); - return 3; + n_periodical_id = dbi_conn_sequence_last(conn, "t_periodical_periodical_id_seq"); } @@ -2104,15 +2098,9 @@ /* retrieve user_id of newly created user entry */ - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { *ptr_n_user_id = dbi_conn_sequence_last(conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - *ptr_n_user_id = dbi_conn_sequence_last(conn, "t_user_user_id_seq"); - } else { - dbi_result_free(dbires1); - dbi_result_free(dbires); - LOG_PRINT(LOG_ERR, "driver not supported"); - return 5; + *ptr_n_user_id = dbi_conn_sequence_last(conn, "t_user_user_id_seq"); } dbi_result_free(dbires1); @@ -2689,15 +2677,9 @@ dbi_result_free(dbires1); - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { n_author_id = dbi_conn_sequence_last(conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - n_author_id = dbi_conn_sequence_last(conn, "t_author_author_id_seq"); - } else { - LOG_PRINT(LOG_ERR, "driver not supported"); - free(sql_command); - free(escape_buffer); - return 4; + n_author_id = dbi_conn_sequence_last(conn, "t_author_author_id_seq"); } } @@ -2962,15 +2944,9 @@ dbi_result_free(dbires1); - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { n_keyword_id = dbi_conn_sequence_last(conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - n_keyword_id = dbi_conn_sequence_last(conn, "t_keyword_keyword_id_seq"); - } else { - LOG_PRINT(LOG_ERR, "driver not supported"); - free(escape_buffer); - free(sql_command); - return 4; + n_keyword_id = dbi_conn_sequence_last(conn, "t_keyword_keyword_id_seq"); } } Index: risxhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/risxhandler.c,v retrieving revision 1.28.2.5 retrieving revision 1.28.2.6 diff -u -U2 -r1.28.2.5 -r1.28.2.6 --- risxhandler.c 15 Apr 2005 22:45:11 -0000 1.28.2.5 +++ risxhandler.c 5 May 2005 17:21:52 -0000 1.28.2.6 @@ -412,14 +412,9 @@ /* retrieve refdb_id of newly created dataset */ - if (!strcmp(ptr_ardata->drivername, "mysql") || !strcmp(ptr_ardata->drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(ptr_ardata->conn, "named_seq"), "f")) { ptr_ardata->n_refdb_id = dbi_conn_sequence_last(ptr_ardata->conn, NULL); } - else if (!strcmp(ptr_ardata->drivername, "pgsql")) { - ptr_ardata->n_refdb_id = dbi_conn_sequence_last(ptr_ardata->conn, "t_refdb_refdb_id_seq"); - } else { - LOG_PRINT(LOG_ERR, "driver not supported"); - (ptr_ardata->ndb_error)++; - return; + ptr_ardata->n_refdb_id = dbi_conn_sequence_last(ptr_ardata->conn, "t_refdb_refdb_id_seq"); } Index: xmlhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/xmlhandler.c,v retrieving revision 1.22.2.13 retrieving revision 1.22.2.14 diff -u -U2 -r1.22.2.13 -r1.22.2.14 --- xmlhandler.c 21 Apr 2005 21:15:25 -0000 1.22.2.13 +++ xmlhandler.c 5 May 2005 17:21:52 -0000 1.22.2.14 @@ -100,14 +100,9 @@ } else { - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(ptr_asdata->conn, "named_seq"), "f")) { *(ptr_asdata->ptr_citstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - *(ptr_asdata->ptr_citstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, "citstyle_id_seq"); - } else { - dbi_result_free(dbires); - LOG_PRINT(LOG_ERR, "driver not supported"); - return; + *(ptr_asdata->ptr_citstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, "citstyle_id_seq"); } dbi_result_free(dbires); @@ -154,14 +149,9 @@ } else { - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(ptr_asdata->conn, "named_seq"), "f")) { *(ptr_asdata->ptr_refstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - *(ptr_asdata->ptr_refstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, "refstyle_id_seq"); - } else { - dbi_result_free(dbires); - LOG_PRINT(LOG_ERR, "driver not supported"); - return; + *(ptr_asdata->ptr_refstyle_id) = dbi_conn_sequence_last(ptr_asdata->conn, "refstyle_id_seq"); } dbi_result_free(dbires); @@ -178,14 +168,9 @@ } else { - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(ptr_asdata->conn, "named_seq"), "f")) { *(ptr_asdata->ptr_separator_id) = dbi_conn_sequence_last(ptr_asdata->conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { - *(ptr_asdata->ptr_separator_id) = dbi_conn_sequence_last(ptr_asdata->conn, "separators_id_seq"); - } else { - dbi_result_free(dbires); - LOG_PRINT(LOG_ERR, "driver not supported"); - return; + *(ptr_asdata->ptr_separator_id) = dbi_conn_sequence_last(ptr_asdata->conn, "separators_id_seq"); } dbi_result_free(dbires); |