/* * This is used with the Ns_DbProc structure. */ typedef enum { DbFn_Name, DbFn_DbType, DbFn_ServerInit, DbFn_OpenDb, DbFn_CloseDb, DbFn_DML, DbFn_Select, DbFn_GetRow, DbFn_Flush, DbFn_Cancel, DbFn_GetTableInfo, DbFn_TableList, DbFn_BestRowId, DbFn_Exec, DbFn_BindRow, DbFn_ResetHandle, DbFn_SpStart, DbFn_SpSetParam, DbFn_SpExec, DbFn_SpReturnCode, DbFn_SpGetParams, DbFn_End } Ns_DbProcId; /* * Database handle structure. */ typedef struct Ns_DbHandle { char *driver; char *datasource; char *user; char *password; void *connection; char *poolname; int connected; int verbose; Ns_Set *row; char cExceptionCode[6]; Ns_DString dsExceptionMsg; void *context; void *statement; int fetchingRows; } Ns_DbHandle; /* * Database procedure structure. */ typedef struct Ns_DbProc { Ns_DbProcId id; void *func; } Ns_DbProc; /* Function prototypes */ int Ns_DbRegisterDriver(char *driver, Ns_DbProc *procs); char *Ns_DbDriverName(Ns_DbHandle *handle); char *Ns_DbDriverDbType(Ns_DbHandle *handle); int Ns_DbDML(Ns_DbHandle *handle, char *sql); Ns_Set *Ns_DbSelect(Ns_DbHandle *handle, char *sql); int Ns_DbExec(Ns_DbHandle *handle, char *sql); Ns_Set *Ns_DbBindRow(Ns_DbHandle *handle); int Ns_DbGetRow(Ns_DbHandle *handle, Ns_Set *row); int Ns_DbFlush(Ns_DbHandle *handle); int Ns_DbCancel(Ns_DbHandle *handle); int Ns_DbResetHandle (Ns_DbHandle *handle); /* This doesn't actually load the driver; it expects the thing to have * already registered itself... */ struct DbDriver *NsDbLoadDriver(char *driver); struct DbDriver *NsDbGetDriver(Ns_DbHandle *handle); void NsDbServerInit(struct DbDriver *driverPtr); int NsDbOpen(Ns_DbHandle *handle); void NsDbClose(Ns_DbHandle *handle); int Ns_DbSpStart(Ns_DbHandle *handle, char *procname); int Ns_DbSpSetParam(Ns_DbHandle *handle, char *paramname, char *paramtype, char *inout, char *value); int Ns_DbSpExec(Ns_DbHandle *handle); int Ns_DbSpReturnCode(Ns_DbHandle *handle, char *returnCode, int bufsize); Ns_Set *Ns_DbSpGetParams(Ns_DbHandle *handle); void Ns_DbSetException(Ns_DbHandle *handle, char *code, char *msg); char *Ns_DbPoolDescription(char *pool); char *Ns_DbPoolDefault(char *hServer); char *Ns_DbPoolList(char *hServer); int Ns_DbPoolAllowable(char *hServer, char *pool); void Ns_DbPoolPutHandle(Ns_DbHandle *handle); Ns_DbHandle *Ns_DbPoolTimedGetHandle(char *pool, int wait); Ns_DbHandle *Ns_DbPoolGetHandle(char *pool); int Ns_DbPoolGetMultipleHandles(Ns_DbHandle **handles, char *pool, int nwant); int Ns_DbPoolTimedGetMultipleHandles(Ns_DbHandle **handles, char *pool, int nwant, int wait); int Ns_DbBouncePool(char *pool); void NsDbDisconnect(Ns_DbHandle *handle); void NsDbLogSql(Ns_DbHandle *handle, char *sql); void Ns_DbQuoteValue(Ns_DString *pds, char *string); Ns_Set *Ns_Db0or1Row(Ns_DbHandle *handle, char *sql, int *nrows); Ns_Set *Ns_Db1Row(Ns_DbHandle *handle, char *sql); int Ns_DbInterpretSqlFile(Ns_DbHandle *handle, char *filename); int Ns_TclDbGetHandle(Tcl_Interp *interp, char *handleId, Ns_DbHandle **handle); void NsDbTclInit(void); void ns_release_all_db_handles(); /* post-request cleanup added here */ void NsDbInit (void); int Ns_DbDriverInit (char *, char *); /* YYY Must go */ extern Ns_ModLogHandle nsDBModLogHandle; #define NS_ROWS 2 #define NS_DML 1 #define NS_END_DATA 4 typedef struct { Ns_Set *table; int size; int ncolumns; Ns_Set **columns; } Ns_DbTableInfo;