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