~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-2.0/result.cc

  • Committer: Mark Atwood
  • Date: 2011-11-22 17:04:41 UTC
  • mfrom: (2462.1.3 drizzle-include)
  • Revision ID: me@mark.atwood.name-20111122170441-5dehm0e0ax20z19b
mergeĀ lp:~brianaker/drizzle/fedora-16-fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 * Common definitions
47
47
 */
48
48
 
49
 
drizzle_result_st *drizzle_result_create(drizzle_con_st *con)
50
 
{
51
 
  return drizzle_result_create_with(con, NULL);
52
 
}
53
 
 
54
 
drizzle_result_st *drizzle_result_create_with(drizzle_con_st *con,
55
 
                                              drizzle_result_st *result)
 
49
drizzle_result_st *drizzle_result_create(drizzle_con_st *con,
 
50
                                         drizzle_result_st *result)
56
51
{
57
52
  if (result == NULL)
58
53
  {
63
58
      return NULL;
64
59
    }
65
60
 
66
 
    result->_options.is_allocated= true;
 
61
    result->options|= DRIZZLE_RESULT_ALLOCATED;
67
62
  }
68
63
  else
69
64
  {
98
93
    result->row_list= NULL;
99
94
    result->field_sizes= NULL;
100
95
    result->field_sizes_list= NULL;
101
 
 
102
 
    result->_options.is_allocated= false;
103
96
  }
104
97
 
105
98
  result->con= con;
115
108
}
116
109
 
117
110
drizzle_result_st *drizzle_result_clone(drizzle_con_st *con,
118
 
                                        drizzle_result_st *source)
 
111
                                        drizzle_result_st *result,
 
112
                                        drizzle_result_st *from)
119
113
{
120
 
  drizzle_result_st *result= drizzle_result_create(con);
 
114
  result= drizzle_result_create(con, result);
121
115
  if (result == NULL)
122
116
  {
123
117
    return NULL;
124
118
  }
125
119
 
126
 
  result->options= source->options;
 
120
  result->options|= from->options & ~DRIZZLE_RESULT_ALLOCATED;
127
121
 
128
 
  drizzle_result_set_info(result, source->info);
129
 
  result->error_code= source->error_code;
130
 
  drizzle_result_set_sqlstate(result, source->sqlstate);
131
 
  result->warning_count= source->warning_count;
132
 
  result->insert_id= source->insert_id;
133
 
  result->affected_rows= source->affected_rows;
134
 
  result->column_count= source->column_count;
135
 
  result->row_count= source->row_count;
 
122
  drizzle_result_set_info(result, from->info);
 
123
  result->error_code= from->error_code;
 
124
  drizzle_result_set_sqlstate(result, from->sqlstate);
 
125
  result->warning_count= from->warning_count;
 
126
  result->insert_id= from->insert_id;
 
127
  result->affected_rows= from->affected_rows;
 
128
  result->column_count= from->column_count;
 
129
  result->row_count= from->row_count;
136
130
 
137
131
  return result;
138
132
}
140
134
void drizzle_result_free(drizzle_result_st *result)
141
135
{
142
136
  drizzle_column_st *column;
 
137
  uint64_t x;
143
138
 
144
139
  if (result == NULL)
145
140
  {
155
150
 
156
151
  if (result->options & DRIZZLE_RESULT_BUFFER_ROW)
157
152
  {
158
 
    for (size_t x= 0; x < result->row_count; x++)
159
 
    {
160
 
      drizzle_row_free(result, result->row_list->at(x));
161
 
    }
 
153
    for (x= 0; x < result->row_count; x++)
 
154
      drizzle_row_free(result, result->row_list->at(static_cast<size_t>(x)));
162
155
 
163
156
    delete result->row_list;
164
157
    delete result->field_sizes_list;
170
163
    if (result->con->result_list == result)
171
164
      result->con->result_list= result->next;
172
165
  }
173
 
 
174
166
  if (result->prev)
175
167
    result->prev->next= result->next;
176
 
 
177
168
  if (result->next)
178
169
    result->next->prev= result->prev;
179
170
 
180
 
  if (result->_options.is_allocated)
181
 
  {
 
171
  if (result->options & DRIZZLE_RESULT_ALLOCATED)
182
172
    delete result;
183
 
  }
184
173
}
185
174
 
186
175
void drizzle_result_free_all(drizzle_con_st *con)
323
312
 
324
313
  if (drizzle_state_none(con))
325
314
  {
326
 
    con->result= drizzle_result_create_with(con, result);
 
315
    con->result= drizzle_result_create(con, result);
327
316
    if (con->result == NULL)
328
317
    {
329
318
      *ret_ptr= DRIZZLE_RETURN_MEMORY;