11 fprintf(
out,
"%s", msg);
13 fprintf(
out,
" %02X", ((
unsigned char*) p)[
n]);
20 printf(
"%s: res %d\n", msg, ret);
23 fprintf(stderr,
"error: %s\n", msg);
35 memset(((
char*) num) +
len, 0,
sizeof(*num) -
len);
41 test(
int bind_type,
const char *bind_name,
int override_prec,
int override_scale,
int out_prec,
int out_scale,
int line)
50 printf(
"*** Starting test msdblib %d bind %s prec %d scale %d out prec %d out scale %d line %d\n",
51 msdblib, bind_name, override_prec, override_scale, out_prec, out_scale, line);
82 "SET CONCAT_NULL_YIELDS_NULL ON;"
84 "SET ANSI_NULL_DFLT_ON ON;"
85 "SET ANSI_PADDING ON;"
86 "SET ANSI_WARNINGS ON;"
87 "SET ANSI_NULL_DFLT_ON ON;"
88 "SET CURSOR_CLOSE_ON_COMMIT ON;"
89 "SET QUOTED_IDENTIFIER ON");
92 chk(ret,
"dbsqlexec");
99 chk(ret,
"dbrpcinit");
105 chk(ret > 0,
"dbconvert_ps");
108 chk(ret,
"dbrpcparam");
110 chk(ret,
"dbrpcsend");
117 ti.
scale = override_scale;
119 chk(ret > 0,
"dbconvert_ps");
129 printf(
"dbrows() returned SUCCEED, processing rows\n");
131 memset(num, 0,
sizeof(*num));
132 num->
precision = out_prec ? out_prec : num2->precision;
133 num->
scale = out_scale ? out_scale : num2->scale;
140 if (memcmp(num, num2,
sizeof(*num)) != 0) {
141 fprintf(stderr,
"Failed. Output results does not match\n");
142 dump_addr(stderr,
"got: ", num,
sizeof(*num));
143 dump_addr(stderr,
"expected: ", num2,
sizeof(*num2));
148 fprintf(stderr,
"Failed. Expected a row\n");
154 fprintf(stderr,
"dbresults returned FAIL\n");
157 fprintf(stderr,
"unexpected return code %d from dbresults\n", ret);
170 #define test(a,b,c,d,e) test(a, #a, b, c, d, e, __LINE__)
CS_RETCODE read_login_info(void)
RETCODE sql_cmd(DBPROCESS *dbproc)
RETCODE sql_reopen(const char *fn)
static void chk(RETCODE ret, const char *msg)
int main(int argc, char **argv)
static void dump_addr(FILE *out, const char *msg, const void *p, size_t len)
#define test(a, b, c, d, e)
static void zero_end(DBNUMERIC *num)
DBPROCESS * tdsdbopen(LOGINREC *login, const char *server, int msdblib)
STATUS dbnextrow(DBPROCESS *dbproc)
static int bind_type(int sybtype)
std::ofstream out("events_result.xml")
main entry point for tests
#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 DBSETLHOST(x, y)
Set the (client) host name in the login packet.
#define DBSETLUSER(x, y)
Set the username in the login packet.
LOGINREC * dblogin(void)
Allocate a LOGINREC structure.
#define DBTDS(a)
Sybase macro, maps to the internal (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 dbcancel(DBPROCESS *dbproc)
Cancel the current command batch.
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 dbcmd(DBPROCESS *dbproc, const char cmdstring[])
Append SQL to the command buffer.
DBINT dbconvert_ps(DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
Convert one datatype to another.
RETCODE dbsqlexec(DBPROCESS *dbproc)
send the SQL command to the server and wait for an answer.
void dbloginfree(LOGINREC *login)
free the LOGINREC
void dbexit()
Close server connections and free all related structures.
RETCODE dbsqlok(DBPROCESS *dbproc)
Wait for results of a query from the server.
void dbclose(DBPROCESS *dbproc)
Close a connection to the server and free associated resources.
RETCODE dbsetmaxprocs(int maxprocs)
Set maximum simultaneous connections db-lib will open to the server.
RETCODE dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options)
Initialize a remote procedure call.
RETCODE dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE *value)
Add a parameter to a remote procedure call.
RETCODE dbrpcsend(DBPROCESS *dbproc)
Execute the procedure and free associated memory.
voidp calloc(uInt items, uInt size)