20 #if !defined(SYBETIME)
21 #define SYBETIME SQLETIME
22 #define INT_TIMEOUT INT_CANCEL
40 fprintf(stderr,
"could not timeout cleanly, breaking connection\n");
44 fprintf(stderr,
"lost patience, cancelling (allowing 10 seconds)\n");
46 fprintf(stderr,
"... but dbsettime() failed in error handler\n");
49 fprintf(stderr,
"continuing to wait\n");
56 "DB-LIBRARY error (severity %d, dberr %d, oserr %d, dberrstr %s, oserrstr %s):\n",
57 severity, dberr, oserr, dberrstr ? dberrstr :
"(null)", oserrstr ? oserrstr :
"(null)");
69 fprintf(stderr,
"error: dbproc (%p) is %s, goodbye\n",
81 printf(
"in chkintr, %ld seconds elapsed\n", (
long int) (time(
NULL) -
start_time));
88 printf(
"in hndlintr, %ld seconds elapsed\n", (
long int) (time(
NULL) -
start_time));
101 int num_resultset = 0;
116 printf(
"About to logon\n");
129 printf (
"using %d 1-second login timeouts\n",
max_timeouts);
135 fprintf(stderr,
"Failed: dbopen\n");
139 printf (
"connected.\n");
152 printf(
"unexpected return code from dbisopt() before calling dbsetopt(..., DBSETTIME, ...)\n");
157 fprintf(stderr,
"Failed: dbsetopt(..., DBSETTIME, \"%d\")\n",
timeout_seconds);
163 printf(
"unexpected return code from dbisopt() after calling dbsetopt(..., DBSETTIME, ...)\n");
168 fprintf(stderr,
"Failed: dbclropt(..., DBSETTIME, ...)\n");
174 printf(
"unexpected return code from dbisopt() after calling dbclropt(..., DBSETTIME, ...)\n");
181 fprintf(stderr,
"Failed: dbsetopt(..., DBSETTIME, \"%d\")\n",
timeout_seconds);
189 fprintf(stderr,
"Failed: dbsettime\n");
195 printf (
"issuing a query that will take 30 seconds\n");
198 fprintf(stderr,
"Failed: dbcmd\n");
208 fprintf(stderr,
"Failed: dbsend\n");
213 printf(
"executing dbsqlok\n");
216 fprintf(stderr,
"dbsqlok should fail for timeout\n");
231 printf(
"dbrows() returned SUCCEED, processing rows\n");
235 printf(
"bound 1 of %d columns ('%s') in result %d.\n", ncols,
dbcolname(
dbproc, 1), ++
r);
245 fprintf(stderr,
"Failed. Expected a row\n");
250 printf(
"row count %d\n", nrows);
253 printf(
"error: dbrows() returned SUCCEED, but dbcount() returned -1\n");
258 printf(
"error: dbclropt(dbproc, DBSETTIME, ...) failed\n");
262 printf(
"dbresults returned FAIL\n");
265 printf(
"unexpected return code %d from dbresults\n", erc);
282 fprintf(stdout,
"Starting %s\n", argv[0]);
291 printf(
"%s %s\n", __FILE__, (
failed ?
"failed!" :
"OK"));
CS_RETCODE read_login_info(void)
RETCODE sql_cmd(DBPROCESS *dbproc)
int syb_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line)
void set_malloc_options(void)
static char teststr[1024]
dbsetinterrupt(DBPROCESS *dbproc, void *hand, void *p)
int main(int argc, char **argv)
static const int timeout_seconds
static int hndlintr(DBPROCESS *dbproc)
static int timeout_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
static int chkintr(DBPROCESS *dbproc)
static const int max_timeouts
static void test(int per_process)
STATUS dbnextrow(DBPROCESS *dbproc)
#define DBSETLPWD(x, y)
Set the password in the login packet.
#define DBSETLAPP(x, y)
Set the (client) application name in the login packet.
#define DBSETLUSER(x, y)
Set the username in the login packet.
LOGINREC * dblogin(void)
Allocate a LOGINREC structure.
#define DBDEAD(x)
Sybase macro mapping to the Microsoft (lower-case) function.
#define DBROWS(x)
Sybase macro mapping to the Microsoft (lower-case) function.
RETCODE dbresults(DBPROCESS *dbproc)
Set up query results.
RETCODE dbinit(void)
Initialize db-lib.
RETCODE dbsetlogintime(int seconds)
Set maximum seconds db-lib waits for a server response to a login attempt.
RETCODE dbuse(DBPROCESS *dbproc, const char *name)
Change current database.
RETCODE dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
Tie a host variable to a resultset column.
RETCODE dbclropt(DBPROCESS *dbproc, int option, const char param[])
Reset an option.
DBINT dbcount(DBPROCESS *dbproc)
Get count of rows processed.
RETCODE dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param)
Set db-lib or server option.
EHANDLEFUNC dberrhandle(EHANDLEFUNC handler)
Set an error handler, for messages from db-lib.
void dbloginfree(LOGINREC *login)
free the LOGINREC
DBBOOL dbisopt(DBPROCESS *dbproc, int option, const char param[])
Get value of an option.
RETCODE dbsqlsend(DBPROCESS *dbproc)
Transmit the command buffer to the server.
void dbexit()
Close server connections and free all related structures.
char * dbcolname(DBPROCESS *dbproc, int column)
Return name of a regular result column.
RETCODE dbsettime(int seconds)
Set maximum seconds db-lib waits for a server response to query.
int dbnumcols(DBPROCESS *dbproc)
Return number of regular columns in a result set.
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler)
Set a message handler, for messages from the server.
RETCODE dbsqlok(DBPROCESS *dbproc)
Wait for results of a query from the server.
unsigned int
A callback function used to compare two keys in a database.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
int(* DB_DBCHKINTR_FUNC)(void *dbproc)
int(* DB_DBHNDLINTR_FUNC)(void *dbproc)