~drizzle-trunk/libdrizzle/jenkins-Libdrizzle-89

« back to all changes in this revision

Viewing changes to tests/unit/statement.c

  • Committer: Continuous Integration
  • Date: 2013-01-27 00:45:31 UTC
  • mfrom: (97.1.3 libdrizzle-5.1)
  • Revision ID: ci@drizzle.org-20130127004531-4nphq510h65sxnnq
Merge lp:~brianaker/libdrizzle/cleanup-api Build: jenkins-Libdrizzle-54

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
{
50
50
  (void) argc;
51
51
  (void) argv;
52
 
  drizzle_stmt_st *stmt;
 
52
  drizzle_stmt_st *stmt= NULL;
 
53
 
 
54
  ASSERT_EQ(UINT64_MAX, drizzle_stmt_row_count(stmt));
53
55
 
54
56
  drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
55
57
                                      getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
92
94
 
93
95
  uint32_t val= 1;
94
96
  ret = drizzle_stmt_set_int(stmt, 0, val, false);
95
 
  if (ret != DRIZZLE_RETURN_OK)
96
 
  {
97
 
    printf("Bind failure\n");
98
 
    return EXIT_FAILURE;
99
 
  }
 
97
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "%s", drizzle_error(con));
100
98
 
101
99
  ret = drizzle_stmt_execute(stmt);
102
 
  if (ret != DRIZZLE_RETURN_OK)
103
 
  {
104
 
    printf("Execute failure\n");
105
 
    return EXIT_FAILURE;
106
 
  }
 
100
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "%s", drizzle_error(con));
 
101
 
107
102
  ret = drizzle_stmt_buffer(stmt);
108
 
  if (ret != DRIZZLE_RETURN_OK)
109
 
  {
110
 
    printf("Buffer failure\n");
111
 
    return EXIT_FAILURE;
112
 
  }
 
103
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "%s", drizzle_error(con));
 
104
 
113
105
  /* Result should have 2 rows */
114
 
  if (drizzle_stmt_row_count(stmt) != 2)
115
 
  {
116
 
    printf("Retrieved bad row count\n");
117
 
    return EXIT_FAILURE;
118
 
  }
 
106
  int count= drizzle_stmt_row_count(stmt);
 
107
  ASSERT_EQ_(2, count, "%s", drizzle_error(con));
 
108
 
119
109
  uint32_t i= 1;
120
110
  while (drizzle_stmt_fetch(stmt) != DRIZZLE_RETURN_ROW_END)
121
111
  {
154
144
    return EXIT_FAILURE;
155
145
  }
156
146
  ret = drizzle_stmt_close(stmt);
157
 
  if (ret != DRIZZLE_RETURN_OK)
158
 
  {
159
 
    printf("Statement close failure ret: %d, err: %d, msg: %s\n", ret, drizzle_errno(con), drizzle_error(con));
160
 
    return EXIT_FAILURE;
161
 
  }
 
147
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "%s", drizzle_error(con));
162
148
 
163
149
  drizzle_query(con, "DROP TABLE libdrizzle.t1", 0, &ret);
164
150
  ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "DROP TABLE libdrizzle.t1");