46 fprintf(stderr,
"executing query failed\n");
64 int num_data = 0, i_row;
66 sprintf(
buf,
"CREATE TABLE #tmp(a %s)",
type);
71 const char *
value = va_arg(ap,
const char *);
75 result = va_arg(ap,
const char *);
78 data[num_data].value =
value;
79 data[num_data].result =
result;
80 sprintf(
buf,
"INSERT INTO #tmp VALUES(CONVERT(%s,'%s'))",
type,
value);
91 fprintf(stderr,
"tds_submit_query() failed\n");
96 fprintf(stderr,
"tds_process_tokens() failed\n");
101 fprintf(stderr,
"expected row fmt() failed\n");
106 fprintf(stderr,
"tds_process_tokens() failed\n");
111 fprintf(stderr,
"expected row result() failed\n");
131 fprintf(stderr,
"Error converting\n");
135 fprintf(stderr,
"Failed! Is \n%s\nShould be\n%s\n", cr.
c, data[i_row].result);
144 fprintf(stderr,
"tds_process_tokens() unexpected return\n");
149 switch (result_type) {
160 fprintf(stderr,
"tds_process_tokens() unexpected result_type\n");
172 fprintf(stdout,
"%s: Testing conversion from server\n", __FILE__);
174 fprintf(stderr,
"try_tds_login() failed\n");
189 test(
"FLOAT",
"-49586.345",
"-49586.345000000001");
192 test(
"MONEY",
"-123.3400",
"-123.34");
193 test(
"MONEY",
"-123.3450",
"-123.35");
194 test(
"MONEY",
"123.3450",
"123.35");
196 test(
"MONEY",
"123456789012345.67",
NULL);
198 test(
"MONEY",
"-922337203685477.5808",
"-922337203685477.58");
199 test(
"SMALLMONEY",
"89123.12",
NULL);
200 test(
"SMALLMONEY",
"-123.3400",
"-123.34");
201 test(
"SMALLMONEY",
"-123.3450",
"-123.35");
202 test(
"SMALLMONEY",
"123.3450",
"123.35");
204 test(
"SMALLMONEY",
"-214748.3648",
"-214748.36");
207 test(
"CHAR(10)",
"pippo",
"pippo ");
209 test0(
"TEXT",
"a",
NULL,
"foofoo",
NULL,
"try with a relatively long value, we hope for the best",
NULL,
NULL);
212 test(
"VARBINARY(6)",
"foo",
"666f6f");
213 test(
"BINARY(6)",
"foo",
"666f6f000000");
214 test0(
"IMAGE",
"foo",
"666f6f",
"foofoofoofoo",
"666f6f666f6f666f6f666f6f",
NULL);
217 test(
"NUMERIC(10,2)",
"12765.76",
NULL);
218 test(
"NUMERIC(18,4)",
"12765.761234",
"12765.7612");
224 test(
"DATETIME",
"2003-04-21 17:50:03",
NULL);
225 test(
"SMALLDATETIME",
"2003-04-21 17:50:03",
"2003-04-21 17:50:00");
228 test(
"UNIQUEIDENTIFIER",
"12345678-1234-A234-9876-543298765432",
NULL);
229 test(
"NVARCHAR(20)",
"Excellent test",
NULL);
230 test(
"NCHAR(20)",
"Excellent test",
"Excellent test ");
231 test(
"NTEXT",
"Excellent test",
NULL);
235 test(
"SQL_VARIANT",
"test123",
NULL);
static void test(const char *type, const char *value, const char *result)
int main(int argc, char **argv)
static void exec_query(const char *query)
static void test0(const char *type,...)
int strcmp(const char *str1, const char *str2)
#define tds_process_simple_query
#define tds_get_conversion_type
#define tds_process_tokens
Information about blobs (e.g.
Metadata about columns in regular and compute rows.
TDS_INT column_size
maximun size of data.
unsigned char * column_data
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Information for a server connection.
TDSRESULTINFO * current_results
Current query information.
int try_tds_logout(TDSLOGIN *login, TDSSOCKET *tds, int verbose)
int try_tds_login(TDSLOGIN **login, TDSSOCKET **tds, const char *appname, int verbose)
TDSCONTEXT * test_context
#define TDS_DONEPROC_RESULT
#define TDS_ROWFMT_RESULT
tds_sysdep_int32_type TDS_INT
#define TDS_NO_MORE_RESULTS
#define TDS_COMPUTE_RESULT
@ TDS_DONE_ERROR
error occurred
#define TDS_DONEINPROC_RESULT