Line data Source code
1 : #include "common.h"
2 :
3 :
4 : /*
5 : Demonstration of triggered assert when invoking this stored procedure
6 : using FreeTDS odbc driver:
7 :
8 : create procedure proc_longerror as
9 : begin
10 : raiserror('reallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylong error', 16, 1)
11 : end
12 :
13 : */
14 :
15 : static void extract_error(SQLHANDLE handle, SQLSMALLINT type);
16 :
17 : int
18 8 : main(void)
19 : {
20 : int i;
21 : char cmd[128 + 110*10];
22 :
23 8 : printf("SQLWCHAR size is: %d\n", (int) sizeof(SQLWCHAR));
24 :
25 8 : odbc_use_version3 = 1;
26 8 : odbc_connect();
27 :
28 : /* this test do not work with Sybase */
29 8 : if (!odbc_db_is_microsoft()) {
30 2 : odbc_disconnect();
31 2 : return 0;
32 : }
33 :
34 6 : strcpy(cmd, "create procedure #proc_longerror as\nbegin\nraiserror('");
35 666 : for (i = 0; i < 110; ++i)
36 660 : strcat(cmd, "reallylong");
37 6 : strcat(cmd, " error', 16, 1)\nend\n");
38 6 : odbc_command(cmd);
39 :
40 6 : CHKExecDirect(T("{CALL #proc_longerror}"), SQL_NTS, "E");
41 :
42 6 : extract_error(odbc_stmt, SQL_HANDLE_STMT);
43 :
44 6 : odbc_disconnect();
45 6 : return 0;
46 : }
47 :
48 : static void
49 6 : extract_error(SQLHANDLE handle, SQLSMALLINT type)
50 : {
51 6 : SQLINTEGER i = 0;
52 : SQLINTEGER native;
53 : SQLTCHAR state[7];
54 : SQLTCHAR text[256];
55 : SQLSMALLINT len;
56 : SQLRETURN ret;
57 :
58 6 : fprintf(stderr, "\n" "The driver reported the following diagnostics\n");
59 :
60 : do {
61 8 : ret = CHKGetDiagRec(type, handle, ++i, state, &native, text, 256, &len, "SINo");
62 8 : state[5] = 0;
63 8 : if (SQL_SUCCEEDED(ret))
64 6 : printf("%s:%ld:%ld:%s\n", C(state), (long) i,
65 : (long) native, C(text));
66 : }
67 8 : while (ret == SQL_SUCCESS);
68 6 : }
69 :
|