From: Stephen D. <sd...@us...> - 2005-06-15 23:21:28
|
Update of /cvsroot/naviserver/modules/nsdbpg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5468 Modified Files: ChangeLog dbpg.h nsdbpg.c tclcmds.c Log Message: Use a regular naming scheme for functions and variables. Index: nsdbpg.c =================================================================== RCS file: /cvsroot/naviserver/modules/nsdbpg/nsdbpg.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nsdbpg.c 15 Jun 2005 20:22:11 -0000 1.2 --- nsdbpg.c 15 Jun 2005 23:20:39 -0000 1.3 *************** *** 40,49 **** - #define OID_QUOTED_STRING " oid = '" - #define STRING_BUF_LEN 256 - - NS_EXPORT int Ns_ModuleVersion = 1; ! char *PgDbName = "PostgreSQL"; [...1136 lines suppressed...] + sql++; + } if (!strncasecmp(sql, "begin", 5)) { + pconn->in_transaction = NS_TRUE; if (handle->verbose) { ! Ns_Log(Notice, "nsdbpg: Entering transaction."); } ! } else if (!strncasecmp(sql, "end", 3) ! || !strncasecmp(sql, "commit", 6)) { ! pconn->in_transaction = NS_FALSE; if (handle->verbose) { ! Ns_Log(Notice, "nsdbpg: Committing transaction."); } ! } else if (!strncasecmp(sql, "abort", 5) ! || !strncasecmp(sql, "rollback", 8)) { ! pconn->in_transaction = NS_FALSE; if (handle->verbose) { ! Ns_Log(Notice, "nsdbpg: Rolling back transaction."); } } Index: tclcmds.c =================================================================== RCS file: /cvsroot/naviserver/modules/nsdbpg/tclcmds.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tclcmds.c 15 Jun 2005 20:22:11 -0000 1.1 --- tclcmds.c 15 Jun 2005 23:20:39 -0000 1.2 *************** *** 136,140 **** { Ns_DbHandle *handle; ! NsPgConn *pgconn; if (Ns_TclDbGetHandle(interp, argv[2], &handle) != TCL_OK) { --- 136,140 ---- { Ns_DbHandle *handle; ! Connection *pconn; if (Ns_TclDbGetHandle(interp, argv[2], &handle) != TCL_OK) { *************** *** 142,155 **** } ! pgconn = (NsPgConn *) handle->connection; /* * Make sure this is a PostgreSQL handle before accessing ! * handle->connection as an NsPgConn. */ ! if (Ns_DbDriverName(handle) != PgDbName) { Tcl_AppendResult(interp, "handle \"", argv[1], "\" is not of type \"", ! PgDbName, "\"", NULL); return TCL_ERROR; } --- 142,155 ---- } ! pconn = handle->connection; /* * Make sure this is a PostgreSQL handle before accessing ! * handle->connection as an Connection. */ ! if (Ns_DbDriverName(handle) != pgDbName) { Tcl_AppendResult(interp, "handle \"", argv[1], "\" is not of type \"", ! pgDbName, "\"", NULL); return TCL_ERROR; } *************** *** 177,181 **** return TCL_ERROR; } ! if (!pgconn->in_transaction) { Tcl_AppendResult(interp, "blob_put only allowed in transaction", NULL); --- 177,181 ---- return TCL_ERROR; } ! if (!pconn->in_transaction) { Tcl_AppendResult(interp, "blob_put only allowed in transaction", NULL); *************** *** 190,194 **** return TCL_ERROR; } ! if (!pgconn->in_transaction) { Tcl_AppendResult(interp, "blob_dml_file only allowed in transaction", NULL); --- 190,194 ---- return TCL_ERROR; } ! if (!pconn->in_transaction) { Tcl_AppendResult(interp, "blob_dml_file only allowed in transaction", NULL); *************** *** 213,229 **** if (!strcmp(argv[1], "db")) { ! Tcl_SetResult(interp, (char *) PQdb(pgconn->conn), TCL_STATIC); } else if (!strcmp(argv[1], "host")) { ! Tcl_SetResult(interp, (char *) PQhost(pgconn->conn), TCL_STATIC); } else if (!strcmp(argv[1], "options")) { ! Tcl_SetResult(interp, (char *) PQoptions(pgconn->conn), TCL_STATIC); } else if (!strcmp(argv[1], "port")) { ! Tcl_SetResult(interp, (char *) PQport(pgconn->conn), TCL_STATIC); } else if (!strcmp(argv[1], "number")) { ! sprintf(interp->result, "%u", pgconn->cNum); } else if (!strcmp(argv[1], "error")) { ! Tcl_SetResult(interp, (char *) PQerrorMessage(pgconn->conn), TCL_STATIC); } else if (!strcmp(argv[1], "status")) { ! if (PQstatus(pgconn->conn) == CONNECTION_OK) { interp->result = "ok"; } else { --- 213,229 ---- if (!strcmp(argv[1], "db")) { ! Tcl_SetResult(interp, (char *) PQdb(pconn->pgconn), TCL_STATIC); } else if (!strcmp(argv[1], "host")) { ! Tcl_SetResult(interp, (char *) PQhost(pconn->pgconn), TCL_STATIC); } else if (!strcmp(argv[1], "options")) { ! Tcl_SetResult(interp, (char *) PQoptions(pconn->pgconn), TCL_STATIC); } else if (!strcmp(argv[1], "port")) { ! Tcl_SetResult(interp, (char *) PQport(pconn->pgconn), TCL_STATIC); } else if (!strcmp(argv[1], "number")) { ! sprintf(interp->result, "%u", pconn->id); } else if (!strcmp(argv[1], "error")) { ! Tcl_SetResult(interp, (char *) PQerrorMessage(pconn->pgconn), TCL_STATIC); } else if (!strcmp(argv[1], "status")) { ! if (PQstatus(pconn->pgconn) == CONNECTION_OK) { interp->result = "ok"; } else { *************** *** 232,236 **** } else if (!strcmp(argv[1], "ntuples")) { char string[16]; ! sprintf(string, "%d", pgconn->nTuples); Tcl_SetResult(interp, string, TCL_VOLATILE); } else { --- 232,236 ---- } else if (!strcmp(argv[1], "ntuples")) { char string[16]; ! sprintf(string, "%d", pconn->nTuples); Tcl_SetResult(interp, string, TCL_VOLATILE); } else { *************** *** 293,302 **** /* * Make sure this is a PostgreSQL handle before accessing ! * handle->connection as an NsPgConn. */ ! if (Ns_DbDriverName(handle) != PgDbName) { Tcl_AppendResult(interp, "handle \"", argv[1], "\" is not of type \"", ! PgDbName, "\"", NULL); return TCL_ERROR; } --- 293,302 ---- /* * Make sure this is a PostgreSQL handle before accessing ! * handle->connection as an Connection. */ ! if (Ns_DbDriverName(handle) != pgDbName) { Tcl_AppendResult(interp, "handle \"", argv[1], "\" is not of type \"", ! pgDbName, "\"", NULL); return TCL_ERROR; } *************** *** 484,489 **** DbFail(Tcl_Interp *interp, Ns_DbHandle *handle, char *cmd, char* sql) { ! NsPgConn *pgconn = handle->connection; ! char *pqerror; Tcl_AppendResult(interp, "Database operation \"", cmd, "\" failed", NULL); --- 484,489 ---- DbFail(Tcl_Interp *interp, Ns_DbHandle *handle, char *cmd, char* sql) { ! Connection *pconn = handle->connection; ! char *pqerror; Tcl_AppendResult(interp, "Database operation \"", cmd, "\" failed", NULL); *************** *** 498,502 **** } ! pqerror = PQerrorMessage(pgconn->conn); if (pqerror[0] != '\0') { Tcl_AppendResult(interp, "\n\n", pqerror, NULL); --- 498,502 ---- } ! pqerror = PQerrorMessage(pconn->pgconn); if (pqerror[0] != '\0') { Tcl_AppendResult(interp, "\n\n", pqerror, NULL); *************** *** 668,672 **** blob_get(Tcl_Interp *interp, Ns_DbHandle *handle, char* lob_id) { ! NsPgConn *nsConn = (NsPgConn *) handle->connection; int segment; char query[100]; --- 668,672 ---- blob_get(Tcl_Interp *interp, Ns_DbHandle *handle, char* lob_id) { ! Connection *pconn = handle->connection; int segment; char query[100]; *************** *** 694,703 **** } ! if (PQntuples(nsConn->res) == 0) { break; } ! byte_len_column = PQgetvalue(nsConn->res, 0, 0); ! data_column = PQgetvalue(nsConn->res, 0, 1); sscanf(byte_len_column, "%d", &byte_len); nbytes += byte_len; --- 694,703 ---- } ! if (PQntuples(pconn->res) == 0) { break; } ! byte_len_column = PQgetvalue(pconn->res, 0, 0); ! data_column = PQgetvalue(pconn->res, 0, 1); sscanf(byte_len_column, "%d", &byte_len); nbytes += byte_len; *************** *** 711,716 **** } ! PQclear(nsConn->res); ! nsConn->res = NULL; return TCL_OK; --- 711,716 ---- } ! PQclear(pconn->res); ! pconn->res = NULL; return TCL_OK; *************** *** 735,744 **** int to_conn_p, char* filename) { ! NsPgConn *nsConn = (NsPgConn *) handle->connection; ! int segment; ! char query[100]; ! int fd; ! char *segment_pos; ! Ns_Conn *conn; if (to_conn_p) { --- 735,744 ---- int to_conn_p, char* filename) { ! Connection *pconn = handle->connection; ! Ns_Conn *conn; ! int segment; ! char query[100]; ! int fd; ! char *segment_pos; if (to_conn_p) { *************** *** 790,799 **** return TCL_ERROR; } ! if (PQntuples(nsConn->res) == 0) { break; } ! byte_len_column = PQgetvalue(nsConn->res, 0, 0); ! data_column = PQgetvalue(nsConn->res, 0, 1); sscanf(byte_len_column, "%d", &byte_len); n = byte_len; --- 790,799 ---- return TCL_ERROR; } ! if (PQntuples(pconn->res) == 0) { break; } ! byte_len_column = PQgetvalue(pconn->res, 0, 0); ! data_column = PQgetvalue(pconn->res, 0, 1); sscanf(byte_len_column, "%d", &byte_len); n = byte_len; *************** *** 811,816 **** } ! PQclear(nsConn->res); ! nsConn->res = NULL; return TCL_OK; --- 811,816 ---- } ! PQclear(pconn->res); ! pconn->res = NULL; return TCL_OK; Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/modules/nsdbpg/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ChangeLog 15 Jun 2005 20:22:11 -0000 1.2 --- ChangeLog 15 Jun 2005 23:20:38 -0000 1.3 *************** *** 1,4 **** --- 1,9 ---- 2005-06-15 Stephen Deasey <sd...@us...> + * dbpg.h: + * nsdbpg.c: + * tclcmds.c: Use a regular naming scheme for functions and + variables. + * nsdbpg.c: Untabify, reindent and reorganize. Drop emulation code for AOLserver 2.x ns_table etc. commands. Index: dbpg.h =================================================================== RCS file: /cvsroot/naviserver/modules/nsdbpg/dbpg.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dbpg.h 15 Jun 2005 20:22:11 -0000 1.1 --- dbpg.h 15 Jun 2005 23:20:39 -0000 1.2 *************** *** 49,64 **** */ ! typedef struct NsPgConn { ! PGconn *conn; ! unsigned int cNum; PGresult *res; int nCols; int nTuples; int curTuple; int in_transaction; ! } NsPgConn; ! extern char *PgDbName; ! extern int Ns_PgServerInit(char *hServer, char *hModule, char *hDriver); --- 49,64 ---- */ ! typedef struct Connection { ! PGconn *pgconn; PGresult *res; + unsigned int id; int nCols; int nTuples; int curTuple; int in_transaction; ! } Connection; ! extern char *pgDbName; ! extern int PgDbServerInit(char *server, char *module, char *driver); |