~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-2.0/query.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:
72
72
                                    drizzle_con_st *con,
73
73
                                    drizzle_result_st *result,
74
74
                                    const char *query_string, size_t size,
75
 
                                    drizzle_query_options_t,
 
75
                                    drizzle_query_options_t options,
76
76
                                    void *context)
77
77
{
78
78
  // @note drizzle_query_st handle the null drizzle case
85
85
  drizzle_query_set_con(query, con);
86
86
  drizzle_query_set_result(query, result);
87
87
  drizzle_query_set_string(query, query_string, size);
 
88
  drizzle_query_add_options(query, options);
88
89
  drizzle_query_set_context(query, context);
89
90
 
90
91
  return query;
91
92
}
92
93
 
93
 
drizzle_query_st *drizzle_query_create(drizzle_st *drizzle, drizzle_query_st *query)
 
94
drizzle_query_st *drizzle_query_create(drizzle_st *drizzle,
 
95
                                       drizzle_query_st *query)
94
96
{
95
97
  if (drizzle == NULL)
96
98
  {
105
107
    {
106
108
      return NULL;
107
109
    }
108
 
    query->options.is_allocated= true;
 
110
    query->options|= DRIZZLE_CON_ALLOCATED;
109
111
  }
110
112
  else
111
113
  {
112
114
    query->prev= NULL;
 
115
    query->options= 0;
113
116
    query->state= DRIZZLE_QUERY_STATE_INIT;
114
117
    query->con= NULL;
115
118
    query->result= NULL;
117
120
    query->size= 0;
118
121
    query->context= NULL;
119
122
    query->context_free_fn= NULL;
120
 
    query->options.is_allocated= false;
121
123
  }
122
124
 
123
125
  query->drizzle= drizzle;
142
144
  }
143
145
 
144
146
  if (query->context != NULL && query->context_free_fn != NULL)
145
 
  {
146
147
    query->context_free_fn(query, query->context);
147
 
  }
148
148
 
149
149
  if (query->drizzle->query_list == query)
150
 
  {
151
150
    query->drizzle->query_list= query->next;
152
 
  }
153
151
 
154
152
  if (query->prev)
155
 
  {
156
153
    query->prev->next= query->next;
157
 
  }
158
154
 
159
155
  if (query->next)
160
 
  {
161
156
    query->next->prev= query->prev;
162
 
  }
163
157
 
164
158
  query->drizzle->query_count--;
165
159
 
166
 
  if (query->options.is_allocated)
167
 
  {
 
160
  if (query->options & DRIZZLE_QUERY_ALLOCATED)
168
161
    delete query;
169
 
  }
170
162
}
171
163
 
172
164
void drizzle_query_free_all(drizzle_st *drizzle)
241
233
  query->size= size;
242
234
}
243
235
 
244
 
int drizzle_query_options(drizzle_query_st *)
245
 
{
246
 
  return 0;
247
 
}
248
 
 
249
 
void drizzle_query_set_options(drizzle_query_st *, int)
250
 
{
251
 
}
252
 
 
253
 
void drizzle_query_add_options(drizzle_query_st *, int)
254
 
{
255
 
}
256
 
 
257
 
void drizzle_query_remove_options(drizzle_query_st *, int)
258
 
{
 
236
int drizzle_query_options(drizzle_query_st *query)
 
237
{
 
238
  if (query == NULL)
 
239
  {
 
240
    return 0;
 
241
  }
 
242
 
 
243
  return query->options;
 
244
}
 
245
 
 
246
void drizzle_query_set_options(drizzle_query_st *query,
 
247
                               int options)
 
248
{
 
249
  if (query == NULL)
 
250
  {
 
251
    return;
 
252
  }
 
253
 
 
254
  query->options= options;
 
255
}
 
256
 
 
257
void drizzle_query_add_options(drizzle_query_st *query,
 
258
                               int options)
 
259
{
 
260
  if (query == NULL)
 
261
  {
 
262
    return;
 
263
  }
 
264
 
 
265
  query->options|= options;
 
266
}
 
267
 
 
268
void drizzle_query_remove_options(drizzle_query_st *query,
 
269
                                  int options)
 
270
{
 
271
  if (query == NULL)
 
272
  {
 
273
    return;
 
274
  }
 
275
 
 
276
  query->options&= ~options;
259
277
}
260
278
 
261
279
void *drizzle_query_context(drizzle_query_st *query)