Line data Source code
1 : #include "common.h"
2 :
3 10 : TEST_MAIN()
4 : {
5 : CS_CONTEXT *ctx;
6 : CS_CONNECTION *conn;
7 : CS_COMMAND *cmd;
8 10 : int verbose = 0;
9 : CS_RETCODE ret;
10 : CS_INT res_type;
11 : CS_SMALLINT msg_id;
12 10 : int got_failure = 0;
13 10 : int got_done = 0;
14 : CS_INT rows_read;
15 :
16 10 : printf("%s: submit a not existing stored procedure\n", __FILE__);
17 10 : check_call(try_ctlogin, (&ctx, &conn, &cmd, verbose));
18 :
19 10 : check_call(ct_command, (cmd, CS_RPC_CMD, "IDoNotExist", CS_NULLTERM, CS_NO_RECOMPILE));
20 :
21 10 : check_call(ct_send, (cmd));
22 :
23 42 : while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) {
24 22 : printf("ct_results returned %s\n", res_type_str(res_type));
25 22 : switch ((int) res_type) {
26 : case CS_STATUS_RESULT:
27 4 : while (ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) == CS_SUCCEED)
28 2 : continue;
29 : break;
30 :
31 0 : case CS_CMD_SUCCEED:
32 0 : fprintf(stderr, "a success was not expected from ct_results.\n");
33 0 : return 1;
34 :
35 0 : case CS_ROW_RESULT:
36 : case CS_PARAM_RESULT:
37 0 : fprintf(stderr, "Only status results are expected\n");
38 0 : return 1;
39 :
40 0 : case CS_MSG_RESULT:
41 0 : check_call(ct_res_info, (cmd, CS_MSGTYPE, (CS_VOID *) & msg_id, CS_UNUSED, NULL));
42 0 : printf("ct_result returned CS_MSG_RESULT where msg id = %d.\n", msg_id);
43 0 : break;
44 :
45 : case CS_CMD_DONE:
46 : got_done = 1;
47 : break;
48 :
49 10 : case CS_CMD_FAIL:
50 10 : got_failure = 1;
51 10 : break;
52 :
53 0 : default:
54 0 : fprintf(stderr, "ct_results returned unexpected result type.\n");
55 0 : return 1;
56 : }
57 : }
58 :
59 10 : if (!got_failure) {
60 0 : fprintf(stderr, "a failure was expected from ct_results.\n");
61 0 : return 1;
62 : }
63 10 : if (!got_done) {
64 0 : fprintf(stderr, "a done result was expected from ct_results.\n");
65 0 : return 1;
66 : }
67 :
68 10 : switch ((int) ret) {
69 : case CS_END_RESULTS:
70 : break;
71 :
72 0 : case CS_FAIL:
73 0 : fprintf(stderr, "ct_results failed.");
74 0 : return 1;
75 :
76 0 : default:
77 0 : fprintf(stderr, "ct_results returned unexpected result type.");
78 0 : return 1;
79 : }
80 :
81 10 : check_call(try_ctlogout, (ctx, conn, cmd, verbose));
82 :
83 10 : return 0;
84 : }
|